/* ==========================================================================
   NEXORA — Sales Intelligence Platform
   Self-initiated product design concept · HTML + CSS only (no JavaScript)
   --------------------------------------------------------------------------
   Interaction model (pure CSS):
   • Date range ......... radio inputs (#r-3m …) + body:has() swap .v-* values
   • Sidebar ............ #navToggle checkbox (desktop collapse / tablet expand / mobile drawer)
   • Menus .............. <details> dropdowns
   • Search ............. :focus-within quick-results panel
   • Tooltips ........... SVG groups revealed on :hover / :focus
   • Sort & filter ...... radio inputs + CSS `order` / display rules
   • Dialogs ............ :target overlays (#preferences, #help)
   ========================================================================== */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  /* Brand */
  --primary-50:  #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary:     #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;

  /* Neutrals (navy-tinted slate) */
  --navy-950: #0b1220;
  --navy-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;

  /* Semantic */
  --bg:            #f6f7fb;
  --surface:       var(--white);
  --surface-muted: var(--slate-50);
  --border:        #e6e8ef;
  --border-strong: var(--slate-300);
  --text:          var(--navy-900);
  --text-2:        var(--slate-600);
  --text-muted:    var(--slate-500);

  /* Status (reserved — never reused as series colors) */
  --good-50: #ecfdf5;  --good: #047857;  --good-500: #10b981;
  --warn-50: #fffbeb;  --warn: #b45309;  --warn-500: #f59e0b;
  --bad-50:  #fef2f2;  --bad:  #b91c1c;
  --info-50: #f0f9ff;  --info: #0369a1;

  /* Categorical data palette (validated: CVD + normal-vision separation) */
  --c1: #4f46e5; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4;

  /* Typography */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: .75rem;      /* 12 */
  --fs-sm: .8125rem;    /* 13 */
  --fs-base: .875rem;   /* 14 */
  --fs-md: 1rem;        /* 16 */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: clamp(1.25rem, 1.1rem + .5vw, 1.5rem);
  --fs-kpi: clamp(1.5rem, 1rem + .9vw, 1.75rem);
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh-tight: 1.2; --lh-base: 1.5;

  /* Spacing (4px scale) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  /* Radius */
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-full: 999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 4px -2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 16px 40px -8px rgba(15, 23, 42, .18), 0 4px 12px -4px rgba(15, 23, 42, .08);
  --ring: 0 0 0 3px rgba(79, 70, 229, .35);

  /* Layout */
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 72px;
  --container-max: 1600px;

  /* Breakpoints (reference values — used in @media below) */
  --bp-sm: 640px; --bp-md: 768px; --bp-lg: 1200px; --bp-xl: 1280px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: .18s;
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, p, ol, ul, dl, dd, fieldset { margin: 0; padding: 0; }
fieldset { border: 0; min-width: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--font-sans); font-size: 11px; font-weight: var(--fw-medium);
  padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted);
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-md); }
.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 300;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: var(--radius-md);
  font-weight: var(--fw-semibold); transition: top var(--dur);
}
.skip-link:focus-visible { top: 16px; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon--sm { width: 16px; height: 16px; }
.icon--xs { width: 14px; height: 14px; }

/* ---------- 3. RANGE SWAP (date range state) ---------- */
.v, .vb { display: none; }
body:has(#r-3m:checked)  .v-3m,
body:has(#r-6m:checked)  .v-6m,
body:has(#r-12m:checked) .v-12m,
body:has(#r-ytd:checked) .v-ytd { display: inline; }
body:has(#r-3m:checked)  .vb-3m,
body:has(#r-6m:checked)  .vb-6m,
body:has(#r-12m:checked) .vb-12m,
body:has(#r-ytd:checked) .vb-ytd { display: block; }

/* ---------- 4. BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-md);
  font-size: var(--fs-base); font-weight: var(--fw-medium); white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur), color var(--dur);
}
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--primary-700); }
.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { border-color: var(--border-strong); background: var(--surface-muted); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--slate-100); color: var(--text); }
.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-sm); }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  color: var(--text-2); background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.icon-btn:hover { background: var(--slate-100); color: var(--text); }
.icon-btn--bordered { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-xs); }
.icon-btn--bordered:hover { border-color: var(--border-strong); background: var(--surface-muted); }

.link-btn { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--primary); cursor: pointer; border-radius: var(--radius-sm); }
.link-btn:hover { color: var(--primary-800); text-decoration: underline; }

/* ---------- 5. BADGES ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px;
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  letter-spacing: .01em; white-space: nowrap; vertical-align: middle;
}
.badge--neutral { background: var(--slate-100); color: var(--slate-600); border: 1px solid var(--border); }
.badge--brand { background: var(--primary-50); color: var(--primary-700); }
.dot-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center; border-radius: var(--radius-full);
  background: var(--primary); color: #fff; font-size: 10px; font-weight: var(--fw-bold);
  border: 2px solid var(--surface);
}

/* ---------- 6. APP SHELL & SIDEBAR ---------- */
.app { display: flex; min-height: 100vh; }
.nav-toggle { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.app:has(.nav-toggle:focus-visible) :is(.sidebar__collapse, .topbar__menu) { box-shadow: var(--ring); }

.sidebar {
  position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5) var(--space-4); background: var(--surface);
  border-right: 1px solid var(--border); z-index: 60;
  transition: width .22s var(--ease), transform .22s var(--ease);
}
.sidebar__brand { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: 0 var(--space-1) var(--space-2); }
.brand { display: flex; align-items: center; gap: 10px; border-radius: var(--radius-md); }
.brand__name { font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: .08em; color: var(--navy-900); }
.sidebar__collapse { width: 34px; height: 34px; }
.sidebar__collapse .icon { transition: transform .22s var(--ease); }

.nav { flex: 1; overflow-y: auto; overflow-x: visible; display: flex; flex-direction: column; gap: var(--space-1); }
.nav__label {
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400);
}
.nav__list { display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: var(--space-3);
  width: 100%; height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  color: var(--text-2); font-weight: var(--fw-medium); white-space: nowrap;
  transition: background var(--dur), color var(--dur);
}
.nav__link:hover { background: var(--slate-100); color: var(--text); }
.nav__meta { margin-left: auto; font-size: 10px; font-weight: var(--fw-semibold); color: var(--slate-400); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 5px; }

/* Active nav: Overview by default, otherwise the targeted section */
body:not(:has(.dash-grid > section:target)) .nav__link[href="#overview"],
body:has(#analytics:target) .nav__link[href="#analytics"],
body:has(#leads:target)     .nav__link[href="#leads"],
body:has(#deals:target)     .nav__link[href="#deals"],
body:has(#pipeline:target)  .nav__link[href="#pipeline"],
body:has(#team:target)      .nav__link[href="#team"] {
  background: var(--primary-50); color: var(--primary-700); font-weight: var(--fw-semibold);
}
body:not(:has(.dash-grid > section:target)) .nav__link[href="#overview"]::before,
body:has(#analytics:target) .nav__link[href="#analytics"]::before,
body:has(#leads:target)     .nav__link[href="#leads"]::before,
body:has(#deals:target)     .nav__link[href="#deals"]::before,
body:has(#pipeline:target)  .nav__link[href="#pipeline"]::before,
body:has(#team:target)      .nav__link[href="#team"]::before {
  content: ""; position: absolute; left: -16px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}

.sidebar__footer { padding-top: var(--space-2); }
.plan-card { padding: var(--space-4); border-radius: var(--radius-lg); background: var(--surface-muted); border: 1px solid var(--border); }
.plan-card__title { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-semibold); font-size: var(--fs-sm); margin-bottom: var(--space-3); color: var(--primary-700); }
.plan-card__meta { margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--text-muted); }
.plan-card__meta strong { color: var(--text); }
.progress { height: 6px; border-radius: var(--radius-full); background: var(--primary-100); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

.scrim { display: none; }

/* Collapsed sidebar (desktop: checkbox on) */
@media (min-width: 1200px) {
  .app:has(#navToggle:checked) .sidebar { width: var(--sidebar-w-collapsed); padding-inline: var(--space-3); }
  .app:has(#navToggle:checked) :is(.brand__name, .nav__text, .nav__meta, .plan-card) { display: none; }
  .app:has(#navToggle:checked) .nav__label { font-size: 0; padding: var(--space-2) 0; border-top: 1px solid var(--border); margin: var(--space-2) var(--space-2) 0; }
  .app:has(#navToggle:checked) .sidebar__brand { flex-direction: column; padding-inline: 0; }
  .app:has(#navToggle:checked) .sidebar__collapse .icon { transform: rotate(180deg); }
  .app:has(#navToggle:checked) .nav__link { justify-content: center; padding: 0; }
  .app:has(#navToggle:checked) .nav__link::before { left: -12px !important; }
  .app:has(#navToggle:checked) .nav { overflow: visible; }
  .app:has(#navToggle:checked) .nav__link:is(:hover, :focus-visible)::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
    padding: 6px 10px; border-radius: var(--radius-sm); background: var(--navy-900); color: #fff;
    font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap; box-shadow: var(--shadow-md); z-index: 70;
  }
}

/* ---------- 7. TOP HEADER ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: var(--topbar-h); padding: var(--space-3) var(--space-8);
  background: rgba(255, 255, 255, .86); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__lead { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar__menu { display: none; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); }
.breadcrumb a { border-radius: 4px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb [aria-current] { color: var(--text-2); font-weight: var(--fw-medium); }
.page-title__h { display: flex; align-items: center; gap: var(--space-3); font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-3); }

/* Search */
.search { position: relative; display: flex; align-items: center; }
.search__icon { position: absolute; left: 12px; color: var(--slate-400); pointer-events: none; }
.search__input {
  width: 280px; height: 40px; padding: 0 52px 0 38px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted);
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur), width var(--dur);
}
.search__input::placeholder { color: var(--slate-400); }
.search__input:hover { border-color: var(--border-strong); }
.search__input:focus { outline: none; background: var(--surface); border-color: var(--primary-400); box-shadow: var(--ring); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__kbd { position: absolute; right: 10px; pointer-events: none; }
.search__panel { display: none; left: 0; right: auto; width: 100%; min-width: 300px; }
.search:focus-within .search__panel { display: block; }

/* ---------- 8. DROPDOWNS (<details>) ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { border-color: var(--primary-300); }
.menu[open] .menu__chev { transform: rotate(180deg); }
.menu__chev { transition: transform var(--dur); color: var(--text-muted); }
.dropdown {
  position: absolute; top: calc(100% + 8px); z-index: 80; min-width: 240px; padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); animation: pop .14s var(--ease);
}
.dropdown--right { right: 0; }
.dropdown--wide { width: 360px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.dropdown__group { padding: var(--space-2) var(--space-3) var(--space-1); font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); }
.dropdown__item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%;
  min-height: 38px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-weight: var(--fw-medium); color: var(--text); cursor: pointer; text-align: left;
}
.dropdown__item:hover, .dropdown__item:focus-visible { background: var(--slate-100); }
.dropdown__item > .icon { color: var(--text-muted); }
.dropdown__hint { margin-left: auto; display: block; font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--text-muted); }
.dropdown__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
.dropdown__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.dropdown__profile { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); }
.dropdown__name { font-weight: var(--fw-semibold); }
.dropdown__meta { font-size: var(--fs-xs); color: var(--text-muted); }
.dropdown__sep { height: 1px; background: var(--border); margin: var(--space-2) 0; }

/* Date range options */
.range-opt { justify-content: space-between; }
.range-opt .dropdown__hint { margin: 0; }
.range-opt__check { visibility: hidden; color: var(--primary); }
body:has(#r-3m:checked)  .range-opt--3m,
body:has(#r-6m:checked)  .range-opt--6m,
body:has(#r-12m:checked) .range-opt--12m,
body:has(#r-ytd:checked) .range-opt--ytd { background: var(--primary-50); color: var(--primary-700); }
body:has(#r-3m:checked)  .range-opt--3m .range-opt__check,
body:has(#r-6m:checked)  .range-opt--6m .range-opt__check,
body:has(#r-12m:checked) .range-opt--12m .range-opt__check,
body:has(#r-ytd:checked) .range-opt--ytd .range-opt__check { visibility: visible; }

/* Notifications */
.notif-list { display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.notif { position: relative; display: flex; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); font-size: var(--fs-sm); }
.notif p { color: var(--text); }
.notif time { font-size: var(--fs-xs); color: var(--text-muted); }
.notif__icon { width: 32px; height: 32px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--primary-50); color: var(--primary); }
.notif__icon--won { background: var(--good-50); color: var(--good); }
.notif__icon--warn { background: var(--warn-50); color: var(--warn); }
.notif.is-unread { background: var(--surface-muted); }
.notif.is-unread::after { content: ""; position: absolute; right: 12px; top: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.read-on { display: none; }
body:has(#notifRead:checked) .dot-badge { display: none; }
body:has(#notifRead:checked) .notif.is-unread { background: none; }
body:has(#notifRead:checked) .notif.is-unread::after { display: none; }
body:has(#notifRead:checked) .read-off { display: none; }
body:has(#notifRead:checked) .read-on { display: inline; }
.dropdown__head:has(.notif-read:focus-visible) .link-btn { box-shadow: var(--ring); }

/* Profile */
.profile-btn {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 var(--space-2) 0 4px;
  border-radius: var(--radius-full); border: 1px solid transparent; cursor: pointer;
}
.profile-btn:hover { background: var(--slate-100); }
.profile-btn__text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; white-space: nowrap; }
.profile-btn .avatar { flex-shrink: 0; }
.profile-btn__text { display: none; } /* avatar only — name & role live in the profile menu */
.profile-btn { padding-right: 6px; }
/* Header never overlaps: title keeps its size, search gives up space first */
.topbar__lead { flex-shrink: 0; }
.topbar__actions { min-width: 0; }
.topbar__actions > .search { flex: 0 1 280px; min-width: 160px; }
.topbar__actions .search__input { width: 100%; }
.nav { scrollbar-width: thin; scrollbar-color: var(--slate-200) transparent; }
.profile-btn__name { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.profile-btn__role { font-size: var(--fs-xs); color: var(--text-muted); }

/* Avatars */
.avatar {
  --av: var(--slate-500);
  width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: .02em; color: #fff;
  background: var(--av);
}
.avatar--brand { background: linear-gradient(135deg, var(--primary-500), var(--primary-800)); }
.avatar--lg { width: 44px; height: 44px; font-size: var(--fs-sm); }
.avatar--xs { width: 24px; height: 24px; font-size: 10px; }

/* ---------- 9. PAGE CONTENT ---------- */
.content { width: 100%; max-width: var(--container-max); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-10); outline: none; }
.section, .card, .trow { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.section-head__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.section-head__sub { color: var(--text-muted); font-size: var(--fs-sm); }

/* Segmented control (date range radios) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--slate-100); border: 1px solid var(--border); border-radius: 10px; }
.segmented__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented__btn {
  min-width: 52px; height: 32px; padding: 0 var(--space-3); display: grid; place-items: center;
  border-radius: 7px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-muted); cursor: pointer;
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.segmented__btn:hover { color: var(--text); }
.segmented__input:checked + .segmented__btn { background: var(--surface); color: var(--primary-700); box-shadow: var(--shadow-sm); }
.segmented__input:focus-visible + .segmented__btn { box-shadow: var(--ring); }

/* ---------- 10. KPI CARDS ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); margin-bottom: var(--space-6); }
.kpi {
  --tone: var(--primary); --tone-50: var(--primary-50);
  position: relative; display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-5); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); overflow: hidden;
  transition: box-shadow var(--dur), transform var(--dur), border-color var(--dur);
}
.kpi::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--tone); opacity: .9; }
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--slate-300); }
.kpi--indigo  { --tone: #4f46e5; --tone-50: #eef2ff; }
.kpi--sky     { --tone: #0284c7; --tone-50: #e0f2fe; }
.kpi--emerald { --tone: #059669; --tone-50: #d1fae5; }
.kpi--amber   { --tone: #d97706; --tone-50: #fef3c7; }
.kpi__top { display: flex; align-items: center; gap: var(--space-3); }
.kpi__icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--tone-50); color: var(--tone); }
.kpi__title { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.kpi__value { font-size: var(--fs-kpi); font-weight: var(--fw-bold); letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__body { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.kpi__foot { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-3); border-top: 1px solid var(--slate-100); }
.kpi__prev { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.trend { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.trend--up { background: var(--good-50); color: var(--good); }
.trend--down { background: var(--bad-50); color: var(--bad); }
.spark { width: 96px; height: 40px; flex-shrink: 0; overflow: visible; }
.spark__line { fill: none; stroke: var(--tone); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark__area { fill: var(--tone); opacity: .1; }
.spark__dot { fill: var(--surface); stroke: var(--tone); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* ---------- 11. CARDS & GRID ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-6); grid-auto-flow: row dense; }
.col-4 { grid-column: span 4; } .col-5 { grid-column: span 5; } .col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.card {
  display: flex; flex-direction: column; gap: var(--space-4); min-width: 0;
  padding: var(--space-6); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-sm);
}
.card:target { border-color: var(--primary-300); box-shadow: var(--shadow-sm), 0 0 0 3px var(--primary-100); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.card__head--wrap { flex-wrap: wrap; }
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.card__sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); }

/* Stat row */
.stat-row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-8); padding-bottom: var(--space-2); }
.stat-row dt { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-medium); }
.stat-row dd { font-size: var(--fs-lg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-row dd.pos { color: var(--good); }

/* Legend (toggle chips) */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.legend__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.legend__item {
  display: inline-flex; align-items: center; gap: var(--space-2); height: 32px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text-2); background: var(--surface); cursor: pointer; transition: opacity var(--dur), background var(--dur);
}
.legend__item:hover { background: var(--surface-muted); }
.legend__input:not(:checked) + .legend__item { opacity: .5; text-decoration: line-through; }
.legend__input:focus-visible + .legend__item { box-shadow: var(--ring); }
.legend--static .legend__item { cursor: default; border: 0; padding: 0 var(--space-1); height: auto; }
.legend--static .legend__item:hover { background: none; }
.legend__swatch { width: 16px; height: 3px; border-radius: 2px; }
.legend__swatch--sq { width: 10px; height: 10px; border-radius: 3px; }
.legend__swatch--primary { background: var(--primary); }
.legend__swatch--target { background: repeating-linear-gradient(90deg, var(--slate-400) 0 5px, transparent 5px 8px); }
.legend__swatch--muted { background: var(--slate-300); }

/* ---------- 12. CHARTS (inline SVG) ---------- */
.chart { position: relative; margin-top: auto; }
.chart-svg { width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.grid { stroke: var(--slate-200); stroke-width: 1; }
.axis { fill: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.axis--y { text-anchor: end; }
.axis--x { text-anchor: middle; }
.band { fill: var(--primary-50); }
.band__label { fill: var(--primary-700); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.rev-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.tgt-line { fill: none; stroke: var(--slate-400); stroke-width: 2; stroke-dasharray: 6 5; stroke-linecap: round; }
.hov, .bar-group { cursor: crosshair; outline: none; }
.hov__hit { fill: transparent; }
.hov__line { stroke: var(--slate-300); stroke-width: 1; opacity: 0; }
.dot { stroke: var(--surface); stroke-width: 2.5; opacity: 0; transition: opacity var(--dur); }
.dot--rev { fill: var(--primary); }
.dot--tgt { fill: var(--slate-400); }
.tip { opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.tip__box { fill: var(--navy-900); filter: drop-shadow(0 8px 16px rgba(15, 23, 42, .25)); }
.tip__title { fill: #fff; font-size: 13px; font-weight: 600; }
.tip__text { fill: var(--slate-300); font-size: 12px; }
.tip__num { fill: #fff; font-size: 12px; font-weight: 600; text-anchor: end; font-variant-numeric: tabular-nums; }
.tip__muted { fill: var(--slate-400); font-size: 11px; }
.tip__sw--rev { fill: var(--primary-400); }
.tip__sw--tgt { fill: var(--slate-400); }
.tip__sw--muted { fill: var(--slate-300); }
:is(.hov, .bar-group):is(:hover, :focus) :is(.tip, .hov__line, .dot) { opacity: 1; }
:is(.hov, .bar-group):focus-visible .hov__hit { fill: rgba(79, 70, 229, .06); stroke: var(--primary-300); stroke-width: 1.5; }

.bar { transition: opacity var(--dur), fill var(--dur); }
.bar--actual { fill: var(--primary); }
.bar--target { fill: var(--slate-200); }
.bar-group:is(:hover, :focus) .bar--actual { fill: var(--primary-700); }
.bar-group:is(:hover, :focus) .bar--target { fill: var(--slate-300); }
.bar-group:is(:hover, :focus) .hov__hit { fill: rgba(15, 23, 42, .035); }
body:has(#r-3m:checked)  .bar-group:not(.in-3m) :is(.bar, .axis),
body:has(#r-6m:checked)  .bar-group:not(.in-6m) :is(.bar, .axis),
body:has(#r-ytd:checked) .bar-group:not(.in-ytd) :is(.bar, .axis) { opacity: .3; }

/* Series visibility (legend toggles + preferences) */
body:has(#lgRev:not(:checked)) #revChart .series-rev,
body:has(#lgTgt:not(:checked)) #revChart .series-tgt,
body:has(#pTargets:not(:checked)) .series-tgt { display: none; }
body:has(#pTargets:not(:checked)) label[for="lgTgt"] { display: none; }

/* ---------- 13. DONUT / LEAD SOURCES ---------- */
.donut { position: relative; width: min(220px, 100%); aspect-ratio: 1; margin: var(--space-2) auto var(--space-1); }
.donut__svg { width: 100%; height: 100%; }
.donut__track { fill: none; stroke: var(--slate-100); stroke-width: 5; }
.seg { fill: none; stroke-width: 5; cursor: pointer; transition: stroke-width var(--dur), opacity var(--dur); }
.seg.s0 { stroke: var(--c1); } .seg.s1 { stroke: var(--c2); } .seg.s2 { stroke: var(--c3); } .seg.s3 { stroke: var(--c4); } .seg.s4 { stroke: var(--c5); }
.seg:hover { stroke-width: 6.4; }
.donut__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.dc { display: none; flex-direction: column; align-items: center; max-width: 60%; }
.dc--default { display: flex; }
.donut__value { font-size: 1.625rem; font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.donut__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-medium); }
#leads:has(:is(.s0:hover, .source--0:hover)) .dc--default,
#leads:has(:is(.s1:hover, .source--1:hover)) .dc--default,
#leads:has(:is(.s2:hover, .source--2:hover)) .dc--default,
#leads:has(:is(.s3:hover, .source--3:hover)) .dc--default,
#leads:has(:is(.s4:hover, .source--4:hover)) .dc--default { display: none; }
#leads:has(:is(.s0:hover, .source--0:hover)) .dc--0,
#leads:has(:is(.s1:hover, .source--1:hover)) .dc--1,
#leads:has(:is(.s2:hover, .source--2:hover)) .dc--2,
#leads:has(:is(.s3:hover, .source--3:hover)) .dc--3,
#leads:has(:is(.s4:hover, .source--4:hover)) .dc--4 { display: flex; }
#leads:has(.source--0:hover) .seg:not(.s0),
#leads:has(.source--1:hover) .seg:not(.s1),
#leads:has(.source--2:hover) .seg:not(.s2),
#leads:has(.source--3:hover) .seg:not(.s3),
#leads:has(.source--4:hover) .seg:not(.s4) { opacity: .25; }

.source-list { display: flex; flex-direction: column; gap: 2px; }
.source {
  display: grid; grid-template-columns: 10px 1fr auto 44px; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-2); border-radius: var(--radius-md); font-size: var(--fs-sm); cursor: default;
}
.source:hover { background: var(--surface-muted); }
.source__sw { width: 10px; height: 10px; border-radius: 3px; }
.source--0 .source__sw { background: var(--c1); } .source--1 .source__sw { background: var(--c2); } .source--2 .source__sw { background: var(--c3); }
.source--3 .source__sw { background: var(--c4); } .source--4 .source__sw { background: var(--c5); }
.source__name { color: var(--text-2); font-weight: var(--fw-medium); }
.source__count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.source__pct { text-align: right; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

/* ---------- 14. PIPELINE ---------- */
.pipeline { display: flex; flex-direction: column; gap: var(--space-2); }
.stage { --stage: var(--primary-300); }
.stage--1 { --stage: var(--primary-400); } .stage--2 { --stage: var(--primary-500); }
.stage--3 { --stage: var(--primary); } .stage--4 { --stage: var(--good-500); }
.stage__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: 6px; }
.stage__name { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--fw-medium); }
.stage__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stage); }
.stage__nums { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stage__nums strong { color: var(--text); font-weight: var(--fw-semibold); }
.stage__track { height: 12px; border-radius: var(--radius-full); background: var(--slate-100); overflow: hidden; }
.stage__fill { height: 100%; border-radius: inherit; background: var(--stage); min-width: 12px; transition: width .4s var(--ease); }
.stage__conv { display: flex; align-items: center; gap: 4px; margin: 6px 0 2px 1px; font-size: var(--fs-xs); color: var(--text-muted); }
.stage--4 .stage__name { color: var(--good); }

/* ---------- 15. CHIPS (filters) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); cursor: pointer;
  transition: background var(--dur), color var(--dur), border-color var(--dur);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip__n { font-size: 11px; padding: 0 6px; border-radius: var(--radius-full); background: var(--slate-100); color: var(--text-muted); }
.chip__input:checked + .chip { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.chip__input:checked + .chip .chip__n { background: rgba(255, 255, 255, .16); color: #fff; }
.chip__input:focus-visible + .chip { box-shadow: var(--ring); }
.chips--sm .chip { height: 28px; }

/* ---------- 16. TABLE (sortable + filterable via CSS) ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--space-6) * -1) calc(var(--space-6) * -1); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.table { min-width: 680px; }
.th-sort { white-space: nowrap; }
.trow {
  display: grid; grid-template-columns: minmax(170px, 1.8fr) minmax(96px, .8fr) minmax(104px, 1fr) minmax(100px, .8fr) minmax(150px, 1.2fr);
  align-items: center; gap: var(--space-3); padding: 12px var(--space-5); border-bottom: 1px solid var(--border);
  transition: background var(--dur), padding var(--dur);
}
.trow--head { padding-block: 10px; background: var(--surface-muted); }
.tbody { display: flex; flex-direction: column; }
.tbody .trow:last-child { border-bottom: 0; }
.tbody .trow:hover { background: var(--surface-muted); }
.trow:target { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary); }
.tcell.num { text-align: right; justify-self: end; font-variant-numeric: tabular-nums; }
.tcell { font-variant-numeric: tabular-nums; }
.th-sort { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.th-sort:hover { color: var(--text); }
.th-sort .icon { opacity: .5; }
.sort__input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sort__input:checked + .th-sort { color: var(--primary-700); }
.sort__input:checked + .th-sort .icon { opacity: 1; }
.sort__input:focus-visible + .th-sort { box-shadow: var(--ring); }

/* Sort: each row carries its rank per column as a custom property */
.tbody .trow { order: var(--o-rev); }
.table:has(#s-name:checked)  .tbody .trow { order: var(--o-name); }
.table:has(#s-deals:checked) .tbody .trow { order: var(--o-deals); }
.table:has(#s-conv:checked)  .tbody .trow { order: var(--o-conv); }
.table:has(#s-att:checked)   .tbody .trow { order: var(--o-att); }

/* Filter by status */
#team:has(#f-ex:checked)   .tbody .trow:not([data-status="ex"]),
#team:has(#f-on:checked)   .tbody .trow:not([data-status="on"]),
#team:has(#f-risk:checked) .tbody .trow:not([data-status="risk"]) { display: none; }

body:has(#pDense:checked) .tbody .trow { padding-block: 6px; }
body:has(#pDense:checked) .tbody .avatar { width: 28px; height: 28px; font-size: 10px; }

.rep { display: flex; align-items: center; gap: var(--space-3); }
.rep__name { display: block; font-weight: var(--fw-semibold); }
.rep__meta { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.rev-cell { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 6px; font-weight: var(--fw-semibold); }
.minibar { width: 80px; height: 4px; border-radius: 2px; background: var(--slate-100); overflow: hidden; }
.minibar span { display: block; height: 100%; margin-left: auto; background: var(--primary-400); border-radius: inherit; }
.status { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.status--ex   { background: var(--good-50); color: var(--good); }
.status--on   { background: var(--info-50); color: var(--info); }
.status--risk { background: var(--warn-50); color: var(--warn); }
.att { display: block; margin-top: 3px; font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- 17. ACTIVITY TIMELINE ---------- */
.timeline { display: flex; flex-direction: column; }
.act { position: relative; display: flex; gap: var(--space-3); padding-bottom: var(--space-4); }
.act:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 38px; bottom: 4px; width: 1px; background: var(--border); }
.act__icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; }
.act__icon--lead { background: var(--primary-50); color: var(--primary); }
.act__icon--deal { background: var(--info-50); color: var(--info); }
.act__icon--won  { background: var(--good-50); color: var(--good); }
.act__title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.act__desc { font-size: var(--fs-sm); color: var(--text-2); }
.act__desc strong { color: var(--text); font-weight: var(--fw-medium); }
.act__time { font-size: var(--fs-xs); color: var(--text-muted); }
#activity:has(#a-lead:checked) .act:not([data-type="lead"]),
#activity:has(#a-deal:checked) .act:not([data-type="deal"]),
#activity:has(#a-won:checked)  .act:not([data-type="won"]) { display: none; }

/* ---------- 18. OVERLAYS (:target dialogs) ---------- */
.overlay { position: fixed; inset: 0; z-index: 200; display: none; justify-content: flex-end; }
.overlay:target { display: flex; }
.overlay--center { align-items: center; justify-content: center; padding: var(--space-4); }
.overlay__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); animation: fade .18s; cursor: default; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: relative; width: min(420px, 100%); height: 100%; display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-lg); animation: slide .22s var(--ease);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer__head, .modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border); }
.drawer__title, .modal__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.drawer__body { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-6); }
.drawer__foot, .modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); }
.modal { position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: pop .18s var(--ease); }
.modal__sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); }
.modal__body { padding: var(--space-5) var(--space-6); }
.help-list { display: flex; flex-direction: column; gap: var(--space-4); }
.help-list li { display: flex; gap: var(--space-3); color: var(--text-2); }
.help-list .icon { margin-top: 2px; color: var(--primary); }
.help-list strong { color: var(--text); }

/* Switch rows */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row strong { display: block; font-weight: var(--fw-semibold); }
.switch-row__hint { display: block; font-size: var(--fs-sm); color: var(--text-muted); }
.switch {
  appearance: none; flex-shrink: 0; width: 40px; height: 24px; margin: 0; border-radius: var(--radius-full);
  background: var(--slate-300); position: relative; cursor: pointer; transition: background var(--dur);
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { box-shadow: var(--ring); }

/* ---------- 19. FOOTER ---------- */
.page-foot { margin-top: var(--space-8); color: var(--text-muted); font-size: var(--fs-xs); }
.page-foot p { display: flex; align-items: center; justify-content: center; gap: var(--space-2); text-align: center; }

/* ---------- 20. MOTION PREFERENCES ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
html:has(#pMotion:checked) { scroll-behavior: auto; }
body:has(#pMotion:checked) *, body:has(#pMotion:checked) *::before, body:has(#pMotion:checked) *::after { transition: none !important; animation: none !important; }

/* ---------- 21. RESPONSIVE ---------- */
/* Large tablet / small laptop */
@media (max-width: 1279px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .col-8, .col-7 { grid-column: span 12; }
  .col-4, .col-5 { grid-column: span 6; }
  #activity { grid-column: span 12; }
  .search__input { width: 220px; }
}

/* Tablet: sidebar collapsed to icons by default, checkbox expands it */
@media (min-width: 768px) and (max-width: 1199px) {
  .app:not(:has(#navToggle:checked)) .sidebar { width: var(--sidebar-w-collapsed); padding-inline: var(--space-3); }
  .app:not(:has(#navToggle:checked)) :is(.brand__name, .nav__text, .nav__meta, .plan-card) { display: none; }
  .app:not(:has(#navToggle:checked)) .nav__label { font-size: 0; padding: var(--space-2) 0; border-top: 1px solid var(--border); margin: var(--space-2) var(--space-2) 0; }
  .app:not(:has(#navToggle:checked)) .sidebar__brand { flex-direction: column; padding-inline: 0; }
  .app:not(:has(#navToggle:checked)) .sidebar__collapse .icon { transform: rotate(180deg); }
  .app:not(:has(#navToggle:checked)) .nav__link { justify-content: center; padding: 0; }
  .app:not(:has(#navToggle:checked)) .nav__link::before { left: -12px !important; }
  .app:not(:has(#navToggle:checked)) .nav { overflow: visible; }
  .app:not(:has(#navToggle:checked)) .nav__link:is(:hover, :focus-visible)::after {
    content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
    padding: 6px 10px; border-radius: var(--radius-sm); background: var(--navy-900); color: #fff;
    font-size: var(--fs-xs); white-space: nowrap; box-shadow: var(--shadow-md); z-index: 70;
  }
  .profile-btn__text { display: none; }
  .topbar, .content { padding-inline: var(--space-6); }
  .topbar { flex-wrap: wrap; }
}

/* Mobile: off-canvas drawer navigation */
@media (max-width: 767px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); box-shadow: var(--shadow-lg); z-index: 120; }
  .app:has(#navToggle:checked) .sidebar { transform: none; }
  .app:has(#navToggle:checked) .scrim { display: block; position: fixed; inset: 0; z-index: 110; background: rgba(15, 23, 42, .45); }
  .switch-row--desktop { display: none; }
  .topbar__menu { display: inline-grid; }
  .topbar { flex-wrap: wrap; padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .topbar__lead { flex: 1; }
  .topbar__actions { width: 100%; gap: var(--space-2); flex-wrap: wrap; }
  .search { flex: 1 1 100%; order: 5; min-width: 0; }
  .topbar__actions > .menu:first-of-type { margin-right: auto; }
  .search__input { width: 100%; }
  .search__kbd, .profile-btn__text { display: none; }
  .search__panel { min-width: 0; }
  .menu > .btn .range-label { max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
  .menu > .btn { padding: 0 var(--space-3); }
  .dropdown--wide { width: min(340px, calc(100vw - 32px)); }
  .page-title__h { font-size: 1.25rem; }
  .breadcrumb li:nth-child(-n+2) { display: none; }
  .content { padding: var(--space-4) var(--space-4) var(--space-8); }
  .dash-grid { gap: var(--space-4); }
  .col-4, .col-5, .col-7, .col-8 { grid-column: span 12; }
  .card { padding: var(--space-4); }
  .table-wrap { margin: 0 calc(var(--space-4) * -1) calc(var(--space-4) * -1); }
  .trow { padding-inline: var(--space-4); }
  .chart { overflow-x: auto; margin-inline: calc(var(--space-4) * -1); padding-inline: var(--space-4); }
  .chart-svg { min-width: 560px; }
  .stat-row { gap: var(--space-2) var(--space-6); }
  .stat-row dd { font-size: var(--fs-md); }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; gap: var(--space-3); }
  .section-head { align-items: flex-start; }
  .segmented { width: 100%; }
  .segmented__btn { flex: 1; }
  .profile-btn { padding: 0; }
  .profile-btn .menu__chev { display: none; }
}

/* Anchor visually-hidden form controls to their component */
.segmented, .chips, .legend, .tcell, .dropdown__head { position: relative; }

/* Short screens: give the navigation all the height */
@media (max-height: 720px) { .sidebar__footer { display: none; } }

/* Plus Jakarta Sans is wider: let card headers wrap and tighten sparklines on mid widths */
.card__head { flex-wrap: wrap; }
@media (max-width: 1359px) { .spark { width: 80px; } }
