/* CXP Analytics v3 – the one shared stylesheet.
   Every color, size and space comes from the tokens below. Approved design: mockups/ (STEP 0). */

/* ---------- Inter, self-hosted (SIL OFL 1.1, see fonts/inter/LICENSE) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/inter/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/inter/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/inter/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/inter/inter-latin-700-normal.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* Surfaces */
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-hover: #eef2f7;
  --border:        #d5dbe3;
  --border-strong: #b4bfcc;

  /* Ink (all >= 4.5:1 on --surface; --text and --text-2 >= 7:1) */
  --text:          #0b1220;
  --text-2:        #3b4656;
  --text-muted:    #5b6676;
  --text-invert:   #ffffff;

  /* Brand / interactive */
  --primary:       #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft:  #e3ebfd;
  --focus:         #1d4ed8;

  /* Status (always paired with icon + label) */
  --good:          #0a7a2f;  --good-soft:     #e3f4e8;
  --warn:          #8a5a00;  --warn-soft:     #fdf1d6;  --warn-mark: #fab219;
  --serious:       #b2430f;  --serious-soft:  #fde7dc;
  --critical:      #b42318;  --critical-soft: #fde4e2;
  --neutral-soft:  #e9edf2;

  /* Chart chrome + categorical series (fixed order, never cycled) */
  --chart-grid:    #e3e7ed;
  --chart-axis:    #b4bfcc;
  --series-1:      #2a78d6;
  --series-2:      #eb6834;
  --series-3:      #1baf7a;
  --series-4:      #eda100;
  --series-muted:  #a9b3c1;

  /* Sequential (blue) ramp for heatmaps */
  --seq-1: #e6effc; --seq-2: #cde2fb; --seq-3: #9ec5f4; --seq-4: #6da7ec;
  --seq-5: #3987e5; --seq-6: #256abf; --seq-7: #184f95;

  /* Type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px;
  --fs-xl: 20px; --fs-2xl: 24px; --fs-3xl: 28px;

  /* Space (4px scale) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  --radius: 8px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(11,18,32,.06), 0 1px 3px rgba(11,18,32,.04);
  --sidebar-w: 248px;
  --row-h: 36px;                 /* table density: compact = 32px */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f16; --surface: #141a23; --surface-2: #10151d; --surface-hover: #1c2430;
    --border: #2a3441; --border-strong: #3d4a5c;
    --text: #f2f5f9; --text-2: #c9d1dc; --text-muted: #a3aebd; --text-invert: #0b1220;
    --primary: #7aa7ff; --primary-hover: #a3c2ff; --primary-soft: #1a2a4a; --focus: #7aa7ff;
    --good: #4ade80; --good-soft: #0f2a1a;
    --warn: #fbbf24; --warn-soft: #2e2208;
    --serious: #fb923c; --serious-soft: #2f1a0c;
    --critical: #f87171; --critical-soft: #331516;
    --neutral-soft: #222b37;
    --chart-grid: #232c38; --chart-axis: #3d4a5c;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-muted: #5b6676;
    --seq-1: #16243a; --seq-2: #183258; --seq-3: #184f95; --seq-4: #256abf;
    --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f16; --surface: #141a23; --surface-2: #10151d; --surface-hover: #1c2430;
  --border: #2a3441; --border-strong: #3d4a5c;
  --text: #f2f5f9; --text-2: #c9d1dc; --text-muted: #a3aebd; --text-invert: #0b1220;
  --primary: #7aa7ff; --primary-hover: #a3c2ff; --primary-soft: #1a2a4a; --focus: #7aa7ff;
  --good: #4ade80; --good-soft: #0f2a1a;
  --warn: #fbbf24; --warn-soft: #2e2208;
  --serious: #fb923c; --serious-soft: #2f1a0c;
  --critical: #f87171; --critical-soft: #331516;
  --neutral-soft: #222b37;
  --chart-grid: #232c38; --chart-axis: #3d4a5c;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-muted: #5b6676;
  --seq-1: #16243a; --seq-2: #183258; --seq-3: #184f95; --seq-4: #256abf;
  --seq-5: #3987e5; --seq-6: #6da7ec; --seq-7: #9ec5f4;
  --shadow: none;
}

