:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14202b; --muted: #5d6b79; --line: #dfe3e8;
  --accent: #b97700; --focus: #1a6fd1;
  --green: #bfe8c9; --yellow: #fff2a8; --orange: #f9cd78; --red: #f7a3a3;
  --green-i: #14602b; --yellow-i: #6b5a00; --orange-i: #7a4a00; --red-i: #8a1313;
  --up: #14783a; --down: #b3261e; --sel: #dbeafe;
  --c1: #2b6cb0; --c2: #d97706; --c3: #7c3aed; --c4: #0f8a6a; --c5: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1218; --panel: #131c25; --ink: #e6edf3; --muted: #8a9aab; --line: #25323f;
    --accent: #f1a409; --focus: #58a6ff;
    --green: #17492a; --yellow: #5a4d0b; --orange: #6a4410; --red: #6e1f1f;
    --green-i: #8be0a3; --yellow-i: #f1de6b; --orange-i: #f7bf63; --red-i: #ff9b9b;
    --up: #4cc77a; --down: #ff7b72; --sel: #1d3350;
    --c1: #58a6ff; --c2: #f1a409; --c3: #b794f6; --c4: #3ddc97; --c5: #ff7b72;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.num, td, .kpi .v, .range .val, .live .p { font-variant-numeric: tabular-nums; }

.top { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between; padding: 20px 16px 8px; max-width: 1280px; margin: 0 auto; }
h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
h1::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--accent); }
.sub { color: var(--muted); font-size: 13px; }
.controls { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.datepick { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
input[type=date], button { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, .tablewrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button[disabled] { opacity: .55; cursor: progress; }

.status { max-width: 1280px; margin: 0 auto; padding: 0 16px; font-size: 13px; color: var(--muted); min-height: 22px; }
.status.warn { color: var(--orange-i); }
.status.err { color: var(--down); }
.status b { color: var(--ink); font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 8px 16px 40px; display: grid; gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 15px; }
.card h2 small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.hint { color: var(--muted); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; position: relative; overflow: hidden; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 30px; font-weight: 650; margin-top: 2px; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--line); }
.kpi.big .v { font-size: 46px; }
.t-green::before { background: var(--green-i); } .t-yellow::before { background: var(--yellow-i); }
.t-orange::before { background: var(--orange-i); } .t-red::before { background: var(--red-i); }
.kpi .tag { display: inline-block; margin-top: 6px; padding: 1px 8px; border-radius: 99px; font-size: 12px; }

.c-green { background: var(--green); color: var(--green-i); }
.c-yellow { background: var(--yellow); color: var(--yellow-i); }
.c-orange { background: var(--orange); color: var(--orange-i); }
.c-red { background: var(--red); color: var(--red-i); }

.ranges { display: grid; gap: 12px; }
.range .row { display: flex; justify-content: space-between; font-size: 13px; }
.range .row span:first-child { font-weight: 600; }
.range .bar { position: relative; height: 8px; border-radius: 4px; background: var(--line); margin: 6px 0 2px; }
.range .bar i { position: absolute; top: -4px; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); transform: translateX(-2px); }
.range .mm { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.live { display: grid; gap: 0; }
.live .r { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.live .r:last-child { border: 0; }
.live .p { text-align: right; } .live .c { min-width: 70px; text-align: right; font-weight: 600; }
.up { color: var(--up); } .down { color: var(--down); }
.empty { color: var(--muted); font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 5px 12px; font-size: 13px; background: transparent; }
.seg button.on { background: var(--ink); color: var(--panel); }
.chartbox { position: relative; height: 340px; }

.tablewrap { max-height: 560px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; white-space: nowrap; }
th, td { padding: 5px 9px; text-align: right; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--panel); z-index: 2; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; }
th:first-child { z-index: 3; }
tbody tr { cursor: pointer; }
tbody tr:hover td:not([class*="c-"]) { background: color-mix(in srgb, var(--sel) 55%, var(--panel)); }
tbody tr.sel td:not([class*="c-"]) { background: var(--sel); }
tbody tr.sel td:first-child { box-shadow: inset 4px 0 var(--accent); font-weight: 600; }
td.pos { color: var(--up); } td.neg { color: var(--down); }

footer { color: var(--muted); font-size: 12px; }
footer p { margin: 4px 0 8px; }
footer details { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
footer summary { cursor: pointer; }
footer li { margin: 3px 0; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr 1fr; } .kpi.big { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
  .chartbox { height: 280px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
