:root {
  --bg: #f5f6f8; --surface: #fff; --fg: #18202a; --muted: #5d6b7a; --line: #dfe3e8;
  --accent: #2160c4; --accent-soft: rgba(33, 96, 196, .14); --good: #1d7a45; --bad: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11161d; --surface: #18202a; --fg: #e3e8ee; --muted: #98a5b3; --line: #2a3441;
          --accent: #7fb0ff; --accent-soft: rgba(127, 176, 255, .18); --good: #6fd39a; --bad: #ff8f86; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 14px; }
.top { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: 12px;
       justify-content: space-between; align-items: center; padding: 10px 16px;
       background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; }
label { color: var(--muted); font-size: 12px; display: inline-flex; flex-direction: column; gap: 2px; }
select, input, button { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line);
                        border-radius: 6px; padding: 5px 8px; }
button { background: var(--accent); color: #fff; border: 0; cursor: pointer; align-self: end; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
h2 { font-size: 14px; margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: 400; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; }
.chart { height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.axis { stroke: var(--line); }
.line { fill: none; stroke: var(--accent); stroke-width: 2; }
.band { fill: var(--accent-soft); stroke: none; }
.note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.n, th.n { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.good { color: var(--good); } .bad { color: var(--bad); }
.est { display: flex; flex-wrap: wrap; gap: 8px; }
.est input { width: 100px; }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--fg);
         width: min(860px, calc(100vw - 32px)); max-height: 90vh; padding: 16px; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); font-size: 12px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { display: grid; gap: 12px; width: min(360px, 100%); }
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login input { width: 100%; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button, button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.tabs button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.who { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters input { width: 110px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.banner { background: rgba(179, 38, 30, .12); color: var(--bad); border: 1px solid var(--bad); border-radius: 8px; padding: 8px 12px; }
a.dl { font-size: 12px; margin-left: 8px; color: var(--accent); }
h2 a.dl, h2 button { float: right; font-weight: 400; }
.admin-only[hidden] { display: none !important; }
td.wrap { white-space: normal; max-width: 360px; }

.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.src { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; align-content: start; }
.src.off { opacity: .85; }
.src-head { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.src-head h3 { margin: 0; font-size: 15px; }
.src-sub { color: var(--muted); font-size: 12px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid currentColor; }
.badge.functional, .badge.ok { color: var(--good); }
.badge.needs_permission, .badge.waiting, .badge.running { color: #a86400; }
.badge.test_only, .badge.demo, .badge.off { color: var(--muted); }
.badge.error, .badge.blocked, .badge.missing { color: var(--bad); }
@media (prefers-color-scheme: dark) { .badge.needs_permission, .badge.waiting, .badge.running { color: #f0b45a; } }
.src dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.src dt { color: var(--muted); }
.src dd { margin: 0; font-variant-numeric: tabular-nums; }
.src .why { font-size: 12px; color: var(--muted); margin: 0; }
.src .why.bad { color: var(--bad); }
.src-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.src-actions button { align-self: center; }
.switch { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--fg); cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; padding: 0; border: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--good); }
.switch input:checked::after { left: 19px; }
.switch input:disabled { cursor: not-allowed; opacity: .5; }
.src select { padding: 3px 6px; }
.test-out { font-size: 12px; background: var(--bg); border-radius: 6px; padding: 6px 8px; margin: 0; }
