:root {
  --bg: #f4f5f7; --panel: #ffffff; --ink: #14181f; --muted: #5d6675; --line: #dfe3ea; --accent: #0b6e8f; --accent-ink: #ffffff;
  --ok: #19703f; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fdf1d3; --bad: #a3261d; --bad-bg: #fbe6e3; --info-bg: #e4eef6;
  --series-a: #0b6e8f; --series-b: #c2571a;
  --radius: 10px; --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318; --panel: #181e26; --ink: #e8ecf1; --muted: #9aa5b5; --line: #2a333f; --accent: #4fb6d6; --accent-ink: #07222c;
    --ok: #6fd39a; --ok-bg: #143524; --warn: #f0c35c; --warn-bg: #3a2e0e; --bad: #f2948c; --bad-bg: #40191a; --info-bg: #1a2a38;
    --series-a: #4fb6d6; --series-b: #f0935a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; }
.muted { color: var(--muted); }
.loading { padding: 40px; color: var(--muted); }
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.narrow { width: 100%; max-width: 380px; }

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.nav { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; cursor: pointer; }
.nav:hover { background: var(--bg); }
.nav[aria-current="page"] { background: var(--info-bg); font-weight: 600; }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.main { padding: 24px 28px 60px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.scroll { overflow-x: auto; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field input, .field select, .field textarea { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 12px; }
.check input { margin-top: 3px; }
.check label { font-size: 14px; color: var(--ink); margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.btn:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { justify-content: space-between; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--info-bg); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; background: var(--info-bg); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.checks { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
.checks li { padding: 3px 0; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .a { stroke: var(--series-a); fill: none; stroke-width: 2; }
.chart .b { stroke: var(--series-b); fill: none; stroke-width: 2; stroke-dasharray: 5 4; }
.chart .dot-a { fill: var(--series-a); }
.chart .dot-b { fill: var(--series-b); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--line); fill-opacity: 0.5; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.swatch { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--series-a); vertical-align: middle; margin-right: 6px; }
.swatch.b { border-top: 2px dashed var(--series-b); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 80px; }
.bar progress { display: none; }
meter { width: 110px; height: 8px; vertical-align: middle; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 20px; width: min(720px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { width: 100%; padding-bottom: 6px; }
  .nav { width: auto; }
  .side .foot { margin: 0; width: 100%; }
  .main { padding: 16px; }
}

.storebox { padding: 0 10px 12px; }
.storebox select { width: 100%; font-weight: 600; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.btn.bad { background: var(--bad); color: var(--panel); }
.card.danger { border-color: var(--bad); }
dialog .row { margin-top: 12px; }
