:root {
  --bg: #ffffff; --surface: #f5f7f8; --text: #1b1f23; --muted: #5d6670; --line: #d9dee3; --grid: #e6e9ec;
  --link: #0b5a75; --accent: #0F5E7A;
  --haiku: #6bbfd8; --sonnet: #2e9bbd; --opus: #0F5E7A; --fable: #073a4a; --other: #a3a9ae; --neutral: #6f8494;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121517; --surface: #1b1f22; --text: #e3e6e8; --muted: #9aa3ab; --line: #2f353a; --grid: #262b2f;
    --link: #8fd0e6; --accent: #5bbdd8;
    --haiku: #0F5E7A; --sonnet: #2a8fb0; --opus: #5bbdd8; --fable: #a6dceb; --other: #6b7176; --neutral: #7f93a3;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .brand { font-weight: 600; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 14px; flex: 1; }
.top form { margin: 0; }
button {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 48px; }
h1 { font-size: 1.45rem; margin: 14px 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
section { margin: 28px 0; }
.periods { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
.periods a {
  white-space: nowrap; text-decoration: none; color: var(--text); padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 999px;
}
.periods a[aria-current="page"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.kpi span { display: block; color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.35rem; font-weight: 600; }
.note, .empty { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.error { color: var(--text); border-left: 3px solid #c0392b; padding-left: 8px; }
.scroll { overflow-x: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 5px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
thead th { background: var(--surface); font-weight: 600; }
tfoot th { background: var(--surface); }
.num { text-align: right; }
.chart { display: block; width: 100%; height: auto; margin: 6px 0; }
.chart text { font-size: 12px; fill: var(--text); }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .val.small { font-size: 10px; }
.chart a text { fill: var(--link); }
.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; }
.fam-haiku { fill: var(--haiku); background: var(--haiku); }
.fam-sonnet { fill: var(--sonnet); background: var(--sonnet); }
.fam-opus { fill: var(--opus); background: var(--opus); }
.fam-fable { fill: var(--fable); background: var(--fable); }
.fam-other { fill: var(--other); background: var(--other); }
.neutral { fill: var(--neutral); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 4px 0; font-size: .88rem; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.more { margin: 28px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.more > summary { cursor: pointer; font-weight: 600; }
.login { display: grid; gap: 12px; max-width: 320px; }
.login label { display: grid; gap: 4px; }
.login input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
@media (max-width: 560px) {
  body { font-size: 14px; }
  .kpi b { font-size: 1.15rem; }
}
