/* THOR Analytics Platform - shell styles.
 * Palette, font, and theme system follow the legacy admin hub
 * (apps/web/AdminWebsite/public/index.html): Barlow, light default,
 * navy/blue gradient chrome, "Vampire Mode" dark theme. */

/* color-scheme (customer feedback 2026-08-05, "legend text black on dark
 * mode"): forced-dark renderers (Android Chrome Auto Dark, Samsung dark
 * mode, Dark Reader) darken CSS surfaces but CANNOT recolor canvas-painted
 * chart ink - the light theme's black legend text ends up on force-darkened
 * cards. "only light" is the documented opt-out: the light theme must never
 * be auto-darkened (dark-preferring viewers get the real Vampire Mode by
 * default instead - see app.js). Vampire Mode declares "dark" so native
 * controls (date pickers, selects, scrollbars) render dark too. */
:root { color-scheme: only light; }
:root.vampire-mode { color-scheme: dark; }

:root {
  --blue-darkest: #0B3072;
  --blue-dark: #366AC7;
  --blue-medium: #1D7AEC;
  --grey-light-1: #D2DFEF;
  --grey-medium: #8C8C90;
  --white: #FFFFFF;
  --font-family: 'Barlow', 'Segoe UI', system-ui, sans-serif;
  --transition-speed: 0.3s;

  --bg-primary: #FFFFFF;
  --bg-secondary: #F4F6F9;
  --bg-tertiary: #EDEEF4;
  --text-primary: #0B3072;
  --text-secondary: #000000;
  --text-muted: #8C8C90;
  --border-color: #E1E2E8;
  --shadow-color: rgba(0, 0, 0, 0.07);
  --shadow-hover: rgba(0, 0, 0, 0.12);
  --input-bg: #FFFFFF;
  --code-bg: #EDEEF4;

  --ok: #10B981;
  --warn: #D97706;
  --bad: #DC2626;

  --sidebar-w: 236px;
  --sidebar-w-collapsed: 54px;
  --topbar-h: 56px;
  --radius: 12px;

  --scrollbar-thumb: #B9C4D6;
  --scrollbar-thumb-hover: #99A8C0;
  --scrollbar-track: transparent;
  --sidebar-scrollbar-thumb: rgba(255, 255, 255, 0.28);
  --sidebar-scrollbar-thumb-hover: rgba(255, 255, 255, 0.45);

  font-size: 14px;
}

.vampire-mode {
  --bg-primary: #121212;
  --bg-secondary: #0D0D0D;
  --bg-tertiary: #1E1E1E;
  --text-primary: #E8EAED;
  --text-secondary: #F0F0F0;
  --text-muted: #9AA0A6;
  --border-color: #3C4043;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --shadow-hover: rgba(0, 0, 0, 0.7);
  --input-bg: #1E1E1E;
  --code-bg: #2D2D2D;
  --scrollbar-thumb: #3C4043;
  --scrollbar-thumb-hover: #5F6368;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

/* ---------- scrollbars (thin, rounded, theme-aware) ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-thumb-hover); background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

#sidebar {
  scrollbar-color: var(--sidebar-scrollbar-thumb) transparent;
}
#sidebar::-webkit-scrollbar-thumb { background-color: var(--sidebar-scrollbar-thumb); background-clip: content-box; }
#sidebar::-webkit-scrollbar-thumb:hover { background-color: var(--sidebar-scrollbar-thumb-hover); background-clip: content-box; }

#app { display: flex; min-height: 100vh; }

/* ---------- sidebar: legacy header gradient, vertical ---------- */

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--blue-darkest) 0%, var(--blue-dark) 130%);
  color: var(--white);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.15s ease;
  box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

#app.collapsed #sidebar { width: var(--sidebar-w-collapsed); }
#app.collapsed .label,
#app.collapsed .nav-section-title { display: none; }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  min-height: var(--topbar-h);
  /* Frozen while the sidebar scrolls (operator 2026-08-03): the brand +
   * collapse button stay reachable however long the nav gets. Solid bg =
   * the gradient's top color so scrolled-under items disappear cleanly. */
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--blue-darkest);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

