/* Layout: sticky header with tab rail; each tab is a working surface. Cards only for machines, the sheet and the status. */
:root {
  --bg: #F4F1EB; --surface: #FBF9F5; --raised: #FFFFFF; --ink: #161616; --muted: #66615A; --line: #DCD5CA; --line-soft: #EAE4DA;
  --accent: #26272B; --accent-ink: #26272B; --accent-soft: #E8E3D8; --on-accent: #F4F1EB;
  --lock: #8A5A0B; --lock-bg: #F5E6C8; --ok: #276C44; --ok-bg: #DCEFE2; --bad: #B4231A; --bad-bg: #F9E1DE; --warn: #8A5A0B; --warn-bg: #FBF0D9;
  --viewer-bg: #222326; --rapid: #D9D3C4; --feed: #6FB0FF; --ghost: #4A4D53; --stock: #8A9097; --tool: #C9CDD2; --grid: #2C2E33; --grid-major: #3A3D43;
  --part: #9FB0C2; --stock-fill: #7E848B; --sim-ok: #E4E7EA; --sim-cut: #B3B9C0;
  --head-bg: #1B1C1F; --head-ink: #F2F0EC; --head-muted: #A39E96; --head-line: #2E3034;
  --f-display: 'Montserrat', 'IBM Plex Sans', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151618; --surface: #1C1D20; --raised: #242528; --ink: #ECEAE6; --muted: #A09B93; --line: #34363B; --line-soft: #2A2C30;
    --accent: #ECE6D8; --accent-ink: #F4F1EB; --accent-soft: #2E3034; --on-accent: #17181A;
    --lock: #E3AA47; --lock-bg: #3A2C12; --ok: #63C08A; --ok-bg: #16301F; --bad: #F07468; --bad-bg: #3B1A17; --warn: #E3AA47; --warn-bg: #33280F;
    --viewer-bg: #1E1F22; --rapid: #D9D3C4; --feed: #6FB0FF; --ghost: #45484E; --stock: #8A9097; --tool: #C9CDD2; --grid: #2A2C30; --grid-major: #383B40;
    --part: #9FB0C2; --stock-fill: #7E848B; --sim-ok: #E4E7EA; --sim-cut: #B3B9C0;
    --head-bg: #121315; --head-ink: #F2F0EC; --head-muted: #A39E96; --head-line: #2A2C30;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151618; --surface: #1C1D20; --raised: #242528; --ink: #ECEAE6; --muted: #A09B93; --line: #34363B; --line-soft: #2A2C30;
  --accent: #ECE6D8; --accent-ink: #F4F1EB; --accent-soft: #2E3034; --on-accent: #17181A;
  --lock: #E3AA47; --lock-bg: #3A2C12; --ok: #63C08A; --ok-bg: #16301F; --bad: #F07468; --bad-bg: #3B1A17; --warn: #E3AA47; --warn-bg: #33280F;
  --viewer-bg: #1E1F22; --rapid: #D9D3C4; --feed: #6FB0FF; --ghost: #45484E; --stock: #8A9097; --tool: #C9CDD2; --grid: #2A2C30; --grid-major: #383B40;
  --part: #9FB0C2; --stock-fill: #7E848B; --sim-ok: #E4E7EA; --sim-cut: #B3B9C0;
  --head-bg: #121315; --head-ink: #F2F0EC; --head-muted: #A39E96; --head-line: #2A2C30;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; margin: 0; text-wrap: balance; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; }
h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; }
p { margin: 0; }
code { font-family: var(--f-mono); font-size: 0.88em; background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }
.muted { color: var(--muted); }
.sr { position: absolute !important; left: 0; top: 0; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--head-bg); border-bottom: 1px solid var(--head-line); --surface: var(--head-bg); --raised: #26272B; --ink: var(--head-ink); --muted: var(--head-muted); --line: #3A3C41; --line-soft: var(--head-line); --accent: #ECE6D8; --accent-soft: #2E3034; --on-accent: #17181A; color: var(--ink); color-scheme: dark; }
body::before { background: var(--head-bg) !important; }
.top-in { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding-block: 10px 6px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand strong { font-family: var(--f-display); font-size: 1.45rem; letter-spacing: 0.02em; display: block; line-height: 1; }
.brand-sub { font-size: 0.8rem; color: var(--muted); }
.mark { width: 40px; height: auto; flex: none; display: block; }
.who { display: flex; gap: 6px; }
.who input { width: 9.5em; }
.pill { font: 600 0.78rem/1 var(--f-body); letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid; border-radius: 999px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; background: none; }
.pill.locked { color: var(--lock); background: var(--lock-bg); border-color: color-mix(in srgb, var(--lock) 40%, transparent); }
.pill.draft { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.bad { color: var(--bad); background: var(--bad-bg); border-color: var(--bad); }
.pad { width: 10px; height: 8px; border: 2px solid currentColor; border-radius: 2px; position: relative; display: inline-block; margin-top: 4px; flex: none; }
.pad::before { content: ""; position: absolute; left: 0; bottom: 100%; width: 6px; height: 6px; border: 2px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-in { display: flex; gap: 2px; min-width: max-content; }
.tabs button { font: 600 0.9rem var(--f-body); color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px 10px; cursor: pointer; white-space: nowrap; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.tabs button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-selected="true"] { color: #F4F1EB; border-bottom-color: #F4F1EB; background: linear-gradient(to top, rgba(244,241,235,0.10), transparent 70%); }
.tabs button:hover { color: var(--ink); }

main { padding-block: 22px 60px; }
#view { display: flex; flex-direction: column; gap: 20px; }
.page-h { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-h > div:first-child { min-width: 0; flex: 1 1 320px; }
.lede { color: var(--muted); max-width: 62ch; margin-top: 6px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, legend { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.unit { text-transform: none; letter-spacing: 0; font-weight: 400; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
input, select, textarea { font: 15px var(--f-body); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; min-width: 0; width: 100%; }
.field.inline select, .who select, .who input { width: auto; }
input[type="number"] { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
input:disabled, select:disabled { background: transparent; border-style: dashed; color: var(--ink); opacity: 1; }
textarea { font-family: var(--f-mono); font-size: 13px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.check input { width: auto; }
.grid-f { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; }
.span4 { grid-column: 1 / -1; }
@media (max-width: 760px) { .grid-f { grid-template-columns: repeat(2, minmax(0, 1fr)); } .span4, .span2 { grid-column: 1 / -1; } }

.btn { font: 600 0.9rem var(--f-body); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 0.8rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { font: 600 0.75rem var(--f-body); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }

/* Status, issues, notes */
.status { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--r); border: 1px solid; }
.status.is-locked { background: var(--lock-bg); border-color: color-mix(in srgb, var(--lock) 35%, transparent); }
.status.is-locked h2 { color: var(--lock); }
.status.is-draft { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.status.is-bad { background: var(--bad-bg); border-color: var(--bad); }
.status-body { flex: 1 1 380px; min-width: 0; }
.status-body p { margin-top: 4px; max-width: 70ch; }
.issues { border-left: 4px solid var(--bad); background: var(--bad-bg); padding: 12px 16px; border-radius: 0 var(--r) var(--r) 0; }
.issues h3 { color: var(--bad); font-size: 1rem; }
.issues ul { margin: 8px 0 0; padding-left: 18px; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.notes li { padding: 8px 12px; border-radius: var(--r); font-size: 0.9rem; border-left: 4px solid; }
.notes li b { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; margin-right: 6px; }
.notes .lock { background: var(--lock-bg); border-color: var(--lock); }
.notes .error { background: var(--bad-bg); border-color: var(--bad); }
.notes .warn { background: var(--warn-bg); border-color: var(--warn); }
.notes .info { background: var(--surface); border-color: var(--line); }
.lockline { display: flex; align-items: center; gap: 8px; color: var(--lock); font-weight: 500; }

/* Machines */
.machines { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.machine { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.machine-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.machine-h .btn { margin-left: auto; }
.ctrl { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); }
.rules { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.rules h4 { color: var(--lock); display: flex; align-items: center; gap: 8px; }
.limits { font-size: 0.9rem; color: var(--muted); }
.limits b { color: var(--ink); font-family: var(--f-mono); font-weight: 500; }

.history ol { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; }
.history > ol > li { padding: 10px 0; border-top: 1px solid var(--line-soft); }
.h-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; }
.tag { font: 600 0.72rem var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 4px; }
.tag.locked { background: var(--lock-bg); color: var(--lock); }
.tag.unlocked { background: var(--accent-soft); color: var(--accent); }
.changes { margin: 6px 0 0; padding-left: 18px; font-size: 0.85rem; color: var(--muted); font-family: var(--f-mono); }
.datatools { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.datatools #import-box { display: flex; flex-direction: column; gap: 8px; }
.confirm { background: var(--bad-bg); padding: 12px; border-radius: var(--r); display: flex; flex-direction: column; gap: 8px; }

/* Pockets */
.pocket-sec { display: flex; flex-direction: column; gap: 10px; }
.pockets { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.pk { position: relative; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; min-height: 52px; background: var(--raised); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pk-n { font: 700 1.05rem/1 var(--f-display); color: var(--muted); }
.pk-t { font: 500 0.72rem var(--f-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk.empty { background: transparent; border-style: dashed; }
.pk.tool { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.pk.tool .pk-n { color: var(--accent); }
.pk.never { background: repeating-linear-gradient(135deg, var(--bad-bg) 0 6px, transparent 6px 12px); border-color: var(--bad); color: var(--bad); }
.pk.conflict { background: var(--bad-bg); border: 2px solid var(--bad); }
.pin { position: absolute; top: 5px; right: 6px; font: 700 0.65rem var(--f-body); color: var(--lock); background: var(--lock-bg); border-radius: 3px; padding: 1px 4px; }
.key { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: 0.8rem; color: var(--muted); }
.k { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 4px; }
.k.tool { border-color: var(--accent); } .k.never { background: repeating-linear-gradient(135deg, var(--bad) 0 2px, transparent 2px 5px); border-color: var(--bad); }
.k.fixed { background: var(--lock-bg); border-color: var(--lock); } .k.conflict { background: var(--bad-bg); border: 2px solid var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { font: 600 0.72rem var(--f-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
td.r { font-family: var(--f-mono); font-size: 0.86rem; }
.tid { font-family: var(--f-mono); font-weight: 500; white-space: nowrap; }
table.editing td { padding: 4px; }
table.editing input, table.editing select { padding: 6px 7px; font-size: 0.86rem; width: 7em; }
table.editing input.num { width: 5.2em; text-align: right; }
table.editing input.wide { width: 13em; }

/* Calculator */
.calc { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); } }
.calc-in { display: flex; flex-direction: column; gap: 12px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.seg legend { width: 100%; margin-bottom: 4px; }
.seg label { flex: 1 1 0; }
.seg input { position: absolute; opacity: 0; width: 1px; }
.seg span { display: block; text-align: center; padding: 8px 6px; border: 1px solid var(--line); border-radius: var(--r); font-weight: 600; font-size: 0.88rem; cursor: pointer; background: var(--surface); }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.calc-out { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ro-main { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ro { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; min-width: 0; }
.ro-l { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ro-v { font: 500 clamp(1.9rem, 6vw, 3rem)/1.1 var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.ro-u { font-size: 0.82rem; color: var(--muted); }
.ro-sub { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line); }
.ro-sub div { padding: 10px 4px; border-bottom: 1px solid var(--line-soft); }
.ro-sub dt { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.ro-sub dd { margin: 2px 0 0; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.power-l { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.88rem; margin-bottom: 6px; }
.bar { height: 10px; background: var(--line-soft); border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 5px; }
.bar.high span { background: var(--warn); }
.bar.over span { background: var(--bad); }
.formula { font-size: 0.8rem; color: var(--muted); font-family: var(--f-mono); }

/* Sheets */
.sheets { display: flex; flex-direction: column; gap: 20px; }
.job { display: flex; flex-direction: column; gap: 14px; }
.ops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ops li { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; }
.op-n { font: 700 1.4rem/1 var(--f-display); color: var(--accent); width: 1.4em; align-self: center; }
.ops .grow { flex: 1 1 200px; }
.ops .field:not(.grow) { flex: 0 1 150px; }
.ops .field.sm { flex: 0 1 80px; }
.op-btns { display: flex; gap: 4px; }
.sheet { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sheet-h { display: flex; gap: 12px 20px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.sheet-h h2 { font-size: 2rem; }
.sheet-h h2 span { font-weight: 600; color: var(--muted); font-size: 1.2rem; }
.eyebrow { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.stamp { font: 500 0.78rem var(--f-mono); border: 2px solid; padding: 6px 10px; border-radius: 4px; max-width: 100%; }
.stamp.ok, .stamp-line.ok { color: var(--ok); }
.stamp.draft, .stamp-line.draft { color: var(--lock); }
.stamp.bad, .stamp-line.bad { color: var(--bad); }
.stamp-line { font: 500 0.8rem var(--f-mono); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.facts .wide { grid-column: span 2; }
.facts dt { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.facts dd { margin: 2px 0 0; }
@media (max-width: 760px) { .facts { grid-template-columns: 1fr 1fr; } .facts .wide { grid-column: 1 / -1; } }
.sheet .table-wrap { border-radius: 4px; }
.foot { font-size: 0.8rem; color: var(--muted); }
.bad-t { color: var(--bad); font-weight: 600; }
.signoff { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 8px; }
.signoff div { border-bottom: 1px solid var(--ink); height: 52px; display: flex; align-items: flex-start; }
.signoff span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
@media (max-width: 560px) { .signoff { grid-template-columns: 1fr; } }
.safety { font-size: 0.84rem; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 10px; }

/* G-code viewer */
#tab-gcode { display: flex; flex-direction: column; gap: 14px; }
#tab-gcode[hidden] { display: none; }
.gc-bar { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.gc-paste { display: flex; flex-direction: column; gap: 8px; }
.gc-paste label { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.checks { border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; border: 1px solid; }
.checks.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.checks.has-err { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.checks .notes { max-height: 220px; overflow-y: auto; }
.checks .notes li { background: var(--raised); }
.linejump { font: 600 0.75rem var(--f-mono); background: none; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; cursor: pointer; color: var(--accent); margin-right: 6px; }
.gc-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 14px; align-items: start; }
@media (max-width: 960px) { .gc-main { grid-template-columns: minmax(0, 1fr); } }
.gc-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gc-view-wrap { position: relative; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--viewer-bg); }
#gc-view { height: min(62vh, 560px); min-height: 300px; touch-action: none; }
#gc-view canvas { display: block; width: 100% !important; height: 100% !important; }
.viewer-error { padding: 56px 24px 24px; color: var(--muted); }
.gc-views { position: absolute; top: 10px; left: 10px; }
.legend { position: absolute; bottom: 8px; left: 10px; display: flex; gap: 12px; font-size: 0.75rem; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 16px; height: 3px; margin-right: 5px; vertical-align: middle; border-radius: 2px; }
.lg.rapid::before { background: var(--rapid); } .lg.feed::before { background: var(--feed); } .lg.stock::before { background: var(--stock); }
.gc-controls { display: flex; flex-direction: column; gap: 10px; }
.transport .wide { flex: 1 1 140px; }
.transport .icon { width: 44px; padding-inline: 0; font-size: 1rem; }
.gc-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gc-state { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.st-top { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }
.st-top b { color: var(--ink); font-family: var(--f-mono); }
.dro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.dro div { background: var(--surface); border-radius: 4px; padding: 6px 8px; display: flex; flex-direction: column; min-width: 0; }
.dro span { font: 700 0.9rem var(--f-display); color: var(--accent); }
.dro b { font: 500 1.1rem var(--f-mono); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.modal { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin: 0; font-size: 0.86rem; }
.modal dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.modal dd { margin: 0; font-family: var(--f-mono); }
.gc-list { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); height: min(48vh, 420px); overflow: auto; font: 13px/1.55 var(--f-mono); position: relative; }
.ln { display: flex; gap: 10px; padding: 0 10px 0 0; cursor: pointer; white-space: pre; border-left: 3px solid transparent; }
.ln .n { width: 3.6em; text-align: right; color: var(--muted); flex: none; user-select: none; }
.ln.cmt .t { color: var(--muted); }
.ln:hover { background: var(--surface); }
.ln.cur { background: var(--accent-soft); border-left-color: var(--accent); }
.ln.flag-error { border-left-color: var(--bad); }
.ln.flag-error .n { color: var(--bad); font-weight: 600; }
.ln.flag-warn { border-left-color: var(--warn); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: 0.9rem; z-index: 40; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgb(0 0 0 / 0.2); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 560px) {
  h1 { font-size: 1.75rem; }
  .who input { width: 7.5em; }
  .ro-main { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

@media print {
  .top, .page-h, .job, .btn-row, body::before { display: none !important; }
  body { background: #fff; color: #000; }
  .sheet { border: 0; padding: 0; }
}

/* ---------- v2 additions ---------- */
.small { font-size: 0.82rem; }
.ok-t { color: var(--ok); font-weight: 600; }
.sync { font-size: 0.75rem; color: var(--muted); }
.who { align-items: center; flex-wrap: wrap; }
.me { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.me .role { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.account { padding-block: 0 10px; }
.acct { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 12px; max-width: 420px; margin-left: auto; }
.acct form { display: flex; flex-direction: column; gap: 8px; }
.chip.static { cursor: default; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.hint { font-size: 0.78rem; color: var(--muted); }
.form-err { color: var(--bad); font-size: 0.9rem; }
.confirm.ok { background: var(--ok-bg); }
code.big { font-size: 1.15rem; padding: 4px 10px; }
.plain { margin: 0; padding-left: 18px; }
.btn.wide { width: 100%; }

/* auth */
.auth { min-height: 100%; display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(100%, 420px); background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.brand.big strong { font-size: 1.8rem; }
.tabs2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tabs2 button { font: 600 0.9rem var(--f-body); padding: 9px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.tabs2 button.on { background: var(--accent); color: var(--on-accent); }

/* jobs list */
.joblist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.jobcard { width: 100%; text-align: left; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; font: inherit; color: inherit; }
.jobcard:hover { border-color: var(--accent); }
.jc-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jc-top b { font-family: var(--f-mono); font-weight: 500; font-size: 1.05rem; }
.jc-sub { color: var(--ink); }
.jc-meta { font-size: 0.8rem; color: var(--muted); }
.st { margin-left: auto; font: 600 0.7rem var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; padding: 3px 8px; border-radius: 4px; }
.st.draft { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.st.programmed { background: var(--accent-soft); color: var(--accent); }
.st.approved { background: var(--ok-bg); color: var(--ok); }
.empty { background: var(--raised); border: 1px dashed var(--line); border-radius: var(--r); padding: 28px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.empty p { max-width: 60ch; color: var(--muted); }

/* job flow */
.job-h { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.job-h h1 { margin-right: auto; font-size: 1.8rem; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.stepper button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 0; border-top: 3px solid var(--line); background: none; font: inherit; color: var(--muted); cursor: pointer; text-align: left; }
.stepper button:disabled { opacity: 0.45; cursor: not-allowed; }
.stepper .sn { font: 700 1.1rem/1 var(--f-display); }
.stepper .sl { font-size: 0.8rem; font-weight: 600; }
.stepper li.done button { border-top-color: var(--ok); color: var(--ink); }
.stepper li.cur button { border-top-color: var(--accent); color: var(--ink); }
.stepper li.cur .sn { color: var(--accent); }
@media (max-width: 760px) { .stepper { grid-template-columns: repeat(6, minmax(0, 1fr)); } .stepper .sl { display: none; } .stepper button { align-items: center; } }
.stepbody { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.stepbody h2 { font-size: 1.5rem; }
.stepnav { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 14px; flex-wrap: wrap; }
.drops { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 10px; }
.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; background: var(--surface); min-width: 0; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop.has { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.drop-t { font-weight: 600; }
.drop-s { font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.busy { color: var(--accent); font-weight: 500; font-size: 0.9rem; }
.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; margin-right: 8px; animation: spin 0.8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .busy::before { animation: none; } }
.part-view { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .part-view { grid-template-columns: minmax(0, 1fr); } }
.pv-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--viewer-bg); }
#pv { height: min(52vh, 420px); min-height: 260px; touch-action: none; }
#pv canvas { display: block; width: 100% !important; height: 100% !important; }
.pv-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.seg.wrap label { flex: 1 1 45%; }
.facts.tight { grid-template-columns: 1fr 1fr; }
.grid-f.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .grid-f.two { grid-template-columns: minmax(0, 1fr); } }
.draw-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.draw-grid:not(:has(.thumb)) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 860px) { .draw-grid { grid-template-columns: minmax(0, 1fr); } }
.thumb { margin: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #fff; }
.thumb img { display: block; width: 100%; height: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpis div { background: var(--surface); border-radius: var(--r); padding: 10px 12px; }
.kpis dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.kpis dd { margin: 2px 0 0; font: 500 1.3rem var(--f-mono); }
details.code summary { cursor: pointer; font-weight: 600; }
details.code pre { max-height: 360px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; font: 12.5px/1.5 var(--f-mono); }
.simsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.simrow { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: var(--r); border-left: 4px solid; background: var(--surface); }
.simrow.ok { border-color: var(--ok); } .simrow.ok b { color: var(--ok); }
.simrow.bad { border-color: var(--bad); background: var(--bad-bg); } .simrow.bad b { color: var(--bad); }
.simrow.warn { border-color: var(--warn); background: var(--warn-bg); }
.approval { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.approval.is-approved { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.approval.is-approved h3 { color: var(--ok); }

/* simulator */
.gc-ctx { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.siminfo { position: absolute; top: 10px; right: 10px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 10px; font-size: 0.78rem; }
.lg.ok::before { background: var(--sim-ok); } .lg.gouge::before { background: var(--bad); }
.legend { flex-wrap: wrap; right: 10px; }

/* team + csv */
.team, .csvbox, .quickadd, .missing { display: flex; flex-direction: column; gap: 10px; }
.addmember .grid-f { align-items: end; }
.catadd { max-width: 720px; }
.catadd select { max-width: 100%; }
/* tolerances */
.tolcalc { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fitrow { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.fitrow .field { flex: 0 1 200px; }
.pair2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fitout { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.ro-v.sm { font-size: 1.35rem; }
.gt { display: flex; gap: 6px; flex-wrap: wrap; }
.gt div { background: var(--surface); border-radius: 4px; padding: 6px 12px; display: flex; flex-direction: column; min-width: 64px; }
.gt span { font: 700 0.9rem var(--f-display); color: var(--accent); text-transform: uppercase; }
.gt b { font: 500 1.05rem var(--f-mono); }
/* part from drawing */
.features { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.features h4 { margin-top: 4px; }
.feat-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .feat-grid { grid-template-columns: minmax(0, 1fr); } }
.feat-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.plan-svg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; }
.plan-svg svg { display: block; width: 100%; height: auto; max-height: 360px; }
.sv-out { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--ink); stroke-linejoin: round; }
.sv-pk { fill: var(--accent-soft); stroke: var(--accent); }
.sv-pk.needs, .sv-h.needs { stroke: var(--warn); fill: var(--warn-bg); }
.sv-slot { stroke: var(--accent-soft); stroke-linecap: round; }
.sv-step { fill: color-mix(in srgb, var(--warn) 18%, transparent); stroke: var(--warn); stroke-dasharray: 2 1; }
.sv-h { fill: var(--raised); stroke: var(--ink); }
.sv-th { fill: none; stroke: var(--muted); stroke-dasharray: 1.5 1; }
.sv-t { fill: var(--muted); font-family: var(--f-mono); text-anchor: middle; dominant-baseline: middle; }
.sv-t.ax { fill: var(--bad); }
.sv-ax line { stroke: var(--bad); }
table.ft td { padding: 4px; }
table.ft input, table.ft select { padding: 5px 6px; font-size: 0.85rem; width: 6.2em; }
table.ft input[type="text"] { width: 6em; }
table.ft td.dc { white-space: nowrap; }
table.ft td.dc .check { margin-right: 6px; }
input.needs { border-color: var(--warn); background: var(--warn-bg); }
.grid-f.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.missing { background: var(--warn-bg); border-left: 4px solid var(--warn); border-radius: 0 var(--r) var(--r) 0; padding: 12px 14px; }

.vtop { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; }
.vtop .siminfo { position: static; }
.toolhead { align-self: stretch; background: color-mix(in srgb, var(--raised) 92%, transparent); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; font-size: 0.8rem; line-height: 1.35; pointer-events: none; }
.toolhead b { font-family: 'IBM Plex Mono', monospace; }
.toolhead .th-op { display: block; }
.lg.cut::before { background: var(--sim-cut); box-shadow: 0 0 0 1px var(--stock); }
tr.total td { border-top: 2px solid var(--line); }

.toolhead .th-time { display: block; font-variant-numeric: tabular-nums; }
.st-time { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 6px 0; font-size: 0.85rem; }
.st-time b { font-family: 'IBM Plex Mono', monospace; font-size: 1.05rem; }
.st-time span:last-child { color: var(--muted); }
.gc-measure { margin-top: 14px; }
.gc-measure h3 { margin: 0 0 8px; }
.meas-at { margin: 10px 0 6px; font-size: 0.85rem; }
table.meas td, table.meas th { font-size: 0.82rem; }
table.meas tr.grp td { font-weight: 600; background: var(--sunk, transparent); padding-top: 10px; }
table.meas tr.m-ok td:last-child { color: var(--ok); }
table.meas tr.m-over td:last-child, table.meas tr.m-over td:nth-child(4) { color: var(--bad); font-weight: 600; }
table.meas tr.m-left td:last-child { color: var(--warn); }
table.meas tr.m-todo td { color: var(--muted); }
.meas-pts { font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; margin-top: 8px; }
.meas-pts .meas-d { margin-top: 4px; }
#gc-meas-pick.on { outline: 2px solid var(--feed); }

.wordmark { font-family: 'Montserrat', 'IBM Plex Sans', system-ui, sans-serif !important; font-size: 1.3rem !important; font-weight: 400; letter-spacing: -0.01em !important; }
.wordmark b { font-weight: 700; }
.logo-full { width: min(340px, 80vw); height: auto; display: block; }
.top .mark { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-full { filter: invert(1); } }
:root[data-theme="dark"] .logo-full { filter: invert(1); }

/* Brand: charcoal buttons on cream (cream on charcoal in dark mode), softer cards */
.btn.primary { font-weight: 700; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.btn.primary:hover { filter: brightness(1.06); }
a { color: var(--accent-ink); }
.lede b, .tid { color: inherit; }
.wordmark { color: var(--ink); }
.brand-sub { letter-spacing: 0.02em; }
.gc-view-wrap { border-color: #2E3034; }
.legend, .gc-views .chip { color: #B8B3AB; }

/* setups and job packs */
.setupsel { margin: 6px 0 14px; }
.setupsel h3 { margin-bottom: 6px; }
.packtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.packtabs button { font: 600 0.85rem var(--f-body); border: 1px solid var(--line); background: var(--raised); color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.packtabs button b { color: var(--accent-ink); }
.packtabs button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.packtabs button.on b { color: inherit; }
.opsplan { border: 1px dashed var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; }

.dimlayer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dimlab { position: absolute; left: 0; top: 0; font: 600 0.72rem var(--f-mono); padding: 2px 6px; border-radius: 4px; background: rgba(20,21,24,.86); color: #fff; white-space: nowrap; border: 1px solid rgba(255,255,255,.15); }
.dimlab.ok { color: #6EF0A5; } .dimlab.over { color: #FF8A80; } .dimlab.left { color: #FFC857; }
table.meas td.show { width: 1%; }
.meas-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }

/* Sketch */
.sk-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.sk-bar select { flex: 1 1 200px; }
.sk-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.sk-tools button { font: 600 0.85rem var(--f-body); border: 1px solid var(--line); background: var(--raised); color: var(--ink); border-radius: var(--r); padding: 8px 12px; cursor: pointer; min-height: 40px; }
.sk-tools button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sk-canvas { height: min(62vh, 560px); min-height: 300px; background: var(--viewer-bg); border-radius: var(--r); border: 1px solid #2E3034; touch-action: none; overflow: hidden; }
.sk-canvas svg { width: 100%; height: 100%; display: block; }
.sk-grid { stroke: #2E3136; }
.sk-ref { fill: none; stroke: #8B939C; }
.sk-line { fill: none; stroke: var(--ink); }
.sk-line.on, .sk-cons.on { stroke: #6FB0FF; }
.sk-cons { stroke: color-mix(in srgb, var(--ink) 35%, transparent); stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.sk-pt { fill: var(--raised); stroke: var(--ink); }
.sk-pt.on { fill: #6FB0FF; }
.sk-pend { fill: #6FB0FF; }
.sk-snap { fill: none; stroke: #6EF0A5; }
.sk-meas { stroke: #6EF0A5; stroke-dasharray: 5 3; vector-effect: non-scaling-stroke; }
.sk-datum line { stroke: #6EB6FF; }
.sk-t { fill: #E9ECEF; font-family: var(--f-mono); }
.sk-t.ax { fill: #6EB6FF; }
.sk-msg { margin: 8px 0; font-family: var(--f-mono); font-size: 0.85rem; min-height: 1.4em; }
.sk-forms details { margin-bottom: 10px; }
.sk-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.sk-row label { display: inline-flex; gap: 4px; align-items: center; font-size: 0.85rem; }
.sk-row input { width: 6.5em; }
.sk-pts tr.on td { background: var(--accent-soft); }
.sk-pts tr[data-id] { cursor: pointer; }
.sketches { margin-top: 16px; }
.sk-thumb { background: #222326; border-radius: var(--r); height: 220px; margin: 6px 0; }
.sk-thumb svg { width: 100%; height: 100%; }
/* CAMstein lockup on the sign-in card (mark + wordmark + slogan) */
.logo-lock { gap: 14px; }
.logo-lock .mark-big { width: 72px; height: auto; display: block; }
.logo-lock .wordmark { font-size: 2.2rem !important; }
.logo-lock .slogan { display: block; margin-top: 6px; font-family: 'Montserrat', system-ui, sans-serif; font-size: 0.82rem; letter-spacing: 0.12em; color: var(--muted, #6b6b6b); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-lock .mark-big { filter: invert(1); } }
:root[data-theme="dark"] .logo-lock .mark-big { filter: invert(1); }
/* Simulator: what to show */
.gc-show { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 4px; }
.gc-show-l { font: 700 0.72rem var(--f-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted, #777); margin-right: 2px; }
.pathseg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.pathseg button { font: 600 0.75rem var(--f-body); border: 0; background: var(--surface); color: var(--ink); padding: 6px 10px; cursor: pointer; min-height: 32px; }
.pathseg button + button { border-left: 1px solid var(--line); }
.pathseg button.on { background: var(--accent); color: var(--on-accent); }
.gc-show .chip.check { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; }
.gc-show .chip.check input { margin: 0; accent-color: var(--accent); }
.gc-show .btn.sm { min-height: 32px; padding: 4px 12px; font-size: 0.78rem; }
.gc-view-wrap.noinfo .vtop, .gc-view-wrap.noinfo .legend { display: none; }
.logo-lock .stein { display: block; margin-top: 6px; font: 600 0.72rem var(--f-body); letter-spacing: 0.06em; color: var(--ink); }
.logo-lock .slogan { margin-top: 4px; }
/* virtual program listing */
.gc-list .vrows { position: absolute; top: 0; left: 0; right: 0; min-width: max-content; will-change: transform; }
.gc-list .ln { height: 20px; line-height: 20px; }
/* "Opening the simulator" cover */
#busy-cover { position: fixed; inset: 0; z-index: 8000; display: grid; place-items: center; background: rgba(20, 21, 24, 0.72); backdrop-filter: blur(2px); }
#busy-cover[hidden] { display: none; }
#busy-cover .bc-in { display: grid; justify-items: center; gap: 14px; color: #F2F0EC; font: 600 0.95rem var(--f-body); text-align: center; padding: 24px; }
#busy-cover img { width: 56px; height: auto; filter: invert(1); animation: sp-fly 1.6s ease-in-out infinite; }
#busy-cover .sp-bar { width: 140px; height: 3px; border-radius: 3px; background: #3A3C41; overflow: hidden; }
#busy-cover .sp-bar i { display: block; width: 40%; height: 100%; background: #ECE6D8; border-radius: 3px; animation: sp-run 1.1s ease-in-out infinite; }
@keyframes sp-run { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes sp-fly { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { #busy-cover img, #busy-cover .sp-bar i { animation: none; } }
/* tool catalogue search */
.catfind input[type=search] { width: 100%; max-width: 520px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: var(--ink); font: 500 1rem var(--f-body); }
.catlist { list-style: none; margin: 10px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); max-width: 820px; }
.catlist li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--line-soft); }
.catlist li:first-child { border-top: 0; }

/* Workholding plan */
details.hold { margin: 18px 0; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
details.hold > summary { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; cursor: pointer; list-style: none; }
details.hold > summary::-webkit-details-marker { display: none; }
details.hold > summary h3 { margin: 0; }
details.hold > summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
details.hold:not([open]) > summary::after { content: '▸'; }
.fx-steps { margin: 10px 0 0 18px; padding: 0; display: grid; gap: 6px; }
.fx-batch { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.fx-batch h4 { margin: 0 0 6px; }
.kpis.sm dd { font-size: 1.05rem; }
.fx-draw { overflow-x: auto; margin: 10px 0; }
.fx-svg { width: 100%; max-width: 720px; height: auto; display: block; }
.fx-plate { fill: var(--line-soft); stroke: var(--muted); stroke-width: 1; }
.fx-part { fill: #6FB0FF33; stroke: #3d7cc4; stroke-width: 1; }
.fx-clamp { fill: #8a8f98; }
.fx-pin { fill: var(--ink, #222); }
.fx-datum { fill: #d23c3c; }
.fx-lbl { font: 600 var(--fs, 10px) 'IBM Plex Mono', ui-monospace, monospace; fill: var(--ink); }
.fx-sub, .fx-dim { font: calc(var(--fs, 10px) * .85) 'IBM Plex Sans', system-ui, sans-serif; fill: var(--muted); }
.grid-f.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.qty-f { max-width: 200px; margin: 10px 0 0; }

/* Send to machine */
.sendto { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.sendto h4, .sendbox h4, .linkbox h4 { margin: 0 0 8px; }
.sendbox { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.linkbox { margin: 22px 0; }
.boxes { list-style: none; padding: 0; margin: 8px 0 12px; display: grid; gap: 8px; }
.boxes li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.boxes li .btn { margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: #2e9e5b; box-shadow: 0 0 0 3px rgba(46, 158, 91, .18); }
.linkbox .btn-row input { flex: 1 1 180px; min-width: 0; }
.linksetup { margin: 10px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
pre.code { white-space: pre-wrap; word-break: break-all; font: 13px/1.45 'IBM Plex Mono', ui-monospace, monospace; background: var(--line-soft); padding: 8px 10px; border-radius: 8px; margin: 6px 0; }
.st.queued, .st.sending { color: var(--muted); }
.st.done { color: #2e9e5b; font-weight: 600; }
.st.failed { color: #c0392b; font-weight: 600; }
.st.cancelled { color: var(--muted); text-decoration: line-through; }
.sendbox .st, .linkbox .st { margin-left: 0; padding: 2px 6px; }
/* jobs: search + folders */
.jobtools { display: grid; gap: 10px; margin: 18px 0 14px; }
.jsearch { position: relative; display: block; }
.jsearch svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted, #777); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.jsearch input { width: 100%; box-sizing: border-box; font: inherit; font-size: 16px; padding: 12px 14px 12px 40px; border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); color: inherit; -webkit-appearance: none; appearance: none; }
.jsearch input:focus { outline: none; border-color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fchips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.fchips::-webkit-scrollbar { display: none; }
.fchip { flex: 0 0 auto; font: inherit; font-size: .9rem; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); color: inherit; cursor: pointer; white-space: nowrap; }
.fchip span { opacity: .55; margin-left: 4px; font-variant-numeric: tabular-nums; }
.fchip.on { background: var(--ink); color: var(--bg, #fff); border-color: var(--ink); }
.fchip.add { border-style: dashed; }
.fbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); }
.fbar-a { display: flex; gap: 6px; }
.jgroup { margin-bottom: 16px; }
.jg-h { display: flex; align-items: center; gap: 8px; width: 100%; font: inherit; background: none; border: 0; padding: 6px 2px 8px; color: inherit; cursor: pointer; text-align: left; }
.jg-h b { font-weight: 600; }
.jg-ic { width: 1em; opacity: .6; }
.jc-folder { font-weight: 500; }
.jl-none, .jl-count { margin: 4px 2px 12px; }
.jfolder { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.jfolder select { font: inherit; font-size: 16px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: inherit; max-width: 60vw; }

/* Lathe jobs and the turning library */
.seg.big label { flex: 1 1 220px; }
.seg.big span { text-align: left; padding: 12px 14px; font-weight: 500; line-height: 1.35; }
.seg.big span b { font-size: 1rem; }
.seg.big .small { color: inherit; opacity: 0.8; font-size: 0.82rem; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.mcard { position: relative; display: block; cursor: pointer; }
.mcard input { position: absolute; opacity: 0; width: 1px; }
.mcard > span { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.mcard input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--raised); }
.mcard input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.libtabs { display: flex; gap: 6px; margin: 4px 0 12px; }
.libtabs button { font: 600 0.88rem var(--f-body); border: 1px solid var(--line); background: var(--raised); color: var(--ink); border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.libtabs button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.libtabs button.on .muted { color: inherit; opacity: 0.75; }
.turn-svg svg { max-height: 300px; }
.sv-bore { fill: var(--bg); stroke: var(--ink); stroke-linejoin: round; }
.sv-bar { fill: none; stroke: var(--muted); stroke-dasharray: 2 1.5; }
.sv-cl { stroke: var(--bad); stroke-dasharray: 6 1.5 1.5 1.5; }
.sv-thr { stroke: var(--ink); }
.sv-knurl { fill: color-mix(in srgb, var(--ink) 25%, transparent); }
.sv-grv { fill: var(--warn); opacity: 0.55; }
.sv-cross { fill: color-mix(in srgb, var(--warn) 25%, transparent); stroke: var(--warn); stroke-dasharray: 1.5 1; }
table.turnrows tr.f-thread td:first-child, table.turnrows tr.f-groove td:first-child, table.turnrows tr.f-undercut td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.turnrows select { width: 7.2em; }
table.turnrows input.sm, table.ft input.sm { width: 4.6em; }
table.turnrows td.small { max-width: 16em; }
table.turnplan tr.miss td { background: var(--bad-bg); }
table.turnplan tr.opt td { color: var(--muted); }
table.turnplan select { max-width: 15em; }
.mono { font-family: var(--f-mono); }
table.tools input.mid { width: 8.5em; }
.seg.big span span { display: inline; border: 0; padding: 0; background: none; color: inherit; font-weight: 400; }
.seg.big input:checked + span span { background: none; color: inherit; }
.sv-target { fill: none; stroke: var(--line); stroke-linejoin: round; }
.sv-sim { fill: none; stroke: var(--ok); }
.sv-sim.in { stroke: var(--feed); }

/* ---------- pop-up pickers (long dropdowns) ---------- */
select.picked { display: none !important; }
.pick-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; text-align: left; font: 15px var(--f-body); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; cursor: pointer; }
.pick-btn:disabled { opacity: .6; cursor: default; }
.pick-btn .pick-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; opacity: .6; }
.pick-btn:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
html.pick-open, html.pick-open body { overflow: hidden; }
.pick-sheet { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.pick-back { position: absolute; inset: 0; background: rgba(15, 16, 18, .45); }
.pick-box { position: relative; width: min(560px, calc(100vw - 24px)); max-height: min(78vh, 720px); display: flex; flex-direction: column; gap: 8px; background: var(--raised); color: var(--ink); border-radius: 14px; padding: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.pick-h { display: flex; align-items: center; gap: 8px; }
.pick-h b { font-size: 16px; }
.pick-h b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-h .pick-n { color: var(--muted, #777); font-size: 13px; white-space: nowrap; }
.pick-q { font-size: 16px !important; }
.pick-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex: none; }
.pick-chips .chip { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 5px 11px; font: 13px var(--f-body); cursor: pointer; white-space: nowrap; }
.pick-chips .chip.on { background: var(--ink); color: var(--raised); border-color: var(--ink); }
.pick-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; min-height: 120px; }
.pick-g { position: sticky; top: 0; background: var(--raised); font: 600 12px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted, #777); padding: 10px 4px 4px; border-bottom: 1px solid var(--line); z-index: 1; }
.pick-g span { font-weight: 400; }
.pick-it { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft, #eee); padding: 11px 6px; font: 15px var(--f-body); color: var(--ink); cursor: pointer; }
.pick-it:hover, .pick-it:focus-visible { background: var(--surface); }
.pick-it.on { font-weight: 600; background: var(--surface); }
.pick-it.on::before { content: "✓ "; }
.pick-it:disabled { opacity: .45; }
.pick-none { padding: 18px 6px; color: var(--muted, #777); }
@media (max-width: 640px) {
  .pick-sheet { align-items: flex-end; }
  .pick-box { width: 100vw; max-height: 86vh; border-radius: 16px 16px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* phones: iOS zooms the page when a field under 16px gets focus, then the page slides sideways. Keep fields at 16px. */
@media (max-width: 760px) { input, select, textarea, .pick-btn { font-size: 16px; } }
html, body { overflow-x: clip; }
.finder { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 8px; }
.finder .chip span, .pick-chips .chip span { opacity: .6; margin-left: 2px; }
table.tools tr.tgrp th { text-align: left; background: var(--surface); font: 600 12px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 6px; }
table.tools tr.tgrp th span { font-weight: 400; }

/* ---------- less scrolling: section links, folding cards ---------- */
.subnav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 4px 0 14px; padding-bottom: 2px; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a { flex: none; text-decoration: none; color: var(--ink); border: 1px solid var(--line); background: var(--raised); border-radius: 999px; padding: 6px 12px; font-size: 14px; white-space: nowrap; }
.subnav a span { opacity: .6; }
.machines-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.machines-top h2 { margin: 0; }
.machines-sec { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
details.machine { padding: 0; gap: 0; }
details.machine > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; position: relative; padding-right: 40px; }
details.machine > summary::-webkit-details-marker { display: none; }
details.machine > summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); transition: transform .15s; }
details.machine[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
details.machine[open] > summary { border-bottom: 1px solid var(--line); }
.mh-t { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.mh-t b { font-size: 17px; }
.mh-k { color: var(--muted); font-size: 13px; }
.machine-b { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
details.msec { border: 1px solid var(--line-soft); border-radius: 10px; padding: 0 12px; }
details.msec > summary { cursor: pointer; padding: 10px 0; font: 600 13px var(--f-body); letter-spacing: .05em; text-transform: uppercase; }
details.msec[open] { padding-bottom: 12px; }
details.fold { border: 1px solid var(--line); border-radius: var(--r); background: var(--raised); padding: 0 14px; margin: 10px 0; }
details.fold > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
details.fold[open] { padding-bottom: 14px; }
.export { border: 2px solid var(--ink); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--raised); margin-top: 8px; }
.export.is-off { border: 1px dashed var(--line); }
.export h3 { margin: 0; }
.ex-ways { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.ex-way { border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ex-way h4 { margin: 0; }
.ex-way .sendbox { border: 0; padding: 0; margin: 0; background: none; }
.xf-sec { margin: 8px 0 22px; display: flex; flex-direction: column; gap: 10px; }
.xf-sec h2 { margin: 0; }
.xf-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.xf-item { border: 1px solid var(--line); border-radius: 10px; background: var(--raised); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.xf-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.rx-files { max-height: 50vh; overflow-y: auto; }
.rx-machine { display: flex; flex-direction: column; gap: 8px; }
details.machine { display: block; }
/* tool library: table on wide screens, folding cards on phones */
.tool-cards { display: none; }
@media (max-width: 760px) {
  #tool-table { display: none; }
  .table-wrap:has(#tool-table) { display: none; }
  .tool-cards { display: flex; flex-direction: column; gap: 6px; }
  .tool-cards h4.tgrp { margin: 10px 0 2px; font: 600 12px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .tool-cards h4.tgrp span { font-weight: 400; }
  .tcard { border: 1px solid var(--line); border-radius: 10px; background: var(--raised); padding: 0 12px; }
  .tcard > summary { cursor: pointer; padding: 10px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  .tcard .tc-d { color: var(--muted); font-size: 14px; flex-basis: 100%; }
  .tcard[open] { padding-bottom: 12px; }
  .tcard .field input, .tcard .field select { width: 100%; }
}