[data-density="compact"] { --row-h: 30px; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-lg); font-weight: 600; }
h3 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0 0 var(--s3); }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: var(--s2) var(--s3); border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s4) var(--s3); font-weight: 700; font-size: var(--fs-lg); color: var(--text); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--primary); color: var(--text-invert); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.nav { padding: var(--s2) var(--s2) var(--s4); flex: 1; }
.nav-group { margin-top: var(--s3); }
.nav-group-label { padding: 0 var(--s3) var(--s1); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-user { border-top: 1px solid var(--border); padding: var(--s3) var(--s4); display: flex; align-items: center; gap: var(--s3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--neutral-soft); color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: var(--fs-sm); flex: none; }
.sidebar-user .who { flex: 1; min-width: 0; line-height: 1.3; }
.sidebar-user .who strong { display: block; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: var(--fs-xs); color: var(--text-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s3);
  height: 56px; padding: 0 var(--s6);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.crumbs { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs strong { color: var(--text); font-weight: 600; }
.topbar .menu-btn { display: none; }
.content { padding: var(--s6); max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 36px; padding: 0 var(--s4); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 var(--fs-sm)/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-hover); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--text-invert); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--text-invert); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm { height: 30px; padding: 0 var(--s3); font-size: var(--fs-xs); }
.btn[aria-disabled="true"], .btn:disabled { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field label, .field .label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); }
.input, .select {
  height: 36px; padding: 0 var(--s3); border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 400 var(--fs-sm)/1 var(--font); min-width: 0; width: 100%;
}
.select { padding-right: var(--s8); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }

/* ---------- Badges & chips ---------- */
.badge-dev {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.badge-dev::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn-mark); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 18px;
}
.chip::before { font-size: 11px; line-height: 1; }
.chip-good     { background: var(--good-soft);     color: var(--good); }     .chip-good::before     { content: "✓"; }
.chip-warn     { background: var(--warn-soft);     color: var(--warn); }     .chip-warn::before     { content: "!"; font-weight: 800; }
.chip-serious  { background: var(--serious-soft);  color: var(--serious); }  .chip-serious::before  { content: "▲"; font-size: 9px; }
.chip-critical { background: var(--critical-soft); color: var(--critical); } .chip-critical::before { content: "✕"; }
.chip-neutral  { background: var(--neutral-soft);  color: var(--text-2); }   .chip-neutral::before  { content: "•"; }
.chip-plain::before { content: none; }

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s6); margin-bottom: var(--s5); }
.page-header .sub { color: var(--text-muted); margin-top: var(--s1); }
.asof { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; }
.asof svg.icon { width: 15px; height: 15px; }
.asof.is-stale { color: var(--serious); font-weight: 600; }
.callout { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--radius); margin-bottom: var(--s4); border: 1px solid; font-size: var(--fs-sm); }
.callout-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); }
.callout-warn strong { color: var(--warn); }
.callout-info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---------- Toolbar: date range + filters ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3);
  padding: var(--s4); margin-bottom: var(--s5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.toolbar .field { flex: 1 1 160px; max-width: 240px; }
.toolbar .field-range { flex: 2 1 460px; max-width: 520px; }
.daterange { display: flex; gap: var(--s2); }
.daterange .select { flex: 1 1 150px; }
.daterange .input { flex: 0 1 148px; min-width: 132px; padding: 0 var(--s2); }
.toolbar .actions { display: flex; gap: var(--s2); margin-left: auto; }
.filter-summary { font-size: var(--fs-xs); color: var(--text-muted); width: 100%; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--s4); box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.kpi-value { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -0.02em; margin: var(--s1) 0 var(--s2); line-height: 1.15; }
.kpi-value small { font-size: var(--fs-md); font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.kpi-deltas { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); font-size: var(--fs-xs); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta .vs { color: var(--text-muted); font-weight: 500; }
.delta.up-good, .delta.down-good { color: var(--good); }
.delta.up-bad, .delta.down-bad { color: var(--critical); }
.delta.flat { color: var(--text-2); }
.delta.up-good::before, .delta.up-bad::before { content: "▲"; font-size: 9px; }
.delta.down-good::before, .delta.down-bad::before { content: "▼"; font-size: 9px; }
.delta.flat::before { content: "■"; font-size: 8px; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: var(--s4); margin-bottom: var(--s5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; margin-bottom: var(--s5); }
.grid > .card { margin-bottom: 0; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: var(--s4) var(--s4) var(--s3); }
.card-header > div:first-child { flex: 1 1 320px; min-width: 0; }
.card-header .desc { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 0 var(--s4) var(--s4); }
.card-body.flush { padding: 0; }
.card-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-top: 1px solid var(--border); font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }
details.table-view { margin-top: var(--s3); font-size: var(--fs-sm); }
details.table-view summary { cursor: pointer; color: var(--text-2); font-weight: 500; width: max-content; }
details.table-view[open] summary { margin-bottom: var(--s2); }
.legend-inline { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-xs); color: var(--text-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data caption { text-align: left; padding: 0 var(--s4) var(--s2); color: var(--text-muted); font-size: var(--fs-xs); }
table.data th, table.data td { height: var(--row-h); padding: 0 var(--s3); text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: var(--s4); }
table.data th:last-child, table.data td:last-child { padding-right: var(--s4); }
table.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border-strong);
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 180px; }
table.data .sub-line { display: block; font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.2; }
table.data td .bar-cell { display: flex; align-items: center; gap: var(--s2); justify-content: flex-end; }
.inline-bar { width: 72px; height: 6px; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; flex: none; }
.inline-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.inline-bar.is-bad > i { background: var(--critical); }
.inline-bar.is-warn > i { background: var(--warn-mark); }
th[aria-sort] { cursor: pointer; }
th[aria-sort]::after { content: " ↕"; color: var(--text-muted); font-weight: 400; }
th[aria-sort="descending"]::after { content: " ↓"; color: var(--text); }
th[aria-sort="ascending"]::after  { content: " ↑"; color: var(--text); }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--neutral-soft); font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); margin-right: var(--s2); }

