:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,.10); --wash: rgba(11,11,11,.05);
  --y2026: #2a78d6; --y2024: #eb6834; --y2022: #1baf7a; --accent: #2a78d6; --band: rgba(42,120,214,.07);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10); --wash: rgba(255,255,255,.06);
  --y2026: #3987e5; --y2024: #d95926; --y2022: #199e70; --accent: #3987e5; --band: rgba(57,135,229,.12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; } h2 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--ink2); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-in, .wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.top-in { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.wrap { padding-top: 16px; padding-bottom: 40px; display: grid; gap: 16px; }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.ghost { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; color: var(--ink2); }
.ghost:hover { background: var(--wash); }
select { background: var(--surface); border: 1px solid var(--axis); border-radius: 8px; padding: 7px 10px; min-width: 0; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.panel-h { display: grid; gap: 2px; margin-bottom: 12px; }
.panel-h.pad { padding: 0 2px; }
.controls, .filters { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.filters { align-items: flex-end; }
.ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink2); }
.selects { display: flex; flex-wrap: wrap; gap: 10px 14px; flex: 1 1 560px; }
.sel { display: grid; gap: 3px; min-width: 140px; flex: 1 1 140px; }
.chips, .pills { display: flex; gap: 6px; flex-wrap: wrap; }
.chip, .pill { border: 1px solid var(--axis); background: var(--surface); border-radius: 999px; padding: 5px 12px; display: inline-flex; align-items: center; gap: 7px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip[aria-pressed="false"] { opacity: .55; }
.chip[aria-pressed="false"] i { background: transparent !important; border: 1.5px solid var(--muted); }
.chip[disabled] { cursor: default; }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.status { padding: 10px 14px; border-radius: 10px; background: var(--wash); color: var(--ink2); }
.status.err { border: 1px solid var(--axis); color: var(--ink); }
.spinner { display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid var(--axis); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#app[aria-busy="true"] > :not(.status) { opacity: .55; transition: opacity .15s; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 3px; }
.kpi .k { font-size: 12px; color: var(--ink2); display: flex; align-items: center; gap: 7px; }
.kpi .k i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.kpi .v { font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.kpi .s { font-size: 13px; color: var(--ink2); }
.delta { font-variant-numeric: tabular-nums; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 11px system-ui, -apple-system, "Segoe UI", sans-serif; fill: var(--muted); }
.chart .lab { fill: var(--ink); font-size: 12px; font-weight: 600; }
.chart .band-lab { fill: var(--ink2); }
.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--axis); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 140px; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.tbl-view { margin-top: 10px; font-size: 13px; color: var(--ink2); }
.tbl-view summary { cursor: pointer; }
.tbl-view table, .cty { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.tbl-view table { margin-top: 8px; font-size: 12px; }
.tbl-view th, .tbl-view td, .cty th, .cty td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tbl-view th:first-child, .tbl-view td:first-child, .cty th:first-child, .cty td:first-child { text-align: left; }
.tbl-view { overflow-x: auto; }

.mixgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.mix { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: grid; gap: 9px; align-content: start; }
.mix h3 { margin: 0 0 2px; font-size: 14px; font-weight: 650; }
.mrow { display: grid; grid-template-columns: 112px 1fr 92px; gap: 10px; align-items: center; font-size: 13px; }
.mrow .nm { color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { position: relative; height: 12px; background: var(--wash); border-radius: 6px; overflow: visible; }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--y2026); border-radius: 6px; min-width: 2px; }
.track .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; border-radius: 1px; }
.mrow .val { text-align: right; font-variant-numeric: tabular-nums; }
.mrow .val small { display: block; color: var(--ink2); font-size: 11px; }
.legend { font-size: 11px; color: var(--muted); }

.tbl-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--grid); border-radius: 8px; }
.cty th { position: sticky; top: 0; background: var(--surface); cursor: pointer; font-size: 12px; color: var(--ink2); font-weight: 600; user-select: none; }
.cty tbody tr { cursor: pointer; }
.cty tbody tr:hover { background: var(--wash); }
.cty tr.sel { background: var(--band); }
.cty .bar { display: inline-block; vertical-align: middle; height: 8px; border-radius: 4px; background: var(--y2026); min-width: 1px; }
.cty .barcell { width: 130px; text-align: left !important; }
.foot { display: grid; gap: 8px; max-width: 900px; }

.gate-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.gate { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; display: grid; gap: 10px; }
.gate form { display: grid; gap: 10px; margin-top: 6px; }
.gate input { padding: 10px 12px; border: 1px solid var(--axis); border-radius: 8px; background: var(--page); width: 100%; }
.gate button { padding: 10px 12px; border-radius: 8px; border: 0; background: var(--ink); color: var(--surface); font-weight: 600; }
.gate-error { color: var(--ink); font-size: 13px; border-left: 3px solid var(--y2024); padding-left: 8px; }

@media (max-width: 640px) {
  .mrow { grid-template-columns: 88px 1fr 78px; }
  .kpi .v { font-size: 24px; }
}
@media (forced-colors: active) {
  .track .fill, .cty .bar { forced-color-adjust: none; }
}

.fdet { padding: 0; }
.fdet > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.fdet > summary::-webkit-details-marker { display: none; }
.fdet > summary::before { content: '▸'; color: var(--ink2); transition: transform .15s; }
.fdet[open] > summary::before { transform: rotate(90deg); }
.fdet .fsum { color: var(--ink2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fdet .fsum.on { color: var(--ink); font-weight: 600; }
.fdet .filters { padding: 0 16px 16px; }
.mixhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; padding: 0 2px; margin-bottom: 12px; }
.mixhead .panel-h { margin: 0; }
.mixhead .ctl { gap: 8px; }
