/* ==========================================================================
   Aura Command Center — shared design system
   Single source of truth for tokens, typography, nav, cards, tables, footer.
   Loaded by: index.html, scorecard.html, strategies.html, spend.html
   CAP-ID: OPS-STRATEGY-SCORECARD-WEB-001
   ========================================================================== */

/* --------------------------------------------------------------------------
   TOKEN CONTRACT (CAP-ID: OPS-CC-THEME-001)
   Every paintable surface MUST reference a token below — never a literal hex
   or rgba dark value. If a surface hardcodes a color it will not flip in light
   mode. That was the root cause of the "light chrome / dark cards" bug.

   Surface ladder (low -> high elevation):
     --bg          page canvas
     --surface-1   cards, sections, panels (was a hardcoded dark rgba)
     --surface-2   nested rows, chips, inputs, tabs
     --surface-3   table headers, sticky heads, footers
     --surface-sunken  wells / progress tracks / param tables
     --scrim-*     translucent chrome (header/nav/context/popover)
   -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #060a14;
  --bg-elev: #0e1626;
  --bg-elev-2: #131f34;
  --bg-elev-3: #101a2c;
  --border: #1e2a42;
  --border-hi: #2d3f60;

  /* elevation ladder — these are what components actually paint with */
  --surface-1: rgba(14, 22, 38, 0.72);
  --surface-2: #131f34;
  --surface-3: rgba(16, 26, 44, 0.92);
  --surface-sunken: rgba(0, 0, 0, 0.18);
  --surface-hover: rgba(255, 255, 255, 0.02);
  --surface-inset: rgba(255, 255, 255, 0.02);

  /* top sheen applied over cards/sections for glass depth */
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 45%);

  /* translucent chrome scrims */
  --scrim-top: linear-gradient(180deg, rgba(6, 10, 20, 0.97) 0%, rgba(6, 10, 20, 0.9) 100%);
  --scrim-nav: rgba(9, 14, 26, 0.94);
  --scrim-ctx: rgba(9, 14, 26, 0.75);
  --scrim-pop: rgba(8, 14, 24, 0.96);
  --scrim-border: rgba(30, 42, 66, 0.9);

  /* text */
  --text: #e9f1ff;
  --muted: #8393b0;
  /* readable text on top of a cyan/blue accent fill */
  --on-accent: #041018;

  /* semantic */
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.16);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.16);
  --amber: #f0b429;
  --amber-dim: rgba(240, 180, 41, 0.15);
  --blue: #60a5fa;
  --cyan: #22d3ee;
  --purple: #bc8cff;
  --purple-dim: rgba(188, 140, 255, 0.1);
  --flat-dim: rgba(147, 160, 184, 0.15);

  /* accent glow strengths (softened in light mode) */
  --glow-accent: 0 4px 16px rgba(34, 211, 238, 0.28), 0 0 0 1px rgba(34, 211, 238, 0.15);
  --glow-soft: 0 0 10px rgba(34, 211, 238, 0.25);
  --nav-underline: rgba(34, 211, 238, 0.35);

  /* heatmap / data-viz (JS reads these via getComputedStyle) */
  --grid-line: rgba(36, 48, 73, 0.55);
  --axis-text: #93a0b8;
  --heat-zero: rgba(147, 160, 184, 0.08);

  /* aliases kept so older markup/scripts keep working */
  --panel: #0e1626;
  --accent: #60a5fa;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(56, 189, 248, 0.12);
  --shadow-pop: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* shell (fixed chrome) */
  --shell-top-h: 64px;
  --shell-nav-h: 48px;
  --shell-ctx-h: 40px;
}

