:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --border: #e2e2dd;
  --text: #191919;
  --text-2: #666666;
  --accent: #1b64be;
  --on-accent: #ffffff;
  --pos: #006c10;
  --neg: #c62828;
  --series-1: #257de0;
  --series-2: #f47230;
  --series-3: #00b894;
  --neutral: #c9c9c4;
  --neutral-line: #8a8a85;
  --div-pos: #257de0;
  --div-neg: #ec4647;
  --grid: #ececec;
  --warn-bg: #fff6e0;
  --warn-text: #7a5300;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111111;
    --surface: #191919;
    --surface-2: #222222;
    --border: #333333;
    --text: #efefef;
    --text-2: #9c9c9c;
    --accent: #6aabf1;
    --on-accent: #111111;
    --pos: #4cc764;
    --neg: #f07070;
    --series-1: #338ced;
    --series-2: #e76624;
    --series-3: #00a888;
    --neutral: #4a4a4a;
    --neutral-line: #8f8f8f;
    --div-pos: #338ced;
    --div-neg: #eb6263;
    --grid: #2a2a2a;
    --warn-bg: #3a2e10;
    --warn-text: #f5d27a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.topbar { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 650; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
main { max-width: 1400px; margin: 0 auto; padding: 20px; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-2); font-weight: 600; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.steps div { background: var(--surface-2); border-radius: 8px; padding: 8px; }
.steps .label { font-size: 11px; }
.steps .value { font-size: 16px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
tfoot td { font-weight: 600; background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tag { display: inline-block; padding: 1px 6px; margin: 1px 2px 1px 0; border: 1px solid var(--border); border-radius: 4px; font-size: 11px; color: var(--text-2); }
.warn { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.warn ul { margin: 4px 0 0; padding-left: 18px; }
button, .btn { font: inherit; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button:disabled { opacity: .6; cursor: default; }
button.link { border: none; background: none; color: var(--accent); padding: 0; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
textarea { width: 100%; min-height: 80px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 14px; }
form.inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; width: min(640px, 94vw); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-2); font-size: 11px; }
.chart .gridline { stroke: var(--grid); }
.chart .zero { stroke: var(--text-2); stroke-width: 1; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgb(0 0 0 / .12); white-space: nowrap; display: none; }
.status-ok { color: var(--pos); }
.status-bad { color: var(--neg); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.active { background: var(--surface-2); font-weight: 600; }
@media (max-width: 640px) { main { padding: 12px 16px; } .steps { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart .end-label { fill: var(--text-2); font-size: 11px; }
.split-bar { display: flex; gap: 2px; height: 22px; border-radius: 4px; overflow: hidden; }
.chip.est { background: var(--warn-bg); color: var(--warn-text); }
tr.excluded td { opacity: .55; }
