:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --border: #e4e2dc;
  --text: #191919;
  --muted: #666666;
  --accent: #257de0;
  --accent-soft: #e8f1fc;
  --good: #008a17;
  --warn: #b26b00;
  --radius: 10px;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121212;
    --surface: #191919;
    --border: #2e2e2e;
    --text: #efefef;
    --muted: #9c9c9c;
    --accent: #338ced;
    --accent-soft: #1b2a3d;
    --good: #0aac23;
    --warn: #e0a030;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
header { display: flex; align-items: center; gap: 24px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
header h1 { font-size: 16px; margin: 0; font-weight: 600; white-space: nowrap; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
nav.tabs button:hover { color: var(--text); background: var(--bg); }
nav.tabs button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
header .spacer { flex: 1; }
header a { color: var(--muted); text-decoration: none; }
header a:hover { color: var(--text); }
main { padding: 20px 24px 48px; max-width: 1400px; margin: 0 auto; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 18px; }
.filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.filters input, .filters select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 34px; }
.filters input:focus-visible, .filters select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.presets { display: flex; gap: 4px; }
.presets button { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px; min-height: 34px; cursor: pointer; }
.presets button:hover { border-color: var(--accent); }
.presets button:active { background: var(--accent-soft); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 4px; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.funnel { display: flex; flex-wrap: wrap; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.funnel .step { flex: 1 1 140px; padding: 12px 16px; border-right: 1px solid var(--border); }
.funnel .step:last-child { border-right: 0; }
.funnel .step .label { color: var(--muted); font-size: 12px; }
.funnel .step .value { font-size: 20px; font-weight: 600; }
.funnel .step .rate { font-size: 12px; color: var(--accent); }

section.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
section.card > h2 { font-size: 14px; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; gap: 12px; align-items: center; }
section.card > h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { padding: 7px 9px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.text { text-align: left; white-space: normal; min-width: 220px; }
th { font-weight: 500; color: var(--muted); font-size: 12px; position: sticky; top: 0; background: var(--surface); }
tbody tr:hover { background: var(--bg); }
tfoot td { font-weight: 600; border-bottom: 0; }
td.immature { color: var(--muted); }
td .muted, .muted { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; padding: 10px 16px; }
.freshness { color: var(--muted); font-size: 12px; text-align: right; }
.freshness .bad { color: var(--warn); }
.empty { padding: 24px 16px; color: var(--muted); }
.loading { opacity: .5; pointer-events: none; }

body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: min(360px, 92vw); display: grid; gap: 14px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.login-card input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.login-card button { font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px; cursor: pointer; font-weight: 600; }
.login-card button:hover { filter: brightness(1.08); }
.login-card .error { color: var(--warn); margin: 0; }
