:root {
  --bg: #f6f7f9;
  --card: #fff;
  --text: #1d2330;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #bfdbfe;
  --line: #e5e7eb;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b22; --text: #e5e7eb; --muted: #9ca3af; --accent: #60a5fa; --accent-soft: #1e3a8a; --line: #2a2f3a; }
}

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; padding: .75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); }
h1 { font-size: 1.25rem; margin: 0; }
.brand-row { display: flex; align-items: center; gap: .75rem; }
.logo { display: flex; flex-shrink: 0; }
.logo img { display: block; width: 36px; height: 36px; }
.brand { font: 650 19px system-ui, sans-serif; color: inherit; text-decoration: none; white-space: nowrap; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h2 small { color: var(--muted); font-weight: normal; margin-left: .5rem; }
form { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
select, button, .button { font: inherit; padding: .35rem .6rem; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
button, .button { cursor: pointer; }
.button { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: .6rem 1.2rem; border: 0; }
a { color: var(--accent); }
main { padding: 1.25rem 1.5rem; max-width: 1400px; margin: 0 auto; }
.center { text-align: center; margin-top: 4rem; }
#status { color: var(--muted); min-height: 1.2em; margin: 0 0 .75rem; }
#status.error { color: #dc2626; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; }
.kpi .value { font-size: 1.6rem; font-weight: 600; }
.kpi .label { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: .75rem; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: .75rem; }
.grid .card { margin-bottom: 0; }
.grid + .card { margin-top: .75rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { word-break: break-all; }
td.ua { max-width: 28rem; color: var(--muted); font-size: 12px; }
tr.bot td { opacity: .55; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: var(--bg); }
.scroll { overflow-x: auto; }
.toolbar { display: flex; gap: 1rem; align-items: center; margin-bottom: .5rem; }
.empty { color: var(--muted); }
#chart svg { width: 100%; height: 220px; display: block; }
#chart .bar { fill: var(--accent-soft); }
#chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
#chart .axis { fill: var(--muted); font-size: 11px; }
#chart .grid-line { stroke: var(--line); }
