:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1c2330; --muted: #667085; --line: #dde1e7;
  --accent: #2557a7; --good: #1f8a4c; --warn: #b7791f; --bad: #c53030; --soft: #eef2f8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --panel: #1d2128; --ink: #e6e9ee; --muted: #98a2b3; --line: #323844;
          --accent: #7aa7f0; --good: #4cc282; --warn: #e0a84a; --bad: #f07171; --soft: #252b35; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, "Segoe UI", sans-serif; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px;
         background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 8px; }
nav button { border: 0; background: none; color: var(--muted); font: inherit; padding: 8px 12px; border-radius: 6px; cursor: pointer; }
nav button.on { background: var(--soft); color: var(--ink); font-weight: 600; }
#asof { margin-left: auto; font-size: 13px; }
main { padding: 12px 16px 40px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
.muted { color: var(--muted); } .err { color: var(--bad); }
form#f, fieldset { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
form#f { padding: 14px; }
fieldset { margin: 10px 0; padding: 8px 12px 12px; }
legend { font-weight: 600; padding: 0 4px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 6px 0; }
label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 3px; min-width: 120px; }
label.grow { flex: 1 1 220px; }
label small, .hint { font-size: 12px; color: var(--muted); }
.hint { align-self: center; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
                border-radius: 6px; padding: 7px 8px; min-height: 38px; }
input[type=number] { width: 120px; }
input[type=checkbox] { min-height: 0; }
.controls label:has(input[type=checkbox]) { flex-direction: row; align-items: center; }
button { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.live { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.live div, .kpis div { background: var(--soft); border-radius: 8px; padding: 8px 12px; min-width: 130px; }
.live b, .kpis b { display: block; font-size: 20px; }
.live span, .kpis span { font-size: 12px; color: var(--muted); }
.kpis { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tbl { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.grp td { background: var(--soft); font-weight: 600; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.pill.good { background: color-mix(in srgb, var(--good) 15%, transparent); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); }
.pill.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); }
.bar { height: 8px; background: var(--soft); border-radius: 4px; min-width: 80px; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }
.bar u { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .5; }
.link { border: 0; background: none; color: var(--accent); padding: 0 4px; cursor: pointer; }
#keybox { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 5; }
#keybox[hidden] { display: none; }
#keyform { background: var(--panel); padding: 20px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
@media (max-width: 640px) { input[type=number] { width: 100%; } label { flex: 1 1 140px; } }
