/* Kho di động — minimal storekeeper shell (role WAREHOUSE).
   Ported from the approved design design-demos/warehouse-mobile/huong-v8.html.
   Everything is scoped under .wm-root and uses V8 --bms-* tokens only, so Light/Dark
   follow body.bms-dark-executive automatically. */

body.warehouse-mode .app-shell,
body.warehouse-mode .floating-actions-container,
body.warehouse-mode .business-cache-readonly-banner { display: none !important; }
/* Chat nội bộ / POP Nexus mở từ nút góc trên phải của app thủ kho: chỉ hiện cửa sổ đang mở, đè lên app; ẩn các bong bóng mở. */
body.warehouse-mode .floating-actions-container:has(.internal-chat-root.is-open, .pop-nexus-launcher.is-open) { display: flex !important; z-index: 2147482600; }
body.warehouse-mode .floating-actions-container :is(.internal-chat-launcher, .pop-nexus-launcher) { display: none !important; }
body.warehouse-mode .floating-actions-container .internal-chat-root:not(.is-open),
body.warehouse-mode .floating-actions-container .pop-nexus-root:not(:has(.pop-nexus-launcher.is-open)) { display: none !important; }

.wm-root {
  --wm-on-primary: var(--bms-surface);
  --wm-camera-bg: var(--bms-text);
  --wm-camera-fg: var(--bms-surface);
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  background: var(--bms-canvas);
  color: var(--bms-text);
  font-family: var(--bms-font-ui);
  font-size: 15px;
  line-height: 1.5;
}
.bms-dark-executive .wm-root {
  --wm-on-primary: var(--bms-frame-text);
  --wm-camera-bg: var(--bms-frame-950);
  --wm-camera-fg: var(--bms-frame-text);
}
.wm-root[hidden] { display: none; }
.wm-app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bms-canvas);
}
@media (min-width: 720px) {
  .wm-app { border-left: 1px solid var(--bms-border); border-right: 1px solid var(--bms-border); box-shadow: var(--bms-shadow-2); }
}
.wm-root :is(h1, h2, h3, p) { margin: 0; }
.wm-root :is(h1, h2, h3) { font-family: var(--bms-font-display); letter-spacing: -0.018em; color: var(--bms-text); }
.wm-root button, .wm-root input { font: inherit; color: inherit; }
.wm-root button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.wm-root :is(button, input):focus-visible { outline: 3px solid var(--bms-primary-soft); outline-offset: 2px; }
.wm-i { width: 20px; height: 20px; stroke: currentColor; stroke-width: 1.75; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.wm-num { font-family: var(--bms-font-data); font-variant-numeric: tabular-nums; }

/* Topbar (V8 mobile topbar grammar) */
.wm-topbar { flex: 0 0 auto; min-height: 64px; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom: 1px solid var(--bms-border); background: var(--bms-surface); }
.wm-icon-btn { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--bms-border); border-radius: var(--bms-radius-1); background: var(--bms-surface); color: var(--bms-text); }
.wm-icon-btn:active { background: var(--bms-neutral-soft); }
.wm-logo { width: 32px; height: 32px; flex: 0 0 32px; object-fit: contain; border-radius: 8px; }
.wm-brand { display: grid; gap: 2px; min-width: 0; flex: 1; }
.wm-crumbs { display: flex; align-items: center; gap: 6px; color: var(--bms-text-muted); font-size: 13px; white-space: nowrap; min-width: 0; }
.wm-crumbs strong { color: var(--bms-text); font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.wm-crumbs b { color: var(--bms-text); font-weight: 700; }
.wm-sub { color: var(--bms-text-muted); font: 500 11px/1.2 var(--bms-font-data); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Scrolling content */
.wm-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 16px 20px; display: grid; align-content: start; gap: 14px; overscroll-behavior: contain; }
.wm-head h2 { font-size: 22px; line-height: 1.2; font-weight: 700; }
.wm-head p { color: var(--bms-text-muted); font-size: 14px; margin-top: 4px; }
.wm-eyebrow { color: var(--bms-text-muted); font: 600 11px/1.2 var(--bms-font-data); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }

/* Cards, buttons, status */
.wm-card { background: var(--bms-surface); border: 1px solid var(--bms-border); border-radius: var(--bms-radius-3); box-shadow: var(--bms-shadow-1); }
.wm-pad { padding: 16px; }
.wm-btn { display: inline-flex; min-height: var(--bms-control-touch); align-items: center; justify-content: center; gap: var(--bms-space-2); padding: 0 18px; border: 1px solid var(--bms-border); border-radius: var(--bms-radius-round); background: var(--bms-surface); color: var(--bms-text); font-weight: 600; font-size: 15px; }
.wm-btn:active:not(:disabled) { background: var(--bms-neutral-soft); }
.wm-btn.primary { border-color: var(--bms-primary); background: var(--bms-primary); color: var(--wm-on-primary); }
.wm-btn.primary:active:not(:disabled) { border-color: var(--bms-primary-active); background: var(--bms-primary-active); }
.wm-btn.danger { border-color: var(--bms-danger); color: var(--bms-danger); background: var(--bms-surface); }
.wm-btn:disabled { cursor: not-allowed; opacity: .45; }
.wm-btn.lg { min-height: 56px; font-size: 16px; width: 100%; }
.wm-text-action { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--bms-primary); font-weight: 600; font-size: 14px; }
.wm-status { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: var(--bms-radius-round); color: var(--bms-neutral); background: var(--bms-neutral-soft); font: 600 12px/1.1 var(--bms-font-ui); white-space: nowrap; }
.wm-status::before { content: ""; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 999px; background: currentColor; }
.wm-status.ok { color: var(--bms-success); background: var(--bms-success-soft); }
.wm-status.warn { color: var(--bms-warning); background: var(--bms-warning-soft); }
.wm-status.danger { color: var(--bms-danger); background: var(--bms-danger-soft); }
.wm-status.info { color: var(--bms-info); background: var(--bms-info-soft); }