#nav-collapse {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid transparent;
  color: var(--white);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background var(--transition-speed) ease;
}
#nav-collapse:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.4); }

.brand { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; letter-spacing: 0.01em; }
/* The Thor hammer mark. The artwork is near-white on transparent and the
   sidebar is dark in BOTH themes, so it reads correctly without a variant.
   Portrait ratio (718x1033) — height drives the size, width follows. */
.brand-mark { height: 22px; width: auto; display: block; flex: 0 0 auto; }

#nav { flex: 1; padding: 6px 0 16px; }

.nav-section-title {
  padding: 16px 14px 5px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}
.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.nav-section-toggle:hover { color: rgba(255, 255, 255, 0.85); }
.nav-chevron { font-size: 9px; padding-right: 2px; }
/* Icon-collapsed sidebar hides titles, so groups must always show there. */
#app.collapsed .nav-group { display: block !important; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  white-space: nowrap;
  border-left: 3px solid transparent;
  font-weight: 500;
  transition: background 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.1); color: var(--white); }
.nav-item.active {
  background: rgba(255, 255, 255, 0.16);
  color: var(--white);
  border-left-color: #FFD666;
}
.nav-icon { width: 18px; text-align: center; flex: 0 0 auto; opacity: 0.95; }

.sidebar-foot {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- main column ---------- */

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

#topbar {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 5px var(--shadow-color);
  position: sticky;
  top: 0;
  z-index: 5;
  transition: background-color var(--transition-speed) ease;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 18px 4px;
}

.crumbs { font-weight: 600; color: var(--text-primary); white-space: nowrap; font-size: 15px; }

.global-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 18px 8px;
}

/* Full-width drawer handle at the bottom edge of the header. */
#filters-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 0 3px;
  cursor: pointer;
  transition: background-color var(--transition-speed) ease;
}
#filters-handle:hover { background: var(--bg-tertiary); color: var(--blue-medium); }
.handle-chevron { font-size: 8px; line-height: 1; }

/* Collapsed: filter row gone, slim header row, handle stays as the reopen affordance. */
#app.filters-collapsed .global-filters { display: none; }
#app.filters-collapsed .topbar-row { padding: 4px 18px; }
#app.filters-collapsed .crumbs { font-size: 13.5px; }
#app.filters-collapsed #filters-handle .handle-chevron { transform: rotate(180deg); }
.global-filters select,
.global-filters input {
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  transition: background-color var(--transition-speed) ease;
}
.global-filters input { width: 180px; }
/* Bin slider (Overview by-site chart): a pill like the selects, holding a
 * label, the range input and its live value. The range input drops the text
 * input box styling above. */
.bin-ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px 9px;
  font-size: 12.5px;
}
.bin-ctl[hidden] { display: none; }
.global-filters .bin-ctl input[type="range"] {
  width: 130px;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: var(--blue-medium);
}
#f-bin-label { min-width: 58px; font-variant-numeric: tabular-nums; }
.global-filters button {
  background: var(--input-bg);
  color: var(--blue-medium);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background-color var(--transition-speed) ease;
}
.global-filters button:hover:not(:disabled) { background: var(--bg-tertiary); }
.global-filters :disabled { opacity: 0.55; cursor: not-allowed; }

/* Multi-select dropdown (website filter, round-1 2026-08-03): a filter-bar
 * button opening a checkbox menu; same tokens as the other controls. */
