/* โทนสีเดียวกับ POS (src/shared/lib/theme.ts) */
:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --surface: #f6f7f9;
  --hover: #f1f3f7;
  --line: #e8ebf0;
  --line-2: #dfe3ea;
  --text: #1b1f27;
  --sub: #6b7280;
  --faint: #a0a6b1;
  --primary: #2f6bff;
  --primary-soft: #eaf0ff;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --success: #1f9d63;
  --success-soft: #e6f6ee;
  --warn: #c27310;
  --warn-soft: #fff2e3;
  --violet: #7a4fe0;
  --violet-soft: #f1ecfe;
  --ink: #16191f;
  --ink-2: #22262e;
  --ink-line: #30353f;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Leelawadee UI', Tahoma, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); }
.muted { color: var(--sub); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ไอคอนเส้น (เติมด้วย JS จาก data-i) */
i.i { display: inline-flex; width: 16px; height: 16px; flex: none; vertical-align: -3px; }
i.i svg { width: 100%; height: 100%; }
i.i.lg { width: 20px; height: 20px; }

/* ---------- โครงหน้า: แถบเมนูซ้าย + เนื้อหา ---------- */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 12px 0 12px 12px; }
.side-in { height: 100%; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; border: 1.5px solid var(--text); display: grid; place-items: center; }
.brand .mark i.i { width: 16px; height: 16px; }
.brand b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 11.5px; color: var(--sub); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: #3a404c; text-align: left; font-size: 13.5px; }
.nav button i.i { color: var(--sub); }
.nav button:hover { background: var(--hover); }
.nav button.on { background: var(--hover); color: var(--text); font-weight: 600; }
.nav button.on i.i { color: var(--text); }
.nav .count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--primary-soft); color: var(--primary); border-radius: 6px; padding: 1px 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.me div { min-width: 0; }
.me b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me span { font-size: 11.5px; color: var(--sub); }
.mtop { display: none; }

main { padding: 22px 26px 40px; min-width: 0; max-width: 1480px; width: 100%; }
.page-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.page-h h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0; flex: 1; }
.page-h .sub { width: 100%; color: var(--sub); margin-top: -6px; font-size: 13px; }

/* ---------- ปุ่ม / ช่องกรอก ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 10px; padding: 7px 13px; cursor: pointer; white-space: nowrap; line-height: 1.3; font-size: 13.5px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.pill { border-radius: 999px; padding: 7px 14px; }
.btn.primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn.primary:hover { background: #2b303a; }
.btn.blue { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
.btn.blue:hover { background: #255de6; }
.btn.ok { background: var(--success); border-color: var(--success); color: #fff; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: #f6c9ca; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.lg { padding: 10px 18px; font-size: 14.5px; border-radius: 12px; }
.btn.icon { padding: 7px; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; background: var(--panel); outline: none; font-size: 14px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .14); }
.input:disabled { background: var(--surface); color: var(--sub); }
label.f { display: block; font-size: 12.5px; color: var(--sub); margin-bottom: 12px; }
label.f > .input, label.f > select, label.f > textarea { margin-top: 5px; color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.search { position: relative; }
.search i.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 34px; }

/* ---------- การ์ด ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.card-h h3 { margin: 0; font-size: 13.5px; font-weight: 500; color: var(--sub); flex: 1; }
.card-b { padding: 14px 18px 18px; }
.gap { display: grid; gap: 14px; }

/* ตัวเลขสรุป */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpis.k5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { padding: 14px 18px 16px; }
.kpi .top { display: flex; align-items: center; gap: 8px; color: var(--sub); font-size: 13px; }
.kpi .top > span:first-child { flex: 1; }
.kpi .top > .delta { flex: none; }
.kpi .v { font-size: 28px; font-weight: 500; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.kpi .v small { font-size: 13px; color: var(--sub); font-weight: 400; letter-spacing: 0; }
.kpi .note { font-size: 12.5px; color: var(--sub); margin-top: 4px; }
.delta { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: var(--surface); color: var(--sub); white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.up { background: var(--success-soft); color: var(--success); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.dot-up, .dot-down { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 10px; }
.dot-up { background: var(--success-soft); color: var(--success); }
.dot-down { background: var(--danger-soft); color: var(--danger); }

/* ป้ายสถานะ */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
span.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft { background: var(--warn-soft); color: var(--warn); }
.st-held { background: var(--violet-soft); color: var(--violet); }
.st-shipped { background: var(--primary-soft); color: var(--primary); }
.st-received { background: var(--success-soft); color: var(--success); }
.st-cancelled { background: var(--danger-soft); color: var(--danger); }
.st-off { background: var(--surface); color: var(--sub); }

/* ตาราง */
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-size: 12px; color: var(--sub); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; z-index: 1; }
table.t th.right { text-align: right; }
table.t th.center { text-align: center; }
table.t td { padding: 11px 14px; border-bottom: 1px dashed var(--line-2); vertical-align: middle; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface); }
table.t tr.flash td { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--primary-soft); } to { background: transparent; } }
.tbl-wrap { overflow: auto; }
.empty { padding: 44px 16px; text-align: center; color: var(--sub); }
.empty .ill { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; color: var(--faint); }

