/* ------------------------------------------------------------ tokens ---
   Respawn Culture theme. Brand phoenix colours own the chrome — header, accents,
   primary actions, single-series marks. The categorical data palette is left as
   the validated set: orange/red/gold are all warm and cannot carry six series
   apart for a colour-blind reader, so identity stays with colours that can. */
:root {
  color-scheme: light;
  --surface-1: #fffdfa;
  --page: #f7f4ef;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e6e0d6;
  --axis: #c9c0b0;
  --border: rgba(11, 11, 11, .10);
  --border-strong: rgba(11, 11, 11, .18);
  --hover: rgba(11, 11, 11, .035);

  /* Brand — light-surface steps, chosen to clear 3:1 (brand orange itself is 2.7:1). */
  --accent: #b34700;          /* 5.19:1 on --surface-1 */
  --accent-ink: #ffffff;      /* text on an --accent fill */
  --gold: #8a5a00;            /* 5.59:1 */
  --gold-line: rgba(201, 168, 76, .45);
  --accent-wash: rgba(255, 107, 0, .09);
  --seq-200: #f6c9a4; --seq-450: #b34700;

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;

  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --pos: #006300; --neg: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #12100e;
    --page: #0a0a0a;
    --ink: #ffffff;
    --ink-2: #c9c4b8;
    --muted: #9a958c;
    --grid: #262320;
    --axis: #35302a;
    --border: rgba(255, 255, 255, .10);
    --border-strong: rgba(201, 168, 76, .28);
    --hover: rgba(255, 255, 255, .05);

    --accent: #FF6B00;        /* 6.65:1 on --surface-1 — the brand orange, as-is */
    --accent-ink: #12100e;    /* white on orange is only 2.9:1, so ink goes dark */
    --gold: #c9a84c;          /* 8.31:1 */
    --gold-line: rgba(201, 168, 76, .32);
    --accent-wash: rgba(255, 107, 0, .12);
    --seq-200: #7a3300; --seq-450: #FF6B00;

    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --pos: #0ca30c; --neg: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #12100e;
  --page: #0a0a0a;
  --ink: #ffffff;
  --ink-2: #c9c4b8;
  --muted: #9a958c;
  --grid: #262320;
  --axis: #35302a;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(201, 168, 76, .28);
  --hover: rgba(255, 255, 255, .05);

  --accent: #FF6B00;
  --accent-ink: #12100e;
  --gold: #c9a84c;
  --gold-line: rgba(201, 168, 76, .32);
  --accent-wash: rgba(255, 107, 0, .12);
  --seq-200: #7a3300; --seq-450: #FF6B00;

  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --pos: #0ca30c; --neg: #e66767;
}

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

body {
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1360px; margin: 0 auto; padding: 20px 20px 72px; }

/* ----------------------------------------------------------- brandbar --- */
.brandbar { display: flex; align-items: center; gap: 11px; padding: 4px 0 14px; }
/* The phoenix always sits on its own dark chip, so it never lands on white. */
.brandbar .mark {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  background: #0a0a0a; border: 1px solid var(--gold-line);
  display: grid; place-items: center;
}
.brandbar .mark img { width: 30px; height: 30px; display: block; filter: drop-shadow(0 0 7px rgba(201, 168, 76, .45)); }
.brandbar .word { font-size: 12.5px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase; color: var(--ink); }
.brandbar .tagline { font-size: 11.5px; color: var(--muted); margin-top: 1px; letter-spacing: .01em; }
.brandbar .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-line), transparent); margin-left: 6px; }

/* ------------------------------------------------------------ header --- */
.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  justify-content: space-between; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand p { margin: 3px 0 0; color: var(--ink-2); font-size: 13px; }
.brand .src { color: var(--muted); font-size: 12px; margin-top: 2px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button, select, .btn {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 11px; cursor: pointer;
}
button:hover, .btn:hover, select:hover { background: var(--hover); border-color: var(--accent); }
button:focus-visible, select:focus-visible, .btn:focus-visible,
[contenteditable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.1); }
input[type=file] { display: none; }