.multi { position: relative; }
.multi > button {
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: normal;
  cursor: pointer;
}
.multi-menu {
  /* Right-aligned to the button (2026-08-04 fix): the responsive reflow can
   * put the websites button at the row's right edge, and a LEFT-aligned
   * dropdown then overflowed the viewport - only the checkbox column was
   * visible ("boxes with no labels"). Right edge = button right edge keeps
   * it on-screen at every layout width. */
  position: absolute; top: calc(100% + 4px); left: auto; right: 0; z-index: 60;
  min-width: 190px; max-width: min(320px, 92vw);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  padding: 6px;
}
.multi-menu label {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 6px; border-radius: 6px;
  font-size: 12.5px; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap;
}
/* The generic .global-filters input rule (width 180px, padded, bordered)
 * was hitting these CHECKBOXES too - each rendered as a giant empty text
 * box dwarfing its label (the operator's "boxes with no labels" /
 * "checkbox side bigger than the labels" reports, 2026-08-04). Checkboxes
 * are checkboxes: */
.multi-menu input[type="checkbox"] {
  width: 14px; height: 14px; flex: 0 0 14px;
  padding: 0; margin: 0; border: none;
  accent-color: var(--blue-medium);
}
.multi-menu label:hover { background: var(--bg-tertiary); }
.multi-menu .multi-all {
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px; padding-bottom: 6px;
  font-weight: 600;
}

/* Floating active-filters banner (customer round-1 #3; unconditional since
 * 2026-08-04): a fixed pill listing every active filter with per-chip clears
 * + Clear all; shows whenever any TAB or GLOBAL filter is non-default,
 * regardless of drawer state - a drilled state is never invisible. */
/* The ID rule's display:flex would beat the UA's [hidden] { display:none }
 * (caught in the Batch-2 verification pass: a stale THIS-TAB chip stayed
 * visible across a route change while banner.hidden was correctly true). */
#active-filters[hidden] { display: none !important; }
#active-filters {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 80; max-width: min(92vw, 980px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
  padding: 7px 12px;
  font-size: 12px; color: var(--text-secondary);
}
#active-filters .af-label { font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; }
#active-filters .af-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 4px 2px 9px;
  white-space: nowrap;
}
#active-filters .af-chip button,
#active-filters .af-clear {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font: inherit; line-height: 1;
  padding: 2px 5px; border-radius: 999px;
}
#active-filters .af-chip button:hover { color: var(--bad); background: var(--bg-primary); }
#active-filters .af-clear {
  color: var(--blue-medium); font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid var(--border-color); padding: 3px 10px;
}
#active-filters .af-clear:hover { background: var(--bg-tertiary); }

/* View-local control rows (per-view filters, filters.md) - same tokens as
 * the global filter bar so controls read as one system. */
.view-ctls {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 14px; margin: 0 0 12px;
  font-size: 12px; color: var(--text-muted);
}
.view-ctls label { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.view-ctls input {
  background: var(--input-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  width: 72px;
}

/* Chip multi-select rows (reason picker etc.) - same tokens as .seg. */
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.chip-row button {
  background: var(--input-bg);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.chip-row button.on { color: var(--blue-medium); border-color: var(--blue-medium); font-weight: 600; }
.chip-row button.chip-quick { font-weight: 700; letter-spacing: 0.04em; }

.status-cluster { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.badge-fresh { border-color: var(--warn); color: var(--warn); }
.badge-fresh.ok { border-color: var(--ok); color: var(--ok); }

.clock { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12.5px; }

#vampire-toggle {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 13px;
  transition: background-color var(--transition-speed) ease;
}
#vampire-toggle:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Wide monitors (operator 2026-08-14): charts stretch with the screen — the
 * old 1500px cap left a dead right half on wide displays. 2400px is a
 * sanity ceiling for ultrawides, not a working cap. */
#content { padding: 22px 26px; max-width: 2400px; }

/* ---------- placeholder pages ---------- */

.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 600; color: var(--text-primary); }
.page-sub { margin: 0 0 18px; color: var(--text-muted); max-width: 72ch; line-height: 1.5; }

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: 0 4px 12px var(--shadow-color);
  transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease,
    background-color var(--transition-speed) ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--shadow-hover); }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--text-primary); }
