/* ── atn BI Dashboard - Core Styles ─────────────────────────── */
/* STAMP: APPCSS-v2 (adds premium themes: ATN Corporate, Executive Light/Dark, Midnight Pro) */
:root {
  /* Brand */
  --atn-red:       #C8102E;
  --atn-red-dark:  #9e0c24;
  --atn-red-light: #f5e6e9;

  /* Neutrals */
  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --surface-2:     #f7f8fa;
  --border:        #e2e6ea;
  --border-light:  #f0f2f5;
  --text:          #1a1d23;
  --text-2:        #4a5568;
  --text-3:        #8a93a4;

  /* Semantic */
  --positive:      #0a7c3e;
  --positive-bg:   #e8f5ee;
  --negative:      #c0392b;
  --negative-bg:   #fdecea;
  --warning:       #d97706;
  --warning-bg:    #fef3cd;
  --info:          #1a6fb5;
  --info-bg:       #dbeafe;
  --neutral:       #6b7280;
  --neutral-bg:    #f3f4f6;

  /* Chart palette */
  --c1: #C8102E; --c2: #1a6fb5; --c3: #0a7c3e;
  --c4: #d97706; --c5: #7c3aed; --c6: #0891b2;
  --c7: #be185d; --c8: #65a30d; --c9: #b45309;

  /* Layout */
  --sidebar-w:     220px;
  --topbar-h:      56px;
  --radius:        8px;
  --radius-sm:     4px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.12);
  --transition:    all .15s ease;
}

/* ── Dark theme overrides ──────────────────────────────────── */
html[data-theme="dark"] {
  --bg:            #14171c;
  --surface:       #1c2026;
  --surface-2:     #23282f;
  --border:        #2e343c;
  --border-light:  #262b32;
  --text:          #e8eaed;
  --text-2:        #b4bcc8;
  --text-3:        #8a93a4;

  --positive-bg:   #16301f;
  --negative-bg:   #3a1c1a;
  --warning-bg:    #3a2e12;
  --info-bg:       #14283f;
  --neutral-bg:    #262b32;

  --atn-red-light: #3a1a20;

  --shadow:        0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:     0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.5);
}
html[data-theme="dark"] body { background: var(--bg); }

/* Form controls must follow the theme in BOTH modes (many page-level styles set
   a background but no text colour, so they fall back to dark default text). */
