/* ── 門市叫貨／工廠收單（store.html、factory.html）── */
:root {
  --bg: #f3ece0;
  --surface: #faf6ef;
  --surface-2: #fffdf8;
  --border: #e8ddc8;
  --text: #1a0f08;
  --text-2: #5c4a3a;
  --muted: #a8916f;
  --accent: #8b1a1a;
  --accent-hover: #b5312a;
  --gold: #c9a84c;
  --gold-light: #f5ecd4;
  --ok: #2d7a4f;
  --info: #2563eb;
  --warn: #b45309;
  --shadow: 0 1px 3px rgba(26,15,8,0.07), 0 1px 2px rgba(26,15,8,0.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Noto Sans TC', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* Top bar */
.om-topbar { background: var(--accent); color: #f5e6c0; height: 52px; padding: 0 16px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
.om-topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, #8b1a1a, #c9a84c, #8b1a1a); }
.om-brand { font-family: 'Noto Serif TC', serif; letter-spacing: 0.16em; font-size: 15px; white-space: nowrap; }
.om-spacer { flex: 1; }
.om-user { font-size: 13px; opacity: 0.85; }
.om-topbar button { background: transparent; border: 1px solid rgba(245,230,192,0.4); color: #f5e6c0; border-radius: 5px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.om-topbar button:hover { background: rgba(201,168,76,0.2); }

/* Login */
.om-login { min-height: 100vh; display: none; align-items: center; justify-content: center; padding: 16px; }
.om-login-card { background: var(--surface); width: 100%; max-width: 360px; border-radius: 8px; box-shadow: 0 4px 16px rgba(26,15,8,0.12); padding: 32px 28px; border-top: 3px solid var(--accent); }
.om-login-card h1 { font-family: 'Noto Serif TC', serif; font-weight: 500; font-size: 20px; letter-spacing: 0.2em; text-align: center; color: var(--accent); }
.om-login-card .sub { text-align: center; font-size: 12px; color: var(--muted); margin: 6px 0 22px; letter-spacing: 0.1em; }
.om-field { display: block; margin-bottom: 14px; }
.om-field span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.om-input { width: 100%; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 9px 10px; font-size: 15px; }
.om-input:focus, .qty:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.om-error { padding: 8px 10px; background: #fdf5f5; border: 1px solid #fecaca; border-radius: 4px; color: var(--accent); font-size: 13px; margin-bottom: 12px; text-align: center; }
.om-denied { min-height: 80vh; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; text-align: center; color: var(--text-2); }

/* Buttons */
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--gold); background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #faf6ef; font-family: 'Noto Serif TC', serif; letter-spacing: 0.08em; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: #b91c1c; border-color: #e7b4b4; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }

/* Layout */
.om-main { max-width: 1500px; margin: 0 auto; padding: 16px; }
.om-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.om-tab { border: none; background: none; padding: 9px 16px; cursor: pointer; font-size: 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.om-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.om-card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
.om-muted { color: var(--muted); font-size: 12px; }

/* Order header form */
.oh { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 14px; padding: 14px 16px; margin-bottom: 12px; }
.oh label span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 3px; }
.oh .om-input { padding: 7px 9px; font-size: 14px; }
.oh-store { font-family: 'Noto Serif TC', serif; font-size: 22px; color: var(--accent); letter-spacing: 0.1em; align-self: end; }
.edit-banner { background: #fff7e6; border: 1px solid #f5d38a; color: #8a5a00; border-radius: 6px; padding: 9px 12px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }

.of-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.of-tools .om-input { max-width: 240px; padding: 7px 10px; font-size: 14px; }
.of-tools label { display: flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }

/* Category cards */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 14px; align-items: start; padding-bottom: 90px; }
.cat { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--accent); color: #f5e6c0; cursor: pointer; user-select: none; }
.cat-head .name { font-family: 'Noto Serif TC', serif; letter-spacing: 0.12em; font-size: 15px; flex: 1; }
.cat-head .sum { font-size: 12px; opacity: 0.9; }
.cat-head .arrow { transition: transform .15s; font-size: 11px; }
.cat.collapsed .cat-head .arrow { transform: rotate(-90deg); }
.cat.collapsed .cat-body { display: none; }
.cat-body { overflow-x: auto; }
.ot { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 340px; }
.ot th { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 6px 6px; border-bottom: 1px solid var(--border); background: var(--gold-light); white-space: nowrap; }
.ot th.grp { text-align: center; }
.ot td { padding: 3px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ot tr.filled td { background: #fffbea; }
.ot tr:last-child td { border-bottom: none; }
.ot .nm { font-weight: 500; min-width: 90px; white-space: normal; }
.ot .upb { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ot .sep { border-left: 1px solid var(--border); }
.qwrap { display: inline-flex; align-items: center; gap: 2px; }
.qty { width: 46px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 4px; padding: 5px 4px; text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.qty:disabled { background: transparent; border-style: dashed; color: transparent; }
.qty::-webkit-outer-spin-button, .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty { -moz-appearance: textfield; }
.qb { display: inline-flex; align-items: center; gap: 2px; }
.qb.none { visibility: hidden; }
.qu { font-size: 11px; color: var(--muted); margin-right: 3px; }
.sub-amt { color: var(--text-2); font-size: 12px; }

/* Sticky footer */
.of-foot { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 2px solid var(--gold); padding: 10px 16px; display: flex; align-items: center; gap: 18px; z-index: 15; box-shadow: 0 -4px 12px rgba(26,15,8,0.06); flex-wrap: wrap; }
.of-foot .tot { display: flex; flex-direction: column; }
.of-foot .tot span { font-size: 11px; color: var(--text-2); }
.of-foot .tot b { font-size: 18px; font-variant-numeric: tabular-nums; }
.of-foot .draft { font-size: 11px; color: var(--muted); }

/* Status tags */
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-submitted { background: #fdf0dc; color: var(--warn); }
.st-transferred { background: #e3f1e8; color: var(--ok); }
.st-cancelled { background: #eee; color: #888; }
.st-counted { background: #e6eefb; color: #2b5fb4; }
.st-none { background: transparent; color: var(--muted); font-weight: 400; }

/* Lists */
.lt { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.lt th { background: var(--accent); color: #f5e6c0; font-weight: 500; font-size: 12px; padding: 9px 10px; text-align: left; white-space: nowrap; }
.lt td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.lt tr:last-child td { border-bottom: none; }
.lt tr.dim td { color: var(--muted); }
.lt input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); }
.lt-wrap { overflow-x: auto; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Order detail */
.od-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 14px; margin-bottom: 12px; font-size: 14px; }
.od-meta span { display: block; font-size: 11px; color: var(--text-2); }
.od-notes { background: var(--gold-light); padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; font-size: 13px; white-space: pre-wrap; }
.od-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.od-table th { font-size: 11px; color: var(--text-2); padding: 6px; border-bottom: 1px solid var(--border); text-align: left; }
.od-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.od-table .od-cat td { background: var(--gold-light); font-weight: 700; font-size: 12px; color: var(--accent); }
.od-table tfoot td { font-weight: 700; border-top: 2px solid var(--gold); }
.od-strong { font-weight: 700; }
.od-zero { color: var(--muted); }
.od-upb { font-size: 10px; color: var(--muted); margin-left: 6px; }

/* Modal */
.om-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; padding: 12px; }
.om-overlay.open { display: flex; }
.om { background: var(--surface); border-radius: 8px; width: 100%; max-width: 820px; max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; border-top: 3px solid var(--accent); }
.om-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-family: 'Noto Serif TC', serif; font-size: 15px; letter-spacing: 0.06em; }
.om-x { width: 30px; height: 30px; border: 1px solid var(--border); background: var(--bg); border-radius: 5px; cursor: pointer; }
.om-body { padding: 16px 18px; overflow-y: auto; }
.om-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }

/* Toast */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1a0f08; color: #faf6ef; padding: 10px 18px; border-radius: 6px; font-size: 14px; opacity: 0; transition: all .2s; z-index: 200; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #8b1a1a; }

/* Factory */
.datebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.datebar .om-input { width: auto; padding: 6px 9px; font-size: 14px; }
.datebar .big { font-family: 'Noto Serif TC', serif; font-size: 20px; color: var(--accent); margin-left: 6px; }
.fsum th.store, .fsum td.store { text-align: right; min-width: 52px; }
.fsum td { font-size: 15px; }
.fsum td.store { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fsum td.tot { font-weight: 700; text-align: right; font-size: 18px; }
.fsum tr.cat td { background: var(--gold-light); color: var(--accent); font-weight: 700; font-size: 12px; }
.fsum td { white-space: nowrap; }

@media (max-width: 640px) {
  .om-main { padding: 10px; }
  .cats { grid-template-columns: 1fr; }
  .om-brand { font-size: 13px; letter-spacing: 0.08em; }
  .oh { grid-template-columns: 1fr 1fr; padding: 12px; }
  .oh-store { grid-column: 1 / -1; font-size: 20px; }
  .of-foot { gap: 12px; padding: 8px 10px; }
  .of-foot .tot b { font-size: 16px; }
  .of-foot .btn-primary { flex: 1; }
  .ot { min-width: 0; }
  .ot .m-hide { display: none; }
  .ot td { padding: 3px 4px; }
  .qty { width: 40px; }
  .qu { margin-right: 1px; }
}

.od-table th.num, .ot th.num, .lt th.num { text-align: right; }

@media print {
  body:has(.om-overlay.open) #om-app { display: none; }
  .om-overlay.open { position: static; background: none; padding: 0; }
  .om-overlay.open .om { max-height: none; border: none; }
  .om-head .om-x, .om-foot { display: none !important; }
  .om-topbar, .om-tabs, .datebar .btn, .no-print, .of-foot, .toast { display: none !important; }
  body { background: #fff; }
  .lt, .om-card { box-shadow: none; }
  .lt th { background: #eee !important; color: #000 !important; }
}

/* 工廠用叫貨單（揀貨單）：各分類並排，品名和數量同字級 */
.pk-head { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 12px; font-size: 14px; }
.pk-head span { font-size: 11px; color: var(--text-2); margin-right: 5px; }
.pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: start; }
.pk-col { min-width: 0; }
.pk-col > .pk-table + .pk-table { margin-top: 6px; }
.pk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pk-table th, .pk-table td { border: 1px solid #c9b896; padding: 3px 6px; }
.pk-table th { background: var(--gold-light); color: var(--accent); font-weight: 700; text-align: left; white-space: nowrap; }
.pk-table td { white-space: nowrap; }
.pk-table .pk-q { text-align: right; width: 1%; }
.pk-table th.pk-q { font-size: 12px; color: var(--text-2); font-weight: 600; }
.pk-table tr.pk-on td { font-weight: 700; background: #fffbea; }
.om.om-wide { max-width: 1200px; }
.pk-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.pk-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* 列印揀貨單：A4 橫式一張。所有分類排成一橫排（--pk-cols = 分類數），
   factory.js 列印前用 .pk-print 量高度，超出一頁就整體等比例縮小（zoom） */
body.pk-print #m-view .om { width: 1077px; max-width: none; }   /* 297mm − 邊界 12mm ≈ 285mm */
body.pk-print #m-view.om-overlay { padding: 0; }
body.pk-print #m-view .om { background: #fff; border: none; border-radius: 0; box-shadow: none; }
body.pk-print #m-view .om-body, .pk-sheet-print { padding: 0; overflow: visible; }
body.pk-print .pk-head, .pk-sheet-print .pk-head { font-size: 11px; gap: 2px 16px; margin-bottom: 4px; }
body.pk-print .pk-head span { font-size: 9px; }
body.pk-print .od-notes { font-size: 10px; padding: 2px 6px; margin-bottom: 4px; }
body.pk-print .pk-grid { grid-template-columns: repeat(var(--pk-cols, 6), minmax(0, 1fr)); gap: 3px; }
body.pk-print .pk-table { font-size: var(--pk-fs, 9px); table-layout: fixed; }
body.pk-print .pk-table th, body.pk-print .pk-table td { padding: 0 2px; line-height: var(--pk-lh, 1.25); overflow: hidden; white-space: nowrap; }
body.pk-print .pk-table th:first-child { width: 50%; }
body.pk-print .pk-table td:first-child { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
body.pk-print .pk-table .pk-q { width: auto; }
body.pk-print .pk-table th.pk-q { font-size: calc(var(--pk-fs, 9px) - 1px); }

@media print {
  .pk-table tr.pk-on td { background: none; }
  .pk-table tr.pk-on td:first-child { text-decoration: underline; }
  .pk-table th { background: #eee !important; color: #000 !important; }
  .pk-table { break-inside: avoid; }
  body.pk-print #m-view .om { width: auto; }
}

/* 叫貨／庫存：一格顯示，點進去填箱／個 */
.ot td.qc { padding: 3px 5px; width: 34%; }
.qcell { width: 100%; min-height: 34px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 5px; cursor: pointer; text-align: right; padding: 5px 9px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.qcell:hover { border-color: var(--gold); }
.qcell .q-short { display: none; }
.qcell:focus-visible, .qcell.editing { outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold); }
.qpop { position: fixed; z-index: 50; display: none; background: var(--surface); border: 1px solid var(--gold); border-radius: 8px; box-shadow: 0 6px 24px rgba(26,15,8,0.18); padding: 10px 12px; min-width: 200px; }
.qpop.open { display: block; }
.qpop-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; white-space: nowrap; }
.qpop-title span { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 6px; }
.qpop-row { display: flex; gap: 10px; }
.qpop-row label { display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text-2); }
.qpop-in { width: 64px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 5px; padding: 7px 8px; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.qpop-in::-webkit-outer-spin-button, .qpop-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qpop-in:focus { outline: 2px solid var(--gold); outline-offset: -1px; }
.qpop-btns { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }

.oh-notes { grid-column: 1 / -1; }

/* 電腦：像紙本盤點表一樣，所有分類並排塞進一個畫面（約一張 A4 橫式） */
.th-cat { display: none; }

/* 電腦：跟揀貨單（列印）一樣的版面——所有分類排成一橫排、表格格線，所有品項在同一個畫面 */
@media all {   /* A4 紙本版面：所有螢幕都用，螢幕小就縮放＋捲動 */
  .om-main:has(.cats) { max-width: none; padding: 8px 10px; }
  .oh { grid-template-columns: auto repeat(4, minmax(130px, 170px)) 1fr; padding: 4px 12px; gap: 4px 12px; margin-bottom: 4px; }
  .oh label span { margin-bottom: 1px; }
  .oh .om-input { padding: 3px 8px; }
  .oh-notes { grid-column: auto; }
  .oh-store { font-size: 20px; }
  .of-tools { margin-bottom: 4px; }
  .of-tools .om-input { padding: 4px 10px; }
  .cards-only { display: none; }
  .cats { grid-template-columns: repeat(var(--cols, 9), minmax(0, 1fr)); gap: 3px; padding-bottom: 64px; }
  .cat { border-radius: 0; box-shadow: none; background: #fff; }
  .cat-head { display: none; }
  .cat.collapsed .cat-body { display: block; }
  .cat-body { overflow: visible; }
  .th-cat { display: inline; }
  .th-item { display: none; }
  .ot { min-width: 0; font-size: 12px; table-layout: fixed; border-collapse: collapse; }
  .ot th, .ot td { border: 1px solid #c9b896; }
  .ot th { padding: 2px 3px; font-size: 10px; line-height: 14px; background: var(--gold-light); color: var(--text-2); }
  .ot th.th-name { width: 46%; text-align: left; font-size: 12px; font-weight: 700; color: var(--accent); }
  .ot td { padding: 0; line-height: 14px; height: 19px; }
  .ot .nm { font-size: 12px; font-weight: 500; min-width: 0; padding: 1px 3px; white-space: normal; word-break: normal; overflow-wrap: anywhere; line-height: 1.15; }
  .ot td.qc { width: auto; padding: 0; }
  .ot .sep { border-left: 1px solid #c9b896; }
  .ot tr.filled td { background: #fff7d6; }
  .ot tr.filled .nm { font-weight: 700; text-decoration: underline; }
  .qcell { display: block; width: 100%; min-height: 18px; height: 100%; line-height: 17px; padding: 0 3px; font-size: 12px; border: none; border-radius: 0; background: transparent; white-space: nowrap; overflow: hidden; letter-spacing: -0.02em; }
  .qcell:hover { background: rgba(201,168,76,0.18); }
  .qcell.editing { outline: 2px solid var(--accent); outline-offset: -2px; }
  .om-tabs { margin-bottom: 4px; }
  .om-tab { padding: 5px 14px; }
  .of-foot { padding: 5px 16px; }
  .of-foot .tot b { font-size: 16px; }
}

/* 工廠實際出貨 */
.od-ship, .pk-ship { color: #b45309; font-weight: 700; }
.pk-edit { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; font-size: 12px; color: var(--text-2); }
.pk-edit input { width: 42px; padding: 2px 4px; border: 1px solid var(--gold); border-radius: 4px; background: #fff; text-align: right; font-size: 13px; -moz-appearance: textfield; }
.pk-edit input::-webkit-outer-spin-button, .pk-edit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.st-picking { background: #e0e9fb; color: #2563eb; }
.st-shipped { background: #ede5fb; color: #6d28d9; }
.st-received { background: #e3f1e8; color: var(--ok); }
.st-diff { background: #fde2e2; color: #b91c1c; }
.st-receiving { background: #e0e9fb; color: #2563eb; }
/* 點貨：點好了打勾（分批到貨可以暫存，下次接著點） */
.rv-table .rv-ok { width: 40px; text-align: center; padding: 0; }
.rv-ok label { display: flex; align-items: center; justify-content: center; min-height: 36px; cursor: pointer; }
/* 收貨狀態（照填的數量自動顯示，不能手動勾）：空框還沒點／黃✓部分／綠✓到齊／紅!比出貨多／灰✕沒收到 */
.rv-st { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 2px solid #c9c0ae; border-radius: 5px; background: #fff; color: #fff; font: 700 14px/1 system-ui, sans-serif; font-style: normal; box-sizing: border-box; vertical-align: middle; }
.rv-st.st-part { background: #e0a800; border-color: #e0a800; }
.rv-st.st-full { background: #2e9e5b; border-color: #2e9e5b; }
.rv-st.st-over { background: #c0392b; border-color: #c0392b; }
.rv-st.st-zero { background: #8f887c; border-color: #8f887c; }
.rv-st.st-part::after, .rv-st.st-full::after { content: '✓'; }
.rv-st.st-over::after { content: '!'; }
.rv-st.st-zero::after { content: '✕'; font-size: 12px; }
.rv-table tr.rv-part td { background: #fdf3c4; }
.rv-table tr.rv-full td { background: #dcf1e2; }
.rv-table tr.rv-over td { background: #fbe3e0; }
.rv-table tr.rv-zero td { background: #eeebe5; }
.rv-table tr.rv-full td:not(.rv-ok) { color: var(--muted); }
.rv-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; font-size: 12px; color: var(--text-2); }
.rv-legend span { display: inline-flex; align-items: center; gap: 5px; }
.rv-legend .rv-st { width: 16px; height: 16px; font-size: 11px; border-radius: 4px; }
.rv-legend .rv-st.st-zero::after { font-size: 9px; }
.rv-table.rv-hide-done tr.rv-done { display: none; }
.rv-table.rv-only-mis tbody tr:not(.rv-mis):not(.od-cat) { display: none; }
/* 篩選後整個分類都沒東西：分類標題也藏起來 */
.rv-table.rv-only-mis tbody:not(:has(tr.rv-mis)),
.rv-table.rv-hide-done tbody:not(:has(tr:not(.rv-done):not(.od-cat))) { display: none; }
.rv-filters { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.rv-filter { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.st-transferred { background: #fff1d6; color: #8a5a00; }
.od-recv, .pk-recv { color: #b91c1c; font-weight: 700; }
.rv-edit { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.rv-edit input { width: 52px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); text-align: right; font-size: 15px; -moz-appearance: textfield; }
.rv-edit input::-webkit-outer-spin-button, .rv-edit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rv-edit.diff input { border-color: #b91c1c; background: #fdf5f5; color: #b91c1c; font-weight: 700; }

/* 中文／音譯切換 */
.nm-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); vertical-align: middle; }
.nm-toggle button { border: none; background: none; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.nm-toggle button + button { border-left: 1px solid var(--border); }
.nm-toggle button.on { background: var(--accent); color: #faf6ef; font-weight: 700; }
.desk-only { display: none; }
.desk-only { display: inline-flex; }

/* 電腦版盤點畫面＝一張 A4 橫式的紙（跟列印的盤點單同排版），整張縮放放進畫面（store.js fitSheet） */
@media all {   /* A4 紙本版面：所有螢幕都用，螢幕小就縮放＋捲動 */
  .paper-wrap { display: block; overflow: auto; padding: 4px 4px 8px; background: var(--bg); }   /* 高度由 store.js fitSheet 設成「工具列到底部總額列」之間 */
  .paper { margin: 0 auto; width: 1077px; min-height: 740px; background: #fff; box-shadow: 0 2px 14px rgba(26,15,8,0.14); padding: 10px 12px; }
  .paper .oh { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; background: none; box-shadow: none; border-radius: 0; padding: 0 0 6px; margin: 0; }
  .paper .oh label { display: flex; align-items: center; gap: 4px; }
  .paper .oh label span { display: inline; font-size: 11px; color: var(--text-2); margin: 0; white-space: nowrap; }
  .paper .oh .om-input { width: auto; border: none; border-bottom: 1px solid #c9b896; border-radius: 0; background: transparent; padding: 1px 4px; font-size: 13px; }
  .paper .oh input[type=date].om-input { width: 132px; }
  .paper .oh input:not([type]).om-input { width: 90px; }
  .paper .oh .oh-notes { flex: 1; }
  .paper .oh .oh-notes .om-input { width: 100%; }
  .paper .oh-store { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.06em; align-self: center; }
  .paper .oh select.om-input { padding: 1px 4px; font-size: 13px; }
  .paper .cats { padding-bottom: 0; gap: 3px; }
  .paper .ot th { background: #efefef; color: #333; font-size: 9px; padding: 1px 2px; line-height: 12px; }
  .paper .ot th.th-name { color: #1a0f08; font-size: 10px; width: 50%; }
  .paper .ot td { height: 21px; line-height: 12px; }
  .paper .ot tr:last-child td { border-bottom: 1px solid #c9b896; }   /* 最後一列也要底線（手機卡片版才不畫） */
  .paper .ot .nm { font-size: 10.5px; padding: 1px 3px; }
  .paper .qcell { font-size: 10.5px; min-height: 20px; line-height: 19px; padding: 0 2px; text-align: right; }
}

/* 音譯模式：品名比中文長 → 品名欄加寬、字小一點、行距收緊，兩行也放得進同一格 */
@media all {   /* A4 紙本版面：所有螢幕都用，螢幕小就縮放＋捲動 */
  body.nm-en .paper .ot th.th-name { width: 60%; }
  body.nm-en .paper .ot .nm { font-size: 9.5px; line-height: 11px; letter-spacing: -0.01em; padding: 1px 2px; }
}
body.nm-en.pk-print .pk-table th:first-child { width: 60%; }
body.nm-en.pk-print .pk-table td:first-child { letter-spacing: -0.01em; }

/* 盤點紙本的縮放控制 */
.zoom-ctl { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.zoom-ctl button { border: none; background: none; padding: 4px 10px; font-size: 14px; cursor: pointer; color: var(--text-2); }
.zoom-ctl button:hover { background: var(--gold-light); }
.zoom-ctl button.fit { font-size: 12px; border-left: 1px solid var(--border); }
.zoom-ctl button.fit.on { background: var(--accent); color: #faf6ef; }
.zoom-ctl .pct { min-width: 46px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; border-left: 1px solid var(--border); border-right: 1px solid var(--border); padding: 4px 0; }

/* 盤點紙本的捲動條：一直顯示（Mac 預設會自動隱藏） */
.paper-wrap::-webkit-scrollbar { width: 14px; height: 14px; }
.paper-wrap::-webkit-scrollbar-track { background: #e9dfcd; border-radius: 7px; }
.paper-wrap::-webkit-scrollbar-thumb { background: #b9a27a; border-radius: 7px; border: 3px solid #e9dfcd; }
.paper-wrap::-webkit-scrollbar-thumb:hover { background: #8b1a1a; }
.paper-wrap::-webkit-scrollbar-corner { background: transparent; }
.paper-wrap { scrollbar-color: #b9a27a #e9dfcd; }

/* 視窗裡的 A4 叫貨單（唯讀）：一張紙縮放到視窗寬度 */
.om.om-sheet { max-width: min(96vw, 1400px); }
.om-overlay:has(.sheet-zoom) { align-items: flex-start; padding-top: 4vh; }   /* 調大小時標題列不跟著跳 */
.sheet-view { overflow: auto; }
/* 放大後表格比視窗寬：讓表格區塊填滿視窗、自己上下左右捲，左右捲軸才會一直在視窗底部（不用先捲到表格最下面） */
@media screen {
  body:not(.pk-print) .om.om-sheet .om-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
  body:not(.pk-print) .om.om-sheet .sheet-view { flex: 1; min-height: 0; }
}
.sheet-view::-webkit-scrollbar { width: 14px; height: 14px; }
.sheet-view::-webkit-scrollbar-track { background: #e9dfcd; border-radius: 7px; }
.sheet-view::-webkit-scrollbar-thumb { background: #b9a27a; border-radius: 7px; border: 3px solid #e9dfcd; }
.sheet-view::-webkit-scrollbar-thumb:hover { background: #8b1a1a; }
.sheet-view::-webkit-scrollbar-corner { background: transparent; }
.sheet-zoom { display: flex; align-items: center; gap: 6px; margin: 0 12px 0 auto; font-family: inherit; letter-spacing: 0; font-size: 13px; }
.sheet-zoom .btn { padding: 3px 9px; font-size: 13px; font-family: system-ui, sans-serif; }
.sheet-zoom input[type=range] { width: 160px; max-width: 30vw; accent-color: var(--accent); }
.sheet-zoom-pct { min-width: 42px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.sheet-zoom .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet-page { width: 1077px; background: #fff; padding: 8px 10px; }
.sheet-page .pk-head { font-size: 12px; gap: 2px 16px; margin-bottom: 4px; }
.sheet-page .pk-head span { font-size: 10px; }
.sheet-page .pk-grid { grid-template-columns: repeat(var(--pk-cols, 9), minmax(0, 1fr)); gap: 3px; }
.sheet-page .pk-table { font-size: 10.5px; table-layout: fixed; }
.sheet-page .pk-table th, .sheet-page .pk-table td { padding: 1px 2px; line-height: 1.35; white-space: nowrap; overflow: hidden; }
.sheet-page .pk-table th { background: #efefef; color: #333; font-size: 9px; }
.sheet-page .pk-table th:first-child { width: 46%; font-size: 10px; color: #1a0f08; }
.sheet-page .pk-table .pk-q { width: auto; text-align: right; }
.sheet-page .pk-table td:first-child { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
.sheet-page .pk-table tr.pk-on td { background: #fff7d6; font-weight: 700; }
body.nm-en .sheet-page .pk-table th:first-child { width: 56%; }
body.nm-en .sheet-page .pk-table td:first-child { font-size: 9.5px; }
.sheet-page .pk-edit { gap: 1px; font-size: 9px; }
.sheet-page .pk-edit input { width: 26px; padding: 0 2px; font-size: 10px; }
.sheet-page .pk-ship { color: #b45309; }
.sheet-page .pk-recv { color: #b91c1c; }
/* 工廠回報實際出貨（同一張 A4）：實出欄加寬，箱＋個放不下就換行 */
.sheet-editing .pk-table th:first-child, body.nm-en .sheet-editing .pk-table th:first-child { width: 40%; }
.sheet-editing .pk-table th:nth-child(2) { width: 22%; }
.sheet-editing .pk-table td.pk-q { overflow: visible; }
.sheet-editing .pk-edit { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 1px 2px; }
.sheet-editing .pk-edit input { width: 24px; padding: 0 2px; font-size: 10.5px; border-radius: 2px; }

/* 音譯模式的數量（例如 1 Xiang 20 Ge）比較長：數量欄可以換行 */
body.nm-en .paper .qcell { white-space: normal; line-height: 10px; padding: 1px 2px; font-size: 9.5px; }
body.nm-en .sheet-page .pk-table td.pk-q, body.nm-en.pk-print .pk-table td.pk-q { white-space: normal; line-height: 1.15; }
/* 音譯：品名欄窄一點、數量欄寬一點，「10 He」放得進一行 */
body.nm-en .paper .ot th.th-name { width: 50%; }
body.nm-en .sheet-page .pk-table th:first-child, body.nm-en.pk-print .pk-table th:first-child { width: 50%; }
body.nm-en .sheet-page .pk-table td.pk-q { font-size: 9.5px; padding: 1px 1px; }
/* 門市點貨後多一欄「實收」：品名欄讓出寬度，數量放不下就換行（不要被切掉） */
.sheet-page .pk-table.pk-has-recv th:first-child, body.nm-en .sheet-page .pk-table.pk-has-recv th:first-child,
body.pk-print .pk-table.pk-has-recv th:first-child { width: 38%; }
.sheet-page .pk-table.pk-has-recv td.pk-q, body.pk-print .pk-table.pk-has-recv td.pk-q { white-space: normal; overflow-wrap: anywhere; }
.sheet-page .pk-table.pk-has-recv td.pk-q { line-height: 1.15; }
.sheet-a4 .pk-table.pk-has-recv th:first-child { width: 40%; }
#m-confirm-box { z-index: 150; }

/* 數量文字（例如 2箱1個）：「2箱」「1個」不拆開，格子放不下就分兩行，不會被切掉 */
.qcell .qt { display: inline-block; white-space: nowrap; }
.paper .qcell { white-space: normal; line-height: 10px; letter-spacing: -0.03em; }
.paper .cats:not(.mode-count) .ot th.th-name { width: 44%; }

/* 盤點模式：只有「庫存」一欄，直接在格子裡填箱／個 */
.mode-toggle button { white-space: nowrap; }
.ot td.qc-in { padding: 0 2px; text-align: right; }
.qin-wrap { display: inline-flex; align-items: center; justify-content: flex-end; gap: 0; white-space: nowrap; }
.paper .cats.mode-count .ot th.th-name, body.nm-en .paper .cats.mode-count .ot th.th-name { width: 38%; }
.paper .cats.mode-count .ot-small th.th-name, body.nm-en .paper .cats.mode-count .ot-small th.th-name { width: 62%; }   /* 只有「個」的分類：一格就夠，品名欄寬一點 */
.qin { width: 22px; height: 17px; padding: 0 2px; border: 1px solid #d8c9a8; border-radius: 2px; background: #fffdf8; text-align: right; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.qin::-webkit-outer-spin-button, .qin::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qin:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); background: #fff; }
.qin-u { font-size: 9px; color: var(--text-2); margin: 0 1px 0 0; }
body.nm-en .qin-u { font-size: 8px; letter-spacing: -0.03em; }
body.nm-en .paper .qcell { font-size: 8px; letter-spacing: -0.04em; line-height: 9px; padding: 0 1px; }
/* 數量字不要太粗 */
.paper .qcell, .qin { font-weight: 400; }

/* ── 工廠配貨／門市新增／自由輸入（不是產品）── */
.x-tag { display: inline-block; margin-left: 3px; padding: 0 3px; border-radius: 3px; background: #fef3c7; color: #b45309; font-size: .8em; font-weight: 700; line-height: 1.3; vertical-align: 1px; }
.pk-edit .pk-unit { width: 26px; text-align: left; }
.pk-cname { width: 100%; min-width: 0; padding: 0 3px; border: 1px solid var(--gold); border-radius: 2px; background: #fff; font-size: 10.5px; font-family: inherit; box-sizing: border-box; }
.sheet-editing .pk-edit .pk-unit { width: 22px; }
.rv-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; font-size: 13px; color: var(--text-2); }
/* 點貨：新增品項彈出視窗（搜尋＋分類篩選，可多選）*/
#m-rpick { z-index: 120; }
#m-rpick .om { max-width: 520px; height: 80vh; }
#m-rpick .om-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }
.rp-sbox { position: relative; flex: none; }
.rp-search { font-size: 16px; padding: 10px 40px 10px 12px; }
.rp-search::-webkit-search-cancel-button { display: none; }
.rp-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: none; border-radius: 50%; background: none; color: var(--muted); font-size: 15px; cursor: pointer; }
.rp-clear[hidden] { display: none; }
.rp-cats { flex: none; display: flex; gap: 6px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; scrollbar-width: thin; }
.rp-cat { flex: none; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap; }
.rp-cat.on { background: var(--accent); border-color: var(--accent); color: #f5e6c0; }
.rp-list { flex: 1; min-height: 0; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.rp-group { position: sticky; top: 0; padding: 5px 12px; background: #f5efe4; color: var(--text-2); font-size: 12px; font-weight: 700; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.rp-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none; border-bottom: 1px solid var(--border); background: none; text-align: left; font-size: 15px; font-family: inherit; color: inherit; cursor: pointer; }
.rp-item:hover { background: #fffbeb; }
.rp-item.on { background: #fef3c7; }
.rp-chk { flex: none; width: 18px; height: 18px; border: 1.5px solid var(--border); border-radius: 4px; background: #fff; display: grid; place-items: center; font-size: 13px; line-height: 1; color: #fff; }
.rp-item.on .rp-chk { background: var(--accent); border-color: var(--accent); }
.rp-item.on .rp-chk::after { content: '✓'; }
.rp-name { flex: 1; min-width: 0; }
.rp-name small { display: block; font-size: 12px; color: var(--muted); }
.rp-unit { flex: none; font-size: 12px; color: var(--muted); }
.rp-item.have { color: var(--muted); }
.rp-item.have .rp-chk { visibility: hidden; }
.rp-have { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.rv-table tr.rv-flash td { animation: rvFlash 1.6s ease-out; }
@keyframes rvFlash { 0%, 40% { background: #fde68a; } 100% { background: transparent; } }
.rp-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.7; }
@media (max-width: 640px) {
  #m-rpick.om-overlay { padding: 0; align-items: stretch; }
  #m-rpick .om { max-width: none; height: 100%; max-height: 100dvh; border-radius: 0; }
  #m-rpick .om-body { padding: 10px; }
  #m-rpick .om-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  #m-rpick .om-foot #rp-count { width: 100%; }
  #m-rpick .om-foot .btn { padding: 11px 16px; font-size: 15px; }
  #m-rpick #rp-ok { flex: 1; }
  .rp-cats { margin: 0 -10px; padding: 0 10px 2px; scrollbar-width: none; }
  .rp-cats::-webkit-scrollbar { display: none; }
  .rp-cat { padding: 8px 14px; font-size: 14px; }
  .rp-item { padding: 13px 12px; min-height: 50px; font-size: 16px; }
  .rp-chk { width: 22px; height: 22px; font-size: 15px; }
  .rv-add { gap: 8px; }
  .rv-add > span { width: 100%; }
  .rv-add .btn { flex: 1; padding: 11px 8px; font-size: 15px; }
}
.rv-edit .rv-unit { width: 44px; text-align: left; background: var(--surface-2); }
.rv-cname { width: 100%; min-width: 120px; padding: 4px 6px; font-size: 14px; }
@media print { .rv-add { display: none; } }
.pk-add { padding: 0 5px; border: 1px dashed var(--border); border-radius: 3px; background: transparent; color: var(--text-3, #999); font-size: 10px; line-height: 1.2; cursor: pointer; }
.pk-add:hover { border-color: var(--gold); color: #b45309; background: #fffbeb; }

/* ── 截圖（screenshotSheet）：欄寬照內容，不裁切 ── */
.sheet-page.sheet-shot { width: max-content; padding: 12px 14px; }
.sheet-shot .pk-head { font-size: 14px; }
.sheet-shot .pk-head span { font-size: 12px; }
.sheet-shot .pk-grid { grid-template-columns: repeat(var(--pk-cols, 9), max-content); gap: 4px; }
.sheet-shot .pk-table { table-layout: auto; width: auto; font-size: 13px; }
.sheet-shot .pk-table th, .sheet-shot .pk-table td { overflow: visible; white-space: nowrap; line-height: 1.4; }
.sheet-shot .pk-table th { font-size: 11px; }
.sheet-shot .pk-table th:first-child { width: auto; font-size: 12px; }
.sheet-shot .pk-table .pk-q { padding: 1px 5px; }

/* ── 揀貨單直接送 A4 印表機（a4-print.js）：畫面外排版，字級／欄數由程式挑最大的 ── */
.sheet-a4 { background: #fff; color: #000; padding: 0; font-family: 'Noto Sans TC', sans-serif; }
.sheet-a4 .pk-head { font-size: clamp(12px, var(--pk-fs, 12px), 22px); gap: 0 0.9em; margin-bottom: 0.25em; line-height: 1.3; }
.sheet-a4 .pk-head span { font-size: 0.75em; color: #444; margin-right: 0.3em; }
.sheet-a4 .od-notes { font-size: clamp(11px, var(--pk-fs, 12px), 20px); padding: 2px 6px; margin-bottom: 0.25em; }
/* 一個分類一欄（跟畫面上的叫貨單一樣），只有「其他（非產品）」會疊在最短那欄下面（pkGridHTML） */
.sheet-a4 .pk-grid { grid-template-columns: repeat(var(--pk-cols, 9), minmax(0, 1fr)); gap: 4px; }
.sheet-a4 .pk-table { font-size: var(--pk-fs, 12px); table-layout: fixed; width: 100%; }
.sheet-a4 .pk-col > .pk-table + .pk-table { margin-top: 4px; }
.sheet-a4 .pk-table th, .sheet-a4 .pk-table td { border-color: #888; padding: 0 0.2em; line-height: var(--pk-lh, 1.25); overflow: hidden; white-space: nowrap; }
.sheet-a4 .pk-table th { background: #e6e6e6; color: #000; }
.sheet-a4 .pk-table th:first-child { width: 52%; }
.sheet-a4 .pk-table th.pk-q { font-size: 0.8em; color: #000; }
.sheet-a4 .pk-table td:first-child { white-space: normal; word-break: normal; overflow-wrap: anywhere; }
.sheet-a4 .pk-table .pk-q { width: auto; text-align: right; }
.sheet-a4 .pk-table tr.pk-on td { background: none; font-weight: 700; }
.sheet-a4 .pk-table tr.pk-on td:first-child { text-decoration: underline; }
.sheet-a4 .pk-ship, .sheet-a4 .pk-recv { color: #000; }
.a4p-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.a4p-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 14px; }
.a4p-item input { accent-color: var(--accent); }

/* 品名「1箱幾個」提示泡泡（order-common.js perHint） */
[data-uh] { cursor: help; }
.uh-tip { position: fixed; z-index: 9999; display: none; pointer-events: none; padding: 4px 9px; border-radius: 6px;
  background: #3b2f1e; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
@media print { .uh-tip { display: none !important; } }
/* 工廠收單：列表上直接改到貨日 */
.lt .of-arrive { width: auto; padding: 3px 6px; font-size: 13px; background: transparent; border-color: transparent; cursor: pointer; }
.lt .of-arrive:hover, .lt .of-arrive:focus { border-color: var(--gold); background: var(--surface-2); }

/* ── 手機點貨（store.js 叫貨紀錄、點貨視窗）── */
.rv-help > summary { display: none; }
@media (max-width: 640px) {
  /* 叫貨紀錄：表格改成一張張卡片，「點貨」按鈕不用左右捲才看得到 */
  .lt-cards, .lt-cards tbody { display: block; background: none; box-shadow: none; border-radius: 0; overflow: visible; }
  .lt-cards thead { display: none; }
  .lt-cards tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; align-items: center; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 10px; }
  .lt-cards td { padding: 0; border: none; text-align: left; }
  .lt-cards .lc-arrive { grid-column: span 2; font-size: 16px; order: -2; }
  .lt-cards .lc-arrive::before { content: attr(data-label) ' '; font-size: 12px; color: var(--muted); }
  .lt-cards .lc-status { text-align: right; order: -1; }
  .lt-cards .lc-meta { font-size: 13px; }
  .lt-cards .lc-meta::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); }
  .lt-cards .lc-actions { grid-column: 1 / -1; padding-top: 6px; }
  .lt-cards .actions { justify-content: stretch; flex-wrap: wrap; }
  .lt-cards .actions .btn { flex: 1; padding: 9px 10px; font-size: 14px; }

  /* 點貨視窗：整個螢幕、說明可收合、不顯示「叫貨」欄、輸入框加大（16px 以上 iPhone 才不會自動放大畫面） */
  #m-recv.om-overlay { padding: 0; }
  #m-recv .om { max-width: none; height: 100%; max-height: 100dvh; border-radius: 0; }
  #m-recv .om-head { padding: 10px 12px; }
  #m-recv .om-body { padding: 10px; flex: 1; }
  #m-recv .om-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  #m-recv .om-foot #recv-diff { width: 100%; }
  #m-recv .om-foot .btn:not(.btn-primary):not(#recv-draft) { padding: 8px 12px; }
  #m-recv #recv-draft, #m-recv #recv-save { flex: 1; padding: 11px 8px; font-size: 15px; }
  #m-recv .om-input { font-size: 16px; }
  .rv-help { margin-bottom: 8px; }
  .rv-help > summary { display: list-item; cursor: pointer; font-size: 13px; color: var(--warn); padding: 4px 0; }
  .rv-help[open] > summary { margin-bottom: 6px; }
  .rv-table .rv-ord { display: none; }
  .rv-table th { white-space: nowrap; }
  .rv-table td { padding: 6px 4px; }
  .rv-table .rv-ok { width: 34px; }
  .rv-ok label { min-height: 44px; }
  .rv-table .rv-st { width: 24px; height: 24px; }
  .rv-edit input { width: 46px; height: 38px; font-size: 16px; padding: 4px 5px; }
  .rv-edit .rv-unit { width: 44px; }
  .rv-cname { min-width: 90px; font-size: 16px; }
  .rv-add select { max-width: 100%; flex: 1 1 100%; font-size: 16px; }
  .rv-add .btn { flex: 1; padding: 8px; }
}

/* 門市叫貨：其他品項（叫貨單上沒有的，自己打品名） */
.so-extras { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; }
.so-extras .so-x { padding: 2px 8px; border-radius: 4px; background: #fff3c4; }
.so-xrow { display: grid; grid-template-columns: 1fr 80px 64px auto; gap: 6px; margin-bottom: 6px; }
@media (max-width: 640px) { .so-xrow .om-input { font-size: 16px; } }

/* ── 工廠庫存（factory-stock.js）── */
.fs-status { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.fs-status > div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 110px; }
.fs-status span { font-size: 12px; color: var(--muted); }
.fs-status b { font-size: 16px; }
.fs-status .ok b { color: var(--ok); }
.fs-status .warn { border-color: #f3c98b; background: #fff8ec; }
.fs-status .warn b { color: var(--warn); }
.fs-note { font-size: 13px; padding: 7px 10px; border-radius: 6px; background: var(--gold-light); margin-bottom: 8px; line-height: 1.6; }
.fs-note.warn { background: #fff8ec; color: var(--warn); border: 1px solid #f3c98b; }
.fs-t-count { background: #e6eefb; color: #2b5fb4; }
.fs-t-produce { background: #e3f1e8; color: var(--ok); }
.fs-t-assemble { background: #fdf0dc; color: var(--warn); }
.fs-table td, .fs-table th { padding: 6px 10px; }
.fs-table tr.fs-cat td { background: var(--gold-light); color: var(--accent); font-weight: 700; font-size: 12px; padding: 5px 10px; }
.fs-tag { display: inline-block; font-size: 10px; padding: 0 4px; border-radius: 3px; background: #e6eefb; color: #2b5fb4; vertical-align: 1px; }
.fs-up { color: #2b5fb4; }
.fs-down { color: #b91c1c; }
.om.om-wide { max-width: min(96vw, 1300px); height: 92vh; }
.om.om-wide .om-body { flex: 1; }
.fs-form-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.fs-form-top label { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.fs-form-top .om-input { width: auto; max-width: 200px; padding: 6px 9px; font-size: 14px; }
.fs-notes { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 12px; }
.fs-notes .om-input { flex: 1; padding: 6px 9px; }
.fs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; align-items: start; }
.fs-card { border: 1px solid #c9b896; border-radius: 6px; overflow: hidden; }
.fs-card-h { background: var(--gold-light); color: var(--accent); font-weight: 700; font-size: 13px; padding: 5px 8px; }
.fs-card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.fs-card td { padding: 3px 6px; border-top: 1px solid #eee3cc; }
.fs-card td.qi { text-align: right; white-space: nowrap; }
.fs-card tr.on td { background: #fffbea; font-weight: 700; }
.fs-in { width: 48px; height: 28px; padding: 0 4px; border: 1px solid #d8c9a8; border-radius: 4px; background: #fffdf8; text-align: right; font-size: 15px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.fs-in::-webkit-outer-spin-button, .fs-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fs-in:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.fs-in-lg { width: 64px; }
.fs-card .u { font-size: 12px; color: var(--text-2); margin: 0 3px 0 2px; }
.fs-asm-row { border: 1px solid #c9b896; border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.fs-asm-h { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fs-asm-h select { width: auto; min-width: 180px; padding: 6px 9px; font-size: 15px; }
.fs-asm-h label { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.fs-asm-c { margin-top: 8px; border-collapse: collapse; font-size: 14px; }
.fs-asm-c td { padding: 4px 10px 4px 0; white-space: nowrap; }
@media (max-width: 640px) {
  .om.om-wide { max-width: none; height: 100vh; max-height: none; border-radius: 0; }
  #m-fs.om-overlay { padding: 0; }
  .fs-grid { grid-template-columns: 1fr; }
  .fs-in { height: 34px; width: 56px; font-size: 16px; }
}
/* ── 盤點：庫存分開數再加總（store.js openParts）── */
.ot td.nm-pt { cursor: pointer; }
.ot td.nm-pt:hover { color: var(--accent); }
.pt-n { display: inline-block; margin-left: 3px; padding: 0 3px; border-radius: 3px; background: #e6eefb; color: #2b5fb4; font-size: 9px; font-weight: 700; line-height: 12px; vertical-align: 1px; text-decoration: none; }
.pt-modal .om { max-width: 400px; }
.pt-hint { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--muted); }
.pt-help { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.pt-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.pt-no { width: 22px; height: 22px; border-radius: 50%; background: var(--gold-light); color: var(--accent); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.pt-in { width: 72px; height: 42px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); text-align: right; font-size: 18px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.pt-in::-webkit-outer-spin-button, .pt-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pt-in:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.pt-u { font-size: 14px; color: var(--text-2); margin-right: 4px; }
.pt-del { margin-left: auto; border: none; background: none; color: var(--muted); font-size: 18px; padding: 6px 10px; cursor: pointer; }
.pt-del:hover { color: #b91c1c; }
.pt-add { width: 100%; padding: 10px; font-size: 15px; border-style: dashed; }
.pt-total { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 15px; text-align: right; }
.pt-total b { font-size: 22px; margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ── 點貨分批（一車一車下貨）：本批輸入、已點／出貨、之前各批；左右拉時「點好、品項」固定 ── */
.rv-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rv-table td.rv-ok, .rv-table th.rv-ok { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.rv-table td.rv-nm, .rv-table th.rv-nm { position: sticky; left: 40px; z-index: 2; background: var(--surface); min-width: 5.5em; box-shadow: 1px 0 0 var(--border); }
.rv-table thead th.rv-ok, .rv-table thead th.rv-nm { background: var(--surface); }
.rv-catn { position: sticky; left: 8px; }   /* 左右拉時分類名稱留在左邊 */
.rv-table tr.rv-part td.rv-ok, .rv-table tr.rv-part td.rv-nm { background: #fdf3c4; }
.rv-table tr.rv-full td.rv-ok, .rv-table tr.rv-full td.rv-nm { background: #dcf1e2; }
.rv-table tr.rv-over td.rv-ok, .rv-table tr.rv-over td.rv-nm { background: #fbe3e0; }
.rv-table tr.rv-zero td.rv-ok, .rv-table tr.rv-zero td.rv-nm { background: #eeebe5; }
.rv-table td.rv-cur { white-space: nowrap; }
.rv-table th.rv-cur { white-space: nowrap; }
.rv-tot { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.rv-tot .rv-sent { font-weight: 400; color: var(--muted); }
.rv-tot.rv-eq { color: var(--ok); }
.rv-tot.rv-over { color: #b91c1c; }
.rv-table th.rv-b, .rv-table td.rv-b { white-space: nowrap; border-left: 1px dashed var(--border); }
/* 每一批之間都有虛線：第一批、第二批…、本批、已點／出貨 */
.rv-table th.rv-cur, .rv-table td.rv-cur, .rv-table td.rv-tot, .rv-table thead th.rv-cur + th { border-left: 1px dashed var(--border); }
.rv-bq { min-width: 44px; min-height: 30px; border: none; background: none; color: var(--text-2); font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; border-radius: 4px; padding: 2px 4px; }
.rv-bq:hover { background: var(--gold-light); color: var(--accent); }
.rv-table tr.rv-done td.rv-b .rv-bq { color: var(--muted); }
@media (max-width: 640px) {
  .rv-table td.rv-nm, .rv-table th.rv-nm { left: 34px; min-width: 4.5em; }
  .rv-tot { font-size: 13px; }
}

/* ── 門市切換（store.js storeSwitchHTML）：網站風格的下拉選單 ── */
.ss-wrap { position: relative; display: flex; align-items: center; gap: 6px; margin-right: 14px; padding-bottom: 4px; }
.ss-lbl { font-size: 13px; color: var(--text-2); }
.ss-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--accent); font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.ss-btn:hover:not(:disabled) { border-color: var(--gold); background: var(--surface-2); }
.ss-btn:disabled { opacity: .55; cursor: not-allowed; }
.ss-caret { font-size: 11px; color: var(--text-2); }
.ss-menu { display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 60; min-width: 140px; padding: 6px; background: var(--surface); border: 1px solid var(--gold); border-radius: 8px; box-shadow: 0 6px 24px rgba(26,15,8,0.18); }
.ss-menu.open { display: block; }
.ss-opt { display: block; width: 100%; padding: 9px 14px; border: none; border-radius: 5px; background: none; text-align: left; font-family: inherit; font-size: 15px; color: var(--text); cursor: pointer; white-space: nowrap; }
.ss-opt:hover { background: var(--gold-light); }
.ss-opt.on { color: var(--accent); font-weight: 700; }
.ss-opt.on::after { content: '✓'; float: right; margin-left: 12px; }
@media (max-width: 640px) { .ss-opt { padding: 12px 16px; font-size: 16px; } }

/* 品項開關：這家門市不叫／不盤點的格子 */
.qcell.qcell-na { display: flex; align-items: center; justify-content: center; color: #c4bdb0; background: repeating-linear-gradient(-45deg, transparent 0 5px, rgba(0,0,0,.04) 5px 10px); cursor: default; border-color: transparent; }

/* 工廠盤點：庫存分 2F、1F 兩欄，品名欄窄一點，數字格才放得下 */
.paper .cats.fs-floors .ot th.th-name, body.nm-en .paper .cats.fs-floors .ot th.th-name { width: 30%; }
.paper .cats.fs-floors .ot-small th.th-name, body.nm-en .paper .cats.fs-floors .ot-small th.th-name { width: 40%; }
.paper .cats.fs-floors .ot-small .qin { width: 28px; }

/* 工廠盤點（平板）：不擠成 A4，每類固定寬度、字和格子放大、品名不換行，左右捲動；表頭固定在上面 */
.paper.fs-wide { width: max-content; min-height: 0; padding: 10px 12px 24px; }
.paper.fs-wide .cats.fs-floors { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: max-content; gap: 10px; align-items: start; }
.paper.fs-wide .cats.fs-floors .ot { table-layout: auto; width: auto; font-size: 15px; }
.paper.fs-wide .cats.fs-floors .ot th { position: sticky; top: 0; z-index: 2; background: #efe6d3; color: #3a2a14; font-size: 14px; font-weight: 700; padding: 6px 8px; line-height: 18px; }
.paper.fs-wide .cats.fs-floors .ot th.th-name, body.nm-en .paper.fs-wide .cats.fs-floors .ot th.th-name { width: auto; font-size: 17px; color: var(--accent); }
.paper.fs-wide .cats.fs-floors .ot td { height: 46px; line-height: 20px; }
.paper.fs-wide .cats.fs-floors .ot tr:nth-child(even) td { background: #faf6ee; }
.paper.fs-wide .cats.fs-floors .ot tr.filled td { background: #fff1bf; }
.paper.fs-wide .cats.fs-floors .ot .nm, body.nm-en .paper.fs-wide .cats.fs-floors .ot .nm { font-size: 17px; font-weight: 600; white-space: nowrap; padding: 2px 10px; line-height: 20px; letter-spacing: 0; }
.paper.fs-wide .cats.fs-floors td.qc-in { padding: 0 6px; }
.paper.fs-wide .cats.fs-floors .ot .sep { border-left: 2px solid #b39a6b; }
.paper.fs-wide .cats.fs-floors .qin, .paper.fs-wide .cats.fs-floors .ot-small .qin { width: 52px; height: 36px; font-size: 18px; padding: 0 5px; border-radius: 5px; border-color: #c9b48a; }
.paper.fs-wide .cats.fs-floors .qin-u, body.nm-en .paper.fs-wide .cats.fs-floors .qin-u { font-size: 14px; margin: 0 6px 0 3px; color: #6b5a40; }
.paper.fs-wide .oh .om-input { font-size: 16px; }
.paper.fs-wide .oh label span, .paper.fs-wide .oh-store { font-size: 15px; }
.fs-jump { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.fs-jump:empty { display: none; }
.fs-jump button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 14px; font-size: 15px; cursor: pointer; }
.fs-jump button:active { background: var(--accent); color: #fff; }
.paper.fs-wide .cats.fs-floors .cat { overflow: visible; }
.paper.fs-wide .cats.fs-floors .ot { min-width: 0; }
.paper.fs-wide .cats.fs-floors .ot td.qc { width: auto; }
/* 平板版面收緊：格子、單位、間距縮小，少留白（還是夠大好點） */
.paper.fs-wide .cats.fs-floors { gap: 6px; }
.paper.fs-wide .cats.fs-floors .ot th { padding: 5px 4px; }
.paper.fs-wide .cats.fs-floors .ot .nm, body.nm-en .paper.fs-wide .cats.fs-floors .ot .nm { padding: 2px 6px; }
.paper.fs-wide .cats.fs-floors td.qc-in { padding: 0 3px; }
.paper.fs-wide .cats.fs-floors .qin, .paper.fs-wide .cats.fs-floors .ot-small .qin { width: 40px; height: 34px; font-size: 17px; padding: 0 3px; }
.paper.fs-wide .cats.fs-floors .qin-u, body.nm-en .paper.fs-wide .cats.fs-floors .qin-u { font-size: 13px; margin: 0 1px 0 2px; }
.paper.fs-wide .cats.fs-floors .qin-wrap { gap: 0; }
.paper.fs-wide .cats.fs-floors .qin-u + .qin { margin-left: 3px; }

/* 品項合計：表頭（門市名稱）固定在上面、品項固定在左邊；門市旁勾選＝算進合計 */
.fsum-wrap { max-height: calc(100vh - 190px); overflow: auto; border-radius: 8px; box-shadow: var(--shadow); }
.fsum { overflow: visible; box-shadow: none; border-radius: 0; }
.fsum thead th { position: sticky; top: 0; z-index: 3; }
.fsum .fsum-nm { position: sticky; left: 0; z-index: 2; background: var(--surface); }
.fsum thead th.fsum-nm { z-index: 4; background: var(--accent); }
.fsum tr.cat td { position: sticky; left: 0; }
.fsum-pick { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.fsum-pick input { width: 16px; height: 16px; accent-color: #f5e6c0; margin: 0; }
.fsum th small { font-size: 11px; opacity: .85; }
.fsum th.off { background: #a87b6f; color: #eadcc6; text-decoration: line-through; }
.fsum td.off { color: #b8ab95; background: #f6f2ea; }
@media print { .fsum-wrap { max-height: none; overflow: visible; box-shadow: none; } .fsum-pick input { display: none; } .fsum th.off, .fsum td.off { display: none; } }
.fsum .fsum-pcs { font-size: 13px; font-weight: 600; color: #8a5300; white-space: nowrap; }

/* 工廠盤點單「其他（自行輸入）」 */
.fs-other .fs-oin { height: 36px; font-size: 16px; padding: 0 6px; border: 1px solid #c9b48a; border-radius: 5px; background: #fff; }
.fs-other .fs-oname { width: 120px; }
.fs-other .fs-ounit { width: 52px; }
.fs-other .fs-odel { border: 0; background: none; color: #b91c1c; font-size: 16px; cursor: pointer; padding: 4px 6px; }
.fs-other .fs-oadd { margin: 8px 6px 0; }
.fs-other .fs-onote { font-size: 12px; color: #6b5a40; margin: 6px; }
.paper.fs-wide .cats.fs-floors .fs-other .qin { width: 60px; }
.fs-t-ship { background: #f3e8f7; color: #7a3e94; }
.fs-shipby { font-size: 11px; color: var(--text-muted, #8a7a60); line-height: 1.4; font-weight: 400; white-space: nowrap; }
.fs-sheet-title { margin: 16px 0 6px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.fs-sheet-title .om-muted { font-weight: 400; font-size: 12px; }
.fs-sheet-view { width: 100%; box-sizing: border-box; max-height: 80vh; background: #fff; border: 1px solid #e3d6bd; border-radius: 6px; padding: 8px; }
/* 組裝禮盒：可搜尋的選禮盒欄位 */
.fs-combo { position: relative; flex: 1 1 220px; max-width: 320px; }
.fs-combo-in { width: 100%; box-sizing: border-box; }
.fs-combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid #c9b48a; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.fs-combo-cat { padding: 4px 10px; font-size: 12px; font-weight: 700; color: var(--accent, #8b1a1a); background: #f6efe2; position: sticky; top: 0; }
.fs-combo-opt { padding: 7px 12px; cursor: pointer; font-size: 15px; }
.fs-combo-opt.on { font-weight: 700; }
.fs-combo-opt.hl, .fs-combo-opt:hover { background: #fff1bf; }
.fs-combo-none { padding: 10px 12px; color: #8a7a60; font-size: 13px; }
/* 扣庫存日期（回報實際出貨、工廠庫存頁） */
.ship-date { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: #b45309; }
.ship-date input, .fs-shipdate input { width: auto; padding: 4px 8px; font-size: 14px; }
.fs-shipdate { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.fs-noship { display: inline-flex; align-items: center; gap: 6px; margin: 4px 12px 0 0; }
.fs-t-outbound { background: #fbe6e6; color: #b03a3a; }
