:root {
  --ground: #F3F0E8; --surface: #FFFFFF; --quiet: #FAF8F3; --ink: #1D1C1A; --muted: #5C5850;
  --line: #DDD7CA; --line-soft: #EFEBE1; --control: #C9C2B3;
  --teal: #1F5F5B; --teal-dark: #16453F; --teal-soft: #E4EFEE; --teal-tint: #F0F6F5;
  --red: #A12A1E; --red-bg: #FDECEA; --red-line: #E8C4BF;
  --amber: #7A4B00; --amber-bg: #FFF1D6; --blue: #1E4E8C; --blue-bg: #E6EEF8;
  --green: #2A6130; --green-bg: #E3F1E4;
  --drawing-bg: #FFFFFF; --drawing-surface: #FFFFFF; --drawing-wood: #F6ECDD;
  --drawing-board: #EFEBE1; --drawing-shelf: #DCD5C6; --drawing-ink: #1D1C1A;
  --drawing-muted: #5C5850; --drawing-accent: #1F5F5B; --drawing-selected: #B42318;
  --drawing-guide: #1E4E8C; --drawing-wood-line: #C08A4A;
  --doc-surface: #FFFFFF;
  --layout-stock-empty: #ECEDEA;
  --layout-part-surface: #FFFFFF;
  --layout-woodgrain-part: #CCC0B3;
  --machining-cup-fill: #FDECEA;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; }
a { color: var(--teal); }
a:hover { color: var(--teal-dark); }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.muted { color: var(--muted); font-weight: 400; }
.mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid #7FB3AE; outline-offset: 2px; }

/* top bar */
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 16px; }
.mark { width: 36px; height: 36px; border-radius: 8px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs a { text-decoration: none; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
button.avatar { border: 0; padding: 0; font-family: inherit; cursor: pointer; }
button.avatar:hover { background: var(--teal-dark); }
.account { position: relative; }
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: 240px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0,0,0,.16);
}
.account-menu[hidden] { display: none; }
.account-profile { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.account-name { font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.account-role { color: var(--muted); font-size: 13px; }
.app-version { margin-top: 4px; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: .01em; }
.account-menu-divider { height: 1px; margin: 12px -14px 8px; background: var(--line); }
.account-menu-item {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.account-menu-item:hover { background: var(--quiet); }

/* layout */
.main { padding: 24px; max-width: 1440px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.row { display: flex; gap: 24px; align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.side { width: 360px; flex-shrink: 0; }
.rail { width: 320px; flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 960px) { .row { flex-direction: column; } .side, .rail { width: 100%; } .main { padding: 16px; } .crumbs { display: none; } }

/* stepper */
.stepper { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); text-decoration: none; min-height: 44px; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; border: 1px solid #A39B8B; display: grid; place-items: center; font-size: 12px; }
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.active { color: var(--ink); font-weight: 600; }
.step.active .dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.step.off { pointer-events: none; opacity: .55; }
.step-line { width: 40px; height: 1px; background: var(--control); }

/* controls */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--control); border-radius: 8px; padding: 0 12px; height: 44px; width: 100%; }
textarea { height: auto; padding: 10px 12px; }
.btn { font: inherit; font-size: 14px; height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--control); background: var(--surface); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--quiet); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--teal-dark); }
.btn.big { height: 48px; padding: 0 24px; font-size: 15px; }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; }
.btn.danger { color: var(--red); }
.btn:disabled { background: var(--line); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; }

/* chips */
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-red { background: var(--red-bg); color: var(--red); }
.chip-amber { background: var(--amber-bg); color: var(--amber); }
.chip-blue { background: var(--blue-bg); color: var(--blue); }
.chip-green { background: var(--green-bg); color: var(--green); }
.chip-grey { background: var(--line-soft); color: var(--muted); }
.chip-teal { background: var(--teal); color: #fff; }
.banner { border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.banner.red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-line); }
.banner.amber { background: var(--amber-bg); color: var(--amber); }
.banner.green { background: var(--green-bg); color: var(--green); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 10px; height: 36px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 0 10px; height: 38px; border-bottom: 1px solid var(--line-soft); font-size: 14px; white-space: nowrap; }
td.num, th.num { text-align: right; }
.cut-list-table th:first-child,
.cut-list-table td:first-child { padding-right: 30px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--quiet); }
.edit td { padding: 4px 4px; }
.edit input, .edit select { height: 36px; padding: 0 8px; font-size: 13px; }
.edit input.n { width: 76px; font-family: var(--mono); text-align: right; }
.edit input.code { width: 72px; font-family: var(--mono); font-weight: 600; }