.card p { margin: 0; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.card .src {
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: Consolas, monospace;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 3px 7px;
  display: inline-block;
}
/* A copyable command (legacy.js cmdPieces): wrap only between pieces. */
.card .src .cmd-part { white-space: nowrap; }

.coming {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--grey-light-1);
  color: var(--blue-darkest);
}
.vampire-mode .coming { background: #1E3A5F; color: #8AB4F8; }

/* ---- Data-viz roles (palette validated via dataviz six-checks on both
 * surfaces: #FFFFFF light, #121212 vampire; see Daily Leads build notes). */
:root {
  --viz-series-1: #2a78d6;
  --viz-series-2: #eb6834;
  --viz-series-3: #1baf7a;
  --viz-series-4: #eda100;
  --viz-series-5: #e87ba4;
  --viz-series-6: #008300;
  --viz-series-7: #4a3aa7;
  --viz-series-8: #e34948;
  --viz-series-9: #9c6b3c;   /* edmunds.com (the fallback slot until 2026-10-21) */
  --viz-series-10: #0f8b8d;  /* classic.com (the fallback slot until 2026-11-12) */
  --viz-series-11: #8a8f98;  /* the unlisted-site fallback (2026-11-12), neutral grey */
  --viz-neg: #e34948;
  /* ordinal blue ramp (palette.md steps 250/400/550/700) for ordered series */
  --viz-ord-1: #86b6ef;
  --viz-ord-2: #3987e5;
  --viz-ord-3: #1c5cab;
  --viz-ord-4: #0d366b;
  --viz-band-fill: rgba(140, 140, 144, 0.16);
  --viz-median: #8C8C90;
  --viz-grid: rgba(140, 140, 144, 0.18);
}
.vampire-mode {
  --viz-series-1: #3987e5;
  --viz-series-2: #d95926;
  --viz-series-3: #199e70;
  --viz-series-4: #c98500;
  --viz-series-5: #d55181;
  --viz-series-6: #008300;
  --viz-series-7: #9085e9;
  --viz-series-8: #e66767;
  --viz-series-9: #b98a5c;
  --viz-series-10: #2bb0b2;
  --viz-series-11: #9aa0a8;
  --viz-neg: #e66767;
  /* dark ordinal ramp capped at step 600 per palette.md */
  --viz-ord-1: #86b6ef;
  --viz-ord-2: #3987e5;
  --viz-ord-3: #256abf;
  --viz-ord-4: #184f95;
  --viz-band-fill: rgba(154, 160, 166, 0.14);
  --viz-median: #9AA0A6;
  --viz-grid: rgba(154, 160, 166, 0.16);
}

/* ---- Tab-view building blocks (KPI tiles, chart cards) */
.kpi-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.kpi {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 18px;
  min-width: 170px;
  box-shadow: 0 1px 3px var(--shadow-color);
}
.kpi-v { font-size: 24px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.chart-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px var(--shadow-color);
}
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.chart-head h3 { margin: 0; font-size: 14.5px; color: var(--text-primary); }

/* Chart-title explainers (operator 2026-07-31): every chart title with a
 * data-info attribute grows an (i) marker and a hover popup stating what the
 * chart shows, which data feeds it, and how to read it. Pure CSS - the popup
 * body is the attribute text, so views keep it plain text (no quotes). */
.chart-head h3[data-info] { position: relative; cursor: help; }
.chart-head h3[data-info]::after {
  content: "\24D8"; /* circled i */
  margin-left: 7px; font-size: 12px; font-weight: 400;
  color: var(--text-muted); vertical-align: 1px;
}
/* Chart provenance chip (customer 2026-08-05: "annotation hover over all
 * charts ... Table / X axis / Y axis / Notes"): the structured companion to
 * the prose data-info popup. Round 4 (2026-08-10, customer: "src hovers all
 * be in the same place in every table / view"): the chip ALWAYS sits
 * immediately right of its card title — margin-right:auto absorbs the
 * space-between distribution so per-card control counts can never push the
 * chip to a different spot. */
.src-chip {
  position: relative; cursor: help;
  color: var(--text-muted); font-size: 10.5px; line-height: 1;
  border: 1px solid var(--border-color); border-radius: 5px;
  padding: 3px 6px; user-select: none;
}
.chart-head .src-chip { margin-left: 2px; margin-right: auto; }
/* Shared hover popup (round 4, 2026-08-10 — "a lot of these src hover
 * windows are off screen or look weird"): the old pure-CSS ::before popups
 * anchored below the chip could overflow the bottom edge and mis-shift on
 * the right (the guard estimated the width). One position:fixed singleton
 * (views/common.js) is measured, clamped to every viewport edge, flips
 * above when there is no room below, and scrolls internally when tall. */
.hover-pop {
  position: fixed; z-index: 200; display: none;
  width: max-content; max-width: min(560px, 86vw);
  max-height: min(60vh, 480px); overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-color); border-radius: 8px;
  padding: 10px 13px;
  font-size: 12.5px; font-weight: 400; line-height: 1.5;
  color: var(--text-secondary);
  box-shadow: 0 6px 22px var(--shadow-color);
  white-space: pre-line;
}
.hover-pop.hover-pop-src {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; line-height: 1.55;
}

