:root {
  --brand: #e7402f;
  --bg: #f6f5f4; --card: #ffffff; --ink: #1f2228; --muted: #626872; --line: #dedad7;
  --accent: #c8321f; --accent-ink: #ffffff; --accent-soft: #fdecea;
  --ok: #17803d; --ok-bg: #e0f3e8; --warn-bg: #fff4d6; --warn-ink: #7a5200; --bad-bg: #fde4e4; --bad-ink: #9b1c1c;
  --field: #ffffff; --calc: #f3f1ef;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --card: #212327; --ink: #ebebed; --muted: #a3a7b0; --line: #373a40;
    --accent: #ff8272; --accent-ink: #2a0c08; --accent-soft: #3d2320;
    --ok: #55c27f; --ok-bg: #1c3427; --warn-bg: #3b3115; --warn-ink: #f1cf7a; --bad-bg: #432024; --bad-ink: #f4a3a3;
    --field: #191b1f; --calc: #2a2c31;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 20px 6px; max-width: 1280px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; gap: 8px; }
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; }
button.small { padding: 3px 9px; font-size: 12.5px; }
button.x { padding: 1px 8px; color: var(--muted); }
button.x:hover { color: var(--bad-ink); background: var(--bad-bg); border-color: var(--bad-ink); }
h1 .aid { display: inline-block; margin-left: 8px; padding: 1px 9px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-ink); font-size: 12px; font-weight: 600; vertical-align: middle; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 20px; max-width: 1280px; margin: 8px auto 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 1px solid transparent; border-bottom: 0; border-top: 3px solid transparent; border-radius: 8px 8px 0 0; background: transparent; padding: 8px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.tabs button small { font-size: 11px; opacity: .85; }
.tabs button:hover { border-color: var(--line); border-top-color: var(--line); }
.tabs button.on { background: var(--card); border-color: var(--line); border-top-color: var(--brand); color: var(--ink); font-weight: 600; margin-bottom: -1px; }

main { max-width: 1280px; margin: 0 auto; padding: 16px 20px 60px; }
[hidden] { display: none !important; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h2 .grow { flex: 1; }
.card h3 { font-size: 13px; margin: 16px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.card h3:first-of-type { border-top: 0; padding-top: 0; margin-top: 4px; }
.n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; flex: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
.grid.g3 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.f { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.f > span i { font-style: normal; opacity: .85; }
.f > span sub, .f > span sup { line-height: 0; }
.f input, .f select, .f textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%; }
.f input:focus, .f select:focus, .f textarea:focus, table.t input:focus, table.t select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.f.span2 { grid-column: span 2; }
.f.span-all { grid-column: 1 / -1; }
@media (max-width: 520px) { .f.span2 { grid-column: auto; } }
.out { background: var(--calc); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 31px; color: var(--ink); font-variant-numeric: tabular-nums; display: flex; align-items: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.two { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 18px; align-items: start; }
.two.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 980px) { .two, .two.even { grid-template-columns: minmax(0, 1fr); } }
.radio { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin: 2px 0 8px; }
.radio label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.msgs { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; }
.msgs:empty { display: none; }
.msg { border-radius: 8px; padding: 7px 10px; font-size: 12.5px; background: var(--warn-bg); color: var(--warn-ink); }
.msg.bad { background: var(--bad-bg); color: var(--bad-ink); }
.msg.info { background: var(--accent-soft); color: var(--ink); }

table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th, table.t td { text-align: left; padding: 4px 5px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.t td.r, table.t th.r { text-align: right; }
table.t td.c, table.t th.c { text-align: center; }
table.t input[type="text"] { font: inherit; width: 100%; min-width: 64px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
table.t input[type="checkbox"] { width: auto; }
table.t td.calc { background: var(--calc); }
table.res td:first-child { width: 50%; }
table.res td:nth-child(2) { text-align: right; white-space: nowrap; font-weight: 600; }
table.res td:nth-child(3) { color: var(--muted); font-size: 11.5px; }
table.res tr.sec td { padding-top: 12px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 0; }
table.res tr.big td { font-size: 17px; background: var(--accent-soft); border-bottom: 0; }
table.res tr.big td:nth-child(2) { color: var(--accent); }
.scroll { overflow: auto; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge.na { background: var(--calc); color: var(--muted); }
td.bad { color: var(--bad-ink); font-weight: 700; }
.dot { font-size: 12px; color: var(--accent); }
.dot.off { color: var(--muted); }

.eq-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 12px; margin: 0 0 10px; background: var(--card); }
.eq-item > .eq-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.eq-item > .eq-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { color: var(--muted); font-size: 13px; padding: 6px 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; font-size: 12.5px; margin-top: 8px; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

svg.chart { width: 100%; height: auto; display: block; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
svg.chart text { fill: var(--muted); font: 11.5px system-ui, sans-serif; }
svg.chart .gl { stroke: var(--line); stroke-width: 1; }
svg.chart .frame { fill: none; stroke: var(--line); }
svg.chart .ln { stroke: var(--accent); stroke-width: 2; fill: none; }
svg.chart .ref { stroke: var(--accent); stroke-width: 1.3; stroke-dasharray: 5 4; fill: none; opacity: .85; }
svg.chart .tolln { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 4; fill: none; }
svg.chart .zero { stroke: var(--muted); stroke-width: 1.2; }
svg.chart .pt { fill: var(--ink); stroke: var(--card); stroke-width: 1.5; }
svg.chart .pt.off { fill: var(--card); stroke: var(--muted); stroke-width: 1.6; }
svg.chart .pt.bad { fill: var(--bad-ink); }
svg.chart .stem { stroke: var(--ink); stroke-width: 1.4; opacity: .5; }
svg.chart text.lbl { fill: var(--ink); font-size: 12.5px; font-weight: 600; }
svg.chart text.ax { font-size: 12px; }
svg.chart text.empty { font-size: 13px; text-anchor: middle; }
.chart-title { font-size: 12.5px; font-weight: 600; margin: 12px 0 4px; }
.chart-title:first-child { margin-top: 0; }

.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .top-actions, .tabs, button, .row, .noprint, .hint { display: none !important; }
  .print-only { display: block; margin: 0 0 10px; }
  .panel[hidden] { display: block !important; }
  .card { break-inside: avoid; border-color: #999; }
  .two, .two.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  input, select, textarea { border: 0 !important; background: transparent !important; padding: 0 !important; appearance: none; }
  main { padding: 0; }
}

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 20; max-width: min(90vw, 560px); padding: 9px 16px; border-radius: 8px; background: var(--ink); color: var(--bg); font-size: 13px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); transition: opacity .25s; }
.toast.bad { background: var(--bad-ink); color: #fff; }
.toast.hide { opacity: 0; pointer-events: none; }
@media print { .toast { display: none; } }
.f select:required:invalid { border-color: var(--bad-ink); background: var(--bad-bg); }
.tabs button:disabled { opacity: .4; cursor: not-allowed; }
.tabs button:disabled:hover { border-color: transparent; border-top-color: transparent; }
.f input:required:invalid { border-color: var(--bad-ink); background: var(--bad-bg); }
.eq-item > .eq-head { flex-wrap: wrap; }
.eq-item > .eq-head .st { flex: 1; }
