:root {
  --serra-yellow: #ffe200;
  --serra-yellow-hover: #ffd400;
  --serra-yellow-pressed: #e6cb00;
  --ink: #111111;
  --header: #0a0a0a;
  --bg: #e6e6e6;
  --card: #ffffff;
  --muted: #6a6a6a;
  --line: #d8d8d8;
  --dash: #c5c5c5;
  --sidebar: #f7f7f7;
  --danger: #b42318;
  --ok: #1f7a3a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
}

button, input, select { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header — OSH Cut structure, Serra colors */
.header {
  min-height: 96px;
  flex-shrink: 0;
  background: var(--header);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 12px 24px;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand img {
  height: 64px;
  width: auto;
  display: block;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-text strong {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 13px;
}
.brand-text span {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--serra-yellow);
}

.nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
  color: #ececec;
  flex: 1;
}
.nav a {
  text-decoration: none;
  opacity: 0.9;
}
.nav a:hover { color: var(--serra-yellow); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.ghost {
  background: transparent;
  color: #fff;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
}
.ghost:hover { border-color: var(--serra-yellow); color: var(--serra-yellow); }

.btn-yellow {
  background: var(--serra-yellow);
  color: #111;
  border: 0;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 650;
}
.btn-yellow:hover { background: var(--serra-yellow-hover); }
.btn-yellow:disabled {
  background: #d4d4d4;
  color: #888;
  cursor: not-allowed;
}

.phone {
  color: var(--serra-yellow);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.side-card .phone {
  color: #000;
  font-weight: 700;
}

/* Workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  padding: 14px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.card {
  min-width: 0;
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 124px);
  display: flex;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 8px;
}
.toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.add-parts {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--serra-yellow);
  color: #111;
  border: 0;
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 650;
  font-size: 14px;
}
.add-parts:hover { background: var(--serra-yellow-hover); }
.add-parts svg { width: 12px; height: 12px; }

.dropzone {
  margin: 8px 16px 16px;
  border: 2px dashed var(--dash);
  border-radius: 8px;
  flex: 1;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px 20px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag {
  border-color: var(--serra-yellow);
  background: #fffce6;
}
.dropzone h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 500;
  color: #3a3a3a;
}
.dropzone .hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 28px;
}
.dropzone .hint a {
  color: #1a5fb4;
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 180px));
  gap: 28px;
  justify-content: center;
  margin-bottom: 28px;
}
.process {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.process svg, .process .icon {
  width: 92px;
  height: 72px;
}
.process label {
  font-size: 13px;
  font-weight: 600;
}
.formats {
  font-size: 11px;
  color: var(--muted);
}

.supported {
  font-size: 11px;
  color: #888;
  max-width: 720px;
  line-height: 1.45;
}

/* Part list */
.parts {
  padding: 0 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.part-row {
  display: grid;
  grid-template-columns: 28px 240px minmax(0, 1fr) 110px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  align-items: start;
}
.part-preview { width: 240px; max-width: 100%; min-width: 0; }
.thumb {
  background: #e8eaed;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  width: 240px;
  height: 180px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.thumb::after {
  content: "3D";
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.85);
  color: #111;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 3px;
  pointer-events: none;
}
.thumb canvas {
  width: 240px;
  height: 180px;
  display: block;
}
.price-col {
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-width: 110px;
}
.price-col .ghost {
  width: 100%;
}
.part-row.selected { outline: 2px solid var(--serra-yellow); }
.thumb .badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: #111;
  color: var(--serra-yellow);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}
.part-meta {
  min-width: 0;
}
.part-meta h3 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.field label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}
.field select, .field input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 8px;
  font-size: 13px;
  background: #fff;
}
.field .profile-size {
  display: block;
  min-height: 32px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.metrics {
  grid-column: 1 / -1;
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 12px;
  color: #444;
  align-items: center;
}
.metrics strong { font-weight: 650; }
.price-col .amount {
  font-size: 18px;
  font-weight: 650;
}
.price-col .each { font-size: 11px; color: var(--muted); }
.warn {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
}
.bend-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px 12px;
  align-items: end;
}
.bend-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding-bottom: 8px;
  white-space: nowrap;
}
.bend-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #111;
}
.bend-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 6px;
}
.bend-detected {
  color: #1a5f2a;
  font-weight: 600;
}
@media (max-width: 980px) {
  .bend-row {
    grid-template-columns: 1fr 1fr;
  }
  .bend-toggle, .bend-meta {
    grid-column: 1 / -1;
  }
}

