:root {
  color-scheme: light;
  --bg: #f4f3ef; --surface: #fcfcfb; --border: #e3e1da; --grid: #e9e7e0;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #7c7a74;
  --s1: #2a78d6; --s2: #eb6834;
  --good: #0a7a3d; --bad: #c62f2e; --warn-bg: #fdf1dc; --warn-text: #7a4b00;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --border: #2e2e2b; --grid: #2a2a27;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e85;
    --s1: #3987e5; --s2: #d95926;
    --good: #3fbf7a; --bad: #e66767; --warn-bg: #3a2c10; --warn-text: #f1cf8a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--text-2); margin: 2px 0 0; font-size: 13px; }
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }
section { margin-top: 22px; }
section > h2 { margin-bottom: 10px; }

.top { max-width: 1100px; margin: 0 auto; padding: 18px 16px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 10px; }
.status { font-size: 13px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-right: 7px; }
.status.live::before { background: var(--good); }
.status.stale::before { background: var(--bad); }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 9px 14px; background: var(--s1); color: #fff; font-weight: 600; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; padding: 5px 12px; }
button:disabled { opacity: .6; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { font-size: 12.5px; color: var(--text-2); }
.tile .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.tiles.small .tile { border: 0; padding: 4px 0; background: none; }
.tiles.small .v { font-size: 19px; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 11px; }
.chart .lbl { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .l1 { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; }
.chart .l2 { fill: none; stroke: var(--s2); stroke-width: 2; stroke-linejoin: round; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; }
.chart .bar { fill: var(--s1); }
.chart .bar.neg { fill: var(--bad); }
.chart .bar:hover { opacity: .8; }
.chart .target { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .zero { stroke: var(--text-3); stroke-width: 1; }
.chart .none { fill: var(--text-3); font-size: 13px; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
.table-wrap.tall { max-height: 460px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th { color: var(--text-2); font-weight: 500; font-size: 12.5px; position: sticky; top: 0; background: var(--surface); }
td.emptyrow { text-align: left; color: var(--text-3); border-bottom: 0; }

.notice { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; font-size: 13.5px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.foot { margin-top: 18px; }
.tip { position: fixed; pointer-events: none; z-index: 10; background: var(--text); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 7px; line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; }
.login-card label { font-size: 13px; color: var(--text-2); margin-top: 14px; margin-bottom: 4px; }
.login-card input { font: inherit; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.login-card input:focus { outline: 2px solid var(--s1); outline-offset: 1px; }
.login-card button { margin-top: 18px; }
.error { color: var(--bad); font-size: 13px; margin: 12px 0 0; }
[hidden] { display: none !important; }