/* Change-KPI table (customer round 5): value + change-vs-prior chip per
 * cell; partial column starred, its % suppressed. Colors are STATUS colors
 * per the row's good direction. */
/* Alignment (round-7 customer fix, 2026-08-13): the LATER `.data-table th`
 * rule (equal specificity) silently overrode the right-aligned headers
 * here, leaving every value column visually shifted right of its header
 * (first column unaffected — both left). Doubled selectors win regardless
 * of order; values now CENTER under centered headers per the client. */
.data-table.change-table th { text-align: center; }
.data-table.change-table th:first-child { text-align: left; }
.change-table .ct-label { font-weight: 600; white-space: nowrap; }
.data-table.change-table .ct-cell { text-align: center; white-space: nowrap; }
/* .ct-v/.ct-chip value+chip styling lives on the .data-table .ct-* block
 * below - every change-table is also a data-table, so one source rules. */
/* Hierarchy pivot rows (service-hierarchy build 2026-08-13): caret column
 * keeps labels aligned whether or not a row expands; expandable rows are
 * the click targets; muted rows = honest "not collected yet" state. */
.change-table .ct-caret { display: inline-block; width: 1.05em; opacity: .65; }
.change-table tr.ct-expandable { cursor: pointer; }
.change-table tr.ct-expandable:hover .ct-label { text-decoration: underline; }
.change-table tr.ct-muted .ct-label, .change-table tr.ct-muted .ct-cell { opacity: .6; font-weight: 400; }
/* Round 6.5: the same value+chip construct inside plain data-tables (the
 * Errors flow table) and muted annotations outside the provider dropdown
 * (origin shares, the sankey action row). Values match the change-table. */
.data-table .ct-v { font-variant-numeric: tabular-nums; }
.data-table .ct-chip { font-size: 10.5px; font-weight: 600; margin-top: 1px; }
.data-table .ct-chip.ct-good { color: var(--ok); }
.data-table .ct-chip.ct-bad { color: var(--bad); }
.data-table .ct-chip.ct-n { color: var(--text-muted); }
.data-table .provdd-n, .chart-head .provdd-n { color: var(--text-muted); font-size: 11px; }

.chart { width: 100%; }
.chart-note { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.45; }