/* Heatmap (cohorts) */
table.heat td.cell { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--fs-xs); min-width: 52px; border: 2px solid var(--surface); }
table.heat td.cell.empty { background: transparent; color: var(--text-muted); font-weight: 400; }
/* Ink is chosen per step so every cell clears contrast in both themes. */
.h1 { background: var(--seq-1); color: var(--text); } .h2 { background: var(--seq-2); color: var(--text); }
.h3 { background: var(--seq-3); color: var(--text); } .h4 { background: var(--seq-4); color: var(--text); }
.h5 { background: var(--seq-5); color: #0b1220; }
.h6 { background: var(--seq-6); color: var(--heat-ink-hi); } .h7 { background: var(--seq-7); color: var(--heat-ink-hi); }
:root { --heat-ink-hi: #ffffff; }
:root[data-theme="dark"] { --heat-ink-hi: #0b1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --heat-ink-hi: #0b1220; } }
.heat-legend { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-xs); color: var(--text-muted); }
.heat-legend .ramp { display: flex; }
.heat-legend .ramp i { width: 22px; height: 10px; display: block; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.pagination a, .pagination span {
  min-width: 32px; height: 32px; padding: 0 var(--s2); display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); font-size: var(--fs-sm); text-decoration: none; color: var(--text-2); border: 1px solid transparent;
}
.pagination a:hover { background: var(--surface-hover); color: var(--text); }
.pagination [aria-current="page"] { border-color: var(--primary); color: var(--primary); font-weight: 700; background: var(--primary-soft); }
.pagination .gap { color: var(--text-muted); }

/* ---------- Tabs & segmented ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin-bottom: var(--s5); overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: var(--s3) var(--s4); font: 600 var(--fs-sm)/1 var(--font); color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: 0; background: var(--surface); color: var(--text-2); padding: 0 var(--s3); height: 32px; font: 600 var(--fs-xs)/1 var(--font); cursor: pointer; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--text-invert); }

/* ---------- Stat list (small key figures inside cards) ---------- */
.stat-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s3); }
.stat-list div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s3); }
.stat-list dt { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }
.stat-list dd { margin: 2px 0 0; font-size: var(--fs-xl); font-weight: 700; }

