:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --line: #e4e2dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #256abf;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --good: #0a7d0a;
  --bad: #c0392b;
  --warn: #b7791f;
  --good-bg: #e7f4e7;
  --bad-bg: #fbe9e7;
  --warn-bg: #fdf3dc;
  --heat-0: #f0efec;
  --heat-1: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --line: #2d2d2a; --text: #fff;
    --text-2: #c3c2b7; --muted: #8d8c85; --accent: #6da7ec;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --good: #4cc24c; --bad: #ef6b5e; --warn: #e3a73a;
    --good-bg: #16301a; --bad-bg: #3a1c19; --warn-bg: #3a2e14;
    --heat-0: #262624; --heat-1: #6da7ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --line: #2d2d2a; --text: #fff;
  --text-2: #c3c2b7; --muted: #8d8c85; --accent: #6da7ec;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --good: #4cc24c; --bad: #ef6b5e; --warn: #e3a73a;
  --good-bg: #16301a; --bad-bg: #3a1c19; --warn-bg: #3a2e14;
  --heat-0: #262624; --heat-1: #6da7ec;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Heebo", system-ui, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 17px; margin: 0 0 10px; font-weight: 600; }
.sub { color: var(--text-2); font-size: 13px; margin: 0 0 14px; }

header.top {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.bar { max-width: 1400px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; padding: 12px 0; white-space: nowrap; }
nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav a { padding: 14px 10px; color: var(--text-2); border-bottom: 2px solid transparent; }
nav a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
nav a:hover { text-decoration: none; color: var(--text); }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }

.filters { max-width: 1400px; margin: 0 auto; padding: 10px 16px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select { font: inherit; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg a { padding: 5px 11px; color: var(--text-2); background: var(--surface); }
.seg a + a { border-inline-start: 1px solid var(--line); }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }
.fresh { margin-inline-start: auto; font-size: 12px; color: var(--muted); }
.fresh.stale { color: var(--bad); font-weight: 600; }

main { max-width: 1400px; margin: 0 auto; padding: 4px 16px 40px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .g2, .g3 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi .l { font-size: 13px; color: var(--text-2); }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .c { font-size: 12px; color: var(--muted); }
.kpi.alert .v { color: var(--bad); }

.d { font-size: 12px; font-weight: 600; white-space: nowrap; }
.d.ok { color: var(--good); } .d.bad { color: var(--bad); } .d.flat { color: var(--muted); }

.ins { list-style: none; margin: 0; padding: 0; }
.ins li { padding: 9px 12px; border-radius: 8px; margin-bottom: 6px; display: flex; gap: 10px;
  align-items: baseline; }
.ins li.l2 { background: var(--bad-bg); }
.ins li.l1 { background: var(--warn-bg); }
.ins li.l0 { background: var(--bg); }
.ins .tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
  white-space: nowrap; }
.l2 .tag { background: var(--bad); color: #fff; }
.l1 .tag { background: var(--warn); color: #fff; }
.l0 .tag { background: var(--muted); color: #fff; }
.ins .go { margin-inline-start: auto; white-space: nowrap; font-size: 13px; }

.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--line);
  vertical-align: top; }
th { font-weight: 600; color: var(--text-2); font-size: 12.5px; background: var(--surface);
  position: sticky; top: 0; cursor: pointer; white-space: nowrap; user-select: none; }
th.sorted-asc::after { content: " ▲"; } th.sorted-desc::after { content: " ▼"; }
td.n, th.n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:hover td { background: var(--bg); }
td.bad { color: var(--bad); font-weight: 600; }
td.good { color: var(--good); }
.desc { color: var(--text-2); font-size: 13px; max-width: 520px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px;
  background: var(--bg); color: var(--text-2); white-space: nowrap; }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.chart { position: relative; height: 260px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px;
  vertical-align: middle; margin-inline-end: 6px; }

.heat { display: grid; grid-template-columns: 52px repeat(24, 1fr); gap: 2px; font-size: 11px; }
.heat div { height: 22px; border-radius: 3px; display: flex; align-items: center;
  justify-content: center; color: var(--text-2); }
.heat .h { background: none; }
.stuck-g { border-inline-start: 4px solid var(--warn); }
.stuck-g.zero { border-inline-start-color: var(--good); opacity: .75; }
.why { color: var(--text-2); font-size: 13px; margin: -4px 0 10px; }
.empty { color: var(--muted); padding: 10px 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; }

.login { max-width: 360px; margin: 12vh auto; }
.login input { width: 100%; font: inherit; padding: 9px 10px; margin: 6px 0 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.login button, .btn { font: inherit; padding: 9px 16px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer; }
.flash { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: 6px; }
