/* ============================================================
   DockSpare — Professional Design System v2
   Dark / Light Mode via [data-theme] attribute
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=DM+Serif+Display:ital@0;1&display=swap');

/* ── Theme: Dark (default) ─────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg-base:        #0b141c;
  --bg-surface:     #12202b;
  --bg-elevated:    #182935;
  --bg-overlay:     #1f3641;
  --bg-hover:       #24404c;

  --border-subtle:  rgba(255,255,255,0.07);
  --border-default: rgba(255,255,255,0.11);
  --border-strong:  rgba(255,255,255,0.18);
  --border-accent:  rgba(47,179,172,0.35);
  /* Reserved for the resting-state boundary of controls whose border is the
     ONLY way to perceive their edge (inputs, outline buttons, borderless
     selection cards) — --border-default measures ~1.4:1 here, well under
     WCAG 1.4.11's 3:1 for UI-component boundaries. Not used for cards/
     dividers, which are separated from their surroundings some other way
     (a fill-color change, spacing) and so aren't covered by that criterion. */
  --border-input:   rgba(255,255,255,0.45);

  --text-primary:   #eef2f4;
  --text-secondary: #9fb0bb;
  /* Lightened from #4e5e7a — the old shade read at ~2.3-2.9:1 against every
     surface in this theme, well under WCAG AA's 4.5:1 for normal text. */
  --text-muted:     #708190;
  --text-inverse:   #0b141c;

  /* "Harbor teal" — the brand accent, replacing the old blue. Reads ~5:1 as
     link/active-tab text and ~7.3:1 as the --text-inverse label on top of
     it (see .btn-primary), both clearing WCAG AA's 4.5:1. */
  --accent-primary:   #2fb3ac;
  --accent-hover:     #3ac2ba;
  --accent-subtle:    rgba(47,179,172,0.08);
  --accent-glow:      rgba(47,179,172,0.2);

  /* "Brass" secondary accent — the --text-inverse label on top of it (see
     .btn-gold) clears ~9.5:1. */
  --gold:           #d9b45e;
  --gold-light:     #e6c67a;
  --gold-subtle:    rgba(217,180,94,0.12);
  --gold-border:    rgba(217,180,94,0.25);
  /* Aliases for call sites that expect a brighter/emphasis brass shade
     (star picks, active tabs, timeline "current" state) — reuses
     --gold-light rather than introducing a third brass value. */
  --gold-400:       var(--gold-light);
  --gold-300:       var(--gold-light);

  --teal:           #2fb3ac;
  --teal-subtle:    rgba(47,179,172,0.12);

  --success:        #22c55e;
  --success-subtle: rgba(34,197,94,0.12);
  --warning:        #f59e0b;
  --warning-subtle: rgba(245,158,11,0.12);
  /* Lightened from #ef4444 — as badge text over --danger-subtle it read
     ~4.09:1, under AA's 4.5:1 (plain-text use against page backgrounds was
     already fine; the badge tint alone was pulling it under). */
  --danger:         #f25f5f;
  --danger-subtle:  rgba(242,95,95,0.12);
  /* Lightened from #3b82f6 for the same reason (badge use was ~4.05:1). */
  --info:           #5a97f7;
  --info-subtle:    rgba(90,151,247,0.12);

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.6);
  --shadow-xl:   0 24px 64px rgba(0,0,0,0.7);

  --theme-icon: '☀️';
}

