[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f9fafb; --line: #e3e6ea; --line-strong: #cfd4da;
  --ink: #1b2430; --ink-2: #4a5563; --ink-3: #7a8594;
  --nav: #1f2a37; --nav-ink: #c9d1db; --nav-active: #e9c46a;
  --brand: #2f5d8a; --brand-ink: #fff; --brand-soft: #e7eef6;
  --good: #1f8a4c; --good-soft: #e3f4ea; --warn: #b7791f; --warn-soft: #fbf1dc;
  --bad: #c0392b; --bad-soft: #fbe6e3; --info: #2f5d8a; --info-soft: #e7eef6; --muted-soft: #eef0f3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --surface: #19212a; --surface-2: #1e2731; --line: #2b3643; --line-strong: #3a4757;
    --ink: #e6ebf1; --ink-2: #b5bfcb; --ink-3: #8592a2;
    --nav: #0c1116; --brand: #5b8fc4; --brand-soft: #1f3044;
    --good: #4cc27f; --good-soft: #173526; --warn: #e2a948; --warn-soft: #3a2d14;
    --bad: #ef6b5b; --bad-soft: #3d1c19; --info: #7fb0e0; --info-soft: #1f3044; --muted-soft: #252f3a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.08rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brandmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; }
.brandmark small { display: block; font-weight: 400; color: var(--nav-ink); font-size: .75rem; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 8px; color: var(--nav-ink); margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { background: rgba(233,196,106,.14); color: var(--nav-active); }
.nav .badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: .72rem; padding: 1px 7px; font-weight: 700; }
.side .me { margin-top: 18px; padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.side .me select { width: 100%; margin-top: 4px; background: #2a3746; color: #fff; border-color: #3a4757; }
.side .me button { margin-top: 8px; width: 100%; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 24px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); border-radius: 99px; padding: 5px 12px; font-size: .85rem; cursor: pointer; font-weight: 500; }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.view { padding: 22px 24px 60px; max-width: 1300px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .sub { color: var(--ink-3); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.menu-btn { display: none; }
.feed.scroll { max-height: 640px; overflow-y: auto; }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 16px 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.stack > * + * { margin-top: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; }
a.tile:hover { text-decoration: none; border-color: var(--line-strong); }
.tile .k { color: var(--ink-3); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile .v { font-size: 1.75rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .d { color: var(--ink-3); font-size: .82rem; }
.tile.bad .v { color: var(--bad); } .tile.warn .v { color: var(--warn); } .tile.good .v { color: var(--good); }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.empty { padding: 26px; text-align: center; color: var(--ink-3); }

/* pills, swatches */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); vertical-align: -1px; margin-right: 6px; }
.label { font-weight: 600; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--muted-soft); color: var(--ink-2); letter-spacing: .03em; }

/* forms */
label.f { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }
label.f > span.hint { font-weight: 400; color: var(--ink-3); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; width: 100%; margin-top: 4px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; margin: 0; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: .9rem; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 4px 0 14px; }
.seg label { border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--surface); }
.seg label b { display: block; }
.seg label span { font-size: .8rem; color: var(--ink-3); }
.seg input { display: none; }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.checklist { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.checklist .item { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.checklist .item:last-child { border-bottom: 0; }
.checklist .item.flag { background: var(--bad-soft); }
.checklist .item .note { grid-column: 1 / -1; }
.toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.toggle button { border: 0; background: var(--surface); padding: 6px 10px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink-3); }
.toggle button + button { border-left: 1px solid var(--line-strong); }
.toggle button.yes.on { background: var(--good); color: #fff; }
.toggle button.no.on { background: var(--bad); color: #fff; }
.formcard { max-width: 820px; }
.callout { border-radius: 10px; padding: 12px 14px; background: var(--info-soft); color: var(--ink); border: 1px solid var(--line); margin-bottom: 14px; font-size: .9rem; }
.callout.bad { background: var(--bad-soft); }
.callout.warn { background: var(--warn-soft); }
.callout.good { background: var(--good-soft); }

/* alerts list */
.alert { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: start; }
.alert:last-child { border-bottom: 0; }
.alert .bar { align-self: stretch; border-radius: 4px; }
.alert.high .bar { background: var(--bad); } .alert.medium .bar { background: var(--warn); } .alert.low .bar { background: var(--line-strong); }
.alert .t { font-weight: 600; }
.alert .d { color: var(--ink-3); font-size: .85rem; }

/* bars */
.hbar { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; margin: 6px 0; font-size: .85rem; }
.hbar .track { height: 14px; background: var(--muted-soft); border-radius: 4px; overflow: hidden; display: flex; gap: 2px; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--brand); position: relative; }
.stacked .fill { border-radius: 0; }
.stacked .fill:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
[data-tip] { cursor: default; }
#tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 6px; font-size: .8rem; z-index: 100; display: none; max-width: 260px; }

/* activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 9px 16px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--ink-3); font-size: .76rem; }

/* kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.col h3 { display: flex; justify-content: space-between; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.pocard { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 8px; display: block; color: inherit; font-size: .86rem; }
.pocard:hover { text-decoration: none; border-color: var(--line-strong); }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 9px 14px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 160px; margin: 0; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,20,.5); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast .t { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; margin-top: 8px; box-shadow: var(--shadow); font-weight: 500; }
#toast .t.err { background: var(--bad); color: #fff; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .view { padding: 16px 16px 60px; }
  .g2, .g3, .g-main { grid-template-columns: minmax(0,1fr); }
  .hbar { grid-template-columns: 80px 1fr 56px; }
  .hide-sm { display: none; }
  .topbar { position: static; flex-wrap: nowrap; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip { flex: none; }
  .checklist .item { grid-template-columns: 1fr 1fr; }
  .checklist .item > div:first-child { grid-column: 1 / -1; }
  .checklist .item .toggle { display: flex; }
  .checklist .item .toggle button { flex: 1; padding: 9px 6px; }
  .tiles { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- QR scan ---------- */
.scan { max-width: 520px; margin: 0 auto; }
.scan-kit { display: flex; gap: 12px; align-items: center; }
.scan-kit .sw { width: 34px; height: 34px; border-radius: 8px; margin: 0; flex: none; }
.scan-label { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.scan-me { margin-top: 8px; }
.scan-ok { display: flex; gap: 14px; align-items: center; margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--info-soft); border: 1px solid var(--line); font-size: 1.05rem; }
.scan-ok .big { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; color: #fff; background: var(--info); flex: none; }
.scan-ok.in { background: var(--good-soft); } .scan-ok.in .big { background: var(--good); }
.scan-ok.pending .big { background: var(--ink-3); }
.scan details.card summary { cursor: pointer; }
.scan-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; }
.bigbtn { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; padding: 16px; font-size: 1.05rem; margin-top: 12px; text-align: center; white-space: normal; }
.bigbtn span { font-size: .85rem; font-weight: 500; opacity: .9; }
.bigbtn.secondary { color: var(--ink-2); }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.who .btn { justify-content: center; padding: 14px 10px; font-size: .95rem; white-space: normal; flex-direction: column; }
.tag.qr { background: var(--info-soft); color: var(--info); }

/* ---------- printable labels ---------- */
.labels { display: flex; flex-wrap: wrap; gap: 0.12in; }
.lbl { background: #fff; color: #111; border: 1px dashed #999; border-left: 0.14in solid var(--c, #999); display: flex; gap: 0.1in; align-items: center; padding: 0.08in 0.1in; break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.lbl.kit { width: 3.5in; height: 1.9in; }
.lbl.kit img { width: 1.55in; height: 1.55in; }
.lbl.part { width: 2.6in; height: 1.1in; }
.lbl.part img { width: 0.9in; height: 0.9in; }
.lbl .lt { min-width: 0; }
.lbl .t1 { font-weight: 800; font-size: 17pt; line-height: 1.05; }
.lbl .t2 { font-weight: 700; font-size: 13pt; }
.lbl .t3 { font-size: 7.5pt; color: #333; }
.lbl .t4 { font-size: 6.5pt; color: #666; margin-top: 2px; word-break: break-all; }
.lbl.part .t1 { font-size: 15pt; margin: 1px 0; }
@media print {
  @page { margin: 0.35in; }
  body, html { background: #fff !important; }
  .side, .topbar, .no-print, #toast, #tip { display: none !important; }
  .shell { display: block; }
  .view { padding: 0; max-width: none; }
  .lbl { border-style: solid; border-color: #ccc; border-left-color: var(--c, #999); }
}

/* ---------- piece-by-piece scanning ---------- */
.piece-scan { margin-top: 12px; display: grid; gap: 10px; }
.pprompt { font-size: 1.15rem; }
.pbar { height: 8px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; }
.pbar > div { height: 100%; background: var(--good); width: 0; transition: width .25s; }
.cam { position: relative; border-radius: 12px; overflow: hidden; background: #0c1116; aspect-ratio: 4 / 3; max-width: 100%; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-frame { position: absolute; inset: 18% 22%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.cam-msg { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: .85rem; text-shadow: 0 1px 2px rgba(0,0,0,.6); padding: 0 10px; }
.plist { display: grid; gap: 4px; }
.pc { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: .92rem; }
.pc .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
.pc.ok { background: var(--good-soft); }
.pc.ok .dot { background: var(--good); border-color: var(--good); color: #fff; }
.lbl .t5 { font-size: 7pt; font-weight: 800; letter-spacing: .12em; color: #fff; background: #111; display: inline-block; padding: 1px 5px; border-radius: 3px; margin-bottom: 3px; }