/* Sidebar */
.aside {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.side-card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.side-card h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
}
.file-start a {
  color: #1a5fb4;
  font-size: 13px;
}
.totals { font-size: 13px; }
.totals .row {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
}
.totals .total {
  font-size: 20px;
  font-weight: 700;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.checkout {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}
.muted-note {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 0;
  text-align: center;
}

/* Viewer overlay */
.viewer-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 24px;
}
.viewer-modal.open { display: flex; }
.viewer-frame {
  width: min(1100px, 100%);
  height: min(720px, 90vh);
  background: #e8eaed;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 48px 1fr;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
.viewer-bar {
  background: #111;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
}
.viewer-bar strong { font-size: 13px; }
.viewer-bar span { color: var(--serra-yellow); font-size: 12px; }
.viewer-bar button {
  margin-left: auto;
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 18px;
}
#viewer-canvas-host {
  width: 100%;
  height: calc(min(720px, 90vh) - 48px);
  min-height: 0;
}

.hidden { display: none !important; }
#file-input { display: none; }

@media (max-width: 1280px) {
  .part-row { grid-template-columns: 24px minmax(0, 1fr) 120px; }
  .part-index { grid-column: 1; grid-row: 1; }
  .part-preview { grid-column: 2; grid-row: 1; }
  .price-col { grid-column: 3; grid-row: 1; }
  .part-meta { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 1100px) {
  .nav { display: none; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .process-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { min-height: 0; }
}
@media (max-width: 480px) {
  .header { padding: 0 10px; gap: 8px; }
  .header-actions .phone, .header-actions .ghost { display: none; }
  .brand img { height: 48px; }
  .brand-text span { letter-spacing: 0; }
  .workspace { padding: 8px; }
  .part-row { grid-template-columns: minmax(0, 1fr) 100px; gap: 8px; }
  .part-index { display: none; }
  .part-preview { grid-column: 1; width: 100%; }
  .thumb { width: 100%; height: auto; aspect-ratio: 4/3; }
  .thumb canvas { width: 100%; height: 100%; }
  .price-col { grid-column: 2; min-width: 0; }
  .controls { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bend-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .process-grid { grid-template-columns: 1fr; }
  .viewer-modal { padding: 8px; }
  .viewer-bar span { display: none; }
}

/* Windows rebuild: accessible configuration and acceptance surfaces. */
.process-model {width:100%;height:auto;max-width:260px;border-radius:12px;display:block;margin:0 auto 16px}
.process label {font-size:16px;font-weight:700}
.labor-notice {padding:16px;background:#fff9cd;border-left:5px solid #f5d400;text-align:left}
.labor-notice strong {display:block;font-size:20px;line-height:1.5;color:#111}
.details-dialog {border:0;border-radius:16px;max-width:760px;width:calc(100% - 32px);max-height:90vh;overflow:auto;padding:28px;color:#171717;box-shadow:0 20px 80px #0006;font:16px/1.5 Inter,Arial,sans-serif}
.details-dialog::backdrop {background:#1119}
.dialog-heading {display:flex;align-items:center;justify-content:space-between;gap:20px}
.dialog-heading h2 {margin:0;font-size:24px}
.dialog-close {border:0;background:transparent;font-size:28px;cursor:pointer}
.upload-name {overflow-wrap:anywhere;font-weight:600}
.upload-preview {width:100%;height:auto;border-radius:10px;background:#e8eaed}
.dialog-fields {display:grid;grid-template-columns:1fr 1fr;gap:18px;margin:18px 0}
.dialog-fields label,.details-dialog form>label {display:block;font-size:15px;font-weight:600}
.dialog-fields input,.dialog-fields select {display:block;width:100%;box-sizing:border-box;border:1px solid #aaa;border-radius:6px;padding:12px;margin-top:6px;font:inherit;background:white;color:#111}
.dialog-fields select:disabled {background:#edf0f3;color:#444}
.batch-choice {display:flex!important;gap:10px;align-items:flex-start;margin:20px 0;font-weight:400!important}
.batch-choice[hidden] {display:none!important}
.batch-choice input {width:20px;height:20px;flex-shrink:0}
.dialog-actions {display:flex;gap:12px;justify-content:flex-end;margin-top:24px;flex-wrap:wrap}
.dialog-actions button {padding:12px 20px;border:1px solid #999;border-radius:6px;font:inherit;cursor:pointer}
.dialog-actions button:disabled {opacity:.55;cursor:default}
.detection-note,.accept-status,.upload-warning {font-size:14px}
.upload-warning {color:#9b3b0a}
.accept-status {padding:12px;background:#edf0f3;border-radius:6px}
.unfold-controls {padding:14px;background:#f2f5f8;display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:12px}
.unfold-controls label {display:flex;gap:8px;align-items:center;font-size:14px}
.unfold-controls input {width:80px;padding:8px}
.unfold-controls p {width:100%;margin:0;font-size:14px}
.unfold-controls button {padding:10px;cursor:pointer}
.border-controls {margin:14px 0;padding:14px;border:1px solid #c4cbd2;border-radius:8px;background:#f5f7f9;font-size:14px}
.border-controls summary {font-weight:700;cursor:pointer}
.border-controls label {display:inline-flex;align-items:center;gap:8px;margin:6px 16px 6px 0}
.border-controls input {width:18px;height:18px}
.tooling-dialog label {display:block;margin:18px 0}
.tooling-dialog input {display:block;width:100%;box-sizing:border-box;padding:10px;font:inherit}
.tooling-dialog details {border-top:1px solid #ccc;padding:14px 0}
.tooling-dialog summary {font-weight:700;cursor:pointer}
.tooling-dialog dl {display:grid;grid-template-columns:140px 1fr;gap:8px;font-size:14px}
.tooling-dialog dd {margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
@media(max-width:600px){.dialog-fields{grid-template-columns:1fr}.details-dialog{padding:18px}.dialog-actions{justify-content:stretch}.dialog-actions button{flex:1}.labor-notice strong{font-size:18px}}
.drawing-doctor{width:min(1200px,96vw);max-width:96vw;max-height:95vh;border:0;border-radius:12px;padding:20px;background:#f8fafc;color:#142135}.drawing-doctor::backdrop{background:#000a}.drawing-doctor header,.drawing-doctor footer,.drawing-doctor nav{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.drawing-doctor header,.drawing-doctor footer{justify-content:space-between}.drawing-doctor h2{margin:0}.drawing-doctor button{padding:9px 14px;border:1px solid #a0adbd;border-radius:6px;cursor:pointer;background:white;color:#142135}.drawing-doctor button[aria-pressed=true]{background:#ffcf24;border-color:#8b6e00}.drawing-doctor button:disabled{opacity:.4;cursor:default}.drawing-doctor svg{display:block;width:100%;height:52vh;background:#101c2d;border-radius:6px;touch-action:none;cursor:crosshair}.drawing-doctor svg path{fill:none;stroke:#d5e9ff;stroke-width:1.5;pointer-events:none}.drawing-doctor svg path.target{stroke:#ffcd27;stroke-width:4}.doctor-help{font-size:13px;color:#526077}.doctor-status{font-weight:600}.doctor-error{color:#ac251d;min-height:1.2em}
.process-upload{display:block;color:inherit;text-decoration:none;cursor:pointer;border-radius:12px}.process-upload:hover{background:#f3f6fa}.process-upload:focus-visible{outline:3px solid #a87900;outline-offset:4px}.process-upload label{cursor:pointer}.upload-prompt{display:block;margin-top:10px;font-size:13px;font-weight:600;color:#765300;text-decoration:underline}

button.process-upload{font:inherit;width:100%;border:0;background:transparent;text-align:center}button.process-upload:hover{background:#f3f6fa}

/* Keep the process choices side by side, including in the narrow app panel. */
.process-grid{display:flex;flex-wrap:nowrap;justify-content:flex-start;gap:16px;width:100%;overflow-x:auto;padding:4px 4px 14px;box-sizing:border-box}
.process-grid > .process-upload{flex:1 0 150px;min-width:150px;width:auto}
.process-grid > input[hidden]{display:none}

.header .brand-text strong{font-size:17px}
.header .brand-text span{font-size:11px;margin-top:5px}
@media(max-width:760px){.header{min-height:88px;flex-wrap:wrap;gap:12px;padding:12px 16px}.header .brand{max-width:100%}.header .brand img{height:56px}.header-actions{flex-wrap:wrap}.card{min-height:0}}
@media(max-width:480px){.header .brand img{height:48px}.header .brand-text strong{font-size:15px}.header .brand-text span{font-size:9px}.header-actions{margin-left:0}}

.bend-review-dialog{max-width:900px;border-top:6px solid #ffe200}
.bend-review-name{font-size:17px;font-weight:700;overflow-wrap:anywhere}
.bend-review-visual{display:grid;grid-template-columns:1fr 1fr;gap:24px;align-items:center}
.bend-review-visual .upload-preview{width:100%;height:210px;object-fit:contain}
.bend-review-visual svg{width:100%;font:14px Arial,sans-serif}
.bend-review-caption{font-size:14px;color:#4b5962}
.bend-review-measurements{padding:12px;background:#fff8d7;border-radius:6px;font-weight:700}
.bend-review-consent{display:flex;gap:12px;align-items:flex-start;font-size:16px;font-weight:600;margin-top:24px}
.bend-review-consent input{width:22px;height:22px;flex:0 0 22px;margin-top:2px;accent-color:#a77b00}
@media(max-width:600px){.bend-review-visual{grid-template-columns:1fr}.bend-review-visual .upload-preview{height:160px}}

.drawing-doctor svg path.selected{stroke:#45caff;stroke-width:3}.drawing-doctor svg path.selected.target{stroke:#ffcd27}.drawing-doctor svg .selection-box{pointer-events:none;stroke-width:1.5}.drawing-doctor svg .selection-box.window{fill:#248cff33;stroke:#58aaff}.drawing-doctor svg .selection-box.crossing{fill:#39d78333;stroke:#48dd93;stroke-dasharray:6 4}

.drawing-doctor button[data-action="apply"]{background:var(--serra-yellow);color:#111;border-color:var(--serra-yellow);font-weight:700}
.drawing-doctor button[data-action="apply"]:hover{background:var(--serra-yellow-hover);border-color:var(--serra-yellow-hover)}