/* ---------- theme: light palette override (CAP-ID: OPS-CC-THEME-001) ----------
   Light = clean fintech dashboard: cool slate-tinted whites, not flat #fff.
   Cards sit ABOVE the canvas (white on tinted grey) so elevation still reads. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #eef1f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #f4f6fb;
  --bg-elev-3: #e9edf6;
  --border: #dde3ee;
  --border-hi: #c2ccdf;

  --surface-1: #ffffff;
  --surface-2: #f4f6fb;
  --surface-3: #eef1f8;
  --surface-sunken: #eef1f8;
  --surface-hover: rgba(37, 99, 235, 0.05);
  --surface-inset: #f7f9fc;

  /* no white-on-white sheen in light mode */
  --sheen: none;

  --scrim-top: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(248, 250, 253, 0.92) 100%);
  --scrim-nav: rgba(255, 255, 255, 0.92);
  --scrim-ctx: rgba(255, 255, 255, 0.78);
  --scrim-pop: rgba(255, 255, 255, 0.98);
  --scrim-border: rgba(203, 213, 233, 0.9);

  --text: #0f172a;
  --muted: #5a6982;
  --on-accent: #ffffff;

  --green: #15803d;
  --green-dim: rgba(21, 128, 61, 0.12);
  --red: #b91c1c;
  --red-dim: rgba(185, 28, 28, 0.10);
  --amber: #b45309;
  --amber-dim: rgba(180, 83, 9, 0.12);
  --blue: #1d4ed8;
  --cyan: #0e7490;
  --purple: #6d28d9;
  --purple-dim: rgba(109, 40, 217, 0.07);
  --flat-dim: rgba(90, 105, 130, 0.12);

  --glow-accent: 0 4px 14px rgba(29, 78, 216, 0.22), 0 0 0 1px rgba(29, 78, 216, 0.10);
  --glow-soft: 0 1px 3px rgba(15, 23, 42, 0.12);
  --nav-underline: rgba(14, 116, 144, 0.30);

  --grid-line: rgba(15, 23, 42, 0.10);
  --axis-text: #5a6982;
  --heat-zero: rgba(90, 105, 130, 0.07);

  --panel: #ffffff;
  --accent: #1d4ed8;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 12px 30px rgba(16, 24, 40, 0.12), 0 0 0 1px rgba(29, 78, 216, 0.08);
  --shadow-pop: 0 12px 40px rgba(16, 24, 40, 0.16), 0 0 0 1px rgba(16, 24, 40, 0.04);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(14, 116, 144, 0.07), transparent 50%),
    radial-gradient(900px 520px at 100% 0%, rgba(29, 78, 216, 0.06), transparent 45%),
    var(--bg);
}

/* Accent fills stay legible in light mode: deepen the gradient so white text passes contrast. */
:root[data-theme="light"] .shell-nav a.active,
:root[data-theme="light"] .tab.active {
  background: linear-gradient(135deg, #0e7490, #1d4ed8);
}
:root[data-theme="light"] .brand-mark .mark span {
  box-shadow: 0 0 6px rgba(14, 116, 144, 0.35);
}
:root[data-theme="light"] .brand-mark .mark span:nth-child(2) {
  box-shadow: 0 0 6px rgba(109, 40, 217, 0.3);
}
:root[data-theme="light"] .chart .col .b { box-shadow: none; }
:root[data-theme="light"] .dot {
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.14);
}
:root[data-theme="light"] .error { color: #7f1d1d; }

/* ---------- theme toggle control ---------- */
.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hi); }
.theme-toggle:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.theme-toggle .icon { font-size: 0.9rem; line-height: 1; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  /* smoother anchor/scroll + sticky-nav backdrop */
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  font-family: var(--sans);
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(34, 211, 238, 0.10), transparent 50%),
    radial-gradient(900px 520px at 100% 0%, rgba(96, 165, 250, 0.09), transparent 45%),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.012) 0px,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 3px
    ),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  opacity: 1;
}

/* Progressive enhancement: hide only when tiny head boot script ran */
html.js-boot body {
  opacity: 0;
}
html.js-boot body.is-ready {
  opacity: 1;
  transition: opacity 0.24s ease;
}
html.js-boot body.is-leaving {
  opacity: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
}

@keyframes cc-nav-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

a { color: var(--blue); }
code { font-family: var(--mono); font-size: 0.85em; }

/* ---------- fixed app shell (P0: header/nav never reflow between routes) ---------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.shell-top,
.shell-nav,
.shell-context {
  width: 100%;
  padding-inline: max(0.75rem, calc((100% - 1200px) / 2));
}

.page-content {
  position: relative;
  padding: 1.1rem 0 3rem;
}
.page-content > .view-panel {
  width: 100%;
  padding-inline: max(0.75rem, calc((100% - 1200px) / 2));
}

/* ---------- shell top (brand + status, FIXED HEIGHT, never reflows) ---------- */
header.shell-top {
  position: sticky;
  top: 0;
  z-index: 32;
  height: var(--shell-top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--scrim-top);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  border-bottom: 1px solid var(--scrim-border);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}
.brand-mark .mark {
  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 3px;
  flex: none;
}
.brand-mark .mark span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.55);
}
.brand-mark .mark span:nth-child(2) { background: var(--purple); box-shadow: 0 0 8px rgba(188, 140, 255, 0.5); opacity: 0.9; }
.brand-mark .mark span:nth-child(3) { grid-column: 1 / 3; width: 100%; background: linear-gradient(90deg, var(--blue), var(--cyan)); opacity: 0.85; }
.brand-mark .wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}
.brand-mark .eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--cyan);
  text-transform: uppercase;
}
.brand-mark .title {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--text);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.dot {
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18), 0 0 6px rgba(34, 197, 94, 0.6);
  flex: none;
  animation: cc-pulse 2.4s ease-in-out infinite;
}
@keyframes cc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ---------- shell nav (primary mode switcher, FIXED HEIGHT) ---------- */
nav.shell-nav {
  position: sticky; /* keep sticky — do not override with position:relative */
  top: var(--shell-top-h);
  z-index: 31;
  height: var(--shell-nav-h);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: var(--scrim-nav);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--scrim-border);
  /* LED underline via inset shadow (avoids ::after + relative killing sticky) */
  box-shadow: inset 0 -2px 0 var(--nav-underline);
}
nav.shell-nav::-webkit-scrollbar { display: none; }
.shell-nav a {
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  flex: none;
  transition:
    color 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}
