:root {
  --bg: #f4f6fb; --surface: #ffffff; --surface-2: #eef2fa; --line: #d6dcea;
  --text: #13213d; --muted: #56627c; --accent: #1f4fbf; --accent-text: #ffffff;
  --gold: #a87b14; --warn-bg: #fff6e0; --warn-line: #e3c36b; --error: #b3261e;
  --white-piece: #1f4fbf; --black-piece: #b3711b;
  --radius: 12px; --shadow: 0 1px 2px rgb(16 32 64 / 6%), 0 4px 16px rgb(16 32 64 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071226; --surface: #0d1d3a; --surface-2: #132a52; --line: #22396a;
    --text: #e8edf7; --muted: #a3b0c9; --accent: #3d6fe0; --accent-text: #ffffff;
    --gold: #d4a843; --warn-bg: #2a2410; --warn-line: #6b5617; --error: #ff8a80;
    --white-piece: #7aa2ff; --black-piece: #e0b25a;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; margin-top: 1.25rem; }

.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 10px; }
.brand { display: flex; gap: 12px; align-items: center; }
.mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: #0b1a33; color: #d4a843; font-size: 24px; flex: none; border: 1px solid #d4a843; }
.brand h1 { font-size: 1.2rem; }
.tag { margin: 0; color: var(--muted); font-size: .9rem; }
.status { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { color: var(--text); }
.chip.warn { border-color: var(--warn-line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }

main { padding-top: 16px; padding-bottom: 32px; }
.caution { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 12px 14px; font-size: .92rem; margin: 0 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.hint { color: var(--muted); margin-top: 0; }
.field { display: block; margin-bottom: 12px; font-weight: 600; font-size: .92rem; border: 0; padding: 0; }
.field legend { padding: 0; margin-bottom: 4px; }
textarea, input:not([type]), select { width: 100%; margin-top: 4px; padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: 14px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
select { font-family: inherit; }
input[type="range"] { width: 100%; margin-top: 10px; accent-color: var(--accent); }
.check { display: inline-flex; gap: 6px; align-items: center; margin: 4px 14px 4px 0; font-weight: 400; }
.file { display: inline-block; font-size: .92rem; margin: 4px 0 12px; }
.file input { display: block; margin-top: 6px; max-width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row select { width: auto; max-width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
button { font: inherit; border-radius: 8px; padding: 10px 18px; cursor: pointer; border: 1px solid transparent; }
.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.primary:disabled { opacity: .55; cursor: progress; }
.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.progress { position: relative; height: 26px; background: var(--surface-2); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.progress div { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); opacity: .35; transition: width .3s; }
.progress span { position: relative; display: block; text-align: center; font-size: .85rem; line-height: 26px; }
.error { color: var(--error); margin: 10px 0 0; }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.side h3 { margin-top: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sub { color: var(--muted); font-size: .85rem; font-weight: 400; }
.side .sub { color: var(--muted); font-weight: 400; font-size: .9rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.stats { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stats td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.stats td:nth-child(2) { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 10px; white-space: nowrap; }
.stats .pct { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.stats .high { color: var(--gold); }
.note { color: var(--muted); font-size: .88rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
table.data th:first-child, table.data td:first-child, table.data .l { text-align: left; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }
svg.chart { width: 100%; height: auto; max-height: 340px; display: block; }
svg.chart text { fill: var(--muted); font-size: 11px; }
svg.chart .axis { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.big { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.kpi .label { font-size: .82rem; color: var(--muted); }
.prose p { max-width: 70ch; }
.foot { color: var(--muted); font-size: .82rem; padding-bottom: 24px; }

@media (max-width: 720px) {
  .sides, .grid2 { grid-template-columns: 1fr; }
  .top { position: static; }
  .tab { padding: 10px 8px; font-size: .92rem; }
  .card { padding: 14px; }
}