/* ── Theme: Light ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:        #f5f2ea;
  --bg-surface:     #ffffff;
  --bg-elevated:    #ebe6d9;
  --bg-overlay:     #e3ddcc;
  --bg-hover:       #ddd5c0;

  --border-subtle:  rgba(0,0,0,0.06);
  --border-default: rgba(0,0,0,0.1);
  --border-strong:  rgba(0,0,0,0.16);
  --border-accent:  rgba(14,124,123,0.3);
  --border-input:   rgba(0,0,0,0.5);

  --text-primary:   #101d28;
  --text-secondary: #4d5f6c;
  /* Darkened from #8a9bb8 — the old shade read at ~2.5-2.8:1 against every
     surface in this theme, well under WCAG AA's 4.5:1 for normal text. */
  --text-muted:     #5c6b85;
  --text-inverse:   #ffffff;

  /* "Harbor teal" — the brand accent, replacing the old blue. Reads ~5:1 as
     link/badge text on white, the same ratio the --text-inverse label needs
     on top of it (see .btn-primary), clearing WCAG AA's 4.5:1. */
  --accent-primary:   #0e7c7b;
  --accent-hover:     #0a5f5e;
  --accent-subtle:    rgba(14,124,123,0.08);
  --accent-glow:      rgba(14,124,123,0.15);

  /* "Brass" secondary accent. The true brass hue (#b3892f) only reads ~3.2:1
     as text on white, under AA, so — same fix as the old beige→taupe swap
     below it used to be — this darkens it instead: verified at ~5:1 on
     white and ~5.1:1 against --bg-elevated, the darkest light-theme surface
     it appears on, and ~4.7:1 for white text on --gold-light (.btn-gold:hover). */
  --gold:           #7a5a1a;
  --gold-light:     #8f6f22;
  --gold-subtle:    rgba(122,90,26,0.08);
  --gold-border:    rgba(122,90,26,0.2);
  /* No lighter brass variant is defined for light theme — --gold already
     clears AA on its own (see comment above), so alias directly to it. */
  --gold-400:       var(--gold);
  --gold-300:       var(--gold);

  --teal:           #0e7c7b;
  --teal-subtle:    rgba(14,124,123,0.08);

  /* Darkened from #16a34a — read ~3.0-3.3:1, under AA's 4.5:1. */
  --success:        #0f7a37;
  --success-subtle: rgba(15,122,55,0.09);
  /* Darkened from #d97706 — read ~2.9-3.2:1, under AA's 4.5:1. */
  --warning:        #a15c00;
  --warning-subtle: rgba(161,92,0,0.09);
  /* Darkened from #dc2626 — as badge text over --danger-subtle it read
     ~4.19:1, under AA's 4.5:1. */
  --danger:         #c81e1e;
  --danger-subtle:  rgba(200,30,30,0.09);
  --info:           #2563eb;
  --info-subtle:    rgba(37,99,235,0.09);

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.12);
  --shadow-xl:   0 24px 64px rgba(0,0,0,0.15);

  --theme-icon: '🌙';
}

/* ── Radius & Transitions ───────────────────────────────────── */
:root {
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* App shell (sidebar + topbar). The sidebar is always dark, independent
     of the light/dark theme toggle — same as the mockup this was approved
     from — so its tokens live here, not in the per-theme blocks above. */
  --sidebar-w:  232px;
  --topbar-h:   64px;
  --sidebar-bg:            #0b141c;
  --sidebar-text:          rgba(245,242,234,0.68);
  --sidebar-text-active:   #f5f2ea;
  --sidebar-active-bg:     rgba(47,179,172,0.22);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: 'DM Serif Display', Georgia, serif;
  line-height: 1.2;
  color: var(--text-primary);
  font-weight: 400;
}
h1 { font-size: clamp(1.9rem, 4.5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.45rem); }
h4 { font-size: 1.1rem; font-family: 'Inter', sans-serif; font-weight: 600; }