.seg { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.seg button {
  border: none; background: var(--bg-primary); color: var(--text-muted);
  font: inherit; font-size: 12px; padding: 5px 12px; cursor: pointer;
}
.seg button.on { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 600; }
/* Labelled dropdown selector for a card's data options (common.js selectFilter) —
 * same tokens as .seg; .on = off-default (a this-tab chip is published). */
.sel-filter { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.sel-filter select {
  background: var(--bg-primary); color: var(--text-secondary);
  border: 1px solid var(--border-color); border-radius: 8px;
  padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.sel-filter.on select { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 600; }

.data-missing {
  border: 1px dashed var(--warn); color: var(--warn);
  border-radius: var(--radius); padding: 12px 16px; font-size: 13px;
}
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }

/* ---- Overview tiles + freshness strip */
.kpi-spark { min-width: 200px; flex: 1; }
.kpi-spark .spark { height: 34px; margin-top: 6px; }
.kpi-d { font-size: 11.5px; margin-top: 2px; color: var(--text-muted); }
.kpi-d.good { color: var(--ok); }
.kpi-d.bad { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
/* Correlations table (diverging r bar + spurious-flag chips) */
.r-cell { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.r-track { flex: 1; height: 8px; background: var(--viz-band-fill); border-radius: 4px; position: relative; overflow: hidden; }
.r-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.flag-chip {
  display: inline-block; font-size: 10.5px; padding: 1px 7px; margin: 1px 2px 1px 0;
  border-radius: 999px; border: 1px solid var(--border-color);
  color: var(--text-muted); cursor: help; white-space: nowrap;
}
.flag-chip.confound { border-color: var(--warn); color: var(--warn); }
tr.pair-row { cursor: pointer; }
tr.pair-row.selected td { background: var(--viz-band-fill); }
tr.pair-insig td { opacity: 0.55; }
/* Small-multiple metric grid (Change Detections) */
.multi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.multi-cell { border: 1px solid var(--border-color); border-radius: 8px; padding: 8px 10px 4px; background: var(--bg-secondary); }
.multi-cell h4 { margin: 0 0 2px; font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.multi-cell .flag-ct { font-weight: 400; color: var(--text-muted); }
.fresh-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.fresh-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-color); color: var(--text-muted);
}
.fresh-chip.ok { border-color: var(--ok); color: var(--ok); }
.fresh-chip.stale { border-color: var(--warn); color: var(--warn); }
/* A stalled SOURCE is not a late refresh: the cube rewrote on time and still
 * carries nothing new. Cube Health calls that "bad"; the strip must agree or
 * the landing page contradicts the detail page. */
.fresh-chip.bad { border-color: var(--bad); color: var(--bad); }
.badge-fresh.bad { border-color: var(--bad); color: var(--bad); }
.kpi-l .good { color: var(--ok); }
.kpi-l .bad { color: var(--bad); }
.kpi-v.good { color: var(--ok); }
.kpi-v.bad { color: var(--bad); }

/* ---- Data tables (Query Ledger, Cube Health) */
.table-wrap { overflow-x: auto; }
/* Frozen headers on every scrolling table (operator 2026-08-14): the header
 * row sticks to the top of its scroll container. Solid background so rows
 * never show through; harmless on non-scrolling tables. */
.table-wrap th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-primary);
}
.data-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.data-table th {
  text-align: left; padding: 6px 10px; color: var(--text-muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color); white-space: nowrap;
  cursor: pointer; user-select: none; /* sortable platform-wide (round-3 A2) */
}
.data-table th:hover { color: var(--text-secondary); }
.data-table th.sort-desc::after { content: " ▼"; font-size: 9px; }
.data-table th.sort-asc::after { content: " ▲"; font-size: 9px; }
.data-table.no-sort th { cursor: default; }

/* Honest-empty KPI tiles (Fleet live-state tiles: collector scope fills
 * them at go-live; dash + muted, never a fake zero). */
.kpi.kpi-empty { opacity: 0.55; }
.kpi.kpi-empty .kpi-v { color: var(--text-muted); }
.data-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-color); color: var(--text-secondary); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }

/* Row severity states (Cube Health and any table reporting health).
   A colored accent bar rides the first cell of EVERY row, so a healthy table
   scans as a continuous green edge and anything wrong breaks it instantly.
   Problem rows additionally take a translucent tint - rgba over whatever the
   row background is, so it works in both themes without a second palette.
   Healthy rows are NOT tinted: 40 green blocks would be noise, and the point
   is that the eye lands on the exceptions. */