/* Inbox queue (V8 queue grammar) */
.wm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--bms-border); }
.wm-card-head h3 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.wm-card-head span { color: var(--bms-text-muted); font-size: 12px; }
.wm-icon-wrap { width: 34px; height: 34px; border-radius: 10px; background: var(--bms-canvas); display: grid; place-items: center; color: var(--bms-text-muted); }
.wm-queue-item { width: 100%; min-height: 68px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border: 0; border-top: 1px solid var(--bms-border); background: transparent; text-align: left; }
.wm-queue-item:first-of-type { border-top: 0; }
.wm-queue-item:active { background: var(--bms-primary-soft); }
.wm-queue-item strong { display: block; font-size: 15px; font-weight: 600; }
.wm-queue-item small { display: block; color: var(--bms-text-muted); font-size: 13px; margin-top: 2px; }
.wm-count { min-width: 36px; height: 36px; padding: 0 8px; display: grid; place-items: center; border-radius: 999px; background: var(--bms-text); color: var(--bms-surface); font: 700 16px/1 var(--bms-font-data); font-variant-numeric: tabular-nums; }
.wm-count.zero { background: var(--bms-neutral-soft); color: var(--bms-text-muted); }
.wm-chev { color: var(--bms-text-subtle); }

/* Rows (lists of lines / items) */
.wm-row { width: 100%; min-height: 72px; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 14px 16px; border: 0; border-top: 1px solid var(--bms-border); background: transparent; text-align: left; }
.wm-row:first-child { border-top: 0; }
.wm-row:active { background: var(--bms-primary-soft); }
.wm-row strong { font-size: 15px; font-weight: 600; display: block; }
.wm-row small { display: block; color: var(--bms-text-muted); font-size: 13px; }
.wm-qty { font: 700 18px/1 var(--bms-font-data); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.wm-qty em { font-style: normal; font-size: 13px; font-weight: 500; color: var(--bms-text-muted); margin-left: 3px; }

/* Line detail facts */
.wm-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wm-code { font: 600 12px/1.2 var(--bms-font-data); letter-spacing: .04em; color: var(--bms-text-muted); }
.wm-line-title { font: 650 18px/1.25 var(--bms-font-display); margin-top: 4px; }
.wm-line-sub { color: var(--bms-text-muted); font-size: 14px; margin-top: 2px; }
.wm-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.wm-fact { padding: 10px 12px; border-radius: var(--bms-radius-2); background: var(--bms-canvas); min-width: 0; }
.wm-fact span { display: block; color: var(--bms-text-muted); font-size: 12px; }
.wm-fact strong { display: block; margin-top: 2px; font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.wm-big { text-align: center; padding: 18px 12px; }
.wm-big span { display: block; color: var(--bms-text-muted); font-size: 12px; font-weight: 600; }
.wm-big strong { display: block; font: 700 44px/1.05 var(--bms-font-data); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.wm-big strong em { font-style: normal; font-size: 16px; font-weight: 600; color: var(--bms-text-muted); letter-spacing: 0; margin-left: 6px; }
.wm-note { color: var(--bms-text-muted); font-size: 13px; }
.wm-field-label { font-size: 12px; font-weight: 600; color: var(--bms-text-muted); margin: 0 2px 8px; }
.wm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wm-chip { min-height: 48px; padding: 0 16px; border: 1px solid var(--bms-border); border-radius: var(--bms-radius-1); background: var(--bms-surface); color: var(--bms-text); font: 600 14px/1.2 var(--bms-font-ui); }
.wm-chip.active { border-color: var(--bms-primary); color: var(--bms-primary); background: var(--bms-primary-soft); }

/* Stock metric strip */
.wm-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--bms-border); border: 1px solid var(--bms-border); border-radius: var(--bms-radius-2); overflow: hidden; margin-top: 14px; }
.wm-metric { padding: 12px; background: var(--bms-surface); min-width: 0; }
.wm-metric span { display: block; color: var(--bms-text-muted); font-size: 12px; font-weight: 600; }
.wm-metric strong { display: block; margin-top: 6px; font: 700 30px/1 var(--bms-font-data); font-variant-numeric: tabular-nums; letter-spacing: -.03em; overflow-wrap: anywhere; }
.wm-metric.available { background: var(--bms-primary-soft); }
.wm-metric.available :is(span, strong) { color: var(--bms-primary); }
.wm-tx { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; padding: 12px 16px; border-top: 1px solid var(--bms-border); }
.wm-tx:first-child { border-top: 0; }
.wm-tx-qty { font: 700 18px/1.3 var(--bms-font-data); font-variant-numeric: tabular-nums; text-align: right; }
.wm-tx-qty.in { color: var(--bms-success); }
.wm-tx-qty.out { color: var(--bms-danger); }
.wm-tx p { font-size: 14px; font-weight: 600; }
.wm-tx small { display: block; color: var(--bms-text-muted); font-size: 12px; margin-top: 2px; }

/* Search */
.wm-search { display: flex; height: 48px; align-items: center; gap: 8px; padding: 0 6px 0 14px; border: 1px solid var(--bms-border); border-radius: var(--bms-radius-round); background: var(--bms-surface); color: var(--bms-text-muted); }
.wm-search:focus-within { border-color: var(--bms-primary); box-shadow: 0 0 0 3px var(--bms-primary-soft); }
.wm-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--bms-text); font-size: 16px; }
.wm-search input::placeholder { color: var(--bms-text-subtle); }
.wm-search .wm-btn { min-height: 38px; padding: 0 14px; font-size: 14px; }