/* ── Layout ─────────────────────────────────────────────────── */
.container       { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.container-wide  { max-width: 1360px; margin: 0 auto; padding: 0 28px; }
.page-content    { min-height: 100vh; }

/* ── Surface Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.card-sm {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: var(--transition);
}
.card-elevated {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.9rem; font-weight: 600;
  border: none; transition: var(--transition);
  white-space: nowrap; letter-spacing: 0.01em;
  position: relative;
}
.btn:hover { transform: scale(1.035); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent-primary);
  /* --text-inverse rather than a literal white — in dark mode, white-on-
     --accent-primary reads at ~3.9:1, under WCAG AA's 4.5:1 for text.
     --text-inverse resolves to a near-black that clears 4.5:1 against this
     background in dark mode, and is plain white in light mode (unchanged). */
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 0 0 1px var(--accent-primary);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px) scale(1.035);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-gold {
  background: var(--gold);
  /* Same reasoning as .btn-primary — white-on-gold in dark mode was ~2.4:1. */
  color: var(--text-inverse);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.btn-gold:hover {
  background: var(--gold-light);
  transform: translateY(-1px) scale(1.035);
  box-shadow: 0 4px 12px rgba(217,180,94,0.3);
}
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-input);
}
.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-subtle);
}
.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--danger);
  /* Same reasoning as .btn-primary — white-on-danger in dark mode was ~3.8:1. */
  color: var(--text-inverse);
}
.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-1px) scale(1.035);
}
.btn-sm  { padding: 7px 15px; font-size: 0.83rem; }
.btn-lg  { padding: 13px 32px; font-size: 1rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); width: 36px; height: 36px; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; margin-bottom: 6px; font-size: 0.845rem; font-weight: 500; color: var(--text-secondary); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif; font-size: 0.9rem;
  transition: var(--transition); outline: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.form-select option { background: var(--bg-elevated); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 96px; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em;
}
.badge-pending   { background: var(--warning-subtle); color: var(--warning);  border: 1px solid rgba(245,158,11,0.25); }
.badge-offer     { background: rgba(6,182,212,0.12);  color: #0891b2;         border: 1px solid rgba(6,182,212,0.3);  }
.badge-accepted  { background: var(--info-subtle);    color: var(--info);     border: 1px solid rgba(59,130,246,0.25); }
.badge-progress  { background: rgba(139,92,246,0.12); color: #7c3aed;         border: 1px solid rgba(139,92,246,0.25); }
.badge-delivered { background: rgba(14,165,233,0.12); color: #0ea5e9;         border: 1px solid rgba(14,165,233,0.25); }
.badge-completed { background: var(--success-subtle); color: var(--success);  border: 1px solid rgba(34,197,94,0.25); }
.badge-paid      { background: var(--success-subtle); color: var(--success);  border: 1px solid rgba(34,197,94,0.25); }
.badge-overdue   { background: var(--danger-subtle);  color: var(--danger);   border: 1px solid rgba(239,68,68,0.25); }
.badge-neutral   { background: var(--bg-elevated);    color: var(--text-secondary); border: 1px solid var(--border-default); }
.badge-gold      { background: var(--gold-subtle);    color: var(--gold);     border: 1px solid var(--gold-border); }
.badge-verified  { background: var(--teal-subtle);    color: var(--teal);     border: 1px solid rgba(47,179,172,0.25); }

/* ── Stars ───────────────────────────────────────────────────── */
.stars    { display: inline-flex; gap: 1px; color: var(--gold); font-size: 0.85rem; }
.stars.lg { font-size: 1.25rem; gap: 3px; }

/* ── Dividers ────────────────────────────────────────────────── */
.divider      { border: none; border-top: 1px solid var(--border-subtle); margin: 20px 0; }
.divider-gold { border-top-color: var(--gold-border); }

/* ── Grid & Flex ─────────────────────────────────────────────── */
.grid-2    { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3    { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4    { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.wrap          { flex-wrap: wrap; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 20px; } .gap-4 { gap: 32px; }

/* ── Spacing ─────────────────────────────────────────────────── */
.mt-1{margin-top:6px;} .mt-2{margin-top:14px;} .mt-3{margin-top:24px;} .mt-4{margin-top:40px;}
.mb-1{margin-bottom:6px;} .mb-2{margin-bottom:14px;} .mb-3{margin-bottom:24px;} .mb-4{margin-bottom:40px;}

/* ── Text Utilities ──────────────────────────────────────────── */
.text-gold      { color: var(--gold); }
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-accent    { color: var(--accent-primary); }
.text-xs   { font-size: 0.75rem; }
.text-sm   { font-size: 0.845rem; }
.text-lg   { font-size: 1.05rem; }
.text-xl   { font-size: 1.3rem; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }
.uppercase     { text-transform: uppercase; letter-spacing: 0.07em; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }

/* ── Section Tags ────────────────────────────────────────────── */
.section-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  background: var(--gold-subtle);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-full);
  font-size: 0.72rem; font-weight: 700;
  color: var(--gold); letter-spacing: 0.09em;
  text-transform: uppercase; margin-bottom: 12px;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}
.tab-btn {
  padding: 9px 20px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: none; background: transparent;
  color: var(--text-muted); font-size: 0.875rem; font-weight: 500;
  transition: var(--transition); position: relative;
}
.tab-btn::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: var(--accent-primary); border-radius: 2px;
  transform: scaleX(0); transition: var(--transition);
}
.tab-btn.active { color: var(--accent-primary); background: var(--accent-subtle); }
.tab-btn.active::after { transform: scaleX(1); }
.tab-btn:hover:not(.active) { color: var(--text-primary); background: var(--bg-elevated); }

/* ── Map ─────────────────────────────────────────────────────── */
#map { width: 100%; height: 420px; border-radius: var(--radius-lg); overflow: hidden; }
.leaflet-container { font-family: 'Inter', sans-serif !important; }

/* ── App Shell: Sidebar + Topbar ─────────────────────────────────
   Replaces the old top navbar site-wide. #navbar (already the first
   element in every page's <body>) becomes a non-boxed mount point for two
   independently fixed-positioned children, so no page's markup needed to
   change — see js/app.js's renderNavbar(). */
.navbar { display: contents; }

/* Only shell pages (everything except index.html — see .navbar-classic
   below) push content over for the sidebar; :has() means this tracks
   whichever markup renderNavbar() actually injected, no JS bookkeeping. */
body:has(.app-sidebar) { margin-left: var(--sidebar-w); transition: margin-left 0.2s ease; }

/* Namespaced .app-sidebar rather than .sidebar — suppliers.html already has
   its own unrelated .sidebar (a category-filter panel) and a bare name
   would collide with it. */
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); z-index: 1000;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; gap: 22px;
  padding: 18px 14px; overflow-y: auto;
  transition: top 0.2s ease, transform 0.2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px; padding: 2px 8px 0;
  font-family: 'Inter', sans-serif; font-size: 1.05rem; font-weight: 800;
  color: var(--sidebar-text-active); letter-spacing: -0.02em;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 800; letter-spacing: -0.03em; color: white;
  flex-shrink: 0;
}
.sidebar-brand .logo-accent { color: var(--gold-400); }

.sidebar-group-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(245,242,234,0.4); padding: 0 10px; margin-bottom: 6px;
}
.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem; font-weight: 500; color: var(--sidebar-text);
  transition: var(--transition);
}
.sidebar-nav a i { font-size: 1.05rem; opacity: 0.85; width: 18px; text-align: center; }
.sidebar-nav a:hover { background: rgba(245,242,234,0.07); color: var(--sidebar-text-active); }
.sidebar-nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.sidebar-nav a.active i { opacity: 1; color: var(--gold-400); }

