:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #4a4f5a;
  --muted: #7a808c;
  --line: #e3e5ea;
  --accent: #2a5bd7;
  --accent-ink: #ffffff;
  --bar: #2a5bd7;
  --good: #1a7f43;
  --bad: #c0362c;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --ink: #eceef2;
    --ink-2: #b9bec8;
    --muted: #8a909c;
    --line: #2c3038;
    --accent: #6b93f5;
    --accent-ink: #0d1020;
    --bar: #6b93f5;
    --good: #4cc17e;
    --bad: #f07a6f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h1 span { color: var(--muted); font-weight: 500; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--bad); min-height: 1em; margin: 6px 0 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
button, select, input {
  font: inherit;
  color: inherit;
}
button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: progress; }
button.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: 4px 0; font-weight: 500; }
button.small { padding: 4px 10px; font-size: 13px; }
select, input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
label.check { display: flex; align-items: center; gap: 8px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); display: grid; gap: 14px; }

/* app */
#app { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.meta { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
#app-error:empty { display: none; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 12px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
td.num, th.num { text-align: right; }
td .sub { display: block; font-size: 12px; color: var(--muted); white-space: normal; }
tfoot td { font-weight: 700; border-bottom: 0; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }

/* single-series horizontal bars */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 80px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 14px; }
.bar { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.bar-row[title] { cursor: default; }

.foot { font-size: 12px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: min(420px, calc(100% - 32px)); padding: 20px; }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
#edit-form { display: grid; gap: 12px; }
#edit-form h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 600px) {
  .bar-row { grid-template-columns: 100px 1fr 64px; }
  .tile .value { font-size: 22px; }
}