/* Scan */
.wm-viewfinder { position: relative; height: 300px; border-radius: var(--bms-radius-3); background: var(--wm-camera-bg); color: var(--wm-camera-fg); overflow: hidden; }
.wm-viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wm-vf-frame { position: absolute; left: 50%; top: 46%; width: 190px; height: 190px; transform: translate(-50%, -50%); pointer-events: none; }
.wm-vf-frame i { position: absolute; width: 34px; height: 34px; border: 3px solid var(--bms-brand-yellow); }
.wm-vf-frame i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.wm-vf-frame i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.wm-vf-frame i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.wm-vf-frame i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.wm-vf-hint { position: absolute; left: 12px; right: 12px; bottom: 18px; text-align: center; font-size: 15px; font-weight: 600; }
.wm-vf-hint small { display: block; font-size: 12px; font-weight: 500; opacity: .75; margin-top: 2px; }

/* Selectable issue lines */
.wm-pick-list { display: grid; gap: 8px; }
.wm-pick { width: 100%; min-height: 80px; display: grid; grid-template-columns: 32px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--bms-border); border-radius: var(--bms-radius-2); background: var(--bms-surface); text-align: left; }
.wm-pick.on { border-color: var(--bms-primary); background: var(--bms-primary-soft); }
.wm-check { width: 30px; height: 30px; border-radius: var(--bms-radius-1); border: 2px solid var(--bms-border-strong); display: grid; place-items: center; color: transparent; background: var(--bms-surface); }
.wm-pick.on .wm-check { background: var(--bms-primary); border-color: var(--bms-primary); color: var(--wm-on-primary); }
.wm-pick strong { display: block; font-size: 15px; font-weight: 600; }
.wm-pick small { display: block; color: var(--bms-text-muted); font-size: 13px; margin-top: 2px; }
.wm-pick-item.on { border: 1px solid var(--bms-primary); border-radius: var(--bms-radius-2); background: var(--bms-primary-soft); }
.wm-pick-item.on .wm-pick { border: 0; background: transparent; }
.wm-stepper { display: grid; grid-template-columns: 1fr 44px 88px 44px; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 0 14px 12px 58px; }
.wm-stepper-label { font-size: 13px; font-weight: 600; color: var(--bms-text-muted); }
.wm-stepper .wm-icon-btn { font-size: 20px; font-weight: 700; }
.wm-step-input { height: 44px; width: 100%; min-width: 0; border: 1px solid var(--bms-border-strong); border-radius: var(--bms-radius-1); background: var(--bms-surface); color: var(--bms-text); text-align: center; font: 700 18px/1 var(--bms-font-data); font-variant-numeric: tabular-nums; }
.wm-step-input:focus { outline: 2px solid var(--bms-primary); outline-offset: 1px; }
.wm-stepper small { grid-column: 2 / 5; text-align: center; color: var(--bms-text-muted); font-size: 12px; margin-top: 4px; }
.wm-progress { width: 100%; height: 6px; margin-top: 12px; border: 0; border-radius: 999px; overflow: hidden; background: var(--bms-neutral-soft); accent-color: var(--bms-primary); }
.wm-progress::-webkit-progress-bar { background: var(--bms-neutral-soft); }
.wm-progress::-webkit-progress-value { background: var(--bms-primary); border-radius: 999px; }
.wm-progress::-moz-progress-bar { background: var(--bms-primary); }

