/* Tara Build Console
   Layout: fixed left rail (build console / store ERP), working canvas on the right,
   dense tables in their own scroll boxes; status shown as chips, never colour alone. */
:root {
  --bg: #eef0ec;
  --surface: #ffffff;
  --surface-2: #f6f7f4;
  --ink: #1b2026;
  --muted: #5b646d;
  --line: #d9ddd6;
  --steel: #2f5d8a;          /* pod blue: primary actions, progress */
  --steel-soft: #e3ebf3;
  --signal: #c9581f;         /* camera orange: needs attention / to buy */
  --signal-soft: #fbe9df;
  --good: #2b7a4b; --good-soft: #e1f1e7;
  --warn: #a8700f; --warn-soft: #f8edd5;
  --bad: #b8322a;  --bad-soft: #f8e1df;
  --rail: #1d2329;  --rail-ink: #c9d1d8; --rail-dim: #7f8a94; --rail-on: #2a333c;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --surface: #191e23; --surface-2: #1f252b; --ink: #e6e9ec; --muted: #98a2ab; --line: #2b333a;
    --steel: #7aa6d6; --steel-soft: #1e2b39; --signal: #f0884f; --signal-soft: #3a2519;
    --good: #57c084; --good-soft: #17301f; --warn: #e2b04a; --warn-soft: #33290f; --bad: #ef7468; --bad-soft: #3a1d1a;
    --rail: #0b0e11; --rail-ink: #c9d1d8; --rail-dim: #6e7983; --rail-on: #1c232a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--steel); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; text-wrap: balance; margin: 0; }
h2 { font-size: 22px; } h3 { font-size: 17px; }
.mono, code { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

/* ----------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; text-decoration: none; }
.brand b { font-family: var(--display); font-size: 22px; display: block; line-height: 1; }
.brand small { color: var(--rail-dim); font-size: 12px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--signal); color: #fff; display: grid; place-items: center;
  font: 700 20px var(--display); flex: none; }
.side nav { display: flex; flex-direction: column; padding: 4px 10px 16px; gap: 1px; }
.nav-group { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .09em; color: var(--rail-dim); padding: 16px 10px 6px; }
.side nav a { color: var(--rail-ink); text-decoration: none; padding: 7px 10px; border-radius: var(--r); display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: var(--rail-on); }
.side nav a.on { background: var(--rail-on); color: #fff; box-shadow: inset 3px 0 0 var(--signal); }
.side-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid #2c343c; font-size: 12px; color: var(--rail-dim); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.linkbtn { background: none; border: 0; color: var(--rail-ink); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 14px; padding: 18px 28px 6px; }
.top h1 { font-size: 30px; }
.top-meta { margin-left: auto; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 12px 28px 48px; display: flex; flex-direction: column; gap: 18px; max-width: 1280px; }
.flash { margin: 8px 28px 0; padding: 10px 14px; border-radius: var(--r); background: var(--good-soft); color: var(--good); border: 1px solid currentColor; }
.flash.err { background: var(--bad-soft); color: var(--bad); }

/* ------------------------------------------------------------ components */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; min-width: 0; }
.card > h2, .card > h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head .grow { flex: 1; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font: 600 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--steel); border-radius: 99px; transition: width .3s; }
.bar.good > i { background: var(--good); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.sig { background: var(--signal-soft); color: var(--signal); border-color: transparent; }
.pill.steel { background: var(--steel-soft); color: var(--steel); border-color: transparent; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 500 13.5px var(--body); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--steel); border-color: var(--steel); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn.on { background: var(--steel-soft); border-color: var(--steel); color: var(--steel); }
input, select, textarea { font: 14px var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 7px 9px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--good); }
textarea { min-height: 60px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font: 600 11.5px var(--body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td input, .tbl td select { padding: 4px 6px; font-size: 13px; }
.tbl tr.sec td { background: var(--surface-2); font-weight: 600; font-family: var(--display); font-size: 15px; letter-spacing: .02em; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.toast { position: fixed; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); opacity: 0; transform: translateY(8px);
  transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); color: #fff; }

/* -------------------------------------------------------------- overview */
.phase-track { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; position: relative; }
.phase { padding: 12px 12px 12px 0; position: relative; }
.phase .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); position: relative; z-index: 1; }
.phase::before { content: ""; position: absolute; left: 0; right: 0; top: 18px; height: 2px; background: var(--line); }
.phase.done::before, .phase.done .dot { background: var(--good); border-color: var(--good); }
.phase.now .dot { border-color: var(--signal); background: var(--signal); box-shadow: 0 0 0 4px var(--signal-soft); }
.phase b { display: block; margin-top: 10px; font-family: var(--display); font-size: 16px; }
.phase span { font-size: 12.5px; color: var(--muted); }
.gate { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.gate:first-child { border-top: 0; }
.feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.feed li { padding: 7px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed .when { color: var(--muted); font-family: var(--mono); font-size: 12px; min-width: 70px; }

/* ----------------------------------------------------------------- steps */
.stage { padding: 0; overflow: hidden; }
.stage-head { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.stage-head h3 { flex: 1; }
.step { display: grid; grid-template-columns: 26px 46px minmax(0, 1fr) auto; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.step:last-child { border-bottom: 0; }
.step .sid { font-family: var(--mono); color: var(--muted); font-size: 12px; padding-top: 2px; }
.step .t { font-weight: 600; }
.step .d { color: var(--muted); font-size: 13px; }
.step.done .t { text-decoration: line-through; text-decoration-color: var(--good); color: var(--muted); }
.step .who { font-size: 12px; color: var(--good); text-align: right; white-space: nowrap; }
.step textarea { margin-top: 8px; min-height: 38px; font-size: 13px; }

/* ----------------------------------------------------------------- tests */
.test { display: grid; grid-template-columns: 40px minmax(0, 1.4fr) minmax(0, 1fr) 140px auto; gap: 12px; align-items: center;
  padding: 10px 18px; border-bottom: 1px solid var(--line); }
.test:last-child { border-bottom: 0; }
.test .crit { font-size: 12.5px; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; cursor: pointer; font: 500 12.5px var(--body); color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.pass.on { background: var(--good-soft); color: var(--good); }
.seg button.fail.on { background: var(--bad-soft); color: var(--bad); }
.seg button.pending.on { background: var(--surface-2); color: var(--ink); }
.valbox { display: flex; align-items: center; gap: 6px; }
.valbox span { font-size: 12px; color: var(--muted); min-width: 34px; }

/* -------------------------------------------------------------------- 3D */
.viewer { position: relative; height: min(72vh, 680px); min-height: 380px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewer .hud { position: absolute; left: 12px; top: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.viewer .hud > * { pointer-events: auto; }
.viewer .info { position: absolute; right: 12px; bottom: 12px; width: min(320px, calc(100% - 24px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.viewer .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.parts-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.parts-strip button { text-align: left; }

/* ------------------------------------------------------------- installer */
.bare { max-width: 860px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 16px; }
.bare-brand { display: flex; gap: 10px; align-items: center; font: 600 24px var(--display); }
.bare .flash { margin: 0; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); align-items: baseline; }
.checks li:first-child { border-top: 0; }
.keybox { font-family: var(--mono); background: var(--surface-2); border: 1px dashed var(--steel); padding: 10px 12px; border-radius: var(--r); word-break: break-all; user-select: all; }
pre.code { background: var(--rail); color: #dfe6ec; padding: 12px 14px; border-radius: var(--r); overflow-x: auto; font: 12.5px/1.6 var(--mono); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .test { grid-template-columns: 34px minmax(0, 1fr) 130px; }
  .test .crit-col { grid-column: 2 / -1; }
  .test .seg-col { grid-column: 2 / -1; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-btn { display: inline-flex; padding: 6px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); color: var(--ink); font: inherit; }
  .top { padding: 14px max(16px, env(safe-area-inset-left, 0px)) 4px; }
  .top h1 { font-size: 24px; }
  .top-meta { display: none; }
  .content { padding: 10px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  .flash { margin: 8px 16px 0; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .phase-track { grid-template-columns: minmax(0, 1fr); }
  .phase::before { display: none; }
  .step { grid-template-columns: 26px minmax(0, 1fr); }
  .step .sid { display: none; }
  .step .who { grid-column: 2; text-align: left; }
  .test { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .test .crit-col, .test .seg-col { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
