:root {
  --bg: #0e1218; --panel: #151b24; --line: #263041; --text: #e6ebf2; --muted: #8b97aa;
  --accent: #3d8bff; --ok: #2ecc71; --warn: #ffb020;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
header { height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 18px; border-bottom: 1px solid var(--line); background: #0b0f14; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); font-size: 12px; }
.logo { width: 28px; height: 22px; border-radius: 4px; background: var(--accent);
  box-shadow: inset 9px 0 0 -7px #fff, inset 18px 0 0 -16px #fff; }
.prog { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.bar { width: 160px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
#progBar { height: 100%; width: 0; background: var(--ok); transition: width .3s; }

main { display: flex; height: calc(100% - 56px); }
#view { position: relative; flex: 1; min-width: 0;
  background: radial-gradient(ellipse at 50% 35%, #273246 0%, #121822 60%, #0b0f14 100%); }
#view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px; background: rgba(12, 18, 28, .82); border: 1px solid rgba(61, 139, 255, .6);
  color: #dce8ff; }
.viewbtns { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; }
.viewbtns button, footer button, #resetProg { background: #1b2330; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; }
.viewbtns button:hover, footer button:hover { border-color: var(--accent); }
#info { position: absolute; top: 56px; left: 12px; max-width: 340px; display: none; font-size: 13px;
  background: rgba(12, 18, 28, .9); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
#info span { color: var(--muted); font-size: 11px; }
.hint { position: absolute; bottom: 10px; left: 12px; color: var(--muted); font-size: 12px; pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
body.ready .loading { display: none; }

aside { width: 430px; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
#dots { padding: 12px 16px 6px; display: flex; flex-wrap: wrap; gap: 6px 14px; border-bottom: 1px solid var(--line); }
.phase span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dotrow { display: flex; gap: 4px; padding: 3px 0 6px; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #1b2330;
  font-size: 11px; padding: 0; }
.dot.done { background: rgba(46, 204, 113, .2); border-color: var(--ok); }
.dot.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
#step { flex: 1; overflow-y: auto; padding: 14px 18px; }
.kicker { color: var(--accent); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
h2 { margin: 2px 0 8px; font-size: 21px; }
p { margin: 0 0 12px; color: #cfd7e3; }
table { width: 100%; border-collapse: collapse; margin: 4px 0 12px; font-size: 13px; }
td { border-bottom: 1px solid var(--line); padding: 5px 6px; }
td:first-child { font-weight: 600; }
.todo { list-style: none; padding: 0; margin: 0 0 12px; }
.todo li { margin: 4px 0; }
.todo label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 9px; border-radius: 8px;
  background: #1a212c; border: 1px solid transparent; cursor: pointer; }
.todo label:hover { border-color: var(--line); }
.todo input { margin-top: 3px; accent-color: var(--ok); width: 16px; height: 16px; flex: none; }
.todo input:checked + span { color: var(--muted); text-decoration: line-through; }
.warn { background: rgba(255, 176, 32, .1); border: 1px solid rgba(255, 176, 32, .45); color: #ffd58a;
  border-radius: 8px; padding: 8px 10px; font-size: 13.5px; margin-bottom: 12px; }
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0; }
.tests { display: grid; gap: 6px; margin-bottom: 10px; }
.test { display: flex; justify-content: space-between; gap: 10px; text-align: left; background: #1a212c;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.test em { font-style: normal; color: var(--muted); font-size: 13px; }
.test.on { border-color: var(--accent); background: rgba(61, 139, 255, .12); }
.meter { display: flex; gap: 12px; align-items: center; font-size: 12.5px; color: #cfd7e3; background: #10151d;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.lcd { flex: none; min-width: 110px; text-align: center; font: 700 18px/1.2 ui-monospace, Consolas, monospace;
  color: #19220f; background: #a9c48a; border-radius: 4px; padding: 6px 8px; }
.sim { margin-bottom: 12px; }
.simcard { background: #1a212c; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; }
.simhead { font-weight: 700; margin-bottom: 4px; }
.simrow { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.simrow b { color: var(--text); font-weight: 600; }
.btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 7px; }
.btns button { background: #222c3b; border: 1px solid var(--line); border-radius: 7px; padding: 6px 2px; font-size: 12.5px; }
.btns button:hover { border-color: var(--accent); }
.simmsg { font: 600 13px ui-monospace, Consolas, monospace; color: #ffd36e; background: #000; border-radius: 6px; padding: 7px 10px; }
.kpad { display: grid; grid-template-columns: repeat(4, 52px); gap: 6px; margin: 8px 0; }
.kpad button { height: 44px; border-radius: 8px; border: 1px solid #555; background: #e8e8e8; color: #111; font-weight: 700; }
.kpad button.l { background: #b3261e; color: #fff; border-color: #b3261e; }
.kpad button:active { transform: translateY(1px); }
.mute { font-size: 13px; color: var(--muted); }
footer { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
footer button { flex: 1; padding: 10px; }
footer button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
footer button:disabled { opacity: .4; cursor: default; }
.fine { font-size: 11.5px; color: var(--muted); padding: 0 16px 12px; }
#resetProg { padding: 2px 8px; font-size: 11.5px; }

@media (max-width: 900px) {
  main { flex-direction: column; height: auto; }
  #view { height: 58vh; flex: none; }
  aside { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  #step { overflow: visible; }
  .prog .bar { width: 80px; }
  .hint { display: none; }
}

/* ---- tabs + Parts & tools page ---- */
[hidden] { display: none !important; }
.tabs { display: flex; gap: 4px; background: #151b24; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--accent); color: #fff; }
body[data-tab="mats"] .prog { visibility: hidden; }
#mats { height: calc(100% - 56px); overflow-y: auto; }
.mwrap { max-width: 1040px; margin: 0 auto; padding: 22px 20px 60px; }
.mtop { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.mtop h2 { font-size: 24px; margin: 0 0 4px; }
.mctl { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13.5px; color: #cfd7e3; }
.mctl select, .mctl button { background: #1b2330; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; color: var(--text); }
.mctl button:hover { border-color: var(--accent); }
.mctl input { accent-color: var(--ok); }
.mnote { color: var(--muted); font-size: 13.5px; margin: 4px 0 10px; }
.mprog { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 13px; }
.mprog .bar { flex: 1; max-width: 360px; }
#matsBar { height: 100%; width: 0; background: var(--ok); transition: width .3s; }
#matsToc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#matsToc a { color: #cfd7e3; text-decoration: none; font-size: 13px; background: #1a212c; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px; }
#matsToc a:hover { border-color: var(--accent); }
.msec { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 14px; scroll-margin-top: 12px; }
.mhead { display: flex; justify-content: space-between; align-items: baseline; }
.mhead h3 { margin: 0; font-size: 17px; }
.mhead span { color: var(--muted); font-size: 13px; }
.mhead span.ok { color: var(--ok); font-weight: 600; }
.mtab { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0 0; }
.mtab th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.mtab td { padding: 8px 6px; border-bottom: 1px solid #1f2836; vertical-align: top; }
.mtab td:first-child { font-weight: normal; }
.mtab .ck { width: 46px; }
.mtab .ck input { width: 18px; height: 18px; accent-color: var(--ok); }
.mtab .q { width: 96px; white-space: nowrap; font-variant-numeric: tabular-nums; color: #dce8ff; font-weight: 600; }
.mtab .spec { color: var(--muted); font-size: 12.5px; }
.mtab .nt { color: #b8c2d1; font-size: 13px; width: 34%; }
.mtab tr.have td { opacity: .5; }
.mtab tr.have b { text-decoration: line-through; }
@media (max-width: 700px) {
  .brand small { display: none; }
  .prog { display: none; }
  .mtab .nt { display: none; }
}
@media print {
  header, main, .mctl, #matsToc, .mprog { display: none !important; }
  html, body { background: #fff; color: #000; height: auto; }
  #mats { height: auto; overflow: visible; }
  .msec { background: #fff; border: 1px solid #bbb; break-inside: avoid; }
  .mtab td, .mtab th, .mnote, .mtab .spec, .mtab .nt, .mtab .q, .mhead span { color: #000; }
  .mtab tr.have td { opacity: .45; }
}