/* Sticky action bar + bottom nav */
.wm-sticky { flex: 0 0 auto; padding: 12px 16px 14px; border-top: 1px solid var(--bms-border); background: var(--bms-surface); display: grid; gap: 8px; }
.wm-sticky .wm-hint { font-size: 12px; color: var(--bms-text-muted); text-align: center; }
.wm-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wm-nav { flex: 0 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--bms-border); background: var(--bms-surface); padding: 4px 6px calc(env(safe-area-inset-bottom) + 6px); }
.wm-nav button { border: 0; background: transparent; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 56px; color: var(--bms-text-muted); font-size: 12px; font-weight: 600; }
.wm-nav .wm-pill { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; }
.wm-nav button.active { color: var(--bms-primary); }
.wm-nav button.active .wm-pill { background: var(--bms-primary-soft); }
.wm-nav .scan .wm-pill { height: 34px; background: var(--bms-primary); color: var(--wm-on-primary); }
.wm-nav .scan { color: var(--bms-text); }
.wm-nav .scan.active .wm-pill { background: var(--bms-primary-active); box-shadow: 0 0 0 4px var(--bms-primary-soft); }

/* Result / undo */
.wm-result { display: grid; justify-items: center; text-align: center; padding: 24px 16px 18px; }
.wm-result-mark { width: 72px; height: 72px; border-radius: 999px; display: grid; place-items: center; background: var(--bms-success-soft); color: var(--bms-success); margin-bottom: 14px; }
.wm-result-mark.pending { background: var(--bms-info-soft); color: var(--bms-info); }
.wm-result-mark.error { background: var(--bms-danger-soft); color: var(--bms-danger); }
.wm-result-mark .wm-i { width: 36px; height: 36px; stroke-width: 2.2; }
.wm-result h2 { font-size: 22px; line-height: 1.25; font-weight: 700; }
.wm-result p { color: var(--bms-text-muted); margin-top: 6px; font-size: 14px; }
.wm-decisions { display: grid; }
.wm-decision { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--bms-border); align-items: center; }
.wm-decision:first-child { border-top: 0; }
.wm-decision span { color: var(--bms-text-muted); font-size: 13px; }
.wm-decision strong { font-size: 15px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Profile + empty states */
.wm-user { display: flex; align-items: center; gap: 12px; padding: 14px; }
.wm-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--bms-text); color: var(--bms-surface); font: 700 14px var(--bms-font-display); }
.wm-user strong { display: block; color: var(--bms-text); font-size: 16px; }
.wm-user span { display: block; color: var(--bms-text-muted); font-size: 13px; }
.wm-user .wm-avatar { display: grid; flex: none; color: var(--bms-surface); font-size: 14px; }
.wm-empty { padding: 28px 16px; text-align: center; color: var(--bms-text-muted); font-size: 14px; }
.wm-error { padding: 12px 14px; border-radius: var(--bms-radius-2); background: var(--bms-danger-soft); color: var(--bms-danger); font-size: 14px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { .wm-root *, .wm-root *::before, .wm-root *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
