:root {
  --bg: #f4f3f0;
  --panel: #ffffff;
  --ink: #1d1f22;
  --muted: #6b6f76;
  --line: #e2e0db;
  --accent: #e8742c;
  --accent-ink: #ffffff;
  --good: #2f8f5b;
  --warn: #c98a12;
  --bad: #c8412f;
  --info: #2f6fd1;
  --idle: #8a8f98;
  --bar-bg: #ecebe7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --panel: #1e2125;
    --ink: #eceef1;
    --muted: #9aa0a8;
    --line: #2e3237;
    --bar-bg: #2a2e33;
    --idle: #7b818a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; white-space: nowrap; flex: none; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; }
.logo::after { content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 3px; background: #fff; border-radius: 2px; }
nav { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 550; white-space: nowrap; }
nav a.active { background: var(--bg); color: var(--ink); }
.conn { margin-left: auto; flex: none; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.conn.ok::before { background: var(--good); }
.conn.bad::before { background: var(--bad); }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
h1 { font-size: 20px; margin: 4px 0 16px; }
h1:has(+ .subtitle) { margin-bottom: 2px; }
.subtitle { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }

.summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; display: flex; align-items: baseline; gap: 8px; }
.stat b { font-size: 20px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.attn b { color: var(--bad); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.attn { border-color: var(--bad); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.p-model { color: var(--muted); font-size: 13px; }
.pill { font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--bar-bg); color: var(--muted); text-transform: capitalize; }
.pill.printing, .pill.preparing { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.pill.finished { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.paused { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.failed, .pill.error, .pill.offline { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.job[hidden] { display: none; }
.job-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; background: var(--bar-bg); border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .6s ease; }
.job-meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.job-meta .pct { color: var(--ink); font-weight: 600; }

.temps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(104px, 100%), 1fr)); gap: 8px; margin: 0; }
.temps:empty { display: none; }
.temps div { background: var(--bg); border-radius: 8px; padding: 6px 10px; }
.temps dt { font-size: 12px; color: var(--muted); }
.temps dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.temps dd small { color: var(--muted); font-weight: 400; }

.errors:empty, .detail:empty { display: none; }
.errors { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 550; }
.detail { color: var(--muted); font-size: 13px; }

.cam { position: relative; border-radius: 8px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.cam img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cam-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ddd; font-size: 13px; text-align: center; padding: 12px; }
.cam-msg:empty { display: none; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.btn { font: inherit; font-size: 14px; font-weight: 550; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn[hidden] { display: none; }

.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Tables */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.res-finished { color: var(--good); font-weight: 600; }
.res-failed { color: var(--bad); font-weight: 600; }
.res-stopped, .res-cancelled { color: var(--warn); font-weight: 600; }
.res-printing { color: var(--info); font-weight: 600; }

/* Settings */
.section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.prow .meta { color: var(--muted); font-size: 13px; }
.prow .grow { flex: 1; }
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
label .help { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.note { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.form-error { color: var(--bad); font-size: 13px; margin-right: auto; align-self: center; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); padding: 20px; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h4 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* shared bits */
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.footnote { color: var(--muted); font-size: 13px; margin-top: 10px; }
.tag { font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); margin-left: 4px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--idle); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); flex: none; }
.sw.none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--ink); border-left: 3px solid var(--warn); border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--line); color: var(--ink); }
.icon-btn[hidden] { display: none; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 13px; font-weight: 550; padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.check.small { font-size: 13px; }

/* printer card additions */
.card-head .pill { margin-top: 2px; }
.transfer { background: color-mix(in srgb, var(--info) 9%, transparent); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.transfer[hidden] { display: none; }
.transfer .bar { margin: 6px 0 0; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slots:empty { display: none; }
.slot { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 550; padding: 3px 9px 3px 6px; border-radius: 99px; background: var(--bg); border: 1px solid transparent; white-space: nowrap; }
.slot small { color: var(--muted); font-weight: 400; }
.slot .slot-n { font-size: 11px; color: var(--muted); font-weight: 650; }
.slot.active { border-color: var(--accent); }
.slot.empty { color: var(--muted); font-weight: 400; }
.slot.low small { color: var(--bad); font-weight: 600; }
.slot.mismatch { border-color: var(--warn); border-style: dashed; }

/* Layerline */
td.mats { white-space: normal; }
span.mats { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.mats small { color: var(--muted); }
.mat { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

/* Spools & Vat */
.spools-grid { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.spool-head { display: flex; gap: 12px; align-items: center; }
.reel { width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, var(--panel) 0 6px, var(--line) 6px 8px, var(--c) 8px 17px, color-mix(in srgb, var(--c) 70%, #000) 17px 20px); }
.bottle { width: 30px; height: 40px; flex: none; border-radius: 6px 6px 8px 8px; position: relative; margin: 0 5px;
  background: linear-gradient(to top, var(--c) 0 72%, color-mix(in srgb, var(--c) 30%, var(--panel)) 72%); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 60%, #000); }
.bottle::before { content: ""; position: absolute; left: 8px; right: 8px; top: -6px; height: 7px; border-radius: 3px 3px 0 0; background: var(--muted); }
.spool .where { font-size: 13px; color: var(--muted); }
.spool .where b { color: var(--ink); }
.spool.low { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.spool.archived { opacity: .65; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 48px; height: 36px; padding: 2px; }
.radio-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 14px; }

/* Library */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel); text-align: center; cursor: pointer; margin-bottom: 14px; font-size: 15px; font-weight: 400; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.drop .link { color: var(--accent); font-weight: 600; text-decoration: underline; }
.drop .help { color: var(--muted); font-size: 13px; font-weight: 400; }
.upload { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; }
.upload.bad { border-color: var(--bad); color: var(--bad); }
.upload .bar.small { width: 160px; margin: 0; }
.files-grid { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.empty.wide { grid-column: 1 / -1; }
.file .thumb { position: relative; aspect-ratio: 4 / 3; border-radius: 8px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.file .thumb img { width: 100%; height: 100%; object-fit: contain; }
.plates-tag { position: absolute; right: 8px; top: 8px; font-size: 12px; font-weight: 650; background: var(--panel); border-radius: 99px; padding: 2px 8px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .job-meta { flex-wrap: wrap; align-items: center; }
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr)); gap: 8px; margin-bottom: 12px; }
.plate { font: inherit; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; padding: 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; text-align: left; font-size: 13px; }
.plate img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.plate small { color: var(--muted); }
.plate.on { border-color: var(--accent); }
.map { display: flex; flex-direction: column; gap: 8px; }
.map-row { display: grid; grid-template-columns: minmax(150px, auto) 20px minmax(0, 1fr) 16px; gap: 8px; align-items: center; }
.map-row select { width: 100%; min-width: 0; }
.map-from { display: inline-flex; align-items: center; gap: 6px; }
.map-from small { color: var(--muted); }
.map .arrow { color: var(--muted); text-align: center; }
.map-warn { grid-column: 3 / -1; color: var(--warn); font-size: 12.5px; font-weight: 550; }
.opts { grid-template-columns: repeat(auto-fit, minmax(150px, max-content)) !important; }
.btn:is(a) { text-decoration: none; display: inline-flex; align-items: center; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--info); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-radius: 10px; padding: 10px 14px; max-width: 360px; font-size: 14px; }
.toast.high, .toast.urgent { border-left-color: var(--bad); }
.toast b { display: block; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .conn { margin-left: 0; }
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  nav { overflow-x: auto; max-width: 100%; }
  nav a { white-space: nowrap; padding: 6px 10px; }
  .toolbar input[type=search] { min-width: 0; flex: 1 1 100%; order: -1; }
  .map-row { grid-template-columns: minmax(0, 1fr) 16px; }
  .map-row .arrow { display: none; }
  .map-row .map-from { grid-column: 1 / -1; }
  .map-warn { grid-column: 1 / -1; }
}

.link-btn { font: inherit; font-size: 13px; font-weight: 550; background: none; border: 0; padding: 6px 4px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--ink); }
.spool .actions { gap: 6px; }

/* Parts Bin */
.part-group { margin-bottom: 18px; }
.part-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.part-group h3 .muted { font-weight: 400; margin-left: 4px; }
.part-rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.part-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 110px auto; gap: 14px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.part-row:last-child { border-bottom: 0; }
.part-row.low { background: color-mix(in srgb, var(--bad) 5%, var(--panel)); }
.part-main { min-width: 0; }
.part-main b { font-weight: 600; }
.spec { color: var(--ink); background: var(--bg); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.part-qty { display: flex; align-items: center; gap: 8px; }
.qty { min-width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
.qty b { font-size: 17px; }
.qty small { color: var(--muted); }
.qbtn { font: inherit; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; }
.qbtn:hover { border-color: var(--muted); }
.part-status { text-align: center; }
.part-actions { display: flex; align-items: center; gap: 4px; }
.shop-group h4 { margin-top: 12px; }
.shop-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.shop-row .grow { display: flex; flex-direction: column; }
.hw-tag { font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 99px; padding: 0 7px; }
.hw-list { display: flex; flex-direction: column; gap: 6px; }
.hw-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.hw-row.short b { color: var(--bad); }
.file-parts .link-btn { padding: 0 2px; font-size: 13px; }
.fp-rows { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.fp-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto; gap: 8px; align-items: center; }
.fp-row select { min-width: 0; width: 100%; }
.bad { color: var(--bad); }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }

/* Labels */
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 6px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.pick { font-weight: 400; }
.pick .sw { margin-right: 2px; }
.preview-h { margin: 18px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.label-sheet { display: flex; flex-wrap: wrap; gap: 10px; }
.label { width: var(--lw); height: var(--lh); box-sizing: border-box; background: #fff; color: #000; display: flex; align-items: center; gap: 0.06in; padding: 0.06in 0.08in; border: 1px dashed #bbb; overflow: hidden; }
.label.blank { border-style: dotted; border-color: #ddd; }
.label .qr { height: min(calc(var(--lh) - 0.12in), calc(var(--lw) * 0.5)); width: auto; aspect-ratio: 1; flex: none; image-rendering: pixelated; }
.label-text { min-width: 0; font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.15; }
.label-text .big { font-weight: 700; font-size: min(0.2in, calc(var(--lh) / 4.2)); overflow-wrap: anywhere; }
.label-text .small { font-size: min(0.16in, calc(var(--lh) / 5.5)); margin-top: 0.03in; overflow-wrap: anywhere; }
@media print {
  body.print-labels { background: #fff; }
  body.print-labels .topbar, body.print-labels .no-print, body.print-labels #toasts { display: none !important; }
  body.print-labels main { padding: 0; max-width: none; margin: 0; }
  .label-sheet { gap: 0; }
  .label { border: 0; break-inside: avoid; }
  .label-sheet.as-roll { display: block; }
  .label-sheet.as-roll .label { break-after: page; page-break-after: always; }
  .label-sheet.as-sheet { display: block; }
  .label-sheet.as-sheet .label { border: 0; }
  .sheet-page { width: 8.5in; height: 11in; box-shadow: none !important; margin: 0 !important; break-after: page; page-break-after: always; }
  .label.blank { visibility: hidden; }
}

/* Scan pages (opened from a QR label on a phone) */
.scan { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.scan h1 { margin: 0; font-size: 26px; }
.scan-head { display: flex; align-items: center; gap: 16px; }
.scan-color { font-size: 18px; color: var(--muted); }
.reel.big { width: 72px; height: 72px; background: radial-gradient(circle, var(--panel) 0 11px, var(--line) 11px 14px, var(--c) 14px 30px, color-mix(in srgb, var(--c) 70%, #000) 30px 36px); }
.bottle.big { width: 46px; height: 64px; margin: 6px 13px 0; }
.scan-amount { font-size: 18px; }
.scan-amount b { font-size: 40px; font-variant-numeric: tabular-nums; }
.bar.big { height: 14px; margin: 0; }
.scan-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.btn.big { padding: 14px 16px; font-size: 16px; justify-content: center; text-align: center; }
.scan-qty { display: flex; align-items: center; justify-content: center; gap: 24px; margin: 10px 0; }
.scan-qty b { font-size: 48px; font-variant-numeric: tabular-nums; }
.qbtn.big { width: 64px; height: 64px; font-size: 30px; border-radius: 16px; }
.scan > .link-btn { align-self: center; }

@media (max-width: 640px) {
  .part-row { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 10px; }
  .part-thumb { grid-row: 1 / span 2; grid-column: 1; align-self: start; }
  .part-main { grid-row: 1; grid-column: 2; }
  .part-actions { justify-content: flex-end; }
  .part-qty { grid-row: 1; grid-column: 3; }
  .part-status { grid-column: 2; grid-row: 2; justify-self: start; text-align: left; }
  .part-actions { grid-row: 2; grid-column: 3; }
  .fp-row { grid-template-columns: minmax(0, 1fr) 70px; }
  .fp-row .link-btn { grid-column: 1 / -1; justify-self: end; }
}

/* Updates */
.pending-update { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.row-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-inline input { width: 140px; }
.bar.small { height: 6px; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.bar-fill.indeterminate { width: 35% !important; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }

/* Quotes */
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.pill.q-sent { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.pill.q-won { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.q-lost { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.quote-head { display: flex; align-items: center; gap: 14px; }
.quote-head h1 { margin: 4px 0 12px; }
.quote-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.quote-form .section { margin-bottom: 14px; }
.quote-form h3 .muted { font-weight: 400; }
.quote-side { position: sticky; top: 76px; }
.quote-price .big-price { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.quote-price .big-price .muted { font-size: 16px; font-weight: 400; }
.quote-price h4 { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.quote-price .warn { margin: 10px 0 0; }
.cost-bars { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.cb { display: grid; grid-template-columns: 96px 1fr 64px; gap: 8px; align-items: center; }
.cb b, .cb > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cb-bar { height: 8px; background: var(--bar-bg); border-radius: 99px; overflow: hidden; }
.cb-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.cb.total { border-top: 1px solid var(--line); padding-top: 6px; }
table.mini { font-size: 13px; }
table.mini th, table.mini td { padding: 5px 6px; }
.quote-actions { flex-wrap: wrap; margin-top: 14px; }
.q-lines { display: flex; flex-direction: column; gap: 8px; }
.q-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.q-line input[type=color] { width: 40px; height: 36px; padding: 2px; }
.q-line.fil > input[data-k=type] { width: 110px; }
.q-line select { min-width: 0; flex: 1 1 220px; }
.q-line.pack > input[data-k=name], .q-line.hw > input[data-k=name] { flex: 1 1 200px; }
.inline-num { flex-direction: row; align-items: center; gap: 4px; font-weight: 500; }
.inline-num input { width: 84px; }
.cost-printers { display: flex; flex-direction: column; gap: 12px; }
.cost-printer { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.cost-printer .rate { font-size: 17px; }
@media (max-width: 900px) {
  .quote-layout { grid-template-columns: 1fr; }
  .quote-side { position: static; order: -1; }
}
.pill.plain { text-transform: none; }

.diag { margin: 10px 0; }
.diag summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.diag-log { background: var(--bg); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap; max-height: 260px; overflow: auto; color: var(--ink); }

/* Letter sheets on screen: show the page so placement can be checked */
.label-sheet.as-sheet { display: flex; flex-direction: column; gap: 16px; }
.sheet-page { width: 8.5in; height: 11in; box-sizing: border-box; background: #fff; display: grid; align-content: start; box-shadow: 0 1px 6px rgba(0,0,0,.15); transform-origin: top left; }
@media screen and (max-width: 900px) { .sheet-page { zoom: 0.4; } }
@media screen and (min-width: 901px) { .sheet-page { zoom: 0.75; } }

.label-sheet.as-ptouch { display: flex; flex-wrap: wrap; gap: 14px; }
.pt-label { display: inline-block; background: #fff; padding: 10px 6px; border: 1px solid var(--line); border-radius: 6px; }
.pt-label img { display: block; height: 0.62in; width: auto; image-rendering: pixelated; }
.errors { white-space: pre-line; }

/* Camera: full-screen button on cards, and the camera view */
.cam-full { position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 8px; border: 0;
  background: rgba(0,0,0,.55); color: #fff; font-size: 18px; cursor: pointer; }
.cam-full:hover { background: rgba(0,0,0,.75); }
.cam img { cursor: zoom-in; }
body.camera-mode .topbar { display: none; }
body.camera-mode main { max-width: none; padding: 0; }
.cv { position: fixed; inset: 0; background: #000; color: #eee; display: flex; flex-direction: column; z-index: 10; }
.cv-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(20,20,22,.9); }
.cv-bar select { background: #222; color: #eee; border-color: #333; max-width: 60vw; }
.cv-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 38px; border-radius: 8px; border: 1px solid #333;
  background: #1b1b1d; color: #eee; font-size: 18px; text-decoration: none; cursor: pointer; }
.cv-btn:hover { background: #2a2a2d; }
.cv-btn[hidden] { display: none; }
.cv-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.cv-stage img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.cv-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #bbb; pointer-events: none; }
.cv-msg:empty { display: none; }
.cv-info { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; background: rgba(20,20,22,.9); font-size: 15px; }
.cv-info .bar { width: 160px; display: inline-block; margin: 0 8px 0 0; vertical-align: middle; }
.cv-prog { display: inline-flex; align-items: center; }
.cv-job { font-weight: 600; }
.cv-err { color: #ff8a7a; }
.cv-empty { margin: auto; text-align: center; line-height: 2.2; }

/* frame-rate picker in the camera view */
.cv-fps { display: inline-flex; align-items: center; border: 1px solid #333; border-radius: 8px; overflow: hidden; height: 38px; }
.cv-fps-btn { background: #1b1b1d; color: #bbb; border: 0; border-right: 1px solid #333; height: 100%; min-width: 40px; padding: 0 8px; font: inherit; font-size: 14px; cursor: pointer; }
.cv-fps-btn:hover { background: #2a2a2d; color: #fff; }
.cv-fps-btn.on { background: var(--accent, #e8742c); color: #fff; }
.cv-fps-unit { padding: 0 10px 0 8px; color: #888; font-size: 13px; }
@media (max-width: 520px) { .cv-fps-unit { display: none; } .cv-fps-btn { min-width: 34px; padding: 0 6px; } }
.cam-rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.cam-rates label { display: flex; flex-direction: column; gap: 6px; }
.copy-box { width: 100%; font: 14px/1.45 ui-monospace, Menlo, Consolas, monospace; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg, #fff); color: var(--ink); resize: vertical; margin: 8px 0 12px; }

/* Settings > Your business */
textarea { width: 100%; resize: vertical; line-height: 1.4; }
#brandform > label { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 12px; margin-top: 12px; }
.brand-grid label { display: flex; flex-direction: column; gap: 6px; }
.brand-logo { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 8px; }
.logo-box { width: 220px; height: 90px; border: 1px dashed var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 10px; background: #fff; text-align: center; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; min-width: 200px; }
.logo-btns .help { flex-basis: 100%; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type=color] { width: 52px; height: 38px; padding: 3px; cursor: pointer; }
.hex-input { width: 110px; font-family: ui-monospace, Menlo, Consolas, monospace; text-transform: uppercase; }
.hex-input.bad { border-color: #d64545; outline-color: #d64545; }
.brand-grid label > .help { margin-top: -2px; }

/* Settings: menu + one page at a time */
.settings-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 76px; }
.settings-nav a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.settings-nav a span { font-size: 12.5px; color: var(--muted); }
.settings-nav a:hover { background: var(--panel); border-color: var(--line); }
.settings-nav a.active { background: var(--panel); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.settings-page > .section:first-child { margin-top: 0; }
@media (max-width: 760px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-nav { display: none; }
}

/* quote statuses + invoices */
.pill.q-accepted { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill.q-invoiced, .pill.inv-sent, .pill.inv-open { background: color-mix(in srgb, #b7791f 16%, transparent); color: #b7791f; }
.pill.q-paid, .pill.inv-paid { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pill.inv-void { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }
.inv-box { display: flex; flex-direction: column; gap: 6px; }
.inv-box h4 { margin-top: 0; }
.inv-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.btn.wide { width: 100%; justify-content: center; }
.inv-total { display: flex; align-items: baseline; gap: 8px; margin: 14px 0 4px; font-size: 15px; }
.inv-total b { font-size: 20px; }
label.check { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-weight: 500; }
label.check .help { flex-basis: 100%; }
#payform details.more { margin-top: 12px; }
#payform details.more label { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
ol.steps { padding-left: 20px; display: grid; gap: 6px; line-height: 1.5; }
[hidden] { display: none !important; }
.pill.inv-open, .pill.inv-sent, .pill.inv-paid, .pill.inv-void, .pill.plain { text-transform: none; }

/* part photos */
.part-thumb { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 10px; border: 1px solid var(--line); background: #fff; padding: 0; overflow: hidden; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.part-thumb img { width: 100%; height: 100%; object-fit: contain; }
.part-thumb.empty { background: var(--bg); color: var(--muted); border-style: dashed; font-size: 18px; }
.part-thumb.empty:hover { color: var(--accent); border-color: var(--accent); }
.part-thumb.big { width: 84px; height: 84px; cursor: default; font-size: 26px; }
.pt-photo-row { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.photo-now { height: 220px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 10px; }
.photo-now img { max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-now.busy, .photo-cand.busy { opacity: .5; }
.photo-opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.photo-opts .help { flex-basis: 100%; }
.photo-find { display: flex; gap: 8px; }
.photo-find input { flex: 1; min-width: 0; }
.photo-title { margin: 12px 0 2px; }
.photo-cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(110px, 100%), 1fr)); gap: 8px; margin-top: 6px; }
.photo-cand { aspect-ratio: 1; border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 4px; cursor: pointer; }
.photo-cand img { width: 100%; height: 100%; object-fit: contain; }
.photo-cand:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.photo-cand.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.scan-photo { width: 160px; height: 160px; object-fit: contain; background: #fff; border-radius: 14px; border: 1px solid var(--line); margin: 6px auto 4px; display: block; }
@media (max-width: 560px) { .part-thumb { width: 44px; height: 44px; } .photo-now { height: 180px; } }

/* Library: search, tags, select */
.lb-uptags { margin: 10px 0 4px; }
.lb-uptags label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.lb-uptags input { flex: 1; min-width: 220px; max-width: 420px; }
.lb-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 10px; }
.lb-tools input[type=search] { flex: 1 1 260px; min-width: 0; }
.lb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip .n { opacity: .6; font-weight: 500; margin-left: 2px; }
.chip.tagchip { border-color: hsl(var(--tag-h) 50% 50% / .35); }
.chip.tagchip.on { background: hsl(var(--tag-h) 55% 42%); border-color: hsl(var(--tag-h) 55% 42%); color: #fff; }
#lb-count { margin: -2px 0 10px; }
.tag { --tag-l: 34%; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 99px;
  background: hsl(var(--tag-h, 220) 65% 50% / .13); color: hsl(var(--tag-h, 220) 55% var(--tag-l)); border: 1px solid transparent; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .tag { --tag-l: 74%; background: hsl(var(--tag-h, 220) 60% 55% / .2); } }
.file-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-height: 22px; }
.file-tags .tag[data-tag] { cursor: pointer; }
.file-tags .tag[data-tag]:hover { border-color: hsl(var(--tag-h) 55% 45% / .5); }
.tag.add { font: inherit; font-size: 12px; font-weight: 600; background: transparent; color: var(--muted); border: 1px dashed var(--line); cursor: pointer; padding: 4px 8px; border-radius: 99px; }
.tag.add:hover { color: var(--accent); border-color: var(--accent); }
.lb-bulk { position: sticky; top: 64px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.card.file { position: relative; }
.card.file.selecting { cursor: pointer; user-select: none; }
.card.file.selecting .actions, .card.file.selecting .file-parts .link-btn, .card.file.selecting .tag.add { pointer-events: none; opacity: .45; }
.card.file.picked { outline: 2px solid var(--accent); outline-offset: -2px; }
.pick { position: absolute; top: 10px; left: 10px; z-index: 2; width: 26px; height: 26px; border-radius: 8px; border: 2px solid #fff; background: rgba(0,0,0,.35);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.card.file.picked .pick { background: var(--accent); }
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.te-chips { display: contents; }
.te-input { flex: 1; min-width: 160px; border: 0 !important; background: transparent !important; outline: none !important; padding: 4px !important; }
.te-x { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; padding: 0 0 0 2px; opacity: .7; }
.te-x:hover { opacity: 1; }
.te-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.tag.sugg { font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.tag.sugg.used { outline: 2px solid hsl(var(--tag-h) 55% 45% / .6); }
.tag-manage { display: grid; gap: 2px; margin: 8px 0; }
.tm-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.link-btn.danger { color: var(--bad); }
@media (max-width: 560px) { .lb-tools select { flex: 1; } .lb-bulk { top: 100px; } }
.lb-uptags label { flex-direction: row !important; justify-content: flex-start; text-align: left; font-weight: 550; }
.lb-uptags { display: flex; justify-content: flex-start; }
.lb-uptags label { flex: 1; }
.lb-uptags input { width: auto; }

/* Parts Bin: tap the amount to type it */
.qty-edit { font: inherit; color: inherit; background: transparent; border: 1px dashed transparent; border-radius: 8px; padding: 4px 6px; cursor: text; }
.qty-edit:hover { border-color: var(--line); background: var(--bg); }
.qty-edit.editing { border-color: var(--accent); cursor: default; }
.qty-edit input { width: 76px; padding: 4px 6px; font-weight: 700; text-align: right; }

/* Quotes: choose the plates that make one set */
.plate-pick { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 12px 0 4px; background: var(--bg); }
.pp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 2px 4px 8px; }
.pp-row { display: grid !important; grid-template-columns: auto 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 6px 6px; border-radius: 10px; cursor: pointer; }
.pp-row + .pp-row { margin-top: 2px; }
.pp-row:hover { background: var(--panel); }
.pp-row.on { background: var(--panel); box-shadow: inset 3px 0 0 var(--accent); }
.pp-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.pp-thumb { width: 52px; height: 52px; border-radius: 8px; background: #fff; border: 1px solid var(--line); overflow: hidden; display: block; }
.pp-thumb img { width: 100%; height: 100%; object-fit: contain; }
.pp-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-weight: 400; }
.pp-copies { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.pp-copies input { width: 58px; padding: 5px 6px; text-align: center; }
.pp-copies.off { opacity: .35; }
.plate-pick .help { margin: 8px 4px 2px; }
@media (max-width: 560px) { .pp-row { grid-template-columns: auto 44px minmax(0, 1fr); } .pp-thumb { width: 44px; height: 44px; } .pp-copies { grid-column: 3; } .pp-copies .muted { display: none; } }

/* Settings > System */
.sys-drive { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg); }
.sys-drive-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.stack-bar { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--muted) 18%, transparent); }
.stack-bar span { display: block; height: 100%; }
.sb-vp { background: var(--accent); }
.sb-other { background: color-mix(in srgb, var(--muted) 70%, transparent); }
.sb-free { background: color-mix(in srgb, var(--muted) 18%, transparent); }
.sb-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); align-items: center; }
.sb-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ok-text { color: var(--good); } .warn-text { color: #b7791f; } .bad-text { color: var(--bad); }
.sys-data { width: 100%; max-width: 560px; }
.sys-data tr.total td { font-weight: 700; border-top: 1px solid var(--line); }
.sys-clean { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }
.sys-live { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; }
.sys-meter { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.sm-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.sm-bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 18%, transparent); overflow: hidden; }
.sm-bar i { display: block; height: 100%; background: var(--good); transition: width .4s; }
.sm-bar.warn i { background: #d69e2e; } .sm-bar.bad i { background: var(--bad); }
.sys-facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; color: var(--muted); }
.sys-facts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sys-live .warn, .sys-live .note { grid-column: 1 / -1; }

/* Settings > System: network */
.net-top, .nif-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 8px 18px; }
.net-top { margin-bottom: 12px; }
.net-top > div, .nif-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.net-top > div > span:first-child, .nif-grid > div > span:first-child { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.net-top b, .nif-grid b { font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.net-ifaces { display: grid; gap: 10px; }
.net-if { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.net-if.down { opacity: .7; }
.nif-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.net-if .note { margin: 10px 0 0; }

/* Printer errors, in plain words */
.errors { background: none !important; padding: 0 !important; color: inherit !important; white-space: normal !important; display: grid; gap: 6px; font-weight: 400 !important; }
.issue { --lv: var(--bad); border-left: 3px solid var(--lv); background: color-mix(in srgb, var(--lv) 9%, transparent); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4; }
.issue.lvl-warning { --lv: #c27c0e; } .issue.lvl-info { --lv: var(--info); }
.iss-text { font-weight: 600; color: var(--ink); }
.iss-lvl { display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--lv, var(--bad)); margin-right: 6px; }
.iss-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.iss-meta code, .tl-code code { font-size: 11.5px; background: color-mix(in srgb, var(--muted) 14%, transparent); padding: 1px 5px; border-radius: 4px; }
.iss-meta a, .tl-code a { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.iss-meta a:hover, .tl-code a:hover { text-decoration: underline; }
.iss-tip { display: block; margin-top: 4px; font-size: 12px; color: var(--ink); opacity: .85; }

/* Layerline */
.ll-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg-btn { font: inherit; font-weight: 600; font-size: 14px; padding: 8px 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg-btn.on { background: var(--ink); color: var(--panel); }
.ll-lookup { display: flex; gap: 8px; flex: 1 1 320px; justify-content: flex-end; }
.ll-lookup input { flex: 1; max-width: 380px; min-width: 0; }
.ll-lookup-res { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 12px; background: var(--panel); display: grid; gap: 6px; }
.ll-lookup-res .link-btn { justify-self: start; }
.ll-row.open td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.ll-chev { color: var(--muted); margin-left: 6px; }
.ev-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.ev-badge { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 14%, transparent); white-space: nowrap; }
.ev-badge.err { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
td small, .res-failed small, .res-cancelled small, .res-stopped small { display: block; color: var(--muted); font-size: 11.5px; }
.ll-detail > td { padding: 4px 14px 14px !important; background: color-mix(in srgb, var(--accent) 3%, transparent); }
.ll-facts { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.tl { list-style: none; margin: 6px 0 0; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; display: grid; grid-template-columns: 24px 76px minmax(0, 1fr); gap: 10px; align-items: start; padding: 5px 0; font-size: 13.5px; }
.tl-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); z-index: 1; }
.tl-item.k-error .tl-dot { border-color: var(--bad); color: var(--bad); }
.tl-item.k-error.lvl-warning .tl-dot { border-color: #c27c0e; color: #c27c0e; }
.tl-item.k-pause .tl-dot { border-color: #c27c0e; color: #c27c0e; }
.tl-item.k-cleared .tl-dot, .tl-item.k-resume .tl-dot { border-color: var(--good); color: var(--good); }
.tl-item.k-job .tl-dot { border-color: var(--accent); color: var(--accent); }
.tl-item.k-job.lvl-serious .tl-dot { border-color: var(--bad); color: var(--bad); }
.tl-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 3px; }
.tl-time small { display: block; font-size: 11px; opacity: .8; }
.tl-body { padding-top: 2px; min-width: 0; overflow-wrap: anywhere; }
.tl-item.k-error .tl-body, .tl-item.k-job .tl-body { font-weight: 600; }
.tl-item.k-stage .tl-body, .tl-item.k-speed .tl-body, .tl-item.k-cleared .tl-body { color: var(--muted); }
.tl-code { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-item .iss-lvl { --lv: var(--bad); }
.tl-item.lvl-warning .iss-lvl { --lv: #c27c0e; }
.tl-printer { color: var(--accent); }
.tl-job { font-size: 12px; margin-left: 6px; }
.ll-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 6px; }
.ll-filters .lb-tags { margin: 0; }
.ll-day { margin: 16px 0 2px; }
@media (max-width: 640px) { .tl-item { grid-template-columns: 24px 58px minmax(0, 1fr); gap: 8px; } .ll-lookup { justify-content: stretch; } .ll-lookup input { max-width: none; } }

.hms-list { margin: 6px 0 10px; padding-left: 18px; color: var(--ink); }
#sys-hms p { margin: 0 0 6px; }

/* Settings > Backups */
.bk-last { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.pill.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
#bkform > label.check { margin-top: 10px; }
.bk-table { width: 100%; max-width: 560px; }

.bk-alerts { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.bk-alerts label.check { margin-top: 6px; }
h4.alert-group { margin: 16px 0 0; font-size: 14px; }

/* Pre-print check */
.pf { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 12px; background: var(--bg); }
.pf-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pf-sum { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.pf-sum.ok { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.pf-sum.warn, .pf-sum.confirm { background: color-mix(in srgb, #c27c0e 16%, transparent); color: #b06d00; }
.pf-sum.stop { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.pf-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.pf-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 13.5px; }
.pf-ic { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: #fff; margin-top: 1px; }
.pf-ok .pf-ic { background: var(--good); } .pf-info .pf-ic { background: var(--info); font-style: italic; font-family: Georgia, serif; }
.pf-warn .pf-ic, .pf-confirm .pf-ic { background: #d08a12; } .pf-stop .pf-ic { background: var(--bad); }
.pf-body b { display: block; font-weight: 600; }
.pf-ok .pf-body b { font-weight: 500; color: var(--muted); }
.pf-body span { display: block; color: var(--muted); font-size: 12.5px; }
.pf-confirm { margin-top: 6px !important; font-weight: 600; color: var(--ink); }

/* Layerline photos */
.ll-job { display: inline-flex; align-items: center; gap: 10px; }
.ll-thumb { width: 44px; height: 33px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); flex: 0 0 auto; background: #111; }
.ll-photos { display: flex; gap: 10px; overflow-x: auto; padding: 10px 2px 8px; }
.ll-photo { flex: 0 0 auto; width: 168px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0; overflow: hidden; cursor: zoom-in; text-align: left; font: inherit; }
.ll-photo img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #111; }
.ll-photo span { display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; font-size: 12.5px; font-weight: 600; }
.ll-photo small { color: var(--muted); font-weight: 400; }
.ll-photo.take { cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 120px; border-style: dashed; color: var(--muted); }
.ll-photo.take:hover { color: var(--accent); border-color: var(--accent); }
.ll-photo.take .cam-ic { font-size: 22px; padding: 0; }
.pv-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.pv-stage { position: relative; margin: 10px 0; background: #111; border-radius: 10px; overflow: hidden; display: flex; justify-content: center; }
.pv-stage img { max-width: 100%; max-height: 70vh; display: block; }
.pv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 24px; cursor: pointer; }
.pv-nav.prev { left: 10px; } .pv-nav.next { right: 10px; }
.ph-kinds { padding-left: 26px; } .ph-kinds.off { opacity: .45; pointer-events: none; }
#ph-set label.check { margin-top: 6px; }

/* Queue */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.qu-auto { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin: 4px 0 14px; }
.switch { position: relative; width: 44px; height: 26px; flex: 0 0 auto; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: color-mix(in srgb, var(--muted) 35%, transparent); transition: background .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.qp-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; margin-bottom: 8px; }
.qp { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; }
.qp.ready { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); }
.qp.bed { border-color: color-mix(in srgb, #d08a12 60%, var(--line)); }
.qp-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.qp-mid { font-size: 13px; color: var(--muted); }
.qp-bed { align-self: flex-start; }
.qs-list, .qi-list { display: grid; gap: 8px; }
.qs { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--good) 45%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--good) 5%, var(--panel)); }
.qs-main .mat { margin-right: 6px; }
.qs-warn { font-size: 12.5px; color: #b06d00; margin-top: 2px; }
.qi { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.qi.held { opacity: .7; }
.qi-thumb { width: 56px; height: 56px; border-radius: 8px; background: #fff; border: 1px solid var(--line); overflow: hidden; display: block; }
.qi-thumb img { width: 100%; height: 100%; object-fit: contain; }
.qi-main { display: grid; gap: 4px; min-width: 0; }
.qi-title { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qi-note { font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); padding: 1px 7px; border-radius: 99px; }
.qi-bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 16%, transparent); overflow: hidden; display: flex; }
.qi-bar i { display: block; height: 100%; }
.qi-bar i.done { background: var(--good); } .qi-bar i.printing { background: var(--info); opacity: .7; }
.qi-acts { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; justify-content: flex-end; max-width: 220px; }
.qi-acts .icon-btn { width: 30px; height: 30px; font-size: 15px; }
.qu-done-h { margin-top: 18px; }
.qi-list.done .qi { opacity: .75; }
.qf-list { display: grid; gap: 6px; max-height: 55vh; overflow: auto; margin-top: 10px; }
.qf { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font: inherit; cursor: pointer; }
.qf:hover { border-color: var(--accent); }
.qf img, .qf > span:first-child { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 6px; }
.qf b { display: block; } .qf small { color: var(--muted); }
.qa-sum { padding: 8px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; margin: 6px 0 4px; }
.qa-printers { padding-left: 26px; } .qa-printers.off { opacity: .45; pointer-events: none; }
#qform-add > label.check, #qform-add .qa-printers label.check { margin-top: 6px; }
#qform-add > label:not(.check) { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
@media (max-width: 640px) {
  .qs, .qi { grid-template-columns: 44px minmax(0, 1fr); }
  .qi-thumb { width: 44px; height: 44px; }
  .qs > .btn, .qi-acts { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}

/* ---------- Maintenance ---------- */
.maint-chip { font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 99px; text-decoration: none; white-space: nowrap; margin-right: 6px; }
.maint-chip.due { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.maint-chip.soon { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.mt-chips { margin-bottom: 14px; }
.mt-printer { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.mt-head { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.mt-head h2 { margin: 0; font-size: 18px; }
.mt-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-stat { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 12px; border-radius: 10px; background: var(--bg); border: 1px solid transparent; font: inherit; color: inherit; text-align: left; }
.mt-stat b { font-size: 18px; font-variant-numeric: tabular-nums; }
.mt-stat span { font-size: 12px; color: var(--muted); }
.mt-stat.link { cursor: pointer; }
.mt-stat.link:hover { border-color: var(--line); }
.mt-pills { margin-left: auto; display: flex; gap: 6px; }
.mt-task { display: grid; grid-template-columns: auto minmax(0, 1fr) 190px auto; gap: 14px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.mt-task:last-child { border-bottom: 0; }
.mt-task.overdue { background: color-mix(in srgb, var(--bad) 5%, var(--panel)); }
.mt-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.mt-task.soon .mt-dot { background: var(--warn); }
.mt-task.overdue .mt-dot { background: var(--bad); }
.mt-bar { height: 5px; border-radius: 99px; background: var(--bg); margin-top: 6px; overflow: hidden; max-width: 420px; }
.mt-bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; }
.mt-task.soon .mt-bar i { background: var(--warn); }
.mt-task.overdue .mt-bar i { background: var(--bad); }
.mt-next { font-size: 13px; color: var(--muted); }
.mt-next.overdue { color: var(--bad); font-weight: 600; }
.mt-next.soon { color: var(--warn); font-weight: 600; }
.mt-acts { display: flex; gap: 10px; align-items: center; }
.mt-empty { padding: 16px; color: var(--muted); }
.mt-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 50%, var(--panel)); }
.mt-log h3 { margin-top: 26px; }
.mt-log-rows { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mt-log-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mt-log-row:last-child { border-bottom: 0; }
.mt-log-date { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mt-log-cost { font-weight: 650; font-variant-numeric: tabular-nums; }
.mt-part-row { align-items: end; }
.mt-part-row label.narrow { flex: 0 0 110px; }
@media (max-width: 700px) {
  .mt-task { grid-template-columns: auto minmax(0, 1fr); row-gap: 6px; }
  .mt-next, .mt-acts { grid-column: 2; }
  .mt-pills { margin-left: 0; }
  .mt-log-row { grid-template-columns: minmax(0, 1fr) auto; }
  .mt-log-date { grid-column: 1 / -1; }
}

/* ---------- Stock ---------- */
.sk-thumb { cursor: default; }
.sk-thumb.empty { font-weight: 700; font-size: 20px; color: var(--accent); border-style: solid; }
.sk-reasons { margin: 10px 0 14px; }
.sk-reasons .chip { cursor: pointer; }
td.neg { color: var(--bad); } td.pos { color: var(--good); }

/* ---------- Smart plugs & remote access ---------- */
.plug-line { font-size: 13px; color: var(--muted); margin-top: 4px; }
.howto { background: var(--bg); border-radius: 10px; padding: 10px 14px; margin: 10px 0 14px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: 8px 0 4px 18px; padding: 0; }
.sb-printer { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: var(--panel); }
.sb-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.sb-printer .check { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
input.tiny { width: 64px; padding: 4px 6px; }
.help.indent { margin: -2px 0 8px 26px; }
.remote-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; background: var(--bg); border-radius: 10px; margin: 10px 0; }
.remote-status a { word-break: break-all; }
ol.rsteps { padding-left: 20px; } ol.rsteps li { margin-bottom: 12px; line-height: 1.5; }
.cmd { display: flex; align-items: center; gap: 10px; margin: 6px 0; padding: 8px 12px; border-radius: 8px; background: #111827; overflow-x: auto; }
.cmd code { color: #e5e7eb; background: none; white-space: nowrap; font-size: 13px; }
.cmd .link-btn { color: #c4b5fd; margin-left: auto; flex: none; }
.help-list { padding-left: 20px; color: var(--muted); font-size: 14px; } .help-list li { margin-bottom: 6px; }
.settings-page { min-width: 0; }
.cmd { max-width: 100%; }
.cmd { overflow: hidden; }
.cmd code { flex: 1; min-width: 0; overflow-x: auto; padding-bottom: 2px; }

/* ---------- Orders ---------- */
.or-sync { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#or-chips { margin-bottom: 14px; }
.or-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.or-card.ready { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.or-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.or-name { font-size: 17px; }
.or-line { display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.2fr); gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.or-qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.or-status { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.or-status select { max-width: 200px; padding: 4px 8px; }
.or-card > p { padding: 0 16px; }
.or-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 50%, var(--panel)); }
.form-actions.left { justify-content: flex-start; flex-wrap: wrap; }
@media (max-width: 700px) { .or-line { grid-template-columns: 36px minmax(0, 1fr); } .or-status { grid-column: 2; } }

/* ---------- Reorder ---------- */
.ro-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ro-store { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.ro-store-head { display: flex; align-items: baseline; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 50%, var(--panel)); }
.ro-store-head h3 { margin: 0; font-size: 15px; }
.ro-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.ro-row:last-child { border-bottom: 0; }
.ro-main { min-width: 0; flex: 1 1 260px; }
.ro-qty { font-size: 13px; padding: 2px 8px; border-radius: 99px; background: var(--bg); margin-left: 4px; white-space: nowrap; }
.ro-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line); }
.ro-sec { margin: 22px 0 8px; }
.ro-skipped { margin: 14px 0; } .ro-skipped summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.ro-row.done { opacity: .8; }

/* ---------- Phone app feel ---------- */
.tabbar { display: none; }
.topbar { padding-top: max(12px, env(safe-area-inset-top)); }
@media (max-width: 700px) {
  .topbar nav { display: none; }
  .topbar { flex-wrap: nowrap; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
    background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
  .tabbar a .ti { width: 24px; height: 24px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .tab-scan .ti { width: 48px; height: 48px; margin-top: -20px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
  .tabbar .tab-scan .ti svg { width: 26px; height: 26px; }
  .tabbar .tab-scan.active { color: var(--accent); }
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  #toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.more-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 10px; margin: 12px 0; }
.more-item { display: block; padding: 14px; border-radius: 12px; background: var(--bg); color: var(--ink); text-decoration: none; font-weight: 600; text-align: center; }
html.standalone body { -webkit-user-select: none; user-select: none; overscroll-behavior-y: none; }
html.standalone input, html.standalone textarea, html.standalone [contenteditable], html.standalone .selectable { -webkit-user-select: text; user-select: text; }
.install-hint { position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 16; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.16); padding: 12px 14px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.install-hint .link-btn { margin-left: auto; }
.push-devices { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.push-dev { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.push-dev:last-child { border-bottom: 0; }

/* ---------- Scanner ---------- */
body.scanning .topbar, body.scanning .tabbar, body.scanning .install-hint { display: none; }
.scanner { position: fixed; inset: 0; z-index: 30; background: #000; color: #fff; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sc-frame { position: absolute; left: 50%; top: 46%; width: min(70vw, 70vh, 320px); aspect-ratio: 1; transform: translate(-50%, -50%); box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); border-radius: 18px; }
.sc-frame i { position: absolute; width: 34px; height: 34px; border: 4px solid #fff; }
.sc-frame i:nth-child(1) { left: -2px; top: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 18px; }
.sc-frame i:nth-child(2) { right: -2px; top: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 18px; }
.sc-frame i:nth-child(3) { left: -2px; bottom: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 18px; }
.sc-frame i:nth-child(4) { right: -2px; bottom: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 18px; }
.sc-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 14px; background: linear-gradient(rgba(0,0,0,.55), transparent); font-weight: 600; }
.sc-top span { flex: 1; text-align: center; }
.sc-close, .sc-torch { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #fff; text-decoration: none; border: 0; font-size: 18px; }
.sc-torch[hidden] { display: grid; visibility: hidden; }
.sc-msg { position: absolute; left: 16px; right: 16px; top: calc(46% + min(35vw, 35vh, 160px) + 24px); background: rgba(20,20,20,.85); border-radius: 12px; padding: 12px 14px; font-size: 15px; opacity: 0; transition: opacity .2s; pointer-events: none; text-align: center; }
.sc-msg.show { opacity: 1; pointer-events: auto; }
.sc-msg a { color: #fdba74; }
.sc-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; justify-content: center; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.sc-bottom .btn { background: rgba(255,255,255,.16); color: #fff; border-color: transparent; }
.scan-where { color: var(--muted); }
.scan-next { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
@media (min-width: 701px) { .scan-next { bottom: 16px; } }
nav a.touch-only { display: none; }
@media (pointer: coarse) { nav a.touch-only { display: inline-block; } }

/* ---------- Grouped top bar ---------- */
.mainnav { overflow: visible; align-items: center; gap: 2px; }
.nav-group { position: relative; }
.nav-btn { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 8px; border: 0; background: none; font: inherit; color: var(--muted); font-weight: 550; cursor: pointer; white-space: nowrap; }
.nav-btn:hover, .mainnav > a:hover { color: var(--ink); }
.nav-btn .caret { transition: transform .15s; opacity: .7; }
.nav-group.open .nav-btn .caret { transform: rotate(180deg); }
.nav-group.active .nav-btn, .nav-group.open .nav-btn { background: var(--bg); color: var(--ink); }
.nav-menu { display: none; position: absolute; top: calc(100% + 8px); left: 0; z-index: 25; min-width: 230px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.14); }
.nav-group.open .nav-menu { display: block; }
.nav-menu a { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav-menu a b { font-weight: 600; }
.nav-menu a span { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.nav-menu a:hover { background: var(--bg); }
.nav-menu a.active { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.gear { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--muted); }
.gear:hover { background: var(--bg); color: var(--ink); }
.gear.active { background: var(--bg); color: var(--accent); }
.conn { margin-left: auto; }
@media (max-width: 700px) { .gear { width: 34px; height: 34px; } }

/* ---------- Settings home and grouped sidebar ---------- */
.settings-home { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 18px; align-items: start; }
.sh-group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px 4px; }
.sh-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.sh-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 10px; padding: 12px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.sh-list a:last-child { border-bottom: 0; }
.sh-list a b { grid-column: 1; }
.sh-list a span { grid-column: 1; font-size: 13px; color: var(--muted); }
.sh-list a i { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-style: normal; font-size: 22px; color: var(--muted); }
.sh-list a:hover { background: var(--bg); }
.settings-back { display: inline-block; margin-bottom: 4px; color: var(--muted); text-decoration: none; font-weight: 600; }
.settings-back:hover { color: var(--ink); }
.settings-title { margin-top: 0; }
.settings-title .muted { font-weight: 500; }
.settings-nav { gap: 2px; }
.settings-nav .sn-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; margin: 14px 12px 4px; }
.settings-nav .sn-group:first-child { margin-top: 0; }
.settings-nav a { padding: 7px 12px; font-weight: 550; }
@media (max-width: 700px) { .settings-title .muted { display: none; } }
.more-head { grid-column: 1 / -1; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; margin-top: 6px; }
.more-head:empty { border-top: 1px solid var(--line); margin: 6px 0 0; }

/* ---------- Plate variants ---------- */
.sk-plate-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.sk-plate { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.sk-plate:last-child { border-bottom: 0; }
.sk-plate.off { opacity: .55; }
.sk-plate img, .sk-pthumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--bg); flex: none; }
.sk-pmain { flex: 1 1 180px; min-width: 0; }
.sk-pcs { display: flex; flex-direction: row !important; align-items: center; gap: 6px; font-size: 13px; }
.sk-pcs input { width: 70px; }
.sk-plate-add select { max-width: 100%; }
.pq-best { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin: 8px 0; }
.pq-table { width: 100%; font-size: 13px; }
.qu-choice { margin: 4px 0 14px; } .qu-choice summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.qu-choice form { margin-top: 10px; }
.tls-urls { margin: 10px 0; }
.tls-urls .cmd a.link-btn { color: #c4b5fd; flex: none; }
.tls-qr { display: flex; gap: 16px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.tls-qr img { background: #fff; border-radius: 10px; padding: 6px; border: 1px solid var(--line); }
#tls-devs { margin: 6px 0 4px; }

/* ---------- v0.25: sign-in, logins, remote access ---------- */
body.signing-in > header, body.signing-in > main, body.signing-in .tabbar, body.signing-in .install-hint { display: none !important; }
#signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; padding-top: max(24px, env(safe-area-inset-top)); background: var(--bg); }
.si-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.si-card h1 { font-size: 22px; margin: 4px 0 0; }
.si-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.si-card input { font-size: 16px; }
.si-card .btn.big { padding: 12px; font-size: 16px; margin-top: 4px; }
.si-logo { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.si-logo img { border-radius: 12px; }
.si-forgot { margin: 4px 0 0; }
.sh-me { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; margin: 0 0 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.sh-me.warn { border-left: 3px solid var(--warn); margin-bottom: 16px; font-size: 14px; }
.sh-me i { color: var(--muted); font-style: normal; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; flex-direction: row; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 400; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.choice input { margin-top: 3px; }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.narrow-form { max-width: 420px; }
.lg-table td { vertical-align: top; }
@media (max-width: 600px) { .hide-sm { display: none; } }
details.guide { border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; margin: 10px 0; background: var(--panel); }
details.guide > summary { cursor: pointer; padding: 12px 0; list-style-position: outside; }
details.guide[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
details.guide .rsteps { margin-top: 8px; }
.rm-h { margin-top: 28px; }
.tn-form, #dm-form { margin: 12px 0; }
.tn-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.tn-on { align-self: end; padding-bottom: 8px; }
.log-box { max-height: 220px; overflow: auto; background: #111827; color: #e5e7eb; padding: 10px; border-radius: 8px; font-size: 11px; white-space: pre-wrap; word-break: break-all; }
.dns-map { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0 12px; font-size: 15px; }
.dns-map code { padding: 6px 10px; border-radius: 6px; background: var(--bg); word-break: break-all; }
.remote-status { flex-direction: column; align-items: stretch; }
.remote-status .warn { margin: 6px 0 0; }

.signout-btn { border: 0; background: none; cursor: pointer; padding: 0; margin-left: -4px; }
.signout-btn[hidden] { display: none; }

/* ---------- v0.25.2: no sideways overflow or zooming on phones ---------- */
/* Grid cards can shrink below their content (long file names were pushing cards off screen). */
.grid > *, .files-grid > *, .spools-grid > *, .plates > *, .pick-list > *, .brand-grid > *, .sys-live > * { min-width: 0; }
select { max-width: 100%; }
label.inline { flex-wrap: wrap; }
label.inline select { min-width: 0; flex: 1 1 auto; }
/* iPhone zooms in when a box with text smaller than 16px gets focus, and stays zoomed. */
@media (max-width: 700px), (pointer: coarse) {
  input, select, textarea, .tn-form textarea { font-size: 16px; }
  input.tiny { font-size: 16px; }
}
.toolbar > label.inline { min-width: 0; max-width: 100%; }
.toolbar > label.inline select { width: 0; min-width: 0; flex: 1 1 160px; }
.toast { overflow-wrap: anywhere; }