.shell-nav a:hover {
  color: var(--text);
  border-color: var(--border-hi);
  background: var(--bg-elev-2);
}
.shell-nav a.active {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
  font-weight: 700;
  box-shadow: var(--glow-accent);
}
nav.shell-nav a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ---------- shell context (secondary bar: short view name + short blurb, FIXED HEIGHT) ---------- */
.shell-context {
  position: sticky;
  top: calc(var(--shell-top-h) + var(--shell-nav-h));
  z-index: 29;
  height: var(--shell-ctx-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--scrim-ctx);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--scrim-border);
}
.shell-context-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  flex: none;
}
.shell-context-meta {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  min-width: 0;
}
/* ---------- MOBILE HEADER (P0 fix): brand must never clip ----------
   Previously the brand row and the "Last updated …" meta pill shared one
   flex row, so on phones the pill squeezed / overlapped the wordmark.
   Below 720px the shell-top becomes auto-height and stacks:
     row 1 = brand + theme toggle
     row 2 = full-width last-updated pill
   --shell-top-h is raised in the same breakpoint so the sticky nav/context
   offsets stay correct (they are calc()'d off that token). */
@media (max-width: 720px) {
  :root { --shell-top-h: 96px; }

  header.shell-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "meta  meta";
    align-content: center;
    align-items: center;
    row-gap: 0.3rem;
    column-gap: 0.5rem;
    padding-block: 0.45rem;
  }
  .brand-mark { grid-area: brand; min-width: 0; }
  .shell-status {
    display: contents; /* let toggle + pill land in their own grid areas */
  }
  .theme-toggle {
    grid-area: toggle;
    justify-self: end;
    /* easier tap target on phones */
    min-height: 34px;
    padding: 0.4rem 0.7rem;
  }
  .meta-pill {
    grid-area: meta;
    justify-self: start;
    max-width: 100%;
    font-size: 0.68rem;
    padding: 0.22rem 0.6rem;
  }
}

@media (max-width: 640px) {
  .shell-context-meta { max-width: 58vw; }
  .brand-mark .eyebrow { display: none; }
}

/* Very narrow phones: drop the toggle text label, keep the icon tappable. */
@media (max-width: 400px) {
  .theme-toggle #themeToggleLabel { display: none; }
  .theme-toggle { padding: 0.4rem 0.55rem; }
  .brand-mark .title { font-size: 0.9rem; }
}

/* ---------- in-view toolbars (filters/tabs) — fixed min-height so swapping doesn't jump ---------- */
.view-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
  min-height: 2.5rem;
  margin-bottom: 1rem;
}

/* ---------- cards (glass panels, luminous hairline) ---------- */
.card {
  position: relative;
  background: var(--sheen), var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.15rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--blue), transparent);
  opacity: 0;
  transition: opacity 0.18s ease;
}
.card:hover {
  border-color: var(--border-hi);
}
.card:hover::before { opacity: 0.85; }
.card h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.card .label,
.stat .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.card .value,
.card .val {
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card .hint,
.card .note {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.25rem;
}
.card .value.sm, .card .val.sm { font-size: 1.05rem; }

/* stat grids */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 1100px) { .grid-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .grid-cards { grid-template-columns: repeat(2, 1fr); } }

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.grid-wide {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.9rem;
}

/* semantic text */
.pos { color: var(--green); }
.neg { color: var(--red); }
.neu { color: var(--text); }

/* ---------- panels / sections ---------- */
.panel, .section { margin-bottom: 1rem; }
.section {
  background: var(--sheen), var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.15rem 1.2rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.section h2 { font-size: 1rem; margin: 0 0 0.85rem; font-weight: 700; letter-spacing: -0.01em; }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.5rem 0 0.7rem;
  flex-wrap: wrap;
}
.section-title h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.section-title a { font-size: 0.82rem; text-decoration: none; white-space: nowrap; }
.section-title a:hover { text-decoration: underline; }