input, select, textarea, .search-input, .fy-select, .st-select, .hc-select,
.cat-filter, .input, .select {
  color: var(--text);
  background-color: var(--surface);
}
input::placeholder, textarea::placeholder, .search-input::placeholder {
  color: var(--text-3);
  opacity: 1;
}
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] option,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .fy-select,
html[data-theme="dark"] .st-select,
html[data-theme="dark"] .hc-select,
html[data-theme="dark"] .cat-filter,
html[data-theme="dark"] .input,
html[data-theme="dark"] .select {
  color: var(--text);
  background-color: var(--surface-2);
  border-color: var(--border);
}
html[data-theme="dark"] select option { background-color: #1c2026; color: var(--text); }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .search-input::placeholder { color: var(--text-3); }
/* native date/number spinners and select arrows */
html[data-theme="dark"] input[type="range"] { accent-color: var(--atn-red); }

/* ── atn theme — black / yellow / fluro ─────────────────────────────────────
   An additive theme. The default (light) and dark themes above are untouched;
   this only applies when data-theme="atn". Brand accent becomes yellow, surfaces
   go near-black, and semantic + chart colours use fluro tones for contrast. */
html[data-theme="atn"] {
  /* Brand → yellow accent, used sparingly. Black/charcoal carries the design. */
  --atn-red:       #ffd200;   /* atn brand yellow (var name kept for compatibility) */
  --atn-red-dark:  #e6bd00;
  --atn-red-light: #2a2400;   /* deep yellow-tinted charcoal for hover/selected */
  --atn-yellow:    #ffd200;   /* explicit brand yellow for fills/highlights */

  /* Neutrals → deep charcoal/near-black */
  --bg:            #0d0d0f;
  --surface:       #161618;
  --surface-2:     #1e1e22;
  --border:        #2f2f36;
  --border-light:  #242429;
  --text:          #f3f3ef;
  --text-2:        #b9b9b2;
  --text-3:        #82827b;

  /* Semantic → professional, lightened for dark (not fluro/neon) */
  --positive:      #34c97a;  --positive-bg:   #11271c;
  --negative:      #f0556a;  --negative-bg:   #2c1418;
  --warning:       #ffc02e;  --warning-bg:    #2c2410;
  --info:          #4cb5e8;  --info-bg:       #0e2533;
  --neutral:       #9a9a92;  --neutral-bg:    #1e1e22;

  /* Chart palette → brand yellow leads, then a restrained professional set */
  --c1: #ffd200; --c2: #4cb5e8; --c3: #34c97a;
  --c4: #f08a3d; --c5: #b48ef0; --c6: #3fc9bd;
  --c7: #ef6aa8; --c8: #a8cf52; --c9: #e0a94a;

  --shadow:        0 1px 3px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.5);
  --shadow-md:     0 4px 12px rgba(0,0,0,.65);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.7);
}
html[data-theme="atn"] body { background: var(--bg); }
html[data-theme="atn"] input,
html[data-theme="atn"] select,
html[data-theme="atn"] textarea,
html[data-theme="atn"] option,
html[data-theme="atn"] .search-input,
html[data-theme="atn"] .fy-select,
html[data-theme="atn"] .st-select,
html[data-theme="atn"] .hc-select,
html[data-theme="atn"] .cat-filter,
html[data-theme="atn"] .input,
html[data-theme="atn"] .select {
  color: var(--text);
  background-color: var(--surface-2);
  border-color: var(--border);
}
html[data-theme="atn"] select option { background-color: #161618; color: var(--text); }
html[data-theme="atn"] input::placeholder,
html[data-theme="atn"] textarea::placeholder,
html[data-theme="atn"] .search-input::placeholder { color: var(--text-3); }
html[data-theme="atn"] input[type="range"] { accent-color: var(--atn-red); }
/* atn brand badge: yellow fill needs dark text + neutral shadow */
html[data-theme="atn"] .sidebar-logo .logo-mark,
html[data-theme="atn_light"] .sidebar-logo .logo-mark {
  color: #141414;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
/* active nav item → brand-gold fill with dark text (atn themes). One clean,
   consistent highlight marks the open page. */
html[data-theme="atn"] .nav-item.active,
html[data-theme="atn_light"] .nav-item.active {
  color: #141414;
  background: linear-gradient(90deg, var(--atn-yellow, #ffd200) 0%, #f0b400 100%);
  box-shadow: 0 2px 12px rgba(0,0,0,.28);
}
html[data-theme="atn"] .nav-item.active .nav-icon,
html[data-theme="atn_light"] .nav-item.active .nav-icon { color: #141414; opacity: 1; }
/* On the yellow brand accent, button text needs to be dark to stay readable. */
html[data-theme="atn"] .btn-primary,
html[data-theme="atn"] button.primary,
html[data-theme="atn"] .ri-vt.on,
html[data-theme="atn"] .ri-viewtoggle button[style*="atn-red"] { color: #0d0d0f !important; }

/* ── atn light theme — soft grey neutrals, black/white/yellow brand ─────────
   Additive. The atn brand is black + yellow with fluro accents. This light
   variant keeps soft light-grey neutrals for page backgrounds and behind cards
   and tables, with near-black text, a readable brand gold for accents/lines,
   and fluro tones (deepened for contrast on light) for highlights and charts. */
html[data-theme="atn_light"] {
  /* Brand → yellow accent used sparingly. Near-black ink does the heavy lifting.
     Bright yellow fails contrast as text on white, so the accent var is a deep
     amber for thin lines/text; bright brand yellow is reserved for solid fills
     (primary buttons, key highlights) via --atn-yellow. */
  --atn-red:       #a87d00;   /* deep amber for accent text/borders/lines (compat name) */
  --atn-red-dark:  #855f00;
  --atn-red-light: #fff6cc;   /* pale yellow tint for hover/selected rows */
  --atn-yellow:    #ffd200;   /* bright brand yellow for solid fills/highlights */

  /* Neutrals → clean white + light neutral greys */
  --bg:            #eceef1;
  --surface:       #ffffff;
  --surface-2:     #f4f6f8;
  --border:        #dce0e4;
  --border-light:  #eaedf0;
  --text:          #141414;   /* near-black brand ink */
  --text-2:        #41454c;
  --text-3:        #71767f;

  /* Semantic → professional, calibrated for light surfaces (not fluro) */
  --positive:      #0f9b4c;  --positive-bg:   #e6f6ed;
  --negative:      #d12537;  --negative-bg:   #fce8eb;
  --warning:       #b87d00;  --warning-bg:    #fdf3d6;
  --info:          #1577b8;  --info-bg:       #e2f1fb;
  --neutral:       #71767f;  --neutral-bg:    #f4f6f8;

  /* Chart palette → brand-led but restrained; c1 a readable gold (pure yellow
     is invisible on white for lines/bars), then a professional set. */
  --c1: #d9a800; --c2: #1577b8; --c3: #0f9b4c;
  --c4: #e8771a; --c5: #8b4fd6; --c6: #119b8d;
  --c7: #d63d8a; --c8: #79a818; --c9: #cf8a16;

  --shadow:        0 1px 3px rgba(20,20,20,.08), 0 1px 2px rgba(20,20,20,.06);
  --shadow-md:     0 4px 12px rgba(20,20,20,.10);
  --shadow-lg:     0 8px 24px rgba(20,20,20,.14);
}
html[data-theme="atn_light"] body { background: var(--bg); }
/* On the brand gold accent, primary-button text stays dark (gold is light-ish);
   use bright yellow as the fill so it still pops as the brand colour. */
html[data-theme="atn_light"] .btn-primary,
html[data-theme="atn_light"] button.primary,
html[data-theme="atn_light"] .ri-vt.on {
  background-color: var(--atn-yellow) !important;
  border-color: var(--atn-yellow) !important;
  color: #161616 !important;
}
html[data-theme="atn_light"] input[type="range"] { accent-color: var(--atn-red); }

/* ═══════════════════════════════════════════════════════════════════════════
   NEW PREMIUM THEME SET (additive). The four themes above (light/dark/atn/
   atn_light) are untouched and remain fully selectable. These four follow the
   enterprise design brief: professional, calm, low-fatigue, colour-for-meaning.
   Each redefines the SAME variable set, including a calibrated chart palette
   (--c1..--c9) so graphs are never over-contrasty — muted on dark, readable on
   light. Switch back any time via the theme picker; nothing here is destructive.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Theme: ATN Corporate ── deep ATN blue primary, red secondary (alerts only),
   very light grey base, white cards. Premium Australian corporate. */
html[data-theme="atn_corporate"] {
  --atn-red:       #1a3e6e;   /* primary = deep ATN blue (compat var name) */
  --atn-red-dark:  #142f54;
  --atn-red-light: #e8eef6;   /* pale blue tint for hover/selected */
  --atn-blue:      #1a3e6e;
  --atn-accent-red:#C8102E;   /* true brand red, reserved for alerts/important */

  --bg:            #eef1f5;
  --surface:       #ffffff;
  --surface-2:     #f5f7fa;
  --border:        #dde3ea;
  --border-light:  #eef1f5;
  --text:          #16202e;
  --text-2:        #45526a;
  --text-3:        #7c889c;

  --positive:      #0f9b4c;  --positive-bg:   #e7f6ed;
  --negative:      #C8102E;  --negative-bg:   #fce8eb;
  --warning:       #c07d00;  --warning-bg:    #fdf3d6;
  --info:          #1a6fb5;  --info-bg:       #e2f0fb;
  --neutral:       #6b7280;  --neutral-bg:    #f3f4f6;

  /* Charts: blue-led, restrained, readable on white. */
  --c1: #1a6fb5; --c2: #1a3e6e; --c3: #0f9b4c;
  --c4: #c07d00; --c5: #6d4bb0; --c6: #128a86;
  --c7: #C8102E; --c8: #5a8f1e; --c9: #b06414;

  --shadow:        0 1px 3px rgba(20,32,46,.08), 0 1px 2px rgba(20,32,46,.06);
  --shadow-md:     0 4px 12px rgba(20,32,46,.10);
  --shadow-lg:     0 8px 24px rgba(20,32,46,.14);
}
html[data-theme="atn_corporate"] body { background: var(--bg); }

/* ── Theme: Executive Light ── soft warm grey base, off-white cards, dark
   charcoal text, muted navy accent. Boardroom meets premium software. */
html[data-theme="exec_light"] {
  --atn-red:       #2f4a6b;   /* muted navy accent (compat name) */
  --atn-red-dark:  #243a55;
  --atn-red-light: #e9edf2;
  --atn-accent-red:#C8102E;

  --bg:            #ecebe8;   /* soft warm grey, not pure white */
  --surface:       #faf9f7;   /* off-white cards */
  --surface-2:     #f2f1ee;
  --border:        #dddbd6;
  --border-light:  #e9e8e4;
  --text:          #2b2f36;   /* dark charcoal, not black */
  --text-2:        #535a64;
  --text-3:        #868d97;

  --positive:      #0f8f47;  --positive-bg:   #e7f4ec;
  --negative:      #c0392b;  --negative-bg:   #fbe9e7;
  --warning:       #b87d00;  --warning-bg:    #fbf2d8;
  --info:          #2f6fa8;  --info-bg:       #e6eff8;
  --neutral:       #6b7280;  --neutral-bg:    #f2f1ee;

  /* Charts: muted, sophisticated, low-fatigue on warm grey. */
  --c1: #2f6fa8; --c2: #2f4a6b; --c3: #0f8f47;
  --c4: #c08438; --c5: #6b5b95; --c6: #2a8f88;
  --c7: #b5485e; --c8: #6f8f3a; --c9: #a9712f;

  --shadow:        0 1px 3px rgba(43,47,54,.07), 0 1px 2px rgba(43,47,54,.05);
  --shadow-md:     0 4px 12px rgba(43,47,54,.09);
  --shadow-lg:     0 8px 24px rgba(43,47,54,.12);
}
html[data-theme="exec_light"] body { background: var(--bg); }

/* ── Theme: Executive Dark ── dark graphite (not black), lighter graphite cards,
   soft grey-white text, steel blue accent. No glow, no saturation. */
html[data-theme="exec_dark"] {
  --atn-red:       #6f9fd0;   /* steel blue accent (compat name) */
  --atn-red-dark:  #5688bd;
  --atn-red-light: #1c2733;
  --atn-accent-red:#f0556a;   /* lightened red for alerts on dark */

  --bg:            #1b1e23;   /* dark graphite, not black */
  --surface:       #23272e;   /* slightly lighter graphite cards */
  --surface-2:     #2b3038;
  --border:        #383e47;
  --border-light:  #2f343c;
  --text:          #dde1e7;   /* soft grey-white */
  --text-2:        #aab2bf;
  --text-3:        #7c8593;

  --positive:      #4cbf80;  --positive-bg:   #15291d;
  --negative:      #e07585;  --negative-bg:   #2b181b;
  --warning:       #d6a23e;  --warning-bg:    #2c2614;
  --info:          #6f9fd0;  --info-bg:       #15222f;
  --neutral:       #8c95a3;  --neutral-bg:    #2b3038;

  /* Charts: calibrated for graphite — clear but not glaring. */
  --c1: #6f9fd0; --c2: #7fb59b; --c3: #4cbf80;
  --c4: #d6a23e; --c5: #a78cc9; --c6: #4fb3ab;
  --c7: #e07585; --c8: #9bbd6a; --c9: #c9954f;

  --shadow:        0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
  --shadow-md:     0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.55);
}
html[data-theme="exec_dark"] body { background: var(--bg); }

/* ── Theme: Midnight Pro ── near-black base, charcoal cards, electric blue
   accent with teal secondary. Premium command centre, low-light operations. */
html[data-theme="midnight_pro"] {
  --atn-red:       #3d9bff;   /* electric blue accent (compat name) */
  --atn-red-dark:  #2f7fd6;
  --atn-red-light: #0e2236;
  --atn-teal:      #2dd4bf;   /* teal secondary accent */
  --atn-accent-red:#ff5d72;

  --bg:            #0c0e13;   /* near-black */
  --surface:       #14171d;   /* charcoal cards */
  --surface-2:     #1b1f27;
  --border:        #282d37;
  --border-light:  #20242d;
  --text:          #e6e9ef;
  --text-2:        #a7afbd;
  --text-3:        #767f8e;

  --positive:      #2dd4bf;  --positive-bg:   #0c2925;
  --negative:      #ff5d72;  --negative-bg:   #2c1419;
  --warning:       #e0a93e;  --warning-bg:    #2c2511;
  --info:          #3d9bff;  --info-bg:       #0e2236;
  --neutral:       #828b99;  --neutral-bg:    #1b1f27;

  /* Charts: electric blue + teal led, kept controlled on near-black. */
  --c1: #3d9bff; --c2: #2dd4bf; --c3: #4cc98a;
  --c4: #e0a93e; --c5: #9d8df0; --c6: #38c5d8;
  --c7: #ff7a98; --c8: #a3d65a; --c9: #d99a4f;

  --shadow:        0 1px 3px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.5);
  --shadow-md:     0 4px 12px rgba(0,0,0,.65);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.7);
}
html[data-theme="midnight_pro"] body { background: var(--bg); }

/* Form controls + active nav for the new dark themes (mirror the dark pattern so
   inputs and the open-page highlight stay readable). */
html[data-theme="exec_dark"] input, html[data-theme="exec_dark"] select,
html[data-theme="exec_dark"] textarea, html[data-theme="exec_dark"] .search-input,
html[data-theme="exec_dark"] .input, html[data-theme="exec_dark"] .select,
html[data-theme="midnight_pro"] input, html[data-theme="midnight_pro"] select,
html[data-theme="midnight_pro"] textarea, html[data-theme="midnight_pro"] .search-input,
html[data-theme="midnight_pro"] .input, html[data-theme="midnight_pro"] .select {
  color: var(--text); background-color: var(--surface-2); border-color: var(--border);
}
html[data-theme="exec_dark"] select option { background-color: #23272e; color: var(--text); }
html[data-theme="midnight_pro"] select option { background-color: #14171d; color: var(--text); }
html[data-theme="exec_dark"] input::placeholder, html[data-theme="midnight_pro"] input::placeholder,
html[data-theme="exec_dark"] .search-input::placeholder, html[data-theme="midnight_pro"] .search-input::placeholder { color: var(--text-3); }
html[data-theme="atn_corporate"] input[type="range"],
html[data-theme="exec_light"] input[type="range"],
html[data-theme="exec_dark"] input[type="range"],
html[data-theme="midnight_pro"] input[type="range"] { accent-color: var(--atn-red); }

/* theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.theme-toggle:hover { border-color: var(--atn-red); color: var(--atn-red); }

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--atn-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1f232b 0%, #15181e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.06);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 11px;
}
.sidebar-logo .logo-mark {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  background: linear-gradient(135deg, var(--atn-red) 0%, var(--atn-red-dark) 100%);
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(200,16,46,.35);
  flex-shrink: 0;
}
.sidebar-logo .logo-sub, #nav-page-name {
  font-size: 10px;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 0;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-nav {
  padding: 10px 10px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
/* Quick-jump search trigger */
.nav-search {
  display: flex; align-items: center; gap: 8px;
  width: 100%; margin: 2px 0 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px; padding: 8px 11px;
  color: rgba(255,255,255,.5);
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.nav-search:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: rgba(255,255,255,.8); }
.nav-search svg { width: 14px; height: 14px; flex-shrink: 0; }
.nav-search span { flex: 1; text-align: left; }
.nav-search kbd {
  font: 600 10px ui-monospace,monospace; color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.08); border-radius: 4px; padding: 1px 5px;
}
/* Frequent strip */
.nav-freq { margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.07); }
.nav-freq-head {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.3px;
  color: rgba(255,255,255,.32); padding: 6px 10px 5px;
}
.nav-pinned {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.nav-section-label {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px;
  color: rgba(255,255,255,.5);
  padding: 11px 11px 10px; margin: 4px 0 0; border-radius: 8px;
  transition: color .16s ease, background .16s ease;
  font-family: inherit;
}
.nav-section-label:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.05); }
.nav-section-label span:first-child { flex: 1; text-align: left; }
/* Current page's group: brighter label so you can see where you are. */
.nav-section-label.active { color: #fff; }
.nav-chev { width: 14px; height: 14px; opacity: .6; transition: transform .2s ease; flex: none; }
.nav-section-label.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-section-label.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-section { position: relative; }
/* Group expands/collapses with a smooth height+fade transition */
.nav-group {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden;
  max-height: 600px; opacity: 1;
  transition: max-height .24s ease, opacity .18s ease, margin .24s ease;
}
.nav-section.is-collapsed .nav-group {
  max-height: 0; opacity: 0; margin: 0; pointer-events: none;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; margin: 1px 0;
  color: rgba(255,255,255,.62);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; border-radius: 8px;
  position: relative; text-decoration: none;
  transition: background .16s ease, color .16s ease, transform .12s ease;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item:active { transform: scale(.985); }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(200,16,46,.95) 0%, rgba(158,12,36,.92) 100%);
  font-weight: 600; cursor: default; pointer-events: none;
  box-shadow: 0 2px 12px rgba(200,16,46,.30);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: #fff;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; opacity: .72; transition: opacity .16s ease;
}
.nav-item:hover .nav-icon { opacity: 1; }
.nav-svg { width: 18px; height: 18px; display: block; }
.nav-label { line-height: 1.2; flex: 1; }

/* ── Command palette ──────────────────────────────────────────────────────── */
.nav-palette {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(10,12,16,.55); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  opacity: 0; transition: opacity .14s ease;
}
.nav-palette.open { display: flex; opacity: 1; }
.np-box {
  margin-top: 12vh; width: min(560px, 92vw);
  background: #1c2027; border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.5);
  overflow: hidden; transform: translateY(-8px); transition: transform .16s ease;
}
.nav-palette.open .np-box { transform: translateY(0); }
.np-input { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.np-input svg { width: 18px; height: 18px; color: rgba(255,255,255,.45); flex-shrink: 0; }
.np-input input { flex: 1; background: none; border: none; outline: none; color: #fff; font: inherit; font-size: 16px; }
.np-input input::placeholder { color: rgba(255,255,255,.4); }
.np-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.np-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 9px; color: rgba(255,255,255,.78); text-decoration: none;
  font-size: 13.5px; cursor: pointer;
}
.np-item .np-ic { width: 18px; height: 18px; opacity: .7; flex-shrink: 0; display: inline-flex; }
.np-item .np-ic svg { width: 18px; height: 18px; }
.np-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.np-lbl { font-size: 13.5px; line-height: 1.25; }
.np-desc { font-size: 11px; color: rgba(255,255,255,.45); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-item.sel .np-desc { color: rgba(255,255,255,.7); }
.np-item.sel { background: linear-gradient(90deg, rgba(200,16,46,.9), rgba(158,12,36,.85)); color: #fff; }
.np-item.sel .np-ic { opacity: 1; }
.np-empty { padding: 22px; text-align: center; color: rgba(255,255,255,.4); font-size: 13px; }
.np-foot {
  display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 10.5px; color: rgba(255,255,255,.4);
}
.np-foot kbd { font: 600 10px ui-monospace,monospace; background: rgba(255,255,255,.1); border-radius: 4px; padding: 1px 5px; margin-right: 3px; }
.sidebar-footer {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px;
  color: rgba(255,255,255,.4);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px;
  border-radius: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--atn-red) 0%, var(--atn-red-dark) 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.btn-logout {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.14);
  color: rgba(255,255,255,.7);
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-logout:hover {
  background: rgba(200,16,46,.85);
  border-color: transparent;
  color: #fff;
}


/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
/* Desktop collapse: hide the sidebar and reclaim the full width. Toggled by the
   collapse button in the sidebar; a floating button brings it back. */
html.nav-hidden .sidebar { transform: translateX(-100%); }
html.nav-hidden .main-content { margin-left: 0; }
.sidebar, .main-content { transition: transform .2s ease, margin-left .2s ease; }
.nav-collapse-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,255,255,.7);
  border-radius: var(--radius-sm);
  width: 26px; height: 26px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.nav-collapse-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-show-btn {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  width: 34px; height: 34px;
  cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
html.nav-hidden .nav-show-btn { display: inline-flex; }
/* When the sidebar is hidden, the floating show button sits top-left; push the
   topbar content across so it never overlaps the page title. */
html.nav-hidden .topbar { padding-left: 60px; }
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Toggle Gross/Net ── */
.toggle-group {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}
.toggle-btn {
  padding: 5px 14px;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
}
.toggle-btn.active {
  background: var(--surface);
  color: var(--atn-red);
  box-shadow: var(--shadow);
}

/* ── FY Selector ── */
.fy-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ── Metric Cards ── */
.metric-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}
.metric-grid-4 { grid-template-columns: repeat(4, 1fr); }
.metric-grid-5 { grid-template-columns: repeat(5, 1fr); }
.metric-grid-3 { grid-template-columns: repeat(3, 1fr); }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-3);
  margin-bottom: 8px;
}
.metric-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.metric-value.large { font-size: 28px; }
.metric-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
}
.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.metric-delta.up   { color: var(--positive); background: var(--positive-bg); }
.metric-delta.down { color: var(--negative); background: var(--negative-bg); }
.metric-delta.flat { color: var(--neutral);  background: var(--neutral-bg);  }

/* ── Data Availability Badge ── */
.data-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}
.data-badge.complete   { background: var(--positive-bg); color: var(--positive); }
.data-badge.partial    { background: var(--warning-bg);  color: var(--warning);  }
.data-badge.unavailable{ background: var(--neutral-bg);  color: var(--text-3);   }