.sidebar-footer {
  margin-top: auto; border-top: 1px solid rgba(245,242,234,0.1);
  padding-top: 14px; display: flex; align-items: center; gap: 10px;
}
.sidebar-footer-auth { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: var(--topbar-h); z-index: 999;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
  transition: left 0.2s ease, top 0.2s ease, background 0.3s ease, border-color 0.3s ease;
}
.topbar-title {
  font-family: 'DM Serif Display', Georgia, serif; font-weight: 400;
  font-size: 1.2rem; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* Signed-out desktop visitors already have Sign In/Join Free in the always-
   visible sidebar footer — showing them again here would be redundant. On
   mobile the sidebar is an off-canvas drawer, so this becomes the only
   visible way in until it's opened (see the mobile override below). */
.topbar-auth-btns { display: none; }

.sidebar-backdrop { display: none; }

/* ── Classic navbar (index.html only) ──────────────────────────
   The fixed top bar the whole site used to have — kept for the homepage
   specifically, since a permanent sidebar doesn't suit a marketing/landing
   page. See renderClassicNavbar() in js/app.js. */
.navbar-classic {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.navbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 1360px; margin: 0 auto; padding: 0 28px;
}
.navbar-logo {
  display: flex; align-items: center; gap: 9px;
  font-family: 'Inter', sans-serif; font-size: 1.2rem; font-weight: 800;
  color: var(--text-primary); letter-spacing: -0.02em;
}
.navbar-logo-icon {
  width: 34px; height: 34px;
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800; letter-spacing: -0.03em; color: white;
}
.navbar-logo .logo-accent { color: var(--gold); }
.navbar-links { display: flex; align-items: center; gap: 2px; list-style: none; }
.navbar-links a {
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; color: var(--text-secondary);
  transition: var(--transition);
}
.navbar-links a:hover { color: var(--text-primary); background: var(--bg-elevated); }
.navbar-links a.active { color: var(--accent-primary); background: var(--accent-subtle); }
.navbar-actions { display: flex; align-items: center; gap: 8px; }

/* Theme Toggle */
.theme-toggle {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

/* Mobile nav menu toggle — hidden on desktop, shown ≤600px (see Responsive section) */
.navbar-menu-toggle {
  display: none; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 1.1rem; transition: var(--transition); flex-shrink: 0;
}
.navbar-menu-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

/* User Menu */
.user-menu-wrap { position: relative; }
.navbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px; border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border-default);
  cursor: pointer; transition: var(--transition);
}
.navbar-user:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.navbar-avatar {
  width: 28px; height: 28px; border-radius: var(--radius-xs);
  background: var(--accent-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff;
}
.navbar-user-name { font-size: 0.845rem; font-weight: 600; color: var(--text-primary); }
.navbar-user-role { font-size: 0.7rem; color: var(--gold); font-weight: 500; }
.navbar-caret    { font-size: 0.65rem; color: var(--text-muted); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 210px;
  box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; gap: 1px;
  z-index: 999;
  animation: fadeDown 0.15s ease;
}
.user-dropdown.open { display: flex; }
.user-dropdown a, .user-dropdown button {
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 0.875rem; color: var(--text-secondary);
  background: none; border: none; text-align: left; width: 100%;
  display: flex; align-items: center; gap: 8px;
  transition: var(--transition);
}
.user-dropdown a:hover, .user-dropdown button:hover {
  background: var(--bg-elevated); color: var(--text-primary);
}
.user-dropdown .divider-item { border-top: 1px solid var(--border-subtle); margin: 4px 0; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius-md);
  background: var(--bg-surface); border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg); color: var(--text-primary);
  font-size: 0.875rem; max-width: 320px;
  display: flex; align-items: center; gap: 10px;
  animation: slideInRight 0.25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 20px 22px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 14px;
}
/* On-brand tint variants for .stat-icon, replacing ad hoc inline
   rgba(...) backgrounds (some off-brand hues) on dashboard stat tiles. */
