:root {
  /* Warm workshop neutrals in OKLCH — every neutral tinted toward the wood hue (~70°),
     nothing pure black or white. Chroma stays low so they read as paper, not colour. */
  --paper: oklch(0.972 0.008 78);       /* was #faf7f2 */
  --card: oklch(0.992 0.005 80);        /* off-white, a hair warm — never #fff */
  --sunk: oklch(0.965 0.010 78);        /* recessed panels / table zebra */
  --ink: oklch(0.28 0.014 55);          /* warm near-black — was #2b2622 */
  --muted: oklch(0.545 0.018 60);       /* darkened for AA on paper (was #7d746a) */
  --line: oklch(0.885 0.012 72);        /* was #e2dad0 */
  --fill: #f4efe8;                      /* subtle fill — chips, code, tags, evidence panels */
  --header: #fcfaf7;                    /* card / section header strip */
  --line-soft: #f0eae2;                 /* soft inner divider — table rows, steps */
  --accent: #e0115f;                    /* magenta — the shop drawings' dimension colour + the landing */
  --accent-ink: #b30a4c;                /* darker magenta, AA text on paper */
  --accent-soft: #fbe4ec;               /* light magenta tint for active/hover surfaces */
  --accent-strong: #c50d50;             /* accent hover */
  --accent-line: #f4c9d8;               /* accent chip border */
  --wood: oklch(0.75 0.055 70);
  --ok: oklch(0.55 0.09 145);
  --ok-soft: #e9f2e9;                   /* good/ok surface */
  --ok-line: #cfe0cf;                   /* good/ok border */
  /* Semantic warning — terracotta, deliberately distinct from the magenta accent. */
  --warn-ink: #86331f;
  --warn-bg: #fdf4ef;
  --warn-line: #f0d9cf;
  --on-accent: #fff;                    /* text on the saturated magenta accent */
  --ink-lift: #443c34;                  /* dark-button hover */
  --radius: 10px;
  --shadow: 0 1px 2px oklch(0.28 0.014 55 / .06), 0 8px 24px oklch(0.28 0.014 55 / .05);
  --shadow-lift: 0 2px 6px oklch(0.28 0.014 55 / .08), 0 14px 34px oklch(0.28 0.014 55 / .09);
  --focus: rgba(224, 17, 95, .5);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out-quint */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* .panel/.plan set display, which beats the attribute */

/* One consistent keyboard-focus ring for every interactive surface. Mouse users never see
   it (:focus-visible); keyboard and screen-reader users always do. */
:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.error { color: var(--accent); font-size: 13.5px; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 16px 28px;
  border-bottom: 1px solid var(--line); background: var(--card);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark { font-size: 26px; }
img.mark { width: 30px; height: 30px; display: block; }
.brand h1 { font-size: 18px; }
.brand p { font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.unit-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.unit-toggle button {
  border: 0; background: var(--card); color: var(--muted);
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.unit-toggle button.active { background: var(--ink); color: var(--paper); }

button.primary, button.ghost {
  font: inherit; font-size: 14px; font-weight: 560; cursor: pointer;
  border-radius: 8px; padding: 9px 16px;
  transition: background-color .18s var(--ease), border-color .18s var(--ease),
              box-shadow .18s var(--ease), transform .12s var(--ease), opacity .18s var(--ease);
}
button.primary { border: 0; background: var(--accent); color: var(--on-accent); }
button.primary:hover:not(:disabled) { background: var(--accent-strong); box-shadow: 0 4px 16px rgba(224,17,95,.28); }
button.primary:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
button.primary:disabled { opacity: .35; cursor: not-allowed; }
button.ghost { border: 1px solid var(--line); background: var(--card); color: var(--ink); }
button.ghost:hover { border-color: var(--muted); background: var(--sunk); }
button.ghost:active { transform: translateY(1px); }

/* ---------------------------------------------------------------- layout */

main { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; padding: 28px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } .sidebar { order: 2; } }

.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.run-list li.muted { font-size: 13px; padding: 4px 0; color: var(--muted); }
.run-empty {
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
  padding: 16px 14px; border: 1px dashed var(--line); border-radius: 8px; background: var(--sunk);
}
.run-list button {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--ink);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.run-list button:hover { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.run-list button.active { background: var(--accent-soft); border-color: var(--accent-soft); }
.run-list button.active .rname { color: var(--accent-ink); }
.run-list .rname { display: block; font-weight: 560; }
.run-list .rmeta { display: block; color: var(--muted); font-size: 11.5px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }

/* ---------------------------------------------------------------- upload */

.dropzone {
  position: relative; display: grid; place-items: center; min-height: 220px;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card), var(--sunk)); cursor: pointer; overflow: hidden;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 14px; padding: 20px; }
.dz-icon { font-size: 34px; }
#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--card); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.field span { font-weight: 560; }
.field em { font-weight: 400; color: var(--muted); font-style: normal; }
textarea {
  font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; resize: vertical; background: var(--card); color: var(--ink);
}
textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--wood); }