/* ── Cards / Panels ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.card-subtitle {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}
.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }

/* ── Grid layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th {
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.data-table th.num, .data-table td.num { text-align: right; }
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  white-space: nowrap;
}
.data-table tr:hover td { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .total-row td {
  font-weight: 700;
  background: var(--surface-2);
  border-top: 2px solid var(--border);
}
.table-wrap { overflow: auto; max-height: 480px; }

/* ── Bar cells ── */
.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-track {
  flex: 1; height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.bar-fill {
  height: 100%;
  background: var(--atn-red);
  border-radius: 3px;
  transition: width .4s ease;
}

/* ── Month sparkline ── */
.spark { display: flex; align-items: flex-end; gap: 2px; height: 24px; }
.spark-bar {
  flex: 1;
  background: var(--atn-red);
  opacity: .7;
  border-radius: 2px 2px 0 0;
  min-width: 3px;
}
.spark-bar.zero { background: var(--border); opacity: 1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary   { background: var(--atn-red); color: #fff; }
.btn-primary:hover { background: var(--atn-red-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost     { background: none; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Inputs ── */
.input, .select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--atn-red);
  box-shadow: 0 0 0 3px var(--atn-red-light);
}
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-group { flex: 1; }
.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}

/* ── Search ── */
.search-wrap { position: relative; }
.search-wrap .input { padding-left: 32px; }
.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 16px;
  pointer-events: none;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 2px;
  margin-bottom: 20px;
}
.tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--atn-red); border-bottom-color: var(--atn-red); }

