:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1d2329; --muted: #66707a; --line: #e3e1dc;
  --accent: #2f5d7c; --accent-soft: #c9dbe8; --bar: #e4eef5; --danger: #a33;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14181b; --card: #1c2226; --ink: #e8ecee; --muted: #9aa5ad; --line: #2c343a;
    --accent: #8cbbe0; --accent-soft: #35566e; --bar: #22343f; --danger: #e88; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 650; text-decoration: none; color: var(--ink); }
.top nav { display: flex; gap: 1rem; align-items: center; }
.top nav form { margin: 0; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1rem 2rem; }
h1 { font-size: 1.25rem; margin: 0 0 .5rem; }
h2 { font-size: .95rem; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: end; margin-bottom: 1.25rem; }
.filters h1 { margin: 0 1rem 0 0; align-self: center; }
.filters label { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.filters .lang { margin-left: auto; align-self: center; }
input, select, button { font: inherit; color: inherit; }
input, select { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); min-width: 0; }
button { padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: var(--card); cursor: pointer; }
button.danger { background: none; color: var(--danger); border-color: var(--danger); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpis div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; display: grid; }
.kpis b { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpis span { color: var(--muted); font-size: .85rem; }
.kpis small { color: var(--muted); font-size: .72rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; }
.card.wide { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; }
.csv { font-size: .75rem; color: var(--muted); }
.empty { color: var(--muted); margin: .25rem 0; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.bars li { position: relative; display: flex; justify-content: space-between; gap: 1rem; padding: .28rem .45rem; border-radius: 4px; }
.bars .bar { position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--bar); border-radius: 4px; z-index: 0; }
.bars .label, .bars .n { position: relative; z-index: 1; }
.bars .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .label small { color: var(--muted); }
.bars .n { font-variant-numeric: tabular-nums; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: .25rem; border-bottom: 1px solid var(--line); }
.chart .col { position: relative; flex: 1; height: 100%; min-width: 2px; }
.chart .col span { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 2px 2px 0 0; }
.chart .pv { background: var(--accent-soft); }
.chart .vi { background: var(--accent); left: 20%; right: 20%; }
.legend { font-size: .8rem; color: var(--muted); margin: .5rem 0 0; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.legend .key { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; }
.legend .key.vi { background: var(--accent); }
.legend .key.pv { background: var(--accent-soft); margin-left: .6rem; }
.legend .range { margin-left: auto; }
.login { max-width: 360px; margin: 3rem auto; display: grid; gap: .8rem; }
.login label, .stack label { display: grid; gap: .25rem; font-size: .85rem; }
.stack { display: grid; gap: .6rem; margin: .8rem 0; max-width: 560px; }
.stack fieldset { border: 1px solid var(--line); border-radius: 8px; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
label.check { display: flex; gap: .4rem; align-items: center; }
details.card { margin-bottom: .6rem; }
summary { cursor: pointer; }
summary small { color: var(--muted); margin-left: .4rem; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: .5rem; border-radius: 6px; font-size: .8rem; }
.error { color: var(--danger); }
.ok { color: var(--accent); }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 1rem 2rem; color: var(--muted); font-size: .78rem; }
.foot p { margin: .2rem 0; }
@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .filters .lang { margin-left: 0; }
}