/* upload */
.drop { border: 2px dashed #A39B8B; border-radius: var(--radius); background: var(--quiet); min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 16px; cursor: pointer; }
.drop.over { border-color: var(--teal); background: var(--teal-tint); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.thumb { display: flex; flex-direction: column; gap: 6px; }
.thumb img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; background: #111; border-radius: 8px; }
.thumb .between { font-size: 12px; font-family: var(--mono); color: var(--muted); }
.checklist { background: var(--quiet); border: 1px solid var(--line-soft); border-radius: 10px; padding: 16px; font-size: 14px; }
.checklist ul { margin: 8px 0 0; padding-left: 20px; }

/* check (option B) */
.qlist { display: flex; flex-direction: column; gap: 4px; }
.qitem { min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; border: 0; background: none; text-align: left; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; width: 100%; }
.qitem:hover { background: var(--quiet); }
.qitem.current { background: var(--teal-soft); font-weight: 600; }
.qnum { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; border: 1px solid #A39B8B; display: grid; place-items: center; font-size: 13px; }
.qitem.current .qnum { background: var(--teal); border-color: var(--teal); color: #fff; }
.qitem.done .qnum { background: var(--green); border-color: var(--green); color: #fff; }
.viewer { background: #111; border-radius: 8px; height: 300px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.viewer img { max-width: 100%; max-height: 100%; display: block; }
.choice { min-height: 56px; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--control); cursor: pointer; }
.choice:has(input:checked) { border: 2px solid var(--teal); background: var(--teal-tint); }
.choice input[type=radio] { width: 20px; height: 20px; accent-color: var(--teal); flex-shrink: 0; }
.qtitle { font-size: 24px; font-weight: 600; }
.qsub { font-size: 18px; color: var(--muted); }

/* documents */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { height: 44px; padding: 0 16px; display: flex; align-items: center; font-size: 14px; color: var(--muted); border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; font-family: inherit; white-space: nowrap; }
.tab.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--teal); }
.tab:disabled { cursor: not-allowed; opacity: .6; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--quiet); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 16px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat strong { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.print-head { display: none; }
.doc-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.doc-logo { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }

/* misc */
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.login { max-width: 400px; margin: 64px auto; }
.error { color: var(--red); font-size: 14px; min-height: 20px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
.toast.show { opacity: 1; }
.toast.bad { background: var(--red); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .toast { transition: none; } }

@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .stepper, .no-print, .tabs, .toast { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .print-head { display: block; margin-bottom: 12px; }
  .doc-logo { width: 32px; height: 32px; }
  td, th { height: 24px; font-size: 11px; }
  .stat { padding: 6px 10px; } .stat strong { font-size: 15px; }
}

/* check layouts: switch, split view, pins */
.segmented { display: inline-flex; border: 1px solid var(--control); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg { font: inherit; font-size: 14px; min-height: 44px; padding: 0 16px; border: 0; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg + .seg { border-left: 1px solid var(--control); }
.seg.on { background: var(--teal); color: #fff; font-weight: 600; }
.panel { width: 480px; flex-shrink: 0; }
@media (max-width: 960px) { .panel { width: 100%; } }
.viewer.tall { height: 460px; }
.fcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.fcard.open { border-color: var(--red-line); }
.pinwrap { position: relative; display: inline-block; max-width: 100%; max-height: 100%; }
.pinwrap img { display: block; max-width: 100%; max-height: 460px; }
.pin { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; color: #fff;
  font: 700 13px var(--sans); display: grid; place-items: center; cursor: pointer; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.pin.static { position: static; transform: none; width: 26px; height: 26px; flex-shrink: 0; box-shadow: none; border: 0; cursor: inherit; }
.pin.sel { outline: 3px solid #FFFFFF; outline-offset: 2px; width: 36px; height: 36px; z-index: 2; }
.pin-red { background: #B42318; } .pin-green { background: var(--green); } .pin-amber { background: #8A5300; } .pin-blue { background: var(--blue); }
td.hl { padding: 0; }
.hl-red { background: var(--red-bg); } .hl-green { background: var(--green-bg); } .hl-amber { background: var(--amber-bg); } .hl-blue { background: var(--blue-bg); }
.cellbtn { font: inherit; color: inherit; background: none; border: 0; width: 100%; height: 38px; padding: 0 10px; text-align: inherit; cursor: pointer; font-weight: 600; }
.hl-red .cellbtn { color: var(--red); } .hl-green .cellbtn { color: var(--green); } .hl-amber .cellbtn { color: var(--amber); } .hl-blue .cellbtn { color: var(--blue); }
.cellbtn sup { font-size: 10px; }
.viewer > a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.viewer img { object-fit: contain; }
.viewer.tall { height: 540px; }
.pinwrap img { max-height: 540px; }
@media (max-width: 960px) { .viewer.tall { height: auto; min-height: 240px; } .pinwrap img { max-height: none; } .viewer { height: 240px; } }
@media (max-width: 600px) {
  .topbar { padding: 0 12px; }
  .brand > span:last-child { display: none; }
  .segmented { display: flex; width: 100%; }
  .seg { flex: 1 1 0; padding: 0 6px; font-size: 13px; white-space: normal; line-height: 1.2; }
  .btn { white-space: normal; height: auto; min-height: 44px; padding: 8px 14px; text-align: center; }
  .pin { width: 24px; height: 24px; font-size: 11px; }
  .pin.sel { width: 28px; height: 28px; }
  .qtitle { font-size: 20px; }
}

input:disabled, select:disabled { background: var(--quiet); color: var(--muted); }

[hidden] { display: none !important; }

/* supplier package */
.sheet { background: var(--doc-surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 10px; }
table.order th { height: 30px; font-size: 11px; border-bottom: 1.5px solid var(--ink); }
table.order td { height: 26px; font-size: 12px; }
table.order .c { text-align: center; padding: 0 4px; }
.supplier-cut-order th.band-col,
.supplier-cut-order td.band-col { text-align: center; }
.supplier-cut-order td { height: 48px; }
.supplier-cut-order .band-symbol { width: 40px; height: 40px; display: block; margin: 2px auto; }
.supplier-grain { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.supplier-grain-symbol { display: block; flex: 0 0 16px; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; break-inside: avoid; }
table.holes { width: auto; }
table.holes th { height: 24px; font-size: 11px; padding: 0 8px; }
table.holes td { height: 22px; font-size: 12px; padding: 0 8px; font-family: var(--mono); }
.pnote { font-size: 11px; line-height: 1.5; border-top: 1px solid var(--line-soft); padding-top: 6px; }
.legend { display: flex; gap: 6px 20px; flex-wrap: wrap; font-size: 11px; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.panel-print-only { display: none !important; }
.pgrid.pgrid-6 { grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.pcard.pcard-panel6 { padding: 8px 10px; gap: 4px; }
.pcard.pcard-panel6 .panel6-head { align-items: center; gap: 10px; }
.pcard.pcard-panel6 .panel6-title { min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.pcard.pcard-panel6 .panel6-code { font-size: 14px; font-weight: 700; }
.pcard.pcard-panel6 .panel6-codes, .pcard.pcard-panel6 .panel6-part { font-size: 12px; }
.pcard.pcard-panel6 .panel6-qty { font-size: 11px; }
.pcard.pcard-panel6 .panel6-sub { font-size: 12px; color: var(--muted); }
.pcard.pcard-panel6 .panel6-meta { font-size: 10px; color: var(--muted); line-height: 1.35; }
.pcard.pcard-panel6 .panel6-foot { font-size: 10px; color: var(--muted); line-height: 1.35; border-top: 1px solid var(--line-soft); padding-top: 4px; }
.pcard.pcard-panel6 svg { max-height: 170px !important; height: 170px; }
@media (max-width: 960px) { .pgrid { grid-template-columns: 1fr; } .pgrid.pgrid-6 { grid-template-columns: 1fr; } }
@media print {
  body.print-supplier .main > *:not(#stepbody), body.print-supplier #stepbody > .stack > *:not(section),
  body.print-supplier .stats, body.print-supplier .print-head, body.print-supplier .banner { display: none !important; }
  body.print-supplier .sheet { border: 0; border-radius: 0; padding: 0; margin: 0; break-after: page; }
  body.print-supplier .sheet:last-child { break-after: auto; }
  body.print-supplier section.card { border: 0; }
  table.order td { height: 20px; }
}
@page panel-a4-landscape { size: A4 landscape; margin: 8mm; }
@media print {
  .panel-screen-only { display: none !important; }
  .panel-print-only { display: block !important; }
  body.print-supplier .sheet.panel-page, body.print-batch-docs .sheet.panel-page { page: panel-a4-landscape; }
  /* Six panel drawings per A4 landscape page: 3 across × 2 rows. */
  body.print-supplier .pgrid, body.print-batch-docs .pgrid { gap: 10px; }
  body.print-supplier .pcard, body.print-batch-docs .pcard { padding: 6px 10px; gap: 3px; break-inside: avoid; }
  body.print-supplier .pcard svg, body.print-batch-docs .pcard svg { max-height: 300px !important; height: 300px; }
  body.print-supplier .pgrid.pgrid-6, body.print-batch-docs .pgrid.pgrid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 6px; }
  body.print-supplier .pcard.pcard-panel6, body.print-batch-docs .pcard.pcard-panel6 { padding: 5px 6px; gap: 3px; border-radius: 6px; }
  body.print-supplier .pcard.pcard-panel6 svg, body.print-batch-docs .pcard.pcard-panel6 svg { max-height: 170px !important; height: 170px; }
  body.print-supplier .pcard.pcard-panel6 .panel6-code, body.print-batch-docs .pcard.pcard-panel6 .panel6-code { font-size: 11px; }
  body.print-supplier .pcard.pcard-panel6 .panel6-codes, body.print-batch-docs .pcard.pcard-panel6 .panel6-codes, body.print-supplier .pcard.pcard-panel6 .panel6-part, body.print-batch-docs .pcard.pcard-panel6 .panel6-part { font-size: 9px; }
  body.print-supplier .pcard.pcard-panel6 .panel6-sub, body.print-supplier .pcard.pcard-panel6 .panel6-meta, body.print-supplier .pcard.pcard-panel6 .panel6-foot, body.print-batch-docs .pcard.pcard-panel6 .panel6-sub, body.print-batch-docs .pcard.pcard-panel6 .panel6-meta, body.print-batch-docs .pcard.pcard-panel6 .panel6-foot { font-size: 8px; line-height: 1.25; }
  body.print-supplier table.holes th, body.print-batch-docs table.holes th { height: 16px; font-size: 9px; }
  body.print-supplier table.holes td, body.print-batch-docs table.holes td { height: 15px; font-size: 9px; }
  body.print-supplier .pnote, body.print-batch-docs .pnote { font-size: 9px; line-height: 1.3; }
  body.print-supplier .legend, body.print-batch-docs .legend { font-size: 9px; margin-top: 4px; }
  body.print-supplier .sheet-head, body.print-batch-docs .sheet-head { margin-bottom: 6px; padding-bottom: 4px; }
}
@media print {
  body.print-supplier table.order th { height: 20px; font-size: 9px; }
  body.print-supplier table.order td { height: 17px; font-size: 9.5px; padding-top: 1px; padding-bottom: 1px; }
  body.print-supplier table.order svg { width: 30px; height: 16px; }
  body.print-supplier .supplier-cut-order td { height: 32px; }
  body.print-supplier .supplier-cut-order .band-symbol { width: 28px; height: 28px; }
}
.edit select[data-d="finish"] { min-width: 118px; }

/* full-screen drawing viewer */
.zoomwrap { position: fixed; inset: 0; z-index: 50; background: rgba(29,28,26,.92); display: flex; flex-direction: column; }
.zoombar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; background: var(--surface); flex-wrap: wrap; }
.zoomstage { flex: 1 1 auto; overflow: hidden; position: relative; touch-action: none; cursor: grab; background: #FFFFFF; }
.zoomstage:active { cursor: grabbing; }
.zoomstage > div { transform-origin: 0 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.zoomstage svg { max-height: none !important; height: 100% !important; width: 100%; }
@media print { .zoomwrap { display: none !important; } }

/* labels: A4 sticker sheet */
.labels .labelgrid { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 6px; }
.label { border: 1px dashed var(--control); border-radius: 6px; padding: 6px 8px; min-height: 92px; display: flex; flex-direction: column; gap: 2px; position: relative; }
.label .lcode { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.label .lname { font-size: 12px; }
.label .lsize { font-family: var(--mono); font-weight: 600; font-size: 14px; }
.label .lmeta { font-size: 10px; color: var(--muted); }
.label .lqr { position: absolute; right: 6px; top: 6px; }
@media print {
  body.print-supplier .sheet { break-after: page; }
  .labels .label { min-height: 34mm; }
}

/* layout window */
.tray { display: flex; flex-wrap: wrap; gap: 8px; }
.traycard { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; min-height: 52px;
  border: 1px solid var(--control); border-radius: 8px; background: var(--surface); cursor: grab; font-family: inherit; text-align: left; }
.traycard:hover { background: var(--quiet); }
#stage .cab { cursor: move; }
#stage .handle { cursor: nwse-resize; }

/* the row for whatever is selected on the drawing */
tr.rowsel > td { background: #FFF8E8; }
tr.rowsel > td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* editable cabinet board: full-screen layout mode */
.board-editor.board-fullscreen {
  position: fixed; inset: 0; z-index: 70; background: var(--surface); padding: 10px;
  display: flex; flex-direction: column; overflow: hidden;
}
body.board-fullscreen-open { overflow: hidden; }
.board-editor.board-fullscreen .board-topbar { flex: 0 0 auto; margin-bottom: 8px !important; }
.board-editor.board-fullscreen #tools { max-width: 100%; }
.board-editor.board-fullscreen #palette,
.board-editor.board-fullscreen .board-tray-section { display: none; }
.board-editor.board-fullscreen #stage {
  flex: 1 1 auto; min-height: 0; height: auto !important; border-radius: 8px !important;
  cursor: grab; border-color: var(--control) !important;
}
.board-editor.board-fullscreen #stage.panning { cursor: grabbing; }
.board-editor #stage.ctrl-pan-ready { cursor: grab; }
.board-editor #stage.panning { cursor: grabbing !important; }
.batch-check { width: 42px; text-align: center; }
.batch-check input { width: 18px; height: 18px; accent-color: var(--teal); vertical-align: middle; }
@media print {
  .board-editor.board-fullscreen { display: none !important; }
  .batch-cut-table th, .batch-cut-table td { font-size: 9.5px; padding-left: 5px; padding-right: 5px; }
}


/* brand + theme */
.brand-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; flex: 0 0 auto; }
.top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.theme-toggle { height: 36px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; border-radius: 8px; border: 1px solid var(--control); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.theme-toggle:hover { background: var(--quiet); }
.theme-icon { font-size: 16px; line-height: 1; }


/* Parts: by-cabinet cards follow the active theme. */
.part-card {
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  color: var(--ink);
}
.band-icon { color-scheme: light dark; }

/* dark theme */
html[data-theme="dark"] {
  --ground: #121415; --surface: #1B1E20; --quiet: #222629; --ink: #F2F1EE; --muted: #A7AAA7;
  --line: #353A3D; --line-soft: #2A2E31; --control: #4A5054;
  --teal: #6DB8B1; --teal-dark: #89CEC7; --teal-soft: #223B39; --teal-tint: #1B302F;
  --red: #FF8F83; --red-bg: #3B211F; --red-line: #6A3731;
  --amber: #FFC96B; --amber-bg: #3A2D18; --blue: #8FB9EE; --blue-bg: #1D2C40;
  --green: #86C98D; --green-bg: #213727;
  --drawing-bg: #0F1213; --drawing-surface: #171B1C; --drawing-wood: #3B3027;
  --drawing-board: #2B302F; --drawing-shelf: #3A4140; --drawing-ink: #E8E7E3;
  --drawing-muted: #A5ABA8; --drawing-accent: #78C1BA; --drawing-selected: #FF8F83;
  --drawing-guide: #8FB9EE; --drawing-wood-line: #C79B66;
  --doc-surface: #171B1C;
  --layout-stock-empty: #34393C;
  --layout-part-surface: #202527;
  --layout-woodgrain-part: #0F1112;
  --machining-cup-fill: #3B211F;
}
html[data-theme="dark"] input[type=text], html[data-theme="dark"] input[type=password], html[data-theme="dark"] input[type=number],
html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: var(--surface); color: var(--ink); color-scheme: dark; }
html[data-theme="dark"] .thumb img { background: #0C0D0E; }
html[data-theme="dark"] .viewer, html[data-theme="dark"] .thumb a > div { background: #0C0D0E !important; }
html[data-theme="dark"] .choice:has(input:checked) { background: var(--teal-tint); }
html[data-theme="dark"] .sheet { background: var(--doc-surface); color: var(--ink); }
html[data-theme="dark"] tr.rowsel > td { background: #3A301F; }
html[data-theme="dark"] .zoomstage { background: var(--drawing-bg); }
html[data-theme="dark"] .pin { border-color: #F2F1EE; }

#redraw, .zoomstage { background: var(--drawing-bg); }
#redraw svg, .zoomstage svg, .board-editor #stage { color-scheme: light dark; }
@media print {
  :root, html[data-theme="dark"] {
    --ground: #FFFFFF; --surface: #FFFFFF; --quiet: #FAF8F3; --ink: #1D1C1A; --muted: #5C5850;
    --line: #DDD7CA; --line-soft: #EFEBE1; --control: #C9C2B3;
    --teal: #1F5F5B; --teal-dark: #16453F; --teal-soft: #E4EFEE; --teal-tint: #F0F6F5;
    --red: #A12A1E; --red-bg: #FDECEA; --red-line: #E8C4BF; --amber: #7A4B00; --amber-bg: #FFF1D6;
    --blue: #1E4E8C; --blue-bg: #E6EEF8; --green: #2A6130; --green-bg: #E3F1E4;
    --drawing-bg: #FFFFFF; --drawing-surface: #FFFFFF; --drawing-wood: #F6ECDD;
    --drawing-board: #EFEBE1; --drawing-shelf: #DCD5C6; --drawing-ink: #1D1C1A;
    --drawing-muted: #5C5850; --drawing-accent: #1F5F5B; --drawing-selected: #B42318;
    --drawing-guide: #1E4E8C; --drawing-wood-line: #C08A4A;
    --doc-surface: #FFFFFF; --layout-stock-empty: #ECEDEA; --layout-part-surface: #FFFFFF;
    --layout-woodgrain-part: #CCC0B3; --machining-cup-fill: #FDECEA;
  }
}

/* grouped board toolbar */
.board-instruction { font-size: 13px; margin: 0 0 6px; min-height: 19px; }
.board-topbar { align-items: flex-start; margin-top: 0; }
.board-tools { display: flex; align-items: stretch; gap: 0; flex: 1 1 auto; justify-content: flex-end; min-width: 0; flex-wrap: wrap; row-gap: 8px; width: 100%; }
.board-tool-group { display: inline-flex; align-items: center; gap: 6px; padding: 0; position: relative; min-height: 36px; }
/* Divider spacing scales with the available toolbar width instead of using a fixed gap. */
.board-tool-group + .board-tool-group {
  border-left: 1px solid var(--line);
  margin-left: clamp(14px, 1.8vw, 30px);
  padding-left: clamp(14px, 1.8vw, 30px);
}
.board-tool-label { display: none; }
.board-tools .board-tool-view { margin-left: 0; }
.board-tool-group .segmented { height: 36px; }
.board-tool-group .seg { min-height: 34px; padding: 0 12px; font-size: 13px; }
.board-tool-zoom { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 900px) {
  .board-topbar { flex-direction: column; align-items: stretch; }
  .board-tools { justify-content: flex-end; }
  .board-tools .board-tool-view { margin-left: 0; }
}
@media (max-width: 600px) {
  #theme-label { display: none; }
  .theme-toggle { width: 36px; padding: 0; justify-content: center; }
  .board-tool-label { display: none; }
}

/* Internal / ungrouped board edit targets. */
.board-editor #stage .shelf:hover rect,
.board-editor #stage .divider:hover rect:first-child,
.board-editor #stage .carcass-member:hover > rect:first-child {
  stroke: var(--drawing-selected);
  stroke-width: 1.4;
}
.board-editor #stage .carcass-handle { pointer-events: all; }

/* Approve: selecting a production part links the measurement card/row to its location in the redraw. */
.part-card.part-picked {
  border-color: var(--drawing-selected) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--drawing-selected) 24%, transparent);
}
table.edit tr.part-picked > td {
  background: var(--red-bg) !important;
}

.cut-size-readout{display:flex;align-items:baseline;gap:8px;padding:7px 9px;border:1px solid var(--line-soft);border-radius:7px;background:var(--quiet);font-size:12px}
.cut-size-readout span{color:var(--muted);font-weight:600}
.cut-size-readout strong{color:var(--ink);font-size:14px}
.cut-size-readout small{color:var(--muted);margin-left:auto}


/* multi-job document package */
.batch-package-controls { gap: 18px; }
.batch-package-heading h1 { margin: 0; }
.batch-package-heading p { margin: 4px 0 0; }
.batch-package-actions,
.batch-section-head,
.batch-layout-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.batch-doc-section,
.batch-layout-toolbar { border-top: 1px solid var(--line-soft); padding-top: 16px; }
.batch-doc-section { display: flex; flex-direction: column; gap: 10px; }
.batch-section-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.batch-doc-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.batch-doc-options .choice { min-height: 48px; padding: 8px 12px; gap: 10px; border-radius: 8px; font-size: 14px; }
.batch-doc-options .choice input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--teal); flex-shrink: 0; }
.batch-doc-options .choice span { line-height: 1.25; }
.batch-layout-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.batch-layout-label { color: var(--muted); font-size: 13px; white-space: nowrap; }
.batch-layout-actions { margin-left: auto; }

@media (max-width: 1080px) {
  .batch-doc-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .batch-package-actions { align-items: stretch; }
  .batch-package-actions-left { width: 100%; }
  .batch-package-actions-left .btn { flex: 1 1 auto; }
  #batchdocprint { width: 100%; }
  .batch-doc-options { grid-template-columns: 1fr; }
  .batch-layout-toolbar { align-items: flex-start; }
  .batch-layout-controls { width: 100%; align-items: flex-start; flex-direction: column; }
  .batch-layout-controls .segmented { width: 100%; overflow-x: auto; }
  .batch-layout-controls .seg { flex: 1 0 auto; }
  .batch-layout-actions { width: 100%; margin-left: 0; }
  .batch-layout-actions .btn { flex: 1 1 auto; }
}
.batch-doc-sheet { break-inside: avoid; }
.batch-cover { min-height: 180px; }
.board-stock-table { margin-top: 8px; }
.board-stock-table table { table-layout: fixed; }
.board-stock-table th:nth-child(1), .board-stock-table td:nth-child(1) { width: 46%; }
.board-stock-table th:nth-child(2), .board-stock-table td:nth-child(2) { width: 34%; }
.board-stock-table th:nth-child(3), .board-stock-table td:nth-child(3) { width: 20%; }
@media (max-width: 680px) {
  .board-stock-table table { table-layout: auto; min-width: 520px; }
}
@media print {
  body.print-batch-docs .sheet { border: 0; border-radius: 0; padding: 0; margin: 0; break-after: page; }
  body.print-batch-docs .sheet:last-child { break-after: auto; }
  body.print-batch-docs .pgrid { gap: 10px; }
  body.print-batch-docs .pcard { padding: 6px 10px; gap: 3px; break-inside: avoid; }
  body.print-batch-docs .pcard svg { max-height: 300px !important; height: 300px; }
  body.print-batch-docs table.holes th { height: 16px; font-size: 9px; }
  body.print-batch-docs table.holes td { height: 15px; font-size: 9px; }
  body.print-batch-docs .pnote { font-size: 9px; line-height: 1.3; }
  body.print-batch-docs .legend { font-size: 9px; margin-top: 4px; }
  body.print-batch-docs .sheet-head { margin-bottom: 6px; padding-bottom: 4px; }
  body.print-batch-docs table.order th { height: 20px; font-size: 9px; }
  body.print-batch-docs table.order td { height: 17px; font-size: 9.5px; padding-top: 1px; padding-bottom: 1px; }
  body.print-batch-docs table.order svg { width: 30px; height: 16px; }
  body.print-batch-docs .supplier-cut-order td { height: 32px; }
  body.print-batch-docs .supplier-cut-order .band-symbol { width: 28px; height: 28px; }
  body.print-batch-docs .labels .label { min-height: 34mm; }
}

/* App 88: App 86 full-screen measurement editor with strict grouped parent-first selection restored. */
.board-measurebar { display: none; }
.board-editor.board-fullscreen .board-measurebar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; min-height: 42px; padding: 6px 10px; margin: -2px 0 8px;
  border: 1px solid var(--control); border-radius: 8px; background: var(--quiet); flex-wrap: wrap;
}
.board-editor.board-fullscreen .board-measurebar[hidden] { display: none !important; }
.board-measure-title { display: inline-flex; align-items: baseline; gap: 9px; min-width: 0; }
.board-measure-summary { font-size: 12px; color: var(--drawing-accent); white-space: nowrap; }
.board-measure-fields { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-measure-fields label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.board-measure-input {
  width: 78px; height: 30px; padding: 4px 7px; border: 1px solid var(--control); border-radius: 6px;
  background: var(--surface); color: var(--ink); font-size: 13px;
}
.board-measure-input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.board-measure-help { font-size: 11px; white-space: nowrap; }
@media (max-width: 760px) {
  .board-editor.board-fullscreen .board-measurebar { align-items: flex-start; }
  .board-measure-title, .board-measure-fields { width: 100%; }
  .board-measure-input { width: 70px; }
  .board-measure-help { display: none; }
}

/* Sticky drawing on desktop. The page itself keeps the original normal document scroll.
   Dock flush to the viewport top with an opaque backing so underlying rows can never show through. */
@media (min-width: 961px) {
  .workspace-sticky-drawing:not(.board-fullscreen),
  .approve-sticky-drawing {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    isolation: isolate;
  }
  .workspace-sticky-drawing:not(.board-fullscreen) {
    padding-top: 0;
    padding-bottom: 8px;
  }
  .approve-sticky-drawing {
    padding-bottom: 10px !important;
  }
  .workspace-sticky-drawing.is-stuck,
  .approve-sticky-drawing.is-stuck {
    box-shadow: 0 8px 12px -12px rgba(0,0,0,.45);
  }
  .workspace-sticky-drawing.is-stuck .board-instruction,
  .approve-sticky-drawing.is-stuck .drawing-instruction {
    display: none !important;
  }
  .workspace-scroll-content,
  .approve-scroll-content {
    overflow: visible;
    max-height: none;
    padding-right: 0;
  }
}

.drawing-instruction { display:block; font-size:12px; margin:0 0 6px; }

/* Approve: clickable edge-band sides. Each physical side is the control. */
.band-click-editor {
  position: relative;
  width: 104px;
  height: 62px;
  flex: 0 0 auto;
  margin: 2px auto;
}
.band-click-editor.compact { width: 92px; height: 54px; }
.band-part-face {
  position: absolute;
  inset: 12px 16px;
  border: 1px solid var(--control);
  border-radius: 3px;
  background: var(--surface);
  display: grid;
  place-items: center;
}
.band-reset-hit {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.band-reset-hit:hover { background: var(--quiet); color: var(--ink); }
.band-edge-hit {
  position: absolute;
  border: 1px solid var(--control);
  background: var(--quiet);
  color: var(--muted);
  cursor: pointer;
  font: 700 9px/1 var(--mono);
  padding: 0;
  border-radius: 4px;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.band-edge-hit:hover { border-color: var(--teal); color: var(--ink); }
.band-edge-hit.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.band-edge-hit span { pointer-events: none; }
.band-edge-hit.edge-l1,
.band-edge-hit.edge-l2 { left: 16px; right: 16px; height: 16px; }
.band-edge-hit.edge-l1 { top: 0; }
.band-edge-hit.edge-l2 { bottom: 0; }
.band-edge-hit.edge-w1,
.band-edge-hit.edge-w2 { top: 12px; bottom: 12px; width: 18px; }
.band-edge-hit.edge-w1 { left: 0; }
.band-edge-hit.edge-w2 { right: 0; }
.band-click-editor.compact .band-part-face { inset: 10px 14px; }
.band-click-editor.compact .band-edge-hit.edge-l1,
.band-click-editor.compact .band-edge-hit.edge-l2 { left: 14px; right: 14px; height: 14px; }
.band-click-editor.compact .band-edge-hit.edge-w1,
.band-click-editor.compact .band-edge-hit.edge-w2 { top: 10px; bottom: 10px; width: 16px; }

/* App 95: desktop Drawing-as-read toolbar stays on one physical row. */
@media (min-width: 961px) {
  .board-editor:not(.board-fullscreen) .board-topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    overflow: hidden;
  }
  .board-editor:not(.board-fullscreen) .board-tools {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    padding-bottom: 2px;
  }
  .board-editor:not(.board-fullscreen) .board-tool-group {
    flex: 0 0 auto;
  }
  .board-editor:not(.board-fullscreen) .board-tool-group + .board-tool-group {
    margin-left: clamp(22px, 2vw, 34px);
    padding-left: clamp(22px, 2vw, 34px);
  }
}

/* App 99: optional sticky Check drawing and two-section accordion editor. */
@media (min-width: 961px) {
  .workspace-sticky-drawing.sticky-disabled:not(.board-fullscreen) {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
  }
}
.check-edit-section {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  margin-top: 14px;
}
.check-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--quiet);
}
.check-edit-head h3 { margin: 0 0 2px; font-size: 15px; }
.check-edit-head .muted { font-size: 11px; }
.check-accordion-table { min-width: 860px; }
.check-accordion-table .check-summary-row > td { vertical-align: middle; }
.check-summary-row.rowsel > td { background: #FFF8E8; }
html[data-theme="dark"] .check-summary-row.rowsel > td { background: #3A301F; }
.detail-toggle {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transform: rotate(0deg);
  transition: transform .14s ease, background .14s ease;
}
.detail-toggle:hover { background: var(--quiet); color: var(--ink); }
.detail-toggle.open { transform: rotate(90deg); color: var(--teal); }
.check-detail-row > td {
  padding: 0 !important;
  background: color-mix(in srgb, var(--quiet) 55%, var(--surface));
  border-top: 0 !important;
}
.check-detail-row.detail-selected > td {
  box-shadow: inset 3px 0 0 var(--red);
}
.check-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 16px 44px;
  border-top: 1px dashed var(--line-soft);
}
.detail-field-group {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface);
}
.detail-field-group > b { display: block; margin-bottom: 8px; font-size: 12px; }
.detail-wide-block { grid-column: 1 / -1; }
.detail-fields { display: flex; gap: 8px 12px; align-items: end; flex-wrap: wrap; }
.detail-fields label, .mini-field {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}
.detail-fields input, .detail-fields select { min-width: 86px; }
.detail-fields .detail-wide { flex: 1 1 220px; }
.detail-fields .detail-wide input { width: 100%; }
.detail-delete { margin-left: auto; }
.compact-detail-table { min-width: 620px; }
.compact-detail-table th, .compact-detail-table td { padding-top: 6px; padding-bottom: 6px; }
.mini-fields { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.mini-field input { width: 84px; height: 30px; }
.shape-detail-grid { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(320px, 1.2fr); gap: 12px; align-items: start; }
[data-detail-part].rowsel > td { background: #FFF8E8 !important; }
html[data-theme="dark"] [data-detail-part].rowsel > td { background: #3A301F !important; }
@media (max-width: 900px) {
  .check-detail-grid { grid-template-columns: 1fr; padding-left: 12px; }
  .detail-wide-block { grid-column: auto; }
  .shape-detail-grid { grid-template-columns: 1fr; }
}
@media (min-width: 961px) {
  .approve-sticky-drawing.sticky-disabled {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
  }
}

/* App 100: one compact expanded Check row, kept immediately below the sticky drawing. */
.check-detail-lines {
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.check-detail-line {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  min-width: 0;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.check-detail-line:last-child { border-bottom: 0; }
.check-detail-label {
  padding: 8px 10px;
  background: color-mix(in srgb, var(--quiet) 70%, var(--surface));
  border-right: 1px solid var(--line-soft);
  font-size: 11px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--ink);
}
.check-detail-body {
  min-width: 0;
  padding: 5px 8px;
}
.check-detail-body .detail-fields {
  gap: 5px 10px;
  align-items: center;
  flex-wrap: wrap;
}
.check-detail-body .detail-fields label,
.check-detail-body .mini-field {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 10px;
}
.check-detail-body .detail-fields input,
.check-detail-body .detail-fields select,
.check-detail-body .mini-field input {
  height: 30px;
  min-width: 72px;
}
.check-detail-body .detail-fields .detail-wide {
  flex: 1 1 250px;
}
.check-detail-body .detail-fields .detail-wide input { min-width: 160px; }
.check-detail-body .table-wrap { margin: 0; }
.check-detail-body .compact-detail-table { min-width: 560px; }
.check-detail-body .compact-detail-table th,
.check-detail-body .compact-detail-table td,
.check-detail-body .edge-band-table th,
.check-detail-body .edge-band-table td {
  padding-top: 4px;
  padding-bottom: 4px;
}
.check-detail-row > td {
  padding: 0 !important;
  background: var(--surface);
}
.check-edit-section { margin-top: 10px; }
.check-edit-head { padding: 8px 12px; }
.check-edit-head h3 { margin: 0; }
@media (max-width: 900px) {
  .check-detail-line { grid-template-columns: 92px minmax(0, 1fr); }
  .check-detail-label { padding: 7px 8px; }
  .check-detail-body { padding: 5px 6px; }
}


/* App 102: semantic orientation labels make every edge-band side unambiguous. */
.band-editor-wrap { display:flex; flex-direction:column; align-items:center; gap:2px; min-width:154px; }
.band-editor-wrap.compact { min-width:132px; }
.band-click-editor { width:150px; height:88px; margin:2px auto 0; }
.band-click-editor.compact { width:128px; height:72px; }
.band-part-face { inset:22px 38px; }
.band-click-editor.compact .band-part-face { inset:18px 32px; }
.band-edge-hit { display:flex; align-items:center; justify-content:center; gap:3px; line-height:1.05; }
.band-edge-hit .band-edge-name { font:700 9px/1.05 var(--sans); white-space:nowrap; }
.band-edge-hit .band-edge-code { font:700 8px/1 var(--mono); opacity:.72; white-space:nowrap; }
.band-edge-hit.edge-top,
.band-edge-hit.edge-bottom { left:34px; right:34px; height:20px; }
.band-edge-hit.edge-top { top:0; }
.band-edge-hit.edge-bottom { bottom:0; }
.band-edge-hit.edge-left,
.band-edge-hit.edge-right { top:18px; bottom:18px; width:34px; flex-direction:column; }
.band-edge-hit.edge-left { left:0; }
.band-edge-hit.edge-right { right:0; }
.band-edge-hit.edge-left .band-edge-name,
.band-edge-hit.edge-right .band-edge-name { white-space:normal; text-align:center; }
.band-click-editor.compact .band-edge-hit.edge-top,
.band-click-editor.compact .band-edge-hit.edge-bottom { left:29px; right:29px; height:18px; }
.band-click-editor.compact .band-edge-hit.edge-left,
.band-click-editor.compact .band-edge-hit.edge-right { top:15px; bottom:15px; width:29px; }
.band-click-editor.compact .band-edge-hit .band-edge-name { font-size:8px; }
.band-click-editor.compact .band-edge-hit .band-edge-code { font-size:7px; }
.band-orientation-note { color:var(--muted); font-size:9px; line-height:1.1; text-align:center; white-space:nowrap; }



/* App 105: selected Check summary row is self-describing; no separate title row. */
.check-summary-inline {
  display:inline-flex;
  align-items:center;
  gap:6px;
  width:100%;
  min-width:0;
  white-space:nowrap;
}
.check-summary-inline > input,
.check-summary-inline > select { min-width:0; }
.check-summary-inline-label {
  flex:0 0 auto;
  color:var(--muted);
  font-size:9px;
  font-weight:800;
  letter-spacing:.06em;
  text-transform:uppercase;
}
.check-summary-type {
  display:inline-flex;
  align-items:center;
  gap:5px;
  margin-left:8px;
  color:var(--muted);
  font-family:var(--sans);
  font-size:10px;
  white-space:nowrap;
}
.check-selected-part-inline {
  display:inline-block;
  margin-left:8px;
  color:var(--drawing-accent);
  font-size:10px;
  font-weight:700;
  white-space:nowrap;
}

/* Sticky Check drawing: force the control row to dock against the viewport edge. */
@media (min-width: 961px) {
  .workspace-sticky-drawing:not(.board-fullscreen) {
    top: 0 !important;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
  }
  .workspace-sticky-drawing.is-stuck:not(.board-fullscreen) {
    top: 0 !important;
  }
  .workspace-sticky-drawing:not(.board-fullscreen) .board-topbar {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
}

/* App 112: a value the DXF does not state, waiting for the operator. */
.needs-input { border-color: var(--red) !important; box-shadow: 0 0 0 1px var(--red) inset; background: var(--red-bg); color: var(--red); }
.needs-input::placeholder { color: var(--red); opacity: 1; font-weight: 700; }

/* App 115: Front is a compact production editor — front panel, hinges and opening method. */
.front-accordion-table { min-width: 940px; }
.front-accordion-table .front-type-select { min-width: 170px; max-width: 220px; }
.front-accordion-table .front-finish-select { min-width: 150px; max-width: 210px; }
.front-accordion-table .front-main-num { width: 74px; min-width: 68px; }
.front-qty { font-size: 11px; white-space: nowrap; }
.front-detail-actions {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:32px;
  padding:4px 8px;
  border-bottom:1px solid var(--line-soft);
  background:var(--surface);
}
.front-door-hinge-wrap {
  display:flex;
  align-items:center;
  gap:14px;
  min-width:0;
  flex-wrap:wrap;
}
.front-part-summaries {
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  min-width:0;
}
.front-part-summary {
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:28px;
  padding:3px 8px;
  border:1px solid var(--line-soft);
  border-radius:6px;
  background:var(--quiet);
  font-size:10px;
  white-space:nowrap;
}
.front-hinge-fields { flex:1 1 420px; }
.opening-method-select { min-width:180px !important; }
.opening-method-fields > label:first-child { flex:0 0 auto; }
#frontdetails .check-detail-body .opening-method-fields .detail-wide { min-width:220px; }
@media (max-width: 900px) {
  .front-door-hinge-wrap { align-items:flex-start; }
  .front-hinge-fields { flex-basis:100%; }
}


/* Machining key mirrors the exact symbols/colors drawn on nested parts. */
.machining-key {
  display:inline-flex;
  align-items:center;
  flex-wrap:wrap;
  gap:5px;
  line-height:1.25;
}
.machining-key-item {
  display:inline-flex;
  align-items:center;
  gap:4px;
  white-space:nowrap;
}
.machining-key-item svg { display:block; flex:0 0 auto; }
.machining-key-sep { color:var(--muted); padding:0 1px; }

/* Combined batch layout: keep a fixed clear zone around the board drawing so the
   nesting diagram never crowds either the header or the traceability footer. The same
   40 px spacing is used in the on-screen Combined Production Package and PDF export. */
.layout-sheet .sheet-head,
.combined-layout-sheet .sheet-head { border-bottom:1px solid var(--ink); }
.combined-layout-sheet .sheet-head { margin-bottom:0; }
.combined-layout-stage {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:0;
  padding:40px 0;
  box-sizing:border-box;
}
.combined-layout-svg { display:block; width:100%; max-height:520px; }
.layout-footer,
.combined-layout-footer {
  border-top:1px solid var(--ink);
  padding-top:8px;
}
.combined-layout-footer { flex:0 0 auto; margin:0; }

/* Manual Sheet Layout editor: dragging selects a destination sheet; the nester
   performs the actual safe re-pack after drop. */
.layout-editing .layout-piece { cursor: grab; touch-action: none; }
.layout-editing .layout-piece:active,
.layout-editing .layout-piece-dragging { cursor: grabbing; opacity: .45; }
[data-layout-edit-svg].layout-drop-compatible { outline: 2px dashed var(--teal); outline-offset: 4px; }
[data-layout-edit-svg].layout-drop-hover { outline-style: solid; outline-width: 4px; }
.layout-drag-ghost {
  position: fixed; left:0; top:0; z-index: 1000; pointer-events: none; padding: 6px 9px;
  border: 1px solid var(--teal); border-radius: 6px; background: var(--surface);
  color: var(--ink); font: 600 12px/1.2 "IBM Plex Mono", monospace;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  will-change: transform; contain: layout paint style;
}
.layout-edit-help { font-size:12px; line-height:1.4; }
@media print {
  .layout-drag-ghost { display:none !important; }
  [data-layout-edit-svg] { outline:none !important; }
}
@media print {
  body.print-batch-docs .combined-layout-sheet,
  body.print-supplier .combined-layout-sheet {
    height:194mm;
    min-height:194mm;
    max-height:194mm;
    display:flex;
    flex-direction:column;
    box-sizing:border-box;
    overflow:hidden;
  }
  body.print-batch-docs .combined-layout-sheet .sheet-head,
  body.print-supplier .combined-layout-sheet .sheet-head {
    flex:0 0 auto;
    margin-bottom:0 !important;
  }
  body.print-batch-docs .combined-layout-stage,
  body.print-supplier .combined-layout-stage {
    flex:1 1 auto;
    min-height:0;
    padding:40px 0;
    box-sizing:border-box;
  }
  body.print-batch-docs .combined-layout-svg,
  body.print-supplier .combined-layout-svg {
    width:100%;
    height:100%;
    max-height:none !important;
  }
  body.print-batch-docs .combined-layout-footer,
  body.print-supplier .combined-layout-footer {
    margin:0;
    flex:0 0 auto;
  }
}


/* A4 landscape six-up panel drawings: clean 3 × 2 production grid. */
@media print {
  body.print-supplier .sheet.panel-page,
  body.print-batch-docs .sheet.panel-page {
    page: panel-a4-landscape;
    height: 194mm;
    min-height: 194mm;
    max-height: 194mm;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
  }
  body.print-supplier .sheet.panel-page .sheet-head,
  body.print-batch-docs .sheet.panel-page .sheet-head {
    flex: 0 0 auto;
    margin-bottom: 3mm;
    padding-bottom: 2mm;
  }
  body.print-supplier .sheet.panel-page .pgrid.pgrid-6,
  body.print-batch-docs .sheet.panel-page .pgrid.pgrid-6 {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 4mm;
    align-items: stretch;
  }
  body.print-supplier .sheet.panel-page .pcard.pcard-panel6,
  body.print-batch-docs .sheet.panel-page .pcard.pcard-panel6 {
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
    padding: 2.2mm 2.6mm;
    gap: 1.2mm;
    border: 0.6px solid var(--line);
    border-radius: 2mm;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  body.print-supplier .sheet.panel-page .pcard.pcard-panel6 svg,
  body.print-batch-docs .sheet.panel-page .pcard.pcard-panel6 svg {
    align-self: center;
    justify-self: stretch;
    width: 100% !important;
    height: 49mm !important;
    max-height: 49mm !important;
  }
  body.print-supplier .sheet.panel-page .panel6-head,
  body.print-batch-docs .sheet.panel-page .panel6-head {
    min-height: 5mm;
  }
  body.print-supplier .sheet.panel-page .panel6-code,
  body.print-batch-docs .sheet.panel-page .panel6-code { font-size: 10.5px; }
  body.print-supplier .sheet.panel-page .panel6-codes,
  body.print-batch-docs .sheet.panel-page .panel6-codes,
  body.print-supplier .sheet.panel-page .panel6-part,
  body.print-batch-docs .sheet.panel-page .panel6-part { font-size: 9px; }
  body.print-supplier .sheet.panel-page .panel6-sub,
  body.print-batch-docs .sheet.panel-page .panel6-sub { font-size: 8.5px; }
  body.print-supplier .sheet.panel-page .panel6-meta,
  body.print-batch-docs .sheet.panel-page .panel6-meta,
  body.print-supplier .sheet.panel-page .panel6-foot,
  body.print-batch-docs .sheet.panel-page .panel6-foot {
    font-size: 7.8px;
    line-height: 1.25;
  }
  body.print-supplier .sheet.panel-page .panel6-foot,
  body.print-batch-docs .sheet.panel-page .panel6-foot {
    padding-top: 1mm;
  }
  body.print-supplier .sheet.panel-page .legend,
  body.print-batch-docs .sheet.panel-page .legend {
    flex: 0 0 auto;
    margin-top: 2.5mm;
    gap: 2mm 5mm;
    font-size: 8px;
  }
}