/* ---------- หน้าส่งของ ---------- */
.ship { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.docs { position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex; flex-direction: column; overflow: hidden; }
.docs .card-h { padding-bottom: 12px; }
.docs .card-h h3 { color: var(--text); font-weight: 600; font-size: 14px; }
.seg { display: flex; background: var(--hover); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--sub); font-size: 12.5px; white-space: nowrap; }
.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.docs .seg { margin: 0 14px; }
.doc-list { overflow: auto; padding: 10px 8px 8px; flex: 1; }
.doc-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 12px; padding: 10px 12px; cursor: pointer; margin-bottom: 2px; }
.doc-item:hover { background: var(--surface); }
.doc-item.on { background: var(--hover); }
.doc-item .no { font-family: var(--mono); font-weight: 600; font-size: 13px; }
.doc-item .meta { font-size: 12px; color: var(--sub); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-item .meta b { color: var(--text); font-weight: 500; }

.doc-top { display: flex; align-items: flex-start; gap: 12px; padding: 18px 18px 0; flex-wrap: wrap; }
.doc-no { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.doc-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 16px 18px 0; border: 1px solid var(--line); border-radius: 12px; }
.doc-meta > div { padding: 10px 14px; border-right: 1px solid var(--line); min-width: 0; }
.doc-meta > div:last-child { border-right: 0; }
.doc-meta .k { font-size: 12px; color: var(--sub); }
.doc-meta .v { font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.banner { margin: 14px 18px 0; padding: 10px 14px; border-radius: 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner.held { background: var(--violet-soft); color: var(--violet); }
.banner.shipped { background: var(--primary-soft); color: #2152c9; }
.banner.received { background: var(--success-soft); color: #147a4b; }
.banner.cancelled { background: var(--danger-soft); color: #b3262b; }

.scan { padding: 16px 18px 0; display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; }
.scan-box { display: flex; flex-direction: column; gap: 10px; }
.scan-field { position: relative; }
.scan-field i.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--sub); width: 20px; height: 20px; }
.scan-input { width: 100%; font-size: 18px; font-family: var(--mono); padding: 13px 14px 13px 44px; border: 1.5px solid var(--line-2); border-radius: 12px; outline: none; background: var(--panel); }
.scan-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(47, 107, 255, .14); }
.scan-input.minus { border-color: var(--danger); }
.scan-input.minus:focus { box-shadow: 0 0 0 4px rgba(229, 72, 77, .14); }
.scan-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scan-tools .seg { flex: none; }
.scan-tools .seg button { min-width: 44px; font-weight: 600; font-family: var(--mono); }
.seg button.minus.on { background: var(--danger); color: #fff; }
.hint { font-size: 12px; color: var(--sub); }
/* ผลสแกนล่าสุด — การ์ดเข้ม */
.last { background: var(--ink); color: #e8eaee; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; min-height: 118px; }
.last .lt { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #9aa1ad; }
.last .lt span { flex: 1; }
.last .lv { font-family: var(--mono); font-size: 34px; font-weight: 500; letter-spacing: -0.02em; margin-top: auto; color: #fff; }
.last .ln { font-size: 13px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last .ls { font-size: 12px; color: #9aa1ad; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last .tag { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.last .tag.up { background: rgba(31, 157, 99, .18); color: #4ad18f; }
.last .tag.down { background: rgba(229, 72, 77, .18); color: #ff8589; }
.last.bad { background: #2a1517; }
.last .btn { color: var(--text); }
.seg button:hover:not(.on) { color: var(--text); }
.last.bad .ln { white-space: normal; }

.totals { display: flex; gap: 26px; padding: 16px 18px 12px; flex-wrap: wrap; align-items: flex-end; }
.totals .k { font-size: 12px; color: var(--sub); }
.totals .v { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.totals .search { width: 240px; max-width: 100%; }
.qty-ctl { display: inline-flex; align-items: center; background: var(--hover); border-radius: 10px; padding: 2px; }
.qty-ctl button { border: 0; background: transparent; width: 30px; height: 30px; cursor: pointer; border-radius: 8px; color: var(--sub); display: grid; place-items: center; }
.qty-ctl button:hover { background: var(--panel); color: var(--text); }
.qty-ctl input { width: 56px; height: 30px; border: 0; background: var(--panel); border-radius: 8px; text-align: center; font-weight: 600; font-family: var(--mono); font-size: 14px; outline: none; }
.recv-input { width: 80px; text-align: center; font-weight: 600; font-family: var(--mono); padding: 6px; }
.diff-pos { color: var(--success); font-weight: 600; }
.diff-neg { color: var(--danger); font-weight: 600; }
.ok-mark { color: var(--success); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line); align-items: center; }
.item-name { font-weight: 500; }
.item-code { font-size: 11.5px; color: var(--sub); font-family: var(--mono); }
.var { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.var span { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 12px; }

/* ---------- รายงาน ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px 18px; }
.filters label { font-size: 12px; color: var(--sub); display: flex; flex-direction: column; gap: 5px; }
.filters .input { min-width: 140px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.chart { padding: 6px 18px 16px; }
.chart .bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.chart .bars div { flex: 1; min-width: 3px; background: #d7dce5; border-radius: 4px 4px 2px 2px; position: relative; }
.chart .bars div.hi { background: var(--success); }
.chart .bars div:hover { background: var(--primary); }
.chart .axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--sub); margin-top: 8px; }
.region td { padding: 10px 18px; }
.region th { padding: 10px 18px; }

/* ---------- เข้าสู่ระบบ (PIN) ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; }
.pin-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 12px 32px rgba(16,24,40,.08); padding: 32px 28px 22px; display: flex; flex-direction: column; align-items: center; }
.pin-lock { width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 8px var(--primary-soft); }
.pin-lock i.i { width: 24px; height: 24px; }
.pin-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 22px 0 6px; text-align: center; }
.pin-sub { min-height: 32px; display: flex; justify-content: center; }
.who-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 12px 3px 3px; cursor: pointer; font-size: 13px; }
.who-chip:hover { background: var(--hover); }
.who-chip .avatar, .user-list .avatar { width: 24px; height: 24px; font-size: 11px; background: var(--panel); }
.who-chip i.i { width: 14px; height: 14px; color: var(--sub); }
.pin-boxes { display: flex; gap: 10px; margin: 20px 0 4px; }
.pin-boxes span { width: 44px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface); display: grid; place-items: center; transition: border-color .12s, background .12s; }
.pin-boxes span.next { border-color: var(--primary); background: var(--panel); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.pin-boxes span.on { border-color: var(--primary-soft); background: var(--primary-soft); }
.pin-boxes span.on::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.pin-boxes.shake { animation: shake .36s ease-in-out; }
.pin-boxes.shake span { border-color: var(--danger); }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.pin-err { min-height: 20px; font-size: 12.5px; color: var(--danger); text-align: center; margin-bottom: 6px; }
.pad { display: grid; grid-template-columns: repeat(3, 64px); gap: 14px 22px; justify-content: center; }
.key { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 22px; font-weight: 500; cursor: pointer; display: grid; place-items: center; transition: background .1s, color .1s, transform .08s; font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; user-select: none; }
.key:hover { background: var(--hover); }
.key:focus { outline: none; }
.key:active, .key.down { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(.96); }
.key.fn { background: transparent; border-color: transparent; color: var(--sub); }
.key.fn:hover { background: var(--hover); color: var(--text); }
.key.fn.down, .key.fn:active { background: var(--hover); color: var(--text); }
.key.fn i.i { width: 22px; height: 22px; }
.pin-go { width: 100%; margin-top: 22px; border-radius: 14px; }
.pin-foot { margin-top: 14px; font-size: 12.5px; color: var(--primary); }
.pin-brand { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--sub); }
.pin-brand .mark { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--sub); display: grid; place-items: center; }
.pin-brand .mark i.i { width: 12px; height: 12px; }
.user-list { display: flex; flex-direction: column; gap: 4px; }
.user-list button { display: flex; align-items: center; gap: 10px; border: 1px solid transparent; background: transparent; padding: 10px 12px; border-radius: 12px; cursor: pointer; text-align: left; }
.user-list button:hover { background: var(--surface); }
.user-list button.on { background: var(--primary-soft); border-color: #cfdcff; }
@media (max-width: 420px) { .pin-card { padding: 28px 18px 20px; border-radius: 24px; } .pad { gap: 12px 18px; } }

/* ---------- modal / toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(22, 25, 31, .38); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border-radius: 18px; width: 100%; max-width: 500px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(16, 24, 40, .18); }
.modal.wide { max-width: 740px; }
.modal-h { padding: 16px 20px 8px; display: flex; align-items: center; }
.modal-h h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -0.01em; }
.modal-b { padding: 8px 20px 18px; overflow: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.result { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 80; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #9aa1ad; }
.toast.ok::before { background: #4ad18f; }
.toast.bad::before { background: #ff6b70; }
.cam video { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; object-fit: cover; }

/* ---------- จอเล็ก ---------- */
@media (max-width: 1280px) {
  .scan { grid-template-columns: 1fr; }
  .last { min-height: 0; }
  .kpis.k5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .ship { grid-template-columns: 1fr; }
  .docs { position: static; max-height: 340px; }
  .split { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 8px 8px 0; }
  .side-in { padding: 8px; border-radius: 14px; flex-direction: row; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .brand { padding: 0 6px 0 2px; }
  .brand > div { display: none; }
  .nav { flex-direction: row; }
  .nav button { white-space: nowrap; padding: 8px 10px; }
  .nav button span.lbl { display: none; }
  .nav button.on span.lbl { display: inline; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .me { display: none; }
  main { padding: 14px 10px 30px; }
  .page-h h1 { font-size: 22px; }
  .doc-meta { grid-template-columns: 1fr; }
  .doc-meta > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .doc-meta > div:last-child { border-bottom: 0; }
  .grid2 { grid-template-columns: 1fr; }
  .kpis, .kpis.k5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 22px; }
  table.t td, table.t th { padding: 9px 10px; }
  .hide-sm { display: none; }
  .scan-tools .seg { flex: 1; }
  .scan-tools .seg button { flex: 1; }
}
.filters label.check { flex-direction: row; align-items: center; font-size: 13px; color: var(--text); }

/* ================= หน้าส่งของ (แบบเดียวกับ POS) ================= */
.layout { transition: grid-template-columns .18s ease; }
.layout.mini { grid-template-columns: 76px minmax(0, 1fr); }
.layout.mini .brand > div, .layout.mini .nav .lbl, .layout.mini .me div, .layout.mini .nav .count { display: none; }
.layout.mini .nav button { justify-content: center; padding: 10px 0; }
.layout.mini .brand { justify-content: center; padding: 2px 0 18px; }
.layout.mini .me { justify-content: center; padding: 8px 0; }
.menu-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--panel); }
.menu-btn i.i { width: 18px; height: 18px; }

.ship-page { display: flex; flex-direction: column; gap: 12px; min-height: calc(100vh - 62px); }
.ship-page .page-h { margin-bottom: 0; align-items: center; }
.ship-page .page-h h1 { font-size: 22px; flex: none; }
.ship-page .page-h .sub { margin-top: 2px; width: auto; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; position: relative; z-index: 5; }
.tb-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.tb-label i.i { color: var(--primary); }
.xl-btn { color: var(--success); border-color: #cdebdc; background: var(--success-soft); }
.xl-btn:hover { background: #d8f1e5; }
.picker { position: relative; }
.picker-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 260px; justify-content: space-between; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 14px; font-weight: 500; }
.picker-btn:hover, .picker.open .picker-btn { background: var(--panel); border-color: var(--primary); }
.picker-pop { position: absolute; top: calc(100% + 6px); left: 0; width: 440px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 48px rgba(16, 24, 40, .16); padding: 10px; }
.picker-list { max-height: 360px; overflow: auto; margin-top: 8px; }
.picker-g { font-size: 11.5px; color: var(--sub); padding: 8px 8px 4px; font-weight: 600; }
.picker-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 8px; border-radius: 10px; cursor: pointer; text-align: left; font-size: 13px; }
.picker-row:hover { background: var(--surface); }
.picker-row.on { background: var(--primary-soft); }

.ship-grid { display: grid; grid-template-columns: minmax(0, 35fr) minmax(0, 65fr); gap: 12px; flex: 1; align-items: stretch; min-height: 0; }
.col-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.col-right { min-width: 0; display: flex; }

.doc-info { padding: 14px 16px; }
.doc-info .k { font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.doc-info .v { font-weight: 500; margin-top: 4px; }
.di-top { display: flex; align-items: flex-start; gap: 12px; }
.di-top .doc-no { font-size: 20px; margin: 2px 0; }
.di-count b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.di-body { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.di-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.di-row .qty-ctl { margin-top: 5px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.chip:hover:not(:disabled) { background: var(--surface); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.chip:disabled { cursor: default; }
.chip.sm { padding: 3px 10px; font-size: 12px; }
.chip.sm.on { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.scan-card { padding: 14px 16px; border: 1.5px solid var(--primary); box-shadow: 0 0 0 4px rgba(47, 107, 255, .06); display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.sc-h, .hist-h { display: flex; align-items: center; gap: 8px; }
.sc-t { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.sc-h .sc-t { flex: 1; }
.sc-t i.i { color: var(--primary); }
.mode { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-weight: 600; color: var(--success); }
.mode.minus { color: var(--danger); background: var(--danger-soft); border-color: #f6c9ca; }
.sc-row { display: flex; gap: 8px; align-items: center; }
.sc-row .scan-input { font-size: 16px; padding: 12px 14px 12px 42px; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; box-shadow: 0 6px 14px rgba(47, 107, 255, .28); }
.round:hover { background: #255de6; }
.round.minus { background: var(--danger); box-shadow: 0 6px 14px rgba(229, 72, 77, .28); }
.round.ghost { background: var(--surface); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.round i.i { width: 20px; height: 20px; }
.sc-steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.scan-card .last { min-height: 0; padding: 12px 14px; }
.scan-card .last .lv { margin-top: 6px; font-size: 28px; }
.scan-card .last .lv span { font-size: 12.5px; color: #9aa1ad; }
.scan-card .last .lt .tag { flex: none; }
.hist-h { padding-top: 12px; border-top: 1px solid var(--line); }
.hist-h .sc-t i.i { color: var(--sub); }
.hist { overflow: auto; flex: 1; min-height: 120px; max-height: 340px; margin: 0 -6px; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.hrow:last-child { border-bottom: 0; }
.hdot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }
.hrow.bad .hdot { background: var(--danger); }
.hrow.bad { color: #b3262b; }
.hrow .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.state-card { padding: 18px; display: flex; gap: 14px; align-items: flex-start; }
.state-card .sc-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--panel); }
.st-bg-held { background: var(--violet-soft); color: #5a36b0; border-color: #e1d6fb; }
.st-bg-shipped { background: var(--primary-soft); color: #2152c9; border-color: #d4e0ff; }
.st-bg-received { background: var(--success-soft); color: #147a4b; border-color: #cdebdc; }
.st-bg-cancelled { background: var(--danger-soft); color: #b3262b; border-color: #f6c9ca; }

.items-card { flex: 1; display: flex; flex-direction: column; min-height: 420px; overflow: hidden; }
.ic-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.ic-h h3 { margin: 0; font-size: 14.5px; font-weight: 600; flex: 1; }
.ic-h h3 .muted { font-weight: 400; }
.ic-h .search { width: 220px; }
.ic-body { flex: 1; max-height: calc(100vh - 300px); }

.action-bar { position: sticky; bottom: 10px; z-index: 4; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 28px rgba(16, 24, 40, .10); padding: 10px 12px 10px 14px; }
.hold-btn { background: var(--violet-soft); color: var(--violet); border-color: #e1d6fb; font-weight: 600; }
.hold-btn:hover { background: #e7defd; }

@media (max-width: 1100px) {
  .ship-grid { grid-template-columns: 1fr; }
  .ic-body { max-height: none; }
  .hist { max-height: 220px; }
}
@media (max-width: 860px) {
  .layout.mini { grid-template-columns: 1fr; }
  .menu-btn { display: none; }
  .ship-page .page-h .sub { display: none; }
  .ship-page .page-h .btn.lg { padding: 8px 12px; font-size: 13px; }
  .picker-btn { min-width: 0; width: 100%; }
  .picker { flex: 1; }
  .toolbar .btn.pill { padding: 6px 10px; font-size: 12.5px; }
  .ic-h .search { width: 100%; }
  .action-bar { bottom: 6px; }
  .action-bar .small.muted { display: none; }
}
/* ล็อกความสูงเท่าหน้าจอ: คอลัมน์ซ้าย/ขวาเลื่อนในตัวเอง แถบปุ่มอยู่ล่างเสมอ */
main { max-width: none; }
@media (min-width: 1101px) {
  .ship-page { height: calc(100vh - 62px); min-height: 560px; }
  .ship-grid { min-height: 0; }
  .col-left { overflow: auto; min-height: 0; padding-bottom: 2px; }
  .col-right { min-height: 0; }
  .items-card { min-height: 0; }
  .ic-body { max-height: none; overflow: auto; }
  .scan-card { min-height: 360px; }
  .hist { max-height: none; }
  .action-bar { position: static; }
}
.scan-card > *, .last > * { flex-shrink: 0; }
.scan-card > .hist { flex: 1 1 auto; min-height: 120px; }
.show-sm { display: none; }
@media (max-width: 860px) {
  .show-sm { display: block; }
  #items td:first-child, #items th:first-child { display: none; }
  .qty-ctl input { width: 44px; }
}

.chip.on:hover:not(:disabled) { background: #255de6; }
.hrow .btn.sm { flex: none; padding: 3px 8px; }

.pos-btn { color: var(--primary); border-color: #cfdcff; background: var(--primary-soft); font-weight: 600; }
.pos-btn:hover { background: #dfe8ff; }

.key.fn[data-k=clear] { font-size: 14px; font-weight: 500; }
.pin-sub { margin-top: 2px; min-height: 0; }

.pin-boxes span { width: 40px; height: 46px; }
.pin-boxes { gap: 8px; }
.pin-foot a { color: var(--primary); }
@media (max-width: 420px) { .pin-boxes span { width: 36px; height: 42px; } }

/* LOG + สำรองข้อมูล */
.input.sm { padding: 5px 8px; font-size: 13px; width: auto; }
table.log-t td { vertical-align: top; }
table.log-t td.detail { min-width: 220px; max-width: 420px; white-space: normal; word-break: break-word; color: var(--sub); }
table.log-t tr.bad td { background: var(--danger-soft); }
#bk-card .card-h { gap: 10px; flex-wrap: wrap; }

/* สลับภาษา ไทย / EN */
.lang-sw { display: inline-flex; background: var(--hover); border-radius: 9px; padding: 3px; gap: 2px; }
.lang-sw button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--sub); font-size: 12px; font-weight: 600; font-family: inherit; }
.lang-sw button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.lang-sw button:hover:not(.on) { color: var(--text); }
.login { position: relative; }
.login-lang { position: absolute; top: 18px; right: 18px; background: var(--panel); box-shadow: var(--shadow); }
.side-lang { margin: 6px 8px 0; align-self: flex-start; }
.layout.mini .side-lang { flex-direction: column; margin: 6px auto 0; }
.layout.mini .side-lang button { padding: 4px 6px; }
