:root {
  color-scheme: light;
  --surface: #f4f5f7; --panel: #ffffff; --border: #e6e8ec; --line: #eef0f3; --text: #111318; --muted: #6b7280;
  --grid: #e9ebef; --accent: #2f5bea; --accent-soft: #eef2ff; --series: #3b6ff5; --pos: #3b6ff5; --neg: #e5484d;
  --good: #12a150; --good-soft: #e8f7ee; --warn: #b7791f; --warn-soft: #fdf4e3; --bad: #e5484d; --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #0f1115; --panel: #171a21; --border: #262a33; --line: #20242c; --text: #f2f4f7; --muted: #9aa3b2;
    --grid: #262a33; --accent: #7c9cff; --accent-soft: #1d2540; --series: #5b86ff; --pos: #5b86ff; --neg: #f06a6e;
    --good: #3ccf7e; --good-soft: #13291d; --warn: #f5b544; --warn-soft: #2d2412; --bad: #f06a6e; --bad-soft: #2f1719;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }

/* Top bar */
header.top { background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
header.top .wrap { display: flex; align-items: center; gap: 14px; padding: 10px 20px; max-width: 1280px; margin: 0 auto; }
header.top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
header.top .brand:hover { text-decoration: none; }
header.top .logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; }
header.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
header.top nav a { color: var(--muted); padding: 6px 11px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
header.top nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
header.top nav a.on { color: var(--accent); background: var(--accent-soft); }
header.top .search input { width: 180px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border-color: transparent; }
header.top .search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--panel); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; padding: 4px 10px; border-radius: 999px; background: var(--surface); }
.live:hover { text-decoration: none; color: var(--text); }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.live.ok .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.live.late .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.who { position: relative; }
.who summary { list-style: none; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 600; }
.who summary::-webkit-details-marker { display: none; }
.who .menu { position: absolute; right: 0; top: 38px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .12); padding: 8px; min-width: 190px; display: flex; flex-direction: column; }
.who .menu > * { padding: 7px 10px; border-radius: 8px; }
.who .menu a { color: var(--text); } .who .menu a:hover { background: var(--surface); text-decoration: none; }
.who .menu form { padding: 0; } .who .menu button.link { width: 100%; text-align: left; padding: 7px 10px; }

/* Page */
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .sub { color: var(--muted); margin: 2px 0 0; }
.meta { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.meta span { margin-right: 14px; display: inline-block; }
section, .card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-top: 16px; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 6px 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.cardhead > a { font-size: 13px; font-weight: 500; }

/* Controls */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 14px 0 4px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; font-weight: 500; }
.filters .hint { color: var(--muted); font-size: 12px; margin-left: auto; align-self: center; }
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=date], input[type=search], input[type=number], select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); }
button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 8px 16px; cursor: pointer; font-weight: 500; display: inline-block; }
button:hover, .btn:hover { filter: brightness(1.07); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--bad); }
button.link { background: none; color: var(--text); padding: 0; border-radius: 0; font-weight: 400; }
button.link:hover { filter: none; background: var(--surface); }
.scopepick select { min-width: 200px; }

/* Period tabs */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.tabs a { padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--accent); color: #fff; }

/* Headline numbers */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 8px; font-variant-numeric: tabular-nums; cursor: default; }
.stat .value small { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.stat.hero { background: linear-gradient(135deg, var(--accent-soft), var(--panel) 70%); }
.stat .foot { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.delta { font-weight: 600; padding: 1px 7px; border-radius: 999px; font-size: 12px; }
.delta.good { color: var(--good); background: var(--good-soft); }
.delta.bad { color: var(--bad); background: var(--bad-soft); }
.delta.none { color: var(--muted); background: var(--surface); }
.wallets { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-top: 14px; padding: 12px 20px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
.wallets:hover { text-decoration: none; border-color: var(--accent); }
.wallets .label { color: var(--muted); font-weight: 500; }
.wallets b { font-size: 17px; font-variant-numeric: tabular-nums; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend i.pos { background: var(--pos); } .legend i.negc { background: var(--neg); }

/* Short lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rows .who a { font-weight: 600; }
.rows .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; }
.rows .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.rows .more { font-size: 11.5px; color: var(--muted); margin-left: 2px; cursor: default; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); padding: 1px 8px; border-radius: 999px; margin-left: 4px; }
.note, .empty { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

/* Older page blocks */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .big { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 12px 0 0; font-size: 12.5px; padding-top: 10px; border-top: 1px solid var(--line); }
.kpi dt { color: var(--muted); } .kpi dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid2 > section { margin-top: 16px; }
.chart h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; } .chart p { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
svg { display: block; width: 100%; height: auto; overflow: visible; } svg text { fill: var(--muted); font-size: 11px; }
.hit { fill: transparent; outline: none; } .hit:hover + .bar, .hit:focus + .bar { opacity: .7; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--panel); position: sticky; top: 0; }
th.l, td.l { text-align: left; } td { font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--surface); }
.neg { color: var(--neg); }
.flag { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; margin: 1px 3px 1px 0; }
.flag.high { color: var(--bad); background: var(--bad-soft); } .flag.medium { color: var(--warn); background: var(--warn-soft); }
.status { font-weight: 600; } .status.ok { color: var(--good); } .status.warn { color: var(--warn); } .status.bad { color: var(--bad); }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--warn); background: var(--panel); padding: 10px 14px; margin: 12px 0; border-radius: 10px; }
.notice.bad { border-left-color: var(--bad); } .notice.ok { border-left-color: var(--good); }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.heat { border-collapse: separate; border-spacing: 2px; }
.heat td { width: 3.4%; height: 26px; border: 0; padding: 0; border-radius: 4px; text-align: center; font-size: 10px; }
.heat th { font-size: 11px; padding: 2px 4px; position: static; }
.login { max-width: 380px; margin: 12vh auto; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; }
#tip { position: fixed; pointer-events: none; background: var(--text); color: var(--panel); border-radius: 8px; padding: 6px 9px;
  font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.18); display: none; z-index: 9; white-space: pre; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  header.top .search input { width: 140px; }
}
@media (max-width: 760px) {
  header.top .wrap { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  header.top .brand { order: 1; flex: 1; }
  .live { order: 2; } .who { order: 3; }
  header.top .search { order: 4; flex: 0 0 100%; } header.top .search input { width: 100%; }
  header.top nav { order: 5; width: 100%; flex: none; }
  main { padding: 16px 16px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 21px; margin: 4px 0 6px; }
  .stat .value small { font-size: 11px; }
  .stat .foot > span:not(.delta) { display: none; }
  .filters .hint { margin-left: 0; }
  .tabs { display: flex; overflow-x: auto; }
  .tabs a { white-space: nowrap; padding: 6px 10px; flex: 1; text-align: center; }
  .scopepick, .scopepick select { width: 100%; }
  section, .card { padding: 16px; }
}