.data-table tr.state-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.data-table tr.state-muted td:first-child { box-shadow: inset 3px 0 0 var(--text-muted); }
.data-table tr.state-warn td { background: rgba(217, 119, 6, 0.10); }
.data-table tr.state-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.data-table tr.state-bad td { background: rgba(220, 38, 38, 0.12); }
.data-table tr.state-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.state-pill { font-weight: 600; }
.state-pill.ok { color: var(--ok); }
.state-pill.warn { color: var(--warn); }
.state-pill.bad { color: var(--bad); }
.state-pill.muted { color: var(--text-muted); }
.data-table .small { font-size: 11px; color: var(--text-muted); }
.warn-text { color: var(--warn); font-weight: 600; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
.card h3 a { color: var(--text-primary); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; }

/* ---- Overview stage funnel */
.funnel { padding: 6px 0 2px; }
.funnel-row {
  display: grid;
  grid-template-columns: 150px 90px 60px 1fr minmax(140px, auto);
  gap: 10px; align-items: center; padding: 7px 0;
  border-bottom: 1px solid var(--border-color);
}
.funnel-row:last-child { border-bottom: none; }
.funnel-label { font-size: 13px; color: var(--text-primary); font-weight: 600; }
.funnel-num { font-size: 17px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; }
.funnel-pct { font-size: 12px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.funnel-track { height: 10px; background: var(--viz-band-fill); border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--viz-median); border-radius: 999px; }
.funnel-bar.hero { background: var(--viz-series-1); }
.funnel-drop { font-size: 11.5px; color: var(--text-muted); text-align: right; }
.chart-note a { color: var(--blue-medium); }
@media (max-width: 800px) {
  .funnel-row { grid-template-columns: 110px 80px 50px 1fr; }
  .funnel-drop { display: none; }
}

/* ---------- Responsive pass (customer round-1 #4, 2026-08-03) ----------
 * The sidebar auto-collapses to icons below 960px (app.js adds .collapsed
 * on crossing the breakpoint; the hamburger still expands). Below 720px
 * paddings/tiles/controls compact, KPI tiles flex to fill rows, grids go
 * single-column, and the topbar wraps instead of overflowing. Tables keep
 * their own horizontal scroll (.table-wrap); the Sankey keeps its scroll
 * canvas. */
@media (max-width: 720px) {
  #content { padding: 14px 10px; }
  .topbar-row { flex-wrap: wrap; row-gap: 4px; }
  .crumbs { font-size: 14px; }
  .global-filters { padding: 2px 10px 8px; }
  .global-filters input { width: 130px; }
  .global-filters #f-search { width: 110px; }
  .kpi-row { gap: 8px; }
  .kpi { min-width: 120px; padding: 10px 12px; flex: 1 1 130px; }
  .kpi .kpi-v { font-size: 20px; }
  .chart-card { padding: 10px 10px; }
  .multi-grid { grid-template-columns: 1fr; }
  #active-filters { bottom: 8px; max-width: 96vw; border-radius: 14px; }
}

/* Provider multi-select dropdown (Valuations round 6: searchable, combos,
 * most-used order). One open panel; closes on outside click. */
.provdd { position: relative; display: inline-block; }
.provdd-btn {
  font: inherit; font-size: 12px; cursor: pointer;
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 999px;
  padding: 4px 12px; white-space: nowrap;
}
.provdd-btn.narrowed { border-color: var(--blue-medium); font-weight: 600; }
.provdd-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 260px; max-width: 330px;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 8px;
}
.provdd-panel input[type="text"] {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 12px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 6px;
}
.provdd-list { max-height: 260px; overflow-y: auto; }
.provdd-list label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--text-primary);
  padding: 4px 6px; border-radius: 6px;
}
.provdd-list label:hover { background: var(--bg-tertiary); }
.provdd-list .provdd-n { margin-left: auto; color: var(--text-muted); font-size: 11px; }
.provdd-foot { border-top: 1px solid var(--border-color); margin-top: 6px; padding-top: 6px; text-align: right; }
.provdd-foot button {
  font: inherit; font-size: 11.5px; cursor: pointer;
  background: none; border: none; color: var(--blue-medium);
}
.ep-sort th { cursor: pointer; user-select: none; white-space: nowrap; }
.ep-sort th.sorted::after { content: " ▾"; opacity: 0.7; }
.ep-sort th.sorted.asc::after { content: " ▴"; }

