:root {
  --bg: #f4f6f8; --card: #fff; --line: #e1e5ea; --text: #1d2733; --muted: #6b7684;
  --primary: #1f6feb; --primary-d: #1859c4; --ok: #1a7f37; --err: #cf222e; --warn: #b26b00;
  --nav: #18212c; --nav-text: #c9d1d9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 14px; margin: 16px 0 8px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid #c7ced6; border-radius: 6px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid #9cc3ff; border-color: var(--primary); }
input:disabled { background: #f0f2f4; color: var(--muted); }

.shell { display: flex; min-height: 100vh; }
.nav { width: 200px; background: var(--nav); color: var(--nav-text); flex-shrink: 0; padding-bottom: 24px; }
.nav .brand { font-weight: 700; color: #fff; padding: 16px; font-size: 16px; }
.nav-group { margin-top: 8px; }
.nav-group-title { font-size: 11px; color: #7d8590; padding: 6px 16px; }
.nav a { display: block; color: var(--nav-text); padding: 7px 16px 7px 24px; }
.nav a:hover { background: #222d3a; }
.nav a.active { background: #2b3a4b; color: #fff; border-left: 3px solid var(--primary); padding-left: 21px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .who { color: var(--muted); }
.menu-btn { display: none; border: 0; background: none; font-size: 20px; cursor: pointer; }
.owner-switch { max-width: 200px; }
.spacer { flex: 1; }
.content { padding: 20px; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 12px; }
.back { color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions.end { justify-content: flex-end; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input:not([type]) { width: 200px; }

.btn { font: inherit; padding: 6px 14px; border-radius: 6px; border: 1px solid #c7ced6; background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #f3f5f7; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-d); }
.btn-danger { color: var(--err); }
.btn-sm { padding: 3px 8px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 8px; padding: 10px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.card .table-wrap { border: 0; border-radius: 0; margin: 0 -16px -16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f7f9fb; font-weight: 600; color: #444f5c; font-size: 13px; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f5f9ff; }
td.num, th.num { text-align: right; }
th.sel, td.sel { width: 32px; }
tfoot td { font-weight: 600; background: #fafbfc; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.neg { color: var(--err); font-weight: 600; }
.pos { color: var(--ok); }
.err { color: var(--err); }
.pad { padding: 20px; }
.warn-input { border-color: var(--warn); background: #fff8e6; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tone-blue { background: #ddeeff; color: #0b4fa8; }
.tone-amber { background: #fff1d6; color: #8a5300; }
.tone-green { background: #dcf5e3; color: #146c2e; }
.tone-red { background: #ffe0e0; color: #a40e26; }
.tone-gray { background: #eceff2; color: #59636e; }
.tone-purple { background: #ede4ff; color: #5b2bb5; }

.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; align-items: end; }
.form.narrow { max-width: 360px; grid-template-columns: 1fr; }
.form.inline { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide, .wide { grid-column: 1 / -1; }
.field .label { font-size: 13px; color: #444f5c; }
.field .hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
dl.info { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 8px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }

.lines table td { padding: 4px 6px; }
.lines input { width: 100%; }
.lines .btn { margin-top: 8px; }

.alert { padding: 10px 12px; border-radius: 6px; margin: 8px 0; }
.alert.error { background: #fff0f0; color: #8e1520; border: 1px solid #ffc9c9; }
.alert ul { margin: 6px 0 0; padding-left: 20px; max-height: 240px; overflow: auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; color: var(--text); }
.tile .n { font-size: 28px; font-weight: 700; }
.tile .l { color: var(--muted); }
.tile.warn { border-color: #ffb3b3; background: #fff6f6; }
.tile.warn .n { color: var(--err); }
.seg { display: inline-flex; border: 1px solid #c7ced6; border-radius: 6px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: #fff; padding: 6px 12px; cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }

.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 32, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 560px; max-width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px; }
.modal-body .table-wrap { margin-top: 8px; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; }
.toast { white-space: pre-line; background: #1f2933; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); cursor: pointer; }
.toast.ok { background: #14532d; }
.toast.error { background: #8e1520; }
.toast ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { width: 340px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- PDA ---------- */
.pda-mode .content { padding: 12px; }
.pda { max-width: 520px; margin: 0 auto; font-size: 16px; }
.pda h1 { font-size: 20px; margin-bottom: 8px; }
.pda-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.pda-btn { display: flex; align-items: center; justify-content: center; height: 100px; background: var(--primary); color: #fff; border-radius: 12px; font-size: 20px; font-weight: 600; }
.pda-field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; font-weight: 600; }
.scan { font-size: 20px; padding: 10px 12px; width: 100%; }
.pda-msg { white-space: pre-line; padding: 12px; border-radius: 8px; margin: 10px 0; font-size: 16px; font-weight: 600; }
.pda-msg.ok { background: #dcf5e3; color: #0f5323; }
.pda-msg.err { background: #ffe0e0; color: #8e1520; }
.pda-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pda-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; cursor: pointer; }
.pda-item:disabled { opacity: .5; }
.pda-lines { margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.pda-lines > div { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pda-lines > div.done { color: var(--ok); }
.pda-home { font-weight: 700; }
.topbar a { white-space: nowrap; }
.pda-mode .topbar { gap: 8px; padding: 6px 10px; }
.pda-mode .topbar .who, .pda-mode .topbar .pw-link { display: none; }
.pda-mode .owner-switch { max-width: 150px; }

/* ---------- 揀貨單列印 ---------- */
.picklist { background: #fff; color: #000; }
.picklist .toolbar { padding: 12px 20px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.pick-page { padding: 16px 24px; max-width: 900px; margin: 0 auto; }
.pick-page header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 8px; }
.pick-page h1 { font-size: 22px; }
.pick-page .meta { font-size: 13px; margin-top: 2px; }
.pick-page .code { text-align: center; }
.pick-page .code .mono { font-size: 13px; }
.pick-page th { background: #eee; color: #000; border-bottom: 1.5px solid #000; }
.pick-page td { border-bottom: 1px solid #999; padding: 7px 6px; }
.pick-page td.loc { font-weight: 700; font-size: 16px; white-space: nowrap; }
.pick-page td.big { font-size: 18px; font-weight: 700; }
.pick-page .box { display: inline-block; width: 16px; height: 16px; border: 1.5px solid #000; }
.pick-page footer { display: flex; justify-content: space-between; margin-top: 24px; font-size: 13px; }

/* ---------- 出貨單：中一刀 3 聯式（241×140mm，點陣印表機） ---------- */
.m1 { width: 229mm; height: 128mm; margin: 16px auto; padding: 6mm; background: #fff; color: #000; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  display: flex; flex-direction: column; font-size: 3.3mm; line-height: 1.35; font-family: "MingLiU", "PMingLiU", "Microsoft JhengHei", "Noto Sans TC", sans-serif; box-sizing: content-box; overflow: hidden; }
.m1 .mono { font-family: ui-monospace, Consolas, "Courier New", monospace; }
.m1-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: .5mm solid #000; padding-bottom: 1mm; }
.m1-company { font-size: 4.6mm; font-weight: 700; }
.m1-tel { font-size: 3mm; font-weight: 400; margin-left: 3mm; }
.m1-title { font-size: 6mm; font-weight: 800; letter-spacing: 1.5mm; }
.m1-page { font-size: 3mm; font-weight: 400; letter-spacing: 0; margin-left: 2mm; }
.m1-info { display: grid; grid-template-columns: 1.25fr 1fr 1.1fr 1fr; gap: .6mm 3mm; margin: 1.5mm 0; }
.m1-info span { display: inline-block; min-width: 9mm; margin-right: 1.5mm; color: #000; font-weight: 600; }
.m1-info .m1-wide { grid-column: span 3; }
.m1-info .m1-wide2 { grid-column: span 1; }
.m1-info .m1-full { grid-column: 1 / -1; }
.m1-items { width: 100%; border-collapse: collapse; table-layout: fixed; }
.m1-items th { border-top: .35mm solid #000; border-bottom: .35mm solid #000; padding: .6mm 1mm; text-align: left; font-weight: 700; }
.m1-items td { border-bottom: .15mm dotted #666; padding: .5mm 1mm; height: 5.6mm; box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m1-items .r { text-align: right; } .m1-items .c { text-align: center; }
.m1-items tfoot td { border-top: .35mm solid #000; border-bottom: none; height: 6mm; }
.m1-bottom { margin-top: auto; }
.m1-note { padding: .8mm 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m1-note span { font-weight: 600; margin-right: 2mm; }
.m1-sign { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 4mm; padding-top: 4mm; }
.m1-sign div { border-bottom: .3mm solid #000; padding-bottom: 1mm; font-weight: 600; }
.m1-legend { font-size: 2.7mm; margin-top: 1mm; }
@media print {
  .m1 { margin: 0; box-shadow: none; page-break-after: always; break-after: page; }
  .m1:last-child { page-break-after: auto; break-after: auto; }
}

/* ---------- 出貨單列印（A4 直式） ---------- */
.dn2-wrap { background: #e9ecef; min-height: 100vh; padding-bottom: 24px; }
.dn2-toolbar { background: #fff; position: sticky; top: 0; z-index: 2; padding: 10px 20px; display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); }
.dn2-toolbar label { display: inline-flex; gap: 6px; align-items: center; }
.dn2 { width: 190mm; min-height: 273mm; margin: 16px auto; padding: 10mm; background: #fff; color: #111; box-shadow: 0 2px 10px rgba(0,0,0,.12);
  display: flex; flex-direction: column; font-size: 3.4mm; line-height: 1.45; font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif; box-sizing: content-box; }
.dn2 .mono { font-family: ui-monospace, Consolas, Menlo, monospace; }
.dn2-head { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 3mm; border-bottom: .8mm solid #111; }
.dn2-company { font-size: 5.6mm; font-weight: 700; letter-spacing: .3mm; }
.dn2-sub { font-size: 3mm; color: #555; margin-top: .8mm; }
.dn2-title { text-align: right; }
.dn2-title-zh { font-size: 8mm; font-weight: 800; letter-spacing: 1.5mm; line-height: 1; }
.dn2-title-en { font-size: 2.6mm; letter-spacing: .9mm; color: #666; margin-top: 1mm; }
.dn2-copy { display: inline-block; margin-top: 1.5mm; font-size: 3mm; font-weight: 600; padding: .4mm 2.5mm; border: .3mm solid #111; border-radius: 1mm; }
.dn2-meta { width: 100%; border-collapse: collapse; margin-top: 3mm; }
.dn2-meta th, .dn2-meta td { border: .25mm solid #999; padding: 1.4mm 2mm; text-align: left; font-size: 3.3mm; }
.dn2-meta th { width: 17mm; background: #f1f3f5; font-weight: 600; color: #333; white-space: nowrap; }
.dn2-meta td.dn2-code { width: 58mm; text-align: center; vertical-align: middle; padding: 1mm; }
.dn2-meta td.dn2-code svg { width: 100%; height: 11mm; display: block; }
.dn2-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; margin-top: 3mm; }
.dn2-box { border: .25mm solid #999; }
.dn2-box-h { background: #f1f3f5; border-bottom: .25mm solid #999; padding: .8mm 2mm; font-size: 2.8mm; font-weight: 600; color: #444; letter-spacing: .3mm; }
.dn2-box-b { padding: 1.8mm 2.5mm; min-height: 15mm; }
.dn2-name { font-size: 4.4mm; font-weight: 700; margin-bottom: .5mm; }
.dn2-muted { color: #666; font-size: 3mm; }
.dn2-items { width: 100%; border-collapse: collapse; margin-top: 3.5mm; table-layout: fixed; }
.dn2-items th { background: #343a40; color: #fff; font-weight: 600; font-size: 3.1mm; padding: 1.6mm 1.5mm; border: .25mm solid #343a40; text-align: left; }
.dn2-items td { border: .25mm solid #adb5bd; padding: 1.6mm 1.5mm; vertical-align: middle; height: 8.5mm; box-sizing: border-box; word-break: break-all; }
.dn2-items tbody tr:nth-child(even) td { background: #f8f9fa; }
.dn2-items .r { text-align: right; } .dn2-items .c { text-align: center; }
.dn2-items tfoot td { border-top: .6mm solid #343a40; font-weight: 700; background: #f1f3f5; height: 9mm; }
.dn2-qty { font-size: 4.2mm; font-weight: 700; }
.dn2-small { font-size: 2.9mm; }
.dn2-spec { font-size: 2.8mm; color: #666; }
.dn2-note { display: flex; gap: 3mm; border: .25mm solid #999; padding: 2mm 2.5mm; margin-top: 3mm; min-height: 9mm; }
.dn2-note-h { font-weight: 600; color: #444; white-space: nowrap; }
.dn2-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; margin-top: auto; padding-top: 5mm; }
.dn2-sign-box { border: .25mm solid #999; padding: 2mm 2.5mm; height: 24mm; display: flex; flex-direction: column; }
.dn2-sign-h { font-weight: 600; color: #333; }
.dn2-sign-line { flex: 1; border-bottom: .25mm dashed #999; margin-bottom: 1.5mm; }
.dn2-sign-d { font-size: 2.8mm; color: #555; }
.dn2-foot { display: flex; justify-content: space-between; margin-top: 3mm; padding-top: 1.5mm; border-top: .25mm solid #ccc; font-size: 2.7mm; color: #666; }
@media print {
  .dn2-wrap { background: #fff; padding: 0; min-height: 0; }
  .dn2 { margin: 0; box-shadow: none; padding: 0; width: auto; min-height: 268mm; page-break-after: always; break-after: page; }
  .dn2:last-child { page-break-after: auto; break-after: auto; }
  .dn2-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dn2-items tbody tr:nth-child(even) td, .dn2-meta th, .dn2-box-h, .dn2-items tfoot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media print {
  html, body, #root { background: #fff !important; }
  .no-print { display: none !important; }
  .pick-page { page-break-after: always; padding: 0; max-width: none; }
  .pick-page:last-child { page-break-after: auto; }
  @page { size: A4; margin: 12mm; }
}

/* ---------- 入庫儲位標籤 ---------- */
.labels { background: #fff; color: #000; }
.labels-toolbar { padding: 12px 20px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.labels-toolbar .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.labels-toolbar .chip { border: 1px solid var(--line); border-radius: 14px; padding: 2px 10px; background: #f7f8fa; }
.label-sheet { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; background: #eef0f3; }
.lbl { background: #fff; border: 1px dashed #999; box-sizing: border-box; padding: 4mm; display: flex; flex-direction: column; gap: 1.5mm; overflow: hidden; font-size: 3.6mm; line-height: 1.25; }
.size-100x100 .lbl { width: 100mm; height: 100mm; }
.size-100x150 .lbl { width: 100mm; height: 150mm; }
.size-100x150 .lbl-loc { font-size: 24mm; }
.size-a4 .lbl { width: 92mm; height: 134mm; }
.size-a4 .lbl-loc { font-size: 20mm; }
.lbl-top, .lbl-foot { display: flex; justify-content: space-between; gap: 2mm; font-size: 3.2mm; }
.lbl-top { border-bottom: .4mm solid #000; padding-bottom: 1mm; }
.lbl-foot { margin-top: auto; border-top: .3mm solid #000; padding-top: 1mm; font-family: ui-monospace, Menlo, Consolas, monospace; }
.lbl-loc-cap { font-size: 3mm; color: #333; margin-bottom: -1.5mm; }
.lbl-loc { font-size: 13mm; font-weight: 800; letter-spacing: .5mm; line-height: 1; white-space: nowrap; font-family: Arial, Helvetica, sans-serif; }
.lbl-code svg { width: 100%; height: 11mm; display: block; }
.lbl-sku { font-size: 4.2mm; }
.lbl-cap { font-size: 3mm; color: #333; font-weight: 400; }
.lbl-ean { display: flex; align-items: center; gap: 3mm; }
.lbl-ean-code svg { height: 12mm; width: auto; max-width: 62mm; display: block; }
.lbl-break { font-size: 3.8mm; margin-top: -1mm; }
.lbl-qty { display: flex; justify-content: space-between; align-items: baseline; font-size: 5mm; }
.lbl-qty b { font-size: 8mm; }
.lbl-seq { white-space: nowrap; font-size: 5mm; font-weight: 700; border: .5mm solid #000; padding: .3mm 2mm; }
.lbl-meta { display: flex; flex-wrap: wrap; gap: 1mm 4mm; font-size: 3.6mm; }
@media print {
  .label-sheet { display: block; padding: 0; background: #fff; }
  .lbl { border: none; page-break-after: always; break-after: page; margin: 0; }
  .lbl:last-child { page-break-after: auto; break-after: auto; }
  .size-a4 .label-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
  .size-a4 .lbl { page-break-after: auto; break-after: auto; break-inside: avoid; border: .2mm dashed #bbb; }
  .size-a4 .lbl:nth-child(4n) { break-after: page; page-break-after: always; }
}

/* ---------- 收貨儲位行 ---------- */
.rcv-rows { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fafbfc; }
.rcv-head, .rcv-row { display: grid; grid-template-columns: 28px minmax(160px, 1fr) 150px 44px; gap: 8px; align-items: start; }
.rcv-head { font-size: 12px; color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.rcv-row { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rcv-no { padding-top: 8px; color: var(--muted); }
.rcv-loc .scan-wrap { display: flex; }
.rcv-loc .scan-wrap input, .rcv-qty input { width: 100%; box-sizing: border-box; }
.rcv-loc small, .rcv-qty small { display: block; margin-top: 2px; }
.rcv-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 8px; flex-wrap: wrap; }
.pda .rcv-head, .pda .rcv-row { grid-template-columns: 22px 1fr 84px 40px; gap: 6px; }

/* 明細必填欄 */
.lines .nowrap { white-space: nowrap; }
.lines .none-chk { display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.lines input.invalid { border-color: #d9480f; background: #fff4e6; }
.lines input:disabled { background: #f1f3f5; }

@media (max-width: 860px) {
  .nav { position: fixed; left: -220px; top: 0; bottom: 0; z-index: 20; transition: left .2s; overflow-y: auto; }
  .nav.open { left: 0; }
  .menu-btn { display: block; }
  .topbar .who { display: none; }
  .content { padding: 12px; }
  dl.info { grid-template-columns: max-content 1fr; }
}

/* ---------- 掃描欄位與鏡頭 ---------- */
.scan-wrap { display: flex; gap: 6px; align-items: stretch; width: 100%; }
.scan-wrap .scan { flex: 1; min-width: 0; }
.scan-cam { border: 1px solid #c7ced6; background: #fff; border-radius: 6px; font-size: 20px; padding: 0 10px; cursor: pointer; }
.field .scan-wrap .scan { font-size: 14px; padding: 6px 8px; }
.scanner { position: fixed; inset: 0; background: #000; z-index: 200; display: flex; flex-direction: column; color: #fff; }
.scanner-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); font-size: 17px; font-weight: 600; }
.scanner-head button { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-size: 16px; }
.scanner-view { position: relative; flex: 1; overflow: hidden; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 28%; border: 3px solid #4ade80; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.scanner-tip { position: absolute; left: 0; right: 0; top: calc(35% + 28% + 16px); text-align: center; font-size: 15px; }
.scanner-torch { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(28px, env(safe-area-inset-bottom)); background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 24px; padding: 12px 22px; font-size: 16px; }
.scanner-error { margin: 24px 16px; padding: 16px; background: #3b1218; border-radius: 10px; line-height: 1.6; }

/* ---------- 手機 App 外框 ---------- */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.app-head { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; background: var(--nav); color: #fff;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.app-back { width: 36px; font-size: 28px; line-height: 1; background: none; border: 0; color: #fff; padding: 0; }
.app-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.app-owner { width: 60px; text-align: right; font-size: 12px; color: #c9d1d9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-main { flex: 1; padding: 12px 12px 84px; }
.app-shell .pda > h1 { display: none; }
.app-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.app-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); font-size: 12px; }
.app-tabs a .ico { font-size: 20px; line-height: 1; }
.app-tabs a.on { color: var(--primary); font-weight: 600; }
.app-hello { font-size: 18px; font-weight: 600; margin: 4px 0 8px; }
.pda-btn .ico { display: block; font-size: 30px; margin-bottom: 4px; }
.pda-btn { flex-direction: column; }
.app-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }
.app-shell .login, .login { padding-top: max(16px, env(safe-area-inset-top)); }
@media (max-width: 480px) { .login form { width: 100%; } }
.rcv-rows .scan { font-size: 15px; padding: 6px 8px; }
.rcv-qty input { font-size: 15px; padding: 6px 8px; }
.pda .rcv-rows .scan, .pda .rcv-qty input { font-size: 18px; padding: 8px; }

/* 加工說明、照片 */
.wo-textarea { width: 100%; box-sizing: border-box; resize: vertical; line-height: 1.6; }
.wo-instructions { white-space: pre-wrap; line-height: 1.7; font-size: 15px; }
.wo-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.wo-photos figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.wo-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; cursor: zoom-in; background: #f3f5f7; }
.wo-photos figcaption { font-size: 13px; word-break: break-all; }
.wo-photos .row-actions { display: flex; gap: 6px; }
.wo-photos figure input { width: 100%; box-sizing: border-box; font-size: 13px; }
.wo-photo-add { border: 2px dashed #c7ced6; border-radius: 8px; display: flex; align-items: center; justify-content: center; min-height: 150px; cursor: pointer; color: var(--muted); }
.wo-photo-add:hover { background: #f8fafb; }
label.btn { display: inline-block; }
label.btn.is-busy { opacity: .5; pointer-events: none; }

.wo-sheet-instr { border: 1px solid #000; padding: 6px 10px; margin-top: 10px; font-size: 13px; }
.wo-sheet-instr div { white-space: pre-wrap; margin-top: 4px; line-height: 1.6; }

/* 紙本加工單 */
.wo-sheet h3 { font-size: 15px; margin: 14px 0 4px; }
.wo-sheet-product { margin: 6px 0 4px; border: 1.5px solid #000; }
.wo-sheet-product th { width: 90px; background: #eee; text-align: center; border: 1px solid #000; font-size: 13px; }
.wo-sheet-product td { border: 1px solid #000; padding: 6px 8px; }
.wo-sheet .wo-sheet-instr { font-size: 15px; min-height: 60px; }
.wo-sheet .wo-sheet-instr div { line-height: 1.8; }
.wo-sheet-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wo-sheet-photos figure { margin: 0; border: 1px solid #999; padding: 4px; break-inside: avoid; page-break-inside: avoid; }
.wo-sheet-photos img { width: 100%; max-height: 95mm; object-fit: contain; display: block; background: #fff; }
.wo-sheet-photos figcaption { font-size: 13px; margin-top: 3px; }
.wo-sheet-record { margin-top: 16px; border: 1.5px solid #000; break-inside: avoid; page-break-inside: avoid; }
.wo-sheet-record th { width: 80px; background: #eee; text-align: center; border: 1px solid #000; font-size: 13px; }
.wo-sheet-record td { border: 1px solid #000; height: 34px; }

/* 商品下拉選單 */
.sku-picker { position: relative; width: 100%; }
.sku-picker input { width: 100%; box-sizing: border-box; }
.sku-menu { position: absolute; z-index: 50; top: calc(100% + 2px); left: 0; min-width: 100%; width: max-content; max-width: 520px; max-height: 300px; overflow-y: auto;
  background: #fff; border: 1px solid #c7ced6; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.sku-opt { display: grid; grid-template-columns: minmax(80px, auto) 1fr auto; gap: 10px; padding: 7px 10px; cursor: pointer; font-size: 14px; align-items: baseline; }
.sku-opt.hi { background: #e8f0fe; }
.sku-opt small { color: var(--muted); font-size: 12px; }
.sku-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
.lines td { overflow: visible; }

.wo-sheet-line { font-size: 22px; line-height: 1.5; padding: 4px 2px; border-bottom: 1px solid #999; }
.wo-sheet-line b { font-size: 26px; letter-spacing: 1px; }
.wo-sheet-done { font-size: 15px; margin-left: 10px; }

.wo-scrap { background: #fff8e6; border: 1px solid #f0d58c; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.wo-scrap-row { display: flex; gap: 8px; }
.wo-scrap-row input { width: 120px; }

/* 瑕疵倉 */
.defect-fields { border-top: 1px dashed #e0c27a; padding-top: 6px; margin-top: 4px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.defect-on { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.defect-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.defect-row label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.defect-row input { width: 150px; }
.defect-chips { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.chip { border: 1px solid #c7ced6; background: #fff; border-radius: 14px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.chip.on { background: #fff1d6; border-color: #d9a400; font-weight: 600; }
.row-actions { display: flex; gap: 6px; align-items: center; }

.class-bill { width: auto; min-width: 360px; }
.class-bill th, .class-bill td { padding: 4px 14px 4px 0; text-align: left; }

/* 新版提示列 */
.update-bar { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 1000; background: #1e293b; color: #fff;
  padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); }
.update-bar button { background: #3b82f6; color: #fff; border: 0; border-radius: 6px; padding: 6px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }

/* 客戶登入帳號小表格 */
.mini-table { width: 100%; margin: 4px 0 8px; }
.mini-table th, .mini-table td { padding: 4px 6px; text-align: left; font-size: 13px; }
.mini-table input:not([type=checkbox]) { width: 100%; min-width: 90px; padding: 5px 7px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 13px; }
.mini-table td.nowrap { white-space: nowrap; display: flex; gap: 4px; align-items: center; }

/* 通知鈴鐺 */
.bell-wrap { position: relative; display: inline-flex; }
.bell { position: relative; background: none; border: 0; font-size: 18px; cursor: pointer; padding: 4px 6px; line-height: 1; }
.bell-badge { position: absolute; top: -4px; right: -6px; background: #dc2626; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 5px; font-weight: 600; }
.bell-panel { position: absolute; right: 0; top: 34px; width: 340px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 900; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #eef2f7; position: sticky; top: 0; background: #fff; }
.bell-head button { background: none; border: 0; color: #2563eb; cursor: pointer; font-size: 13px; }
.bell-empty { padding: 18px; color: #94a3b8; text-align: center; font-size: 13px; }
.bell-item { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.bell-item:hover { background: #f8fafc; }
.bell-item.unread { background: #eff6ff; }
.bell-title { font-weight: 600; font-size: 13px; }
.bell-body { font-size: 13px; color: #334155; margin-top: 2px; }
.bell-time { font-size: 11px; color: #94a3b8; margin-top: 3px; }

/* 客戶停用時，登入帳號整區反灰 */
.mini-table.off tbody { opacity: .45; }
.mini-table.off tbody input { background: #f1f5f9; }

/* 儲位看板：使用率長條（單一顏色；75% 以上黃、90% 以上紅，並附文字） */
.ubar { display: inline-flex; align-items: center; gap: 8px; min-width: 150px; vertical-align: middle; }
.ubar-track { flex: 1; height: 8px; background: #e8edf3; border-radius: 4px; overflow: hidden; min-width: 80px; }
.ubar-fill { display: block; height: 100%; background: #2563eb; border-radius: 4px; }
.ubar-fill.warn { background: #d97706; }
.ubar-fill.crit { background: #dc2626; }
.ubar-pct { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; color: #334155; }
.tile-bar { display: block; margin: 6px 0 4px; }
.ulevel { font-size: 13px; font-weight: 600; margin-left: 8px; }
.ulevel.warn { color: #b45309; }
.ulevel.crit { color: #dc2626; }
.board-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 18px; }

/* 儲位看板：可點的方塊、空儲位清單 */
.tile-btn { text-align: left; cursor: pointer; font: inherit; color: inherit; }
.tile-btn:hover { border-color: #2563eb; }
.tile-btn .l { color: #2563eb; }
a.link { color: #2563eb; cursor: pointer; text-decoration: underline; }
.loc-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 55vh; overflow: auto; padding: 2px; }
.loc-chip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; }
.loc-chip.own { border: 2px solid #64748b; }

/* 版權字樣（表頭下方、登入頁） */
.copyright { font-size: 12px; color: var(--muted); text-align: center; }
.top-copy { padding: 4px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.app-copy { font-size: 11px; padding: 2px 8px; }
.login-col { flex-direction: column; gap: 16px; }
.loc-chip.rsv { border-style: dashed; color: var(--muted); }
.lbl-loc-blank { font-size: 5mm; padding: 4mm 0; }
.text-warn { color: #b45309; }