/* -------------------------------------------------------------- tabs --- */
.tabs { display: flex; gap: 2px; margin: 18px 0 16px; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent; background: transparent; color: var(--ink-2);
  border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tab:hover { background: var(--hover); }
.tab[aria-selected="true"] {
  background: var(--surface-1); border-color: var(--border);
  border-bottom-color: var(--accent); color: var(--ink);
}

/* ------------------------------------------------------------- cards --- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.card > h3 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.card > .sub { margin: 0 0 12px; color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.grid-tiles { grid-template-columns: repeat(auto-fit, minmax(206px, 1fr)); }

/* --------------------------------------------------------- hero + kpi --- */
.hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; }
.hero .label { color: var(--ink-2); font-size: 13px; margin-bottom: 2px; }
.hero .figure { font-size: 52px; line-height: 1.05; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.hero .meta { color: var(--muted); font-size: 12px; margin-top: 6px; }
.hero .delta { font-size: 14px; }
/* The one hero figure on the page wears the brand flame. */
.hero .figure {
  background: linear-gradient(96deg, var(--accent) 0%, var(--gold) 88%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (forced-colors: active) { .hero .figure { color: CanvasText; -webkit-text-fill-color: CanvasText; } }

.tile { display: flex; flex-direction: column; gap: 4px; }
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 23px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.tile .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile .spark { flex: none; }
.delta { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--muted); }

.spark-line { fill: none; stroke: var(--seq-200); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-ring { fill: var(--surface-1); }
.spark-dot { fill: var(--seq-450); }

/* ------------------------------------------------------------ charts --- */
.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; }
.ch-grid { stroke: var(--grid); stroke-width: 1; }
.ch-zero { stroke: var(--axis); stroke-width: 1; }
.ch-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ch-endlabel { fill: var(--ink-2); font-size: 11px; font-weight: 500; }
.ch-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-dot-ring { fill: var(--surface-1); }
.ch-band { fill: transparent; }
.ch-band.on { fill: var(--hover); }
.ch-hit { cursor: crosshair; }

.ch-tip {
  position: absolute; transform: translate(-50%, 0); pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; min-width: 168px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .16); z-index: 4;
}
.ch-tip-h { font-weight: 600; margin-bottom: 5px; }
.ch-tip-r { display: grid; grid-template-columns: 10px 1fr auto; gap: 7px; align-items: center; padding: 1.5px 0; }
.ch-tip-r span:nth-child(2) { color: var(--ink-2); }
.ch-tip-r b { font-variant-numeric: tabular-nums; font-weight: 600; }
.ch-tip-t { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 5px; }
.ch-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.ch-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.ch-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }

/* ------------------------------------------------------------ tables --- */
.tbl-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 190px; }
thead th { color: var(--muted); font-weight: 500; font-size: 12px; border-bottom: 1px solid var(--axis); }
tbody td { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--hover); }
tr.sub td { font-weight: 600; background: var(--hover); }
tr.grp td { color: var(--muted); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; padding-top: 14px; border-bottom: none; }
td.derived { color: var(--ink-2); }
td.derived::after { content: " ƒ"; color: var(--muted); font-size: 10px; }
td.missing { color: var(--muted); }
.num-neg { color: var(--neg); }

td[contenteditable] { background: var(--accent-wash); cursor: text; border-radius: 4px; }
tr.grp td { color: var(--gold); }

/* ------------------------------------------------------------ checks --- */
.check { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.check:last-child { border-bottom: none; }
.check .icon { font-size: 13px; width: 16px; flex: none; text-align: center; line-height: 1.5; }
.check.ok .icon { color: var(--good); }
.check.bad .icon { color: var(--critical); }
.check .body { flex: 1; min-width: 0; }
.check .name { font-size: 13px; }
.check .detail { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.check .tag { font-size: 11px; color: var(--ink-2); background: var(--hover); border-radius: 5px; padding: 1px 6px; }

.banner {
  display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); font-size: 13px; margin-bottom: 14px;
}
.banner.bad { border-color: var(--critical); color: var(--ink); background: color-mix(in srgb, var(--critical) 8%, var(--surface-1)); }
.banner.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--surface-1)); }
.banner b { font-weight: 600; }

/* -------------------------------------------------------------- drop --- */
.drop {
  border: 1.5px dashed var(--border-strong); border-radius: 12px;
  padding: 26px; text-align: center; color: var(--ink-2); background: var(--surface-1);
}
.drop.hot { border-color: var(--accent); background: var(--accent-wash); }
.drop strong { color: var(--ink); }
.drop .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

#dropZone.overlay {
  position: fixed; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--page));
  font-size: 17px; font-weight: 500;
}
#dropZone.overlay.on { display: flex; }

/* ------------------------------------------------------- empty state --- */
.empty { text-align: center; padding: 26px 0 8px; }
.empty .phoenix {
  width: 108px; height: 108px; margin: 0 auto 16px; border-radius: 22px;
  background: radial-gradient(circle at 50% 42%, rgba(255, 107, 0, .18), #0a0a0a 70%);
  border: 1px solid var(--gold-line); display: grid; place-items: center;
}
.empty .phoenix img { width: 78px; height: 78px; filter: drop-shadow(0 0 14px rgba(201, 168, 76, .5)); }
.empty h2 { margin: 0 0 8px; font-size: 25px; font-weight: 600; letter-spacing: -.015em; }
.empty .lede { max-width: 620px; margin: 0 auto 22px; color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.btn-primary.big { font-size: 14px; padding: 10px 20px; }
.bullets { margin: 6px 0 0; padding-left: 18px; }
.bullets li { margin-bottom: 5px; }
table.mini th, table.mini td { padding: 5px 8px; font-size: 12px; }
code { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--hover); padding: 1px 4px; border-radius: 4px; }

.err { color: var(--critical); font-size: 13px; }
.hide { display: none !important; }
.note { color: var(--muted); font-size: 12px; line-height: 1.6; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.rowline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

@media print {
  .controls, .tabs, .drop, #dropZone { display: none !important; }
  .card { break-inside: avoid; border-color: #ccc; }
  body { background: #fff; }
}
