/* Sơ đồ kho · giao diện kiểu bàn vẽ kỹ thuật: nền xám lạnh, lưới, viền mảnh, màu hồng sen đánh dấu chọn */
:root {
  /* NPP Cẩm Vân: một giao diện nền tối duy nhất, điểm nhấn vàng (giống app Soạn hàng).
     Khai báo color-scheme: dark để trình duyệt điện thoại không tự đảo màu khi bật chế độ tối. */
  --paper: #121316; --panel: #1C1D21; --panel-2: #24262B; --stage: #0D0E10; --floor: #1E2024; --yard: #1C2420; --room: #221F2B; --empty: #2A2C31;
  --grid: rgba(240,180,30,.06); --grid-major: rgba(240,180,30,.18);
  --ink: #ECEDEF; --ink-2: #A3A7AF; --ink-3: #6E727A; --line: #34363C; --wall: #C9CDD4;
  --accent: #F2B21E; --accent-soft: rgba(242,178,30,.14); --on-accent: #17130A;
  --ok: #4CC07D; --ok-soft: rgba(76,192,125,.14); --bad: #FF6B5E; --bad-soft: rgba(255,107,94,.14);
  --warn: #F2B21E; --warn-soft: rgba(242,178,30,.14); --info: #6EA8F0; --info-soft: rgba(110,168,240,.14);
  --f-ui: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-code: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --r: 9px; --top: 60px; --nav: 58px;
  color-scheme: dark;
  background: #121316;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.45 var(--f-ui); -webkit-tap-highlight-color: transparent; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.boot { display: grid; place-items: center; height: 100%; color: var(--ink-2); }
.code { font-family: var(--f-code); font-weight: 700; letter-spacing: .02em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.sec-title { font-family: var(--f-code); font-weight: 600; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }

/* Nút, ô nhập */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); font-weight: 500; font-size: 14px; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.acc { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 38px; padding: 0; }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.in, select.in, textarea.in { width: 100%; min-width: 0; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
textarea.in { min-height: 70px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.err { color: var(--bad); font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--panel); }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-right: 1px solid var(--line); background: none; font-size: 13px; font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); white-space: nowrap; color: var(--ink-2); }
.chip.ok { color: var(--ok); border-color: var(--ok); } .chip.bad { color: var(--bad); border-color: var(--bad); }
.chip.warn { color: var(--warn); border-color: var(--warn); } .chip.acc { color: var(--accent); border-color: var(--accent); }
.chip.info { color: var(--info); border-color: var(--info); }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.2); }
.step { display: flex; }
.step button { width: 38px; min-height: 38px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.step button:first-child { border-radius: var(--r) 0 0 var(--r); } .step button:last-child { border-radius: 0 var(--r) var(--r) 0; }
.step input { width: 100%; min-width: 0; text-align: center; border: 1px solid var(--line); border-left: 0; border-right: 0; background: var(--paper); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.step input::-webkit-inner-spin-button, .step input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.list .item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.list .item:first-child { border-top: 0; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { color: var(--ink-2); font-size: 12px; display: block; }
.item .q { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13px; }
.empty { padding: 28px 12px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.bar { height: 8px; border-radius: 4px; background: var(--empty); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }

/* Khung app */
.shell { display: grid; grid-template-rows: auto 1fr auto; height: 100%; padding-top: env(safe-area-inset-top, 0px); }
.top { display: flex; align-items: center; gap: 10px; height: var(--top); padding: 0 14px; background: var(--paper); border-bottom: 1px solid var(--line); min-width: 0; }
.top .brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.top .brand .logo { width: 26px; height: 26px; border: 4px solid var(--accent); border-radius: 4px; display: grid; place-items: center; flex: none; }
.top .brand .logo::after { content: ""; width: 8px; height: 8px; background: var(--accent); border-radius: 1px; }
.top .brand .t { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.top .brand b { font-family: var(--f-code); font-weight: 700; font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.top .brand small { font-family: var(--f-code); font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.userbtn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 6px 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-weight: 600; max-width: 220px; }
.userbtn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbtn .gear { display: grid; place-items: center; width: 30px; height: 30px; border-left: 1px solid var(--line); color: var(--accent); }
.userbtn svg { width: 18px; height: 18px; }
.top select.kho { max-width: 240px; width: auto; min-height: 34px; font-weight: 600; }
.top .search { flex: 1; min-width: 0; max-width: 460px; margin-left: auto; position: relative; }
.top .search input { width: 100%; min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); }
.bell { position: relative; }
.bell .badge { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.netbar { padding: 6px 12px; font-size: 13px; background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid var(--line); }
.netbar.upd { background: #F7D44A; color: #1C1600; display: flex; gap: 10px; align-items: center; }
.netbar.demo { background: var(--accent-soft); }
.views { min-height: 0; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; overflow: auto; }
.page { max-width: 980px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; padding-bottom: 40px; }
.nav { display: flex; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--nav); color: var(--ink-2); text-decoration: none; font-size: 11.5px; font-weight: 500; }
.nav a svg { width: 22px; height: 22px; }
.nav a[aria-current="page"] { color: var(--accent); }
@media (min-width: 900px) {
  .shell { grid-template-columns: 76px 1fr; grid-template-rows: auto auto 1fr; }
  .shell > .top, .shell > .bars { grid-column: 1 / -1; }
  .nav { grid-row: 3; grid-column: 1; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 8px 0; }
  .nav a { flex: none; height: 64px; }
  .views { grid-row: 3; grid-column: 2; }
}
@media (max-width: 899px) { .shell { grid-template-rows: auto auto 1fr auto; } .shell > .bars { grid-row: 2; } .views { grid-row: 3; } .nav { grid-row: 4; } }
@media (max-width: 560px) { .top .brand small { display: none; } .top .brand b { font-size: 18px; } .userbtn .nm { display: none; } .userbtn { padding-left: 6px; } }

/* Trang sơ đồ */
.planview { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: 100%; }
.stage { position: relative; min-width: 0; min-height: 0; background: var(--stage); overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.tools { position: absolute; left: 10px; top: 28px; z-index: 2; display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 80px); overflow: auto; padding-right: 2px; }
.tool { display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); font-size: 13px; font-weight: 500; white-space: nowrap; }
.tool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.vtog { position: absolute; right: 10px; top: 28px; z-index: 2; }
.zoom { position: absolute; right: 10px; bottom: 12px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.hint { position: absolute; left: 10px; bottom: 12px; right: 60px; z-index: 2; pointer-events: none; }
.hint span { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; font-size: 12px; color: var(--ink-2); }
.side { background: var(--panel); border-left: 1px solid var(--line); overflow: auto; min-height: 0; }
.side .inner { padding: 14px 16px 30px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 899px) {
  .planview { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: 48vh; }
  .side.collapsed { max-height: 44px; overflow: hidden; }
  .tool span { display: none; }
  .tool { width: 38px; justify-content: center; padding: 0; }
}
.sidehead { display: flex; align-items: center; gap: 8px; }
.codein { font-family: var(--f-code); font-weight: 700; font-size: 22px; letter-spacing: .03em; text-transform: uppercase; }
.tier { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.tier .hd { display: flex; align-items: center; gap: 8px; }
.lot { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.eq { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.eq b { color: var(--ink); font-size: 16px; font-weight: 600; }

/* Lớp phủ: hộp thoại, bảng trượt, thông báo */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(10,14,20,.45); pointer-events: auto; display: grid; place-items: center; padding: 16px; }
.dialog { width: min(440px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--panel); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { font-size: 17px; }
.dialog .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.fullscreen { position: absolute; inset: 0; background: var(--paper); pointer-events: auto; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.panelpop { position: absolute; top: calc(var(--top) + env(safe-area-inset-top, 0px)); right: 8px; width: min(420px, calc(100% - 16px)); max-height: 75%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; pointer-events: auto; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.toasts { position: absolute; left: 50%; bottom: calc(var(--nav) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100% - 32px)); }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 8px; font-size: 14px; pointer-events: auto; }
.toast.bad { background: var(--bad); color: #fff; }

/* Đăng nhập */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; overflow: auto; }
.auth .box { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth .logo { font-family: var(--f-code); font-weight: 700; font-size: 34px; letter-spacing: .03em; text-transform: uppercase; line-height: 1; }
.notice { border-radius: 8px; padding: 10px 12px; font-size: 14px; border: 1px solid var(--line); background: var(--panel); }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.notice.wait { border-color: var(--info); background: var(--info-soft); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* Trình xếp pallet */
.bld-top { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bld-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 200px minmax(0, 1fr) 210px; }
.bld-tray, .bld-layers { overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--panel); }
.bld-tray { border-right: 1px solid var(--line); } .bld-layers { border-left: 1px solid var(--line); }
.bld-stage { position: relative; min-width: 0; min-height: 0; background: var(--stage); }
.bld-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.tray-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); text-align: left; font-size: 13px; touch-action: none; user-select: none; }
.tray-item[aria-pressed="true"] { border: 2px solid var(--accent); padding: 6px 7px; }
.layer-item { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); text-align: left; font-size: 13px; }
.layer-item[aria-pressed="true"] { border: 2px solid var(--accent); padding: 6px 8px; }
.bld-acts { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); }
@media (max-width: 899px) {
  .bld-body { grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr) auto; }
  .bld-tray { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .bld-tray .tray-item { flex: none; }
  .bld-tray .sec-title, .bld-layers .sec-title { display: none; }
  .bld-layers { flex-direction: row; overflow-x: auto; border-left: 0; border-top: 1px solid var(--line); padding: 8px; }
  .bld-layers .layer-item { flex: none; }
}

/* Bảng */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--ink-2); font-weight: 500; font-size: 12px; }
.tblwrap { overflow-x: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 500; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.photo { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--empty); flex: none; }

/* ---------- Xuất nhập tồn ---------- */
.lb-short { display: none; }
@media (max-width: 899px) { .lb-long { display: none; } .lb-short { display: inline; } }
.page.wide { max-width: 1240px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
input.in.num { text-align: right; }
.daynav { align-items: center; }
.daynav input[type=date] { width: auto; }
.daynav .wd { font-family: var(--f-code); font-weight: 600; color: var(--ink-2); min-width: 22px; text-align: center; }
label.f.inline { flex-direction: row; align-items: center; gap: 6px; }
label.f.inline .in { width: auto; }
.seg button { border: 0; background: none; padding: 0 12px; min-height: 36px; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--panel); }
.card.flush { padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi small { color: var(--ink-2); font-size: 12px; }
.kpi b { font-size: 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi.bad b { color: var(--bad); }
.tbl.ton { min-width: 560px; }
.tbl.ton td, .tbl.ton th { white-space: nowrap; }
.tbl.ton td.sticky, .tbl.ton th.sticky { position: sticky; left: 0; background: var(--panel); z-index: 1; white-space: normal; min-width: 150px; max-width: 240px; box-shadow: 1px 0 0 var(--line); }
.tbl.ton thead th { position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tbl.ton thead th.sticky { z-index: 3; }
.tbl.ton tbody tr:hover td { background: var(--paper); }
.tbl.ton td.strong { font-weight: 600; }
.tbl.ton td.neg { color: var(--bad); }
.tbl.days td.num, .tbl.days th.num { min-width: 64px; }
.tblwrap.card.flush { max-height: 70vh; overflow: auto; }

/* Ô chọn mặt hàng */
.picker { position: relative; min-width: 0; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); min-width: 240px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.16); max-height: 300px; overflow: auto; }
.picker-list .opt { padding: 7px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; border-top: 1px solid var(--line); }
.picker-list .opt:first-child { border-top: 0; }
.picker-list .opt small { color: var(--ink-2); font-size: 12px; }
.picker-list .opt.on { background: var(--accent-soft); }
.picker-list .opt.new { color: var(--accent); font-weight: 500; }
.picker-list .opt.none { color: var(--ink-2); cursor: default; font-size: 13px; }

/* Phiếu */
div.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.ph-head { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.ph-head > .f:first-child { width: 170px; }
.ph-head > .grow2 { flex: 1 1 280px; }
.in.ro { display: flex; align-items: center; color: var(--ink); background: var(--panel-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chipbtn { min-height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--line); background: var(--panel-2); font-size: 13px; font-weight: 500; color: var(--ink); }
.chipbtn.le { border-color: var(--accent); color: var(--accent); }
.chipbtn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ph-sec { display: flex; flex-direction: column; gap: 8px; }
.ph-sec-h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ph-sec-h > b { font-size: 16px; }
.ph-sec-h .kt { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.ph-sec-h .kt .in { width: 130px; min-height: 32px; }
.kt-info { color: var(--info); }
.ph-part { display: flex; flex-direction: column; gap: 4px; padding: 8px 0 2px; border-top: 1px dashed var(--line); }
.ph-part-h { display: flex; align-items: center; gap: 8px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.tag.t-out { background: var(--bad-soft); color: var(--bad); }
.tag.t-in { background: var(--ok-soft); color: var(--ok); }
.xrow { display: grid; grid-template-columns: 76px 70px minmax(170px, 2fr) 96px minmax(170px, 3fr) 26px 32px; gap: 6px; align-items: center; }
.xrow.hd { font-size: 12px; color: var(--ink-2); padding: 0 2px; }
.xrow.ok .tot b { color: var(--ok); }
.xrow .qty { text-align: right; font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.xrow .qty.theo { font-weight: 500; color: var(--ink-2); }
.xrow .qty.bad, .dotc .in.dot.bad { border-color: var(--bad); color: var(--bad); }
.xrow .unit { padding-right: 4px; }
.xrow .ck { justify-content: center; }
.xrow .ck input { width: 20px; height: 20px; accent-color: var(--accent); }
.xrow .x { padding: 0; width: 32px; }
.tot { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-variant-numeric: tabular-nums; padding-right: 4px; }
.tot b { font-size: 18px; font-weight: 700; }
.tot small { font-size: 11px; font-weight: 600; }
.tot.ok small { color: var(--ok); }
.tot.thua b, .tot.thua small { color: var(--info); }
.tot.thieu b, .tot.thieu small { color: var(--bad); }
.dots { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.dotc { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--paper); }
.dotc .sign { width: 24px; padding: 0; border: 0; border-right: 1px solid var(--line); background: var(--panel-2); font-weight: 700; color: var(--ok); font-size: 15px; }
.dotc .sign.neg { color: var(--bad); }
.dotc .in.dot { width: 54px; min-height: 34px; border: 0; border-radius: 0; text-align: right; padding: 4px 6px; background: transparent; font-variant-numeric: tabular-nums; }
.dots .addot { min-height: 34px; width: 34px; padding: 0; font-size: 18px; }
.quickbox { display: flex; flex-direction: column; gap: 3px; padding-top: 4px; }
.quickbox .in.quick { background: var(--panel); border-style: dashed; font-family: var(--f-code); font-size: 16px; }
.ph-actions { position: sticky; bottom: 0; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 -6px 18px rgba(0,0,0,.35); }
.ph-totals { font-size: 14px; font-variant-numeric: tabular-nums; }
.pend { border-color: var(--warn); }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.picker-list .opt-h { padding: 6px 10px 3px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--panel-2); position: sticky; top: 0; }
@media (max-width: 720px) {
  .ph-head > .f:first-child { width: auto; flex: 1 1 140px; }
  .ph-head > .grow2 { flex-basis: 100%; }
  .xrow { grid-template-columns: 64px 64px 1fr 32px; grid-template-areas: "s s s x" "q t u c" "d d d d"; row-gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); }
  .xrow > :nth-child(1) { grid-area: q; } .xrow > :nth-child(2) { grid-area: t; } .xrow > :nth-child(3) { grid-area: s; }
  .xrow > :nth-child(4) { grid-area: u; } .xrow > :nth-child(5) { grid-area: d; } .xrow > :nth-child(6) { grid-area: c; } .xrow > :nth-child(7) { grid-area: x; }
  .xrow.hd { display: none; }
  .xrow.blank > :nth-child(1), .xrow.blank > :nth-child(2), .xrow.blank > :nth-child(4), .xrow.blank > :nth-child(6) { display: none; }
  .xrow.blank { grid-template-areas: "s s s x" "d d d d"; }
  .ph-actions .row .btn { flex: 1; }
}

/* Hàng tồn */
.ucards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.ucard { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ucard .ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex: none; }
.ucard .ic svg { width: 24px; height: 24px; }
.ucard .t { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ucard small { color: var(--ink-2); font-size: 12px; }
.ucard b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ucard span { font-size: 12px; font-variant-numeric: tabular-nums; }
.ucard i { font-style: normal; } .ucard i.pos { color: var(--ok); } .ucard i.neg { color: var(--bad); }
.dayc summary { cursor: pointer; display: flex; gap: 4px; flex-wrap: wrap; }
.dayc .list { margin-top: 6px; }

/* Thiết lập (hộp mở từ nút người dùng) */
.sheet-scrim { place-items: center; }
.sheet { width: min(760px, 100%); height: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-h h2 { font-size: 19px; }
.sheet-tabs { display: flex; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.sheet-tabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 10px 10px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.sheet-tabs button svg { width: 17px; height: 17px; }
.sheet-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.sheet-b { flex: 1; overflow: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.sheet-b h3.sub { font-size: 15px; margin-top: 6px; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.ulist { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.urow { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.urow:first-child { border-top: 0; }
.urow.req { background: var(--bad-soft); }
.urow .t { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.urow .t small { color: var(--ink-2); font-size: 12px; }
.urow .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.row.tight { gap: 4px 6px; }
.netbar.beta { background: var(--info-soft); }
.netbar a { color: var(--accent); }
.err:empty { display: none; }
.err { color: var(--bad); font-size: 13px; }
@media (max-width: 640px) {
  .sheet-scrim { padding: 0; }
  .sheet { width: 100%; height: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top, 0px); }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

.row.nowrap { flex-wrap: nowrap; }
@media (max-width: 720px) { .ph-actions { padding: 8px; gap: 6px; } .ph-actions .row .btn { flex: 0 1 auto; } .ph-actions .row .btn.pri { flex: 1; } }
/* Thông báo nhanh hiện phía trên để không che nút Lưu */
.toasts { bottom: auto; top: calc(var(--top) + 10px + env(safe-area-inset-top, 0px)); }
.tbl td.num, .tbl th.num { text-align: right; }
.xrow .qty.theo::placeholder { font-size: 11px; font-weight: 400; color: var(--ink-3); }
@media (max-width: 560px) { .top .brand .t { display: none; } .top select.kho { max-width: 170px; } }