/* Errors triage segmentation card (round 6): clickable cut columns - each
 * row a mini bar with count + share. Click = toggle that segment across
 * the whole page. Round 7 adds the fourth column (the service hierarchy)
 * via .seg-grid-4; .seg-caret is its expand/collapse affordance. */
.seg-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  margin-top: 6px;
}
.seg-grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1250px) { .seg-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .seg-grid, .seg-grid-4 { grid-template-columns: 1fr; } }
.seg-caret {
  display: inline-block; width: 13px; color: var(--text-muted);
  cursor: pointer; user-select: none;
}
.seg-col-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px;
}
.seg-item {
  display: grid; grid-template-columns: minmax(90px, 1.1fr) 1fr auto;
  align-items: center; gap: 8px; width: 100%;
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
  background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-primary); padding: 3px 6px;
}
.seg-item:hover { background: var(--bg-tertiary); }
.seg-item.on {
  border-color: var(--blue-medium); background: var(--bg-tertiary);
  font-weight: 600;
}
.seg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg-bar {
  height: 8px; border-radius: 4px; background: var(--bg-tertiary);
  overflow: hidden;
}
.seg-bar i {
  display: block; height: 100%; border-radius: 4px;
  background: var(--viz-series-1); opacity: 0.75;
}
.seg-n { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* ---- Services & Processes topology (legacy Operations Map look, v2
 * 2026-08-04): zone container boxes, node cards with type badges and
 * endpoint pills, SVG typed edges underneath, legend. Theme-aware via the
 * existing variables - works in light and Vampire Mode. ---- */
.sx-zone {
  position: absolute;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-secondary) 55%, transparent);
}
.sx-zone-head { padding: 9px 12px 0; white-space: nowrap; overflow: hidden; }
.sx-zone-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.09em;
  color: var(--warn); text-transform: uppercase; margin-right: 8px;
}
.sx-zone-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.sx-card {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 1px 4px var(--shadow-color);
  padding: 6px 8px 7px;
  transition: opacity 0.15s, box-shadow 0.15s;
  cursor: default;
}
.sx-card:hover { box-shadow: 0 3px 10px var(--shadow-hover); z-index: 5; }
.sx-card.sx-dim { opacity: 0.14; }
.sx-card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.sx-badge {
  font-size: 8.5px; font-weight: 800; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--warn);
}
.sx-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px;
  background: var(--grey-medium); display: inline-block;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--grey-medium) 25%, transparent);
}
/* live status (the shared statusClass rule; grey = not checked / no recent verdict) */
.sx-dot.ok { background: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 25%, transparent); }
.sx-dot.stale { background: var(--warn); box-shadow: 0 0 0 2px color-mix(in srgb, var(--warn) 25%, transparent); }
.sx-dot.bad { background: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 25%, transparent); }
.sx-title {
  font-size: 12px; font-weight: 700; color: var(--text-primary);
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sx-desc {
  font-size: 10px; color: var(--text-muted); line-height: 1.25;
  max-height: 26px; overflow: hidden; margin-top: 2px;
}
.sx-pills { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.sx-pills span {
  font-size: 8.5px; font-weight: 700; letter-spacing: 0.04em;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  color: var(--text-secondary); border-radius: 4px; padding: 1.5px 6px;
  white-space: nowrap;
}
.sx-card-sm { padding: 5px 8px; }
.sx-card-sm .sx-title { font-size: 11px; }
.sx-legend {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center;
  margin-top: 8px; font-size: 11px; color: var(--text-muted);
}
.sx-leg-item { display: inline-flex; align-items: center; gap: 6px; }