/* ── Alerts / Notices ── */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  margin-bottom: 16px;
}
.notice.warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fed7aa; }
.notice.info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #bfdbfe; }
.notice.error   { background: var(--negative-bg);color: var(--negative);border: 1px solid #fecaca; }
.notice-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Tooltips ── */
[data-tip] { position: relative; cursor: help; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85);
  color: #fff;
  font-size: 11px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 999;
  max-width: 240px;
  white-space: normal;
  text-align: center;
}
[data-tip]:hover::after { opacity: 1; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 540px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 20px; cursor: pointer;
  color: var(--text-3); line-height: 1; padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── Loading ── */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  color: var(--text-3);
  gap: 10px;
  font-size: 13px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--atn-red);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 15px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--text);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 380px;
  max-width: 95vw;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .mark {
  font-size: 36px; font-weight: 900;
  color: var(--atn-red);
  letter-spacing: -1px;
  display: block;
}
.login-logo .sub {
  font-size: 12px; color: var(--text-3);
  letter-spacing: 1px; text-transform: uppercase;
  margin-top: 2px;
}
.login-error {
  background: var(--negative-bg);
  color: var(--negative);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

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

/* ── Utility ── */
.mt-4 { margin-top: 4px; }  .mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; } .flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.text-right { text-align: right; }
.text-sm { font-size: 11.5px; } .text-xs { font-size: 11px; }
.text-muted { color: var(--text-3); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .metric-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .metric-grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
}