.progress { flex-direction: row; align-items: flex-start; gap: 16px; }
.progress-body { flex: 1; min-width: 0; }
.progress .spinner { margin-top: 2px; }
.thinking {
  margin: 12px 0 0; padding: 12px 14px; max-height: 150px; overflow-y: auto;
  background: var(--sunk); border: 1px solid var(--line); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.5; color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
}
.spinner {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- plan */

.plan { display: flex; flex-direction: column; gap: 22px; }

.plan-head { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: grid; grid-template-columns: minmax(0,1fr) 220px; gap: 22px; }
@media (max-width: 760px) { .plan-head { grid-template-columns: 1fr; } }
.plan-head h2 { font-size: 24px; letter-spacing: -.02em; }
.plan-head .style { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.plan-head .summary { margin-top: 12px; font-size: 14.5px; max-width: 62ch; }
.plan-head img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--fill); border: 1px solid var(--line); color: var(--ink); }
.chip.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.chip.good { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--header); }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-body svg { display: block; width: 100%; height: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td:nth-child(2) { min-width: 116px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--fill); padding: 1px 5px; border-radius: 4px; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps li { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.steps li:last-child { border-bottom: 0; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.step-body h4 { font-size: 14.5px; margin-bottom: 4px; }
.step-body p { font-size: 14px; }
.step-meta { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--fill); color: var(--muted); }
.check { margin-top: 7px; font-size: 13px; color: var(--ok); }

.part-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.part-card { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.part-card svg { display: block; width: 100%; height: auto; }
.part-card figcaption { padding: 8px 11px; border-top: 1px solid var(--line); font-size: 12.5px; background: var(--header); }
td.shape { width: 148px; min-width: 148px; padding: 6px 10px; }
td.shape svg { display: block; width: 140px; height: auto; border: 1px solid var(--line); border-radius: 5px; }

.notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.notes-grid ul { margin: 0; padding-left: 18px; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 12px 14px; font-size: 13px; color: var(--warn-ink); }

.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- market board */

.market { display: flex; flex-direction: column; gap: 22px; }
.market-head { grid-template-columns: 1fr; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat strong { font-size: 21px; letter-spacing: -.02em; color: var(--accent); }
.stat span { font-size: 13px; color: var(--muted); }
.stat-src { font-size: 11.5px; color: var(--wood); text-decoration: none; }
.stat-src:hover { text-decoration: underline; }

.designs { display: flex; flex-direction: column; gap: 14px; }
.design { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.design-head { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 14px; align-items: start; padding: 16px 18px; background: var(--header); border-bottom: 1px solid var(--line); }
.design-rank { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.design-title h3 { font-size: 17px; }
.design-title p { font-size: 13.5px; margin-top: 3px; }
.design-price { text-align: right; display: flex; flex-direction: column; }
.design-price strong { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.design-price span { font-size: 11.5px; }

.design-body { display: grid; grid-template-columns: minmax(0,1fr) 270px; gap: 22px; padding: 18px; }
@media (max-width: 860px) { .design-body { grid-template-columns: 1fr; } .design-head { grid-template-columns: 34px minmax(0,1fr); } .design-price { grid-column: 2; text-align: left; } }
.design-main { display: flex; flex-direction: column; gap: 10px; font-size: 14px; max-width: 68ch; }
.design-main strong { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: block; margin-bottom: 2px; }
.evidence, .edge, .risk { font-size: 13.5px; padding: 10px 12px; border-radius: 8px; }
.evidence { background: var(--fill); }
.edge { background: var(--ok-soft); }
.edge strong { color: var(--ok); }
.risk { background: var(--warn-bg); }
.risk strong { color: var(--warn-ink); }
.evidence a { color: var(--accent); }
.caveat { font-size: 11.5px; color: var(--warn-ink); cursor: help; white-space: nowrap; }

.design-side { display: flex; flex-direction: column; gap: 12px; }
.scores { display: flex; flex-direction: column; gap: 4px; }
.score { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; cursor: help; }
.score-label { color: var(--muted); }
.score-dots { letter-spacing: 2px; font-size: 11px; color: var(--wood); }
.score-dots.s5, .score-dots.s4 { color: var(--accent); }
.score-dots.s1 { color: var(--muted); }
.sizes { font-size: 12.5px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.sizes td { padding: 5px 10px; border-bottom: 1px solid var(--line-soft); }
.sizes td:first-child { color: var(--muted); }
.design-side .chips { margin-top: 0; }
.materials { font-size: 12.5px; }

/* Competitor strip — full width under the card body, because five columns need the room. */
.competitors { border-top: 1px solid var(--line); padding: 14px 18px 16px; background: var(--card); }
.competitors h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.competitors table { width: 100%; font-size: 12.5px; }
.competitors th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 500; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.competitors td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--fill); vertical-align: top; }
.competitors tr:last-child td { border-bottom: none; }
.comp-name { display: block; }
.comp-note { display: block; font-size: 11.5px; color: var(--muted); font-style: italic; margin-top: 1px; }
.comp-seller { color: var(--muted); white-space: nowrap; }
.comp-mrp { display: block; font-size: 11px; color: var(--muted); text-decoration: line-through; font-variant-numeric: tabular-nums; }
.comp-rev { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.band { font-size: 11px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.band-under { background: var(--warn-bg); color: var(--warn-ink); }   /* they undercut you — the threat */
.band-inside { background: var(--fill); color: var(--muted); }
.band-over { background: var(--ok-soft); color: var(--ok); }  /* headroom above your ceiling */

@media (max-width: 620px) {
  .competitors { padding: 12px 12px 14px; overflow-x: auto; }
  .competitors table { min-width: 480px; }
}

.method-note { font-size: 12.5px; color: var(--muted); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.retailers { margin: 8px 0 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 5px; }
.retailers a { color: var(--accent); }

.sources { margin: 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 7px; }
.sources a { color: var(--accent); }
.caveat-line { display: block; font-size: 12px; color: var(--warn-ink); }

/* ---------------------------------------------------------------- auth gate */

/* Covers the app rather than replacing it, so nothing has to be torn down and rebuilt
   when a session appears — and `body.locked` stops the page behind it scrolling. */
.auth-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
             background: var(--paper); padding: 20px; }
body.locked { overflow: hidden; }

/* Fail closed. Until auth.js has decided, show nothing rather than the app: a blank
   moment is the honest state when we do not yet know who the visitor is. */
body.booting .topbar,
body.booting main { visibility: hidden; }

.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
             box-shadow: var(--shadow); padding: 28px; width: min(400px, 100%);
             display: flex; flex-direction: column; gap: 12px; text-align: left; }
.auth-card .mark { font-size: 30px; }
.auth-card img.mark { width: 34px; height: 34px; margin: 0 auto 2px; }
.auth-card h2 { font-size: 20px; }
.auth-card p.muted { font-size: 13.5px; }
.auth-card .field { margin: 4px 0 0; }
.auth-card input[type="email"] { width: 100%; }

.auth-note { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.auth-note.error { color: var(--accent); }

.auth-who { font-size: 12.5px; color: var(--muted); align-self: center; }

/* ---------------------------------------------------------------- print */

@media print {
  .topbar, .sidebar, .plan-actions, #upload-panel, #progress-panel { display: none !important; }
  body { background: var(--card); }
  main { display: block; padding: 0; max-width: none; }
  .card, .plan-head, .design { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .steps li { break-inside: avoid; }
}

/* ---------------------------------------------------------------- multi-view + BOQ + joinery */

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb { position: relative; margin: 0; width: 116px; }
.thumb img { width: 116px; height: 88px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.thumb figcaption { font-size: 11.5px; color: var(--muted); margin-top: 3px; text-align: center; }
.thumb-x {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.thumb-x:hover { background: var(--accent-soft); border-color: var(--accent); }

input[type="number"] {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); width: 130px;
}
input[type="number"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--wood); }

/* Compact thumbnail grid, not a tall stack — the source photos are reference, not the
   deliverable, so they shouldn't push the plan's tabs below the fold. */
.head-views { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.head-views img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.head-views img:first-child:nth-last-child(odd) { grid-column: 1 / -1; aspect-ratio: 16 / 9; }

.boq-sep td { padding: 3px; background: var(--header); }
.boq-total td { background: var(--header); }

.part-plate { padding: 6px; }
.part-plate svg { display: block; width: 100%; height: auto; }
/* Skeleton, not a spinner: a soft shimmer where the drawing/3D/locator will land. */
.plate-loading {
  position: relative; overflow: hidden;
  min-height: 120px; display: grid; place-items: center;
  padding: 40px 18px; text-align: center; font-size: 13px;
  background: var(--sunk); border-radius: 8px;
}
.plate-loading::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, oklch(1 0 0 / .5), transparent);
  transform: translateX(-100%); animation: shimmer 1.5s var(--ease) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.part-locator { padding: 14px 14px 0; }
.part-locator svg { display: block; width: 100%; max-width: 700px; height: auto; margin: 0 auto; }
.part-3d { height: 440px; position: relative; background: var(--sunk); }
.part-3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.raw-cut { padding: 12px 12px 0; }
.raw-cut svg { display: block; width: 100%; height: auto; max-width: 700px; margin: 0 auto; }

.joint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.joint-card { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--card); }
.joint-card svg { display: block; width: 100%; height: auto; }
.joint-card figcaption { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 12.5px; background: var(--header); }

/* The drawing set is the main deliverable, so it gets the emphasis in the plan header. */
.primary-link {
  font: inherit; font-size: 14px; font-weight: 560; text-decoration: none;
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
}
.primary-link:hover { background: var(--ink-lift); }

/* ---------------------------------------------------------------- part drill-down */

a.part-link { text-decoration: none; }
a.part-link:hover code { background: var(--accent-soft); color: var(--accent-ink); }
a.plan-link { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 560; }
a.plan-link:hover { color: var(--ink); }
.part-head h2 { margin-top: 6px; }
.part-head > div:last-child svg { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }

/* Part-detail tabs — group the drill-down into a few focused views. Sticky under the
   topbar so the active view's controls stay reachable on a long panel. */
.part-tabs {
  position: sticky; top: 57px; z-index: 5;
  display: flex; gap: 2px; overflow-x: auto;
  margin-bottom: -8px; padding-top: 2px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.part-tabs::-webkit-scrollbar { display: none; }
.part-tabs .tab {
  appearance: none; border: 0; background: transparent; font: inherit;
  font-weight: 600; font-size: 14px; color: var(--muted);
  padding: 11px 16px 13px; cursor: pointer; white-space: nowrap;
  border-radius: 8px 8px 0 0; position: relative;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.part-tabs .tab:hover { color: var(--ink); background: var(--accent-soft); }
.part-tabs .tab.active { color: var(--accent-ink); }
.part-tabs .tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
}
.tab-panel { display: flex; flex-direction: column; gap: 22px; animation: tab-in .24s var(--ease); }
@keyframes tab-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* Raw stock, per part — a totals strip over hairline-divided rows (picture left, specs
   right). One card, no nested boxes. */
.rawcut-total { display: flex; flex-wrap: wrap; gap: 12px 34px; padding: 2px 2px 18px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.rawcut-total > div { display: flex; flex-direction: column; gap: 3px; }
.rawcut-total .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.rawcut-total strong { font-size: 21px; letter-spacing: -.01em; }
.rawcut-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(190px, 1fr); gap: 22px; align-items: center; padding: 20px 0; border-top: 1px solid var(--line); }
.rawcut-row:first-of-type { border-top: 0; padding-top: 8px; }
@media (max-width: 640px) { .rawcut-row { grid-template-columns: 1fr; } }
.rawcut-svg svg { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.rawcut-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rawcut-head code { font-size: 13px; }
.rawcut-row figcaption p { font-size: 13.5px; }
.rawcut-row figcaption p + p { margin-top: 6px; }
.rawcut-row .chip { padding: 2px 9px; }

/* ---------------------------------------------------------------- projects */

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 190px; }
select {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); width: 100%;
}
select:focus { outline: 2px solid var(--accent-soft); border-color: var(--wood); }

.proj-group { margin-bottom: 14px; }
.proj-head {
  display: flex; align-items: baseline; gap: 6px; padding: 2px 10px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700;
}
.proj-head .count { font-weight: 500; letter-spacing: 0; text-transform: none; }
.plan-project { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; }
.plan-project select { width: auto; min-width: 180px; padding: 6px 10px; font-size: 13px; }
