/* ═══════════════════════════════════════════════════════
   FGrid — Global Stylesheet
   Brand: Black & White / No external CSS frameworks
═══════════════════════════════════════════════════════ */

/* ── Reset & Root ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:   #000000;
  --white:   #ffffff;
  --gray-1:  #111111;
  --gray-2:  #222222;
  --gray-3:  #444444;
  --gray-4:  #888888;
  --gray-5:  #bbbbbb;
  --gray-6:  #dddddd;
  --gray-7:  #f2f2f2;
  --gray-8:  #f8f8f8;
  --clean:   #1a7a3c;
  --warn:    #8a6200;
  --alert:   #9a1a1a;
  --clean-bg:#e8f5ee;
  --warn-bg: #fff8e1;
  --alert-bg:#fdecea;
  --radius:  4px;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono:    'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --shadow:  0 2px 8px rgba(0,0,0,.08);
  --transition: 0.18s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--gray-1);
  background: var(--white);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button, input, select, textarea { font-family: inherit; }

/* ── Typography ───────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--gray-3); }
small { font-size: .8rem; color: var(--gray-4); }

/* ── Layout ───────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.section    { padding: 64px 0; }

/* ── Navigation ───────────────────────────────────── */
.site-nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-6);
  height: 56px; display: flex; align-items: center;
}
.site-nav .container {
  display: flex; align-items: center;
  justify-content: space-between; width: 100%;
}
.nav-brand { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.5px; color: var(--black); }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { font-size: .9rem; color: var(--gray-3); transition: color var(--transition); }
.nav-links a:hover { color: var(--black); text-decoration: none; }
.nav-hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; background: none; border: none; padding: 4px; }
.nav-hamburger span { display: block; width: 22px; height: 2px; background: var(--black); }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 22px; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  border: 2px solid transparent; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--black); color: var(--white); border-color: var(--black); }
.nav-links .btn-primary { background: var(--white); border-color: var(--black); }
.btn-primary:hover { background: var(--gray-2); border-color: var(--gray-2); text-decoration: none; }
.btn-outline { background: var(--white); color: var(--black); border-color: var(--black); }
.btn-outline:hover { background: var(--gray-7); text-decoration: none; }
.btn-danger  { background: #9a1a1a; color: var(--white); border-color: #9a1a1a; }
.btn-danger:hover { background: #7a1414; text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; color: var(--gray-2); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--gray-6); border-radius: var(--radius);
  font-size: .9rem; transition: border-color var(--transition);
  background: var(--white); color: var(--gray-1);
}
.form-control:focus { outline: none; border-color: var(--black); }
.form-hint { font-size: .78rem; color: var(--gray-4); margin-top: 4px; }
.form-error { font-size: .78rem; color: #9a1a1a; margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--gray-6);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 20px; }

/* ── Alerts ───────────────────────────────────────── */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: var(--clean-bg); color: var(--clean); border: 1px solid #b8ddc7; }
.alert-error   { background: var(--alert-bg); color: var(--alert); border: 1px solid #f3b3b0; }
.alert-warn    { background: var(--warn-bg);  color: var(--warn);  border: 1px solid #ffe0a0; }
.alert-info    { background: #e8f0fe; color: #1a4a8a; border: 1px solid #b3c8f5; }

/* ── Tables ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--gray-6); }
th { font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-3); background: var(--gray-8); }
tr:hover td { background: var(--gray-8); }

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
}
.badge-clean  { background: var(--clean-bg); color: var(--clean); }
.badge-warn   { background: var(--warn-bg);  color: var(--warn); }
.badge-alert  { background: var(--alert-bg); color: var(--alert); }
.badge-neutral{ background: var(--gray-7);  color: var(--gray-3); }

/* ── Pagination ───────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.page-btn {
  padding: 7px 13px; border: 1px solid var(--gray-6); border-radius: var(--radius);
  font-size: .85rem; color: var(--gray-3); transition: all var(--transition);
}
.page-btn:hover { background: var(--gray-7); text-decoration: none; color: var(--black); }
.page-btn.active { background: var(--black); color: var(--white); border-color: var(--black); }

/* ── Score display ────────────────────────────────── */
.score-result {
  border-radius: var(--radius); padding: 28px;
  text-align: center; margin: 24px 0;
}
.score-clean  { background: var(--clean-bg); border: 2px solid var(--clean); color: var(--clean); }
.score-warn   { background: var(--warn-bg);  border: 2px solid var(--warn); color: var(--warn); }
.score-alert  { background: var(--alert-bg); border: 2px solid #9a1a1a; color: #9a1a1a; }
.score-label  { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; }
.score-pct    { font-size: 1.1rem; }
.score-msg    { font-size: .9rem; margin-top: 8px; opacity: .85; }

/* ── Dashboard Layout ─────────────────────────────── */
.dash-wrap    { display: flex; min-height: calc(100vh - 56px); }
.dash-sidebar {
  width: 220px; min-width: 220px; background: var(--gray-1);
  padding: 24px 0; position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; transition: transform var(--transition);
}
.dash-sidebar .sidebar-logo {
  padding: 0 20px 20px; border-bottom: 1px solid var(--gray-2);
  margin-bottom: 12px;
}
.dash-sidebar .sidebar-logo span { color: var(--white); font-weight: 700; font-size: 1.1rem; }
.dash-sidebar .credits-pill {
  margin: 0 20px 20px; padding: 8px 12px;
  background: var(--gray-2); border-radius: var(--radius);
  font-size: .8rem; color: var(--gray-5);
}
.dash-sidebar .credits-pill strong { color: var(--white); display: block; font-size: 1rem; }
.sidebar-nav { padding: 0; }
.sidebar-nav a {
  display: block; padding: 11px 20px; color: var(--gray-5);
  font-size: .88rem; transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--white); background: var(--gray-2); text-decoration: none; }
.sidebar-nav a.active { color: var(--white); border-left-color: var(--white); background: var(--gray-2); }
.sidebar-nav .nav-section {
  padding: 16px 20px 6px; font-size: .7rem; letter-spacing: 1px;
  text-transform: uppercase; color: var(--gray-4);
}
.dash-main { flex: 1; padding: 32px; background: var(--gray-8); overflow-x: hidden; }
.dash-header { margin-bottom: 28px; }
.dash-header h1 { font-size: 1.6rem; }
.dash-header p  { color: var(--gray-4); margin-top: 4px; font-size: .9rem; }

/* ── Stats Grid ───────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-6);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stat-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: .78rem; color: var(--gray-4); margin-top: 6px; text-transform: uppercase; letter-spacing: .5px; }

/* ── File Upload ──────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-5); border-radius: var(--radius);
  padding: 32px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--black); background: var(--gray-8); }
.upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone .uz-title { font-weight: 600; margin-bottom: 4px; }
.upload-zone .uz-sub   { font-size: .82rem; color: var(--gray-4); }
.upload-zone .uz-file  { margin-top: 8px; font-size: .82rem; color: var(--black); font-weight: 600; }

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--white); border-radius: var(--radius);
  padding: 32px; width: 90%; max-width: 480px; box-shadow: 0 8px 40px rgba(0,0,0,.2);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }

/* ── Spinner ──────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--gray-6);
  border-top-color: var(--black); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 16px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ─────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-6); margin-bottom: 24px; gap: 0; }
.tab-btn {
  padding: 10px 22px; font-size: .88rem; font-weight: 600;
  color: var(--gray-4); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn.active { color: var(--black); border-bottom-color: var(--black); }
.tab-btn:hover { color: var(--gray-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Homepage Hero ────────────────────────────────── */
.hero {
  padding: 80px 0; border-bottom: 1px solid var(--gray-6);
  background: linear-gradient(to bottom, var(--gray-8), var(--white));
}
.hero-inner { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.hero-title { font-size: 2.8rem; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.hero-desc { font-size: 1.05rem; color: var(--gray-3); margin: 18px 0 28px; line-height: 1.7; }
.hero-form { background: var(--white); border: 1px solid var(--gray-6); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }

/* ── Products Section ─────────────────────────────── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.product-card {
  border: 1px solid var(--gray-6); border-radius: var(--radius);
  padding: 28px; transition: all var(--transition);
}
.product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.product-card h3 { margin-bottom: 10px; font-size: 1rem; }
.product-card p  { font-size: .87rem; color: var(--gray-4); }
.product-tag {
  display: inline-block; margin-bottom: 12px; padding: 3px 10px;
  background: var(--gray-7); border-radius: 20px;
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}

/* ── API Docs ─────────────────────────────────────── */
.code-block {
  background: var(--gray-1); color: #e0e0e0;
  border-radius: var(--radius); padding: 16px 20px;
  font-family: var(--mono); font-size: .82rem;
  overflow-x: auto; white-space: pre; margin: 12px 0;
}

/* ── Admin override ───────────────────────────────── */
.admin-dash .dash-sidebar { background: #0a0a0a; }

/* ── Mobile Sidebar Toggle ────────────────────────── */
.sidebar-close { display: none; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; gap: 36px; }
  .hero-title { font-size: 2rem; }
  .dash-wrap  { flex-direction: column; }
  .dash-sidebar {
    position: fixed; top: 56px; left: 0; z-index: 200; height: calc(100vh - 56px);
    transform: translateX(-100%); width: 240px;
  }
  .dash-sidebar.open { transform: translateX(0); }
  .dash-main { padding: 20px 16px; }
  .nav-hamburger { display: flex; }
  .nav-links { display: none; flex-direction: column; position: absolute; top: 56px; left: 0; right: 0; background: var(--white); border-bottom: 1px solid var(--gray-6); padding: 12px 24px; gap: 12px; }
  .nav-links.open { display: flex; }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 199; display: none; }
  .sidebar-overlay.visible { display: block; }
  .sidebar-close { display: block; position: absolute; top: 12px; right: 12px; background: none; border: none; color: var(--gray-5); font-size: 1.4rem; cursor: pointer; }
}

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 18px; }
  .hero { padding: 40px 0; }
  .section { padding: 40px 0; }
}

/* ── Utility ──────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16{ margin-top: 16px; }
.mt-24{ margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16{ margin-bottom: 16px; }
.mb-24{ margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: .85rem; }