.stat-icon-gold   { background: var(--gold-subtle);    color: var(--gold);    }
.stat-icon-teal   { background: var(--teal-subtle);    color: var(--teal);    }
.stat-icon-info   { background: var(--info-subtle);    color: var(--info);    }
.stat-icon-warn   { background: var(--warning-subtle); color: var(--warning); }
.stat-icon-ok     { background: var(--success-subtle); color: var(--success);}
.stat-icon-danger { background: var(--danger-subtle);  color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1; font-family: 'Inter', sans-serif; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.stat-change { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 6px; font-family: 'Inter', sans-serif; }
.empty-state p  { font-size: 0.875rem; }

/* ── Divider Line ────────────────────────────────────────────── */
.section-divider {
  display: flex; align-items: center; gap: 16px; margin: 32px 0;
  color: var(--text-muted); font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.section-divider::before, .section-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border-subtle);
}

/* ── Keyframes ───────────────────────────────────────────────── */
@keyframes fadeIn     { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeDown   { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideInRight { from { opacity:0; transform:translateX(16px); } to { opacity:1; transform:translateX(0); } }
@keyframes pulse      { 0%,100%{opacity:1} 50%{opacity:.5} }

.animate-in              { animation: fadeIn 0.4s ease both; }
.animate-in-delay-1      { animation-delay: 0.07s; }
.animate-in-delay-2      { animation-delay: 0.14s; }
.animate-in-delay-3      { animation-delay: 0.21s; }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Page BG helper ──────────────────────────────────────────── */
.bg-mesh {
  background: var(--bg-base);
}
[data-theme="dark"] .bg-mesh {
  background-image:
    radial-gradient(ellipse at 15% 30%, rgba(47,179,172,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 70%, rgba(217,180,94,0.04) 0%, transparent 50%);
}

/* ── Responsive tables ───────────────────────────────────────── */
/* Wide data tables (auto layout) don't shrink below their content's natural
   width — without this, they silently stretch the whole document wider than
   the viewport on narrow screens, which drags fixed elements like the navbar
   along with it. Scroll the table itself instead. */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container, .container-wide { padding: 0 16px; }
  .card { padding: 20px; }

  /* Sidebar: collapse to an off-canvas drawer, toggled by the hamburger in
     the topbar, closed by tapping the backdrop. Shrink the account pill to
     just the avatar so the topbar's right side fits ~360-400px screens. */
  body { margin-left: 0; }
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .topbar { left: 0; }
  .topbar-title { display: none; }
  .navbar-menu-toggle { display: flex; }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.45);
  }
  .navbar-user-text, .navbar-caret { display: none; }
  /* The sidebar (with its own Sign In/Join Free footer) is now off-canvas,
     so these become the only visible way in until the drawer is opened. */
  .topbar-auth-btns { display: flex; gap: 6px; }
  .navbar-user { padding: 5px; gap: 0; }

  /* Classic navbar (index.html/login.html/register.html): swap the inline
     link row for a hamburger-triggered dropdown, matching the same
     .navbar-menu-toggle used above. */
  .navbar-links {
    display: none;
    position: fixed; top: 64px; left: 0; right: 0; z-index: 999;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-surface); border-bottom: 1px solid var(--border-default);
    padding: 10px; box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 64px); overflow-y: auto;
  }
  .navbar-links.mobile-open { display: flex; }
  .navbar-links a { padding: 12px 14px; }
  /* "Sign In" is already reachable from the hamburger's link list, so drop
     the redundant standalone button — otherwise hamburger + theme toggle +
     Sign In + Join Free don't fit next to the logo. */
  .navbar-signin-btn { display: none; }
}
