:root {
  --bg: #f6f7f9; --surface: #fff; --text: #14181f; --muted: #667085; --line: #e4e7ec;
  --accent: #2563eb; --accent-soft: #e8efff; --good: #12805c; --bad: #b42318; --warn: #b54708;
  --c1: #2563eb; --c2: #0f9d8a; --c3: #d97706; --c4: #7c3aed; --c5: #db2777; --c6: #64748b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #161b22; --text: #e6e9ef; --muted: #8b95a5; --line: #262d38;
    --accent: #6ea0ff; --accent-soft: #1b2740; --good: #3ccf9b; --bad: #ff8a7a; --warn: #f5a35a;
    --c1: #6ea0ff; --c2: #3cc9b4; --c3: #f0b34a; --c4: #a78bfa; --c5: #f472b6; --c6: #94a3b8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { font-weight: 700; font-size: 16px; padding: 0 10px 18px; display: flex; align-items: center; gap: 10px; }
.brand-login { display: flex; align-items: center; gap: 10px; }
.side nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .sep { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side .me { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.side .me form { display: inline; }
main { padding: 24px 28px 48px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-rows { display: grid; gap: 14px; }
.form-rows label { display: grid; grid-template-columns: 1fr minmax(180px, 280px); gap: 16px; align-items: center; }
.form-rows label input { width: 100%; }
.form-rows .actions { display: flex; justify-content: flex-end; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; word-break: break-word; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-left: 8px; opacity: .55; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; }
input, select, button { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
button, .btn { background: var(--accent); color: #fff; border-color: var(--accent); cursor: pointer; font-weight: 600; display: inline-block; }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.presets a { padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: 12px; background: var(--surface); }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.msg.ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.msg.err { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.muted { color: var(--muted); }
.chart { position: relative; height: 280px; }
.chart.sm { height: 220px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent-soft); color: var(--accent); }
.pill.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pill.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 6px 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.inline { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.login { max-width: 360px; margin: 14vh auto; }
.login .card { padding: 24px; }
.login input { width: 100%; margin-bottom: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .side .sep, .side .me { display: none; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-rows label { grid-template-columns: 1fr; gap: 4px; }
  main { padding: 16px; }
}

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted, var(--text)); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