/* ---------- pills / tabs / buttons ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tab {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  min-height: 32px;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.tab:hover { color: var(--text); border-color: var(--border-hi); }
.tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.tab.active {
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: transparent;
  font-weight: 700;
}
.tab.alt.active {
  background: var(--purple);
  color: var(--on-accent);
  border-color: var(--purple);
}
.toggle-row {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.toggle-row button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.toggle-row button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.5rem; }
.chip {
  font-size: 0.68rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge.up { background: var(--green-dim); color: var(--green); }
.badge.down { background: var(--red-dim); color: var(--red); }
.badge.flat { background: var(--flat-dim); color: var(--muted); }

.status {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.status.live { background: var(--green-dim); color: var(--green); }
.status.disabled { background: var(--red-dim); color: var(--red); }
.status.monitor { background: var(--amber-dim); color: var(--amber); }
.status.paper { background: rgba(96,165,250,0.15); color: #60a5fa; }

/* ---------- tables ---------- */
.table-scroll {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-scroll table { min-width: 560px; }
th, td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table-scroll th, .table-scroll td { white-space: nowrap; }
th {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.table-scroll th {
  position: sticky;
  top: 0;
  background: var(--surface-3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-hover); }
td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.rank { color: var(--muted); font-family: var(--mono); width: 2.5rem; }
.strategy-name { font-weight: 600; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 280px; }
@media (max-width: 640px) { .chart-wrap { height: 220px; } }

/* Bar chart: fixed track so bars paint. % height on auto-height cols was collapsing flat. */
.chart {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 4px;
  height: 180px;
  margin-top: 0.65rem;
  padding: 0.25rem 0.15rem 0;
}
.chart .col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  height: 100%;
}
.chart .col .b-track {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.chart .col .b {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--cyan), var(--blue));
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  box-shadow: var(--glow-soft);
}
.chart .col .b.b-billed {
  background: linear-gradient(180deg, var(--purple), var(--purple));
  opacity: 0.9;
  box-shadow: var(--glow-soft);
}
.chart .col .d {
  flex: none;
  color: var(--muted);
  font-size: 0.58rem;
  font-family: var(--mono);
  margin-top: 6px;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .chart {
    height: 165px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .chart .col {
    flex: 1 0 48px;
    min-width: 48px;
  }
  .chart-daily .col {
    flex: 1 0 20px;
    min-width: 20px;
  }
  .chart-daily .col .d {
    visibility: hidden;
  }
  .chart-daily .col:nth-child(5n + 1) .d,
  .chart-daily .col:last-child .d {
    visibility: visible;
  }
}

.bar-wrap {
  background: var(--surface-sunken);
  border-radius: 4px;
  height: 7px;
  overflow: hidden;
  min-width: 60px;
}
.bar { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--blue)); }

/* sparkline */
.spark { display: block; width: 100%; height: 46px; }

/* ---------- misc ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.65rem;
}
.swatch {
  width: 0.75rem; height: 0.75rem; border-radius: 3px;
  display: inline-block; margin-right: 0.3rem; vertical-align: -1px;
}
.callout {
  background: var(--purple-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.callout b { color: var(--text); }
.error {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 1rem;
  border-radius: var(--radius);
  font-weight: 500;
}

/* form controls inherit theme (previously UA-default white boxes in dark mode) */
input, select, textarea, button {
  font-family: inherit;
}
input, select, textarea {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 1px;
  border-color: var(--border-hi);
}
::placeholder { color: var(--muted); opacity: 0.8; }
.loading {
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  animation: cc-loading-pulse 1.6s ease-in-out infinite;
}
@keyframes cc-loading-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .loading { animation: none; }
}

footer, .footer {
  margin-top: 2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.6;
}
footer a, .footer a { color: var(--blue); }

/* ---------- polish: hierarchy + readability ----------
   KPI numerals get optical tightening; tables get zebra banding that works
   in both themes; focus states are always visible for keyboard users. */
.card .value, .card .val, .stat .v {
  font-variant-numeric: tabular-nums;
}
.table-scroll tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}
.table-scroll tbody tr:nth-child(even):hover td,
.table-scroll tbody tr:hover td {
  background: var(--surface-hover);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .table-scroll tbody tr:nth-child(even) td { background: var(--surface-inset); }
}
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}
/* theme flip should feel deliberate, not jarring */
@media (prefers-reduced-motion: no-preference) {
  .card, .section, .table-scroll th, .tab, .chip, .meta-pill, .mini-row {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  }
}

@media (max-width: 600px) {
  .card .value, .card .val { font-size: 1.12rem; }
  .hide-sm { display: none; }
  .nav a { padding: 0.4rem 0.75rem; font-size: 0.82rem; }
}

/* Respect reduced motion — hard cuts, no blur/slide */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body.is-ready,
  .shell-nav a,
  .hub-card,
  .view-panel {
    transition: none !important;
    animation: none !important;
    transform: none !important;
    filter: none !important;
  }
}