/* ---------- Auth / standalone pages ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: var(--s8); box-shadow: var(--shadow); }
.auth-card .brand { padding: 0; margin-bottom: var(--s6); }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: var(--s1); }
.auth-card form { display: grid; gap: var(--s4); margin-top: var(--s6); }
.auth-card .btn { width: 100%; height: 40px; }
.auth-top { position: fixed; top: var(--s4); right: var(--s4); display: flex; gap: var(--s2); align-items: center; }
.dev-box { margin-top: var(--s6); padding: var(--s4); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.dev-box h2 { font-size: var(--fs-sm); margin-bottom: var(--s1); }
.dev-box p { font-size: var(--fs-xs); color: var(--text-muted); }
.dev-box .row { display: flex; gap: var(--s2); }
.form-error { padding: var(--s2) var(--s3); border-radius: var(--radius-sm); background: var(--critical-soft); color: var(--critical); font-size: var(--fs-sm); font-weight: 500; }

.empty-state { text-align: center; padding: var(--s8) var(--s4); max-width: 520px; margin: 8vh auto 0; }
.empty-state .big-icon { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto var(--s4); display: grid; place-items: center; background: var(--critical-soft); color: var(--critical); }
.empty-state .big-icon svg.icon { width: 28px; height: 28px; }
.empty-state h1 { margin-bottom: var(--s2); }
.empty-state .actions { display: flex; gap: var(--s2); justify-content: center; margin-top: var(--s5); flex-wrap: wrap; }

.form-info { padding: var(--s2) var(--s3); border-radius: var(--radius-sm); background: var(--good-soft); color: var(--good); font-size: var(--fs-sm); font-weight: 500; }
.auth-card .actions { margin-top: var(--s5); }
.auth-card .actions .btn { width: auto; }
.auth-card form .btn { width: 100%; }
.empty-state h2 { margin-bottom: var(--s2); }
.empty-state .big-icon.is-info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Responsive ---------- */
.scrim { display: none; }
@media (max-width: 1100px) {
  .grid-2, .grid-3-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  /* Closed: off-screen, no shadow, and hidden from keyboard/screen readers. */
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 24px rgba(0,0,0,.25); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(11,18,32,.45); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 var(--s4); }
  .content { padding: var(--s4); }
}
@media (max-width: 600px) {
  h1 { font-size: var(--fs-xl); }
  .toolbar .field, .toolbar .field-range { max-width: none; flex-basis: 100%; }
  .daterange { flex-wrap: wrap; }
  .daterange .select { flex-basis: 100%; }
  .daterange .input { flex: 1 1 0; min-width: 0; }
  .toolbar .actions { margin-left: 0; width: 100%; }
  .toolbar .actions .btn { flex: 1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .kpi { padding: var(--s3); }
  .kpi-value { font-size: var(--fs-xl); }
  .chart-box, .chart-box.tall { height: 240px; }
  .topbar .hide-sm { display: none; }
  .auth-card { padding: var(--s6) var(--s5); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .sidebar, .topbar, .toolbar, .pagination { display: none !important; }
  .content { padding: 0; }
}

/* ---------- Phase C report elements ---------- */
.header-meta { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s1); }
.howto { font-size: var(--fs-sm); font-weight: 600; }
.small { font-size: var(--fs-sm); }
.guide-panel { margin-bottom: var(--s5); }
.guide-panel > summary { cursor: pointer; padding: var(--s3) var(--s4); list-style-position: inside; }
.guide-panel .guide-body { padding: 0 var(--s4) var(--s4); font-size: var(--fs-sm); }
.guide-panel h3 { margin: var(--s4) 0 var(--s2); }
.guide-panel ul { margin: 0 0 var(--s3); padding-left: var(--s5); }
.guide-list { margin: 0; padding-left: var(--s5); }
.guide-list li { margin-bottom: var(--s2); }
.guide-panel table.data td.wrap { min-width: 220px; }
.tabs a { padding: var(--s3) var(--s4); font: 600 var(--fs-sm)/1 var(--font); color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); }
.field-check { justify-content: flex-end; flex: 0 1 auto; max-width: none; }
.field-check .check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--text-2); height: 36px; white-space: nowrap; }
.segmented a { display: inline-grid; place-items: center; border-right: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 0 var(--s3); height: 32px; font: 600 var(--fs-xs)/1 var(--font); text-decoration: none; }
.segmented a:last-child { border-right: 0; }
.segmented a[aria-current="true"] { background: var(--primary); color: var(--text-invert); }
.empty-row td { color: var(--text-muted); text-align: center; padding: var(--s5); }
.note { font-size: var(--fs-xs); color: var(--text-muted); }
.kpi-deltas { flex-direction: column; flex-wrap: nowrap; }
.delta { white-space: nowrap; }
.field-check .check { white-space: normal; height: auto; min-height: 36px; }
