/* ERP area styles: POS counter + bill view (prefix pos-) */
.pos-grid { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 14px; align-items: start; }
.pos-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pos-rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; position: sticky; top: calc(var(--topbar-h) + 10px); max-height: calc(100vh - var(--topbar-h) - 20px); overflow-y: auto; padding-bottom: 4px; scrollbar-width: thin; }
.pos-rail .card-b { padding: 10px 14px 14px; }
.pos-rail .card-h { padding: 11px 14px 0; }
@media (max-width: 1180px) { .pos-grid { grid-template-columns: 1fr; } .pos-rail { position: static; max-height: none; } }

.pos-banner:empty { display: none; }
.pos-banner { margin-bottom: 12px; }
.pos-block { border-width: 1.5px; }
.pos-block ul { margin: 4px 0 4px 18px; padding: 0; }
.pos-block b { font-size: 14px; }

/* search */
.pos-search-card { overflow: hidden; }
.pos-search { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.pos-search > .ico { color: var(--brand); }
.pos-search-input.input { flex: 1; height: 44px; font-size: 16px; font-weight: 500; border-radius: 12px; border-color: var(--brand-100); background: var(--surface-2); }
.pos-search-input.input:focus { background: var(--surface); }
.pos-scan-hint { display: inline-flex; gap: 6px; align-items: center; font-size: 11.5px; font-weight: 600; color: var(--success); white-space: nowrap; }
.pos-find { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); border-top: 1px solid var(--border); max-height: 360px; }
.pos-find[hidden] { display: none; }
.pos-results { overflow-y: auto; border-right: 1px solid var(--border); padding: 6px; }
.pos-detail { overflow-y: auto; padding: 10px 14px 12px; font-size: 12.5px; }
.pos-detail .erp-section-title { margin: 10px 0 6px; font-size: 11px; }
.pos-detail-h { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.pos-salt-note { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--brand); padding: 4px 8px 6px; }
.pos-res { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.pos-res.hl { background: var(--brand-50); border-color: var(--brand-100); }
.pos-res-main, .pos-res-side { min-width: 0; }
.pos-res-side { text-align: right; flex: none; }
.pos-res-name { font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pos-res-name .badge { height: 18px; padding: 0 6px; font-size: 10.5px; }
.pos-res-sub { font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; justify-content: inherit; }
.pos-res-side .pos-res-sub { justify-content: flex-end; }
.pos-res-stock { font-weight: 650; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pos-match { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); border: 1px solid var(--border); border-radius: 5px; padding: 0 4px; }
.pos-chip-warn { font-size: 10.5px; font-weight: 700; color: #92400e; background: #fef3c7; border-radius: 5px; padding: 0 4px; }
.pos-batch-tbl td { padding: 5px 6px; }
.pos-step.btn.sm.icon { width: 26px; height: 26px; padding: 0; flex: none; }
.pos-cart-tbl .pos-qty.input, .pos-cart-tbl .pos-disc.input { width: 46px !important; min-width: 46px; max-width: 46px; flex: none !important; }
.pos-loose { margin-top: 4px; }
.pos-loose .subtle:first-child { width: 26px; text-align: center; }
.pos-ret-scroll { overflow-x: auto; max-width: 100%; }
.pos-drawer-f, .pos-preview-modal .modal-f { flex-wrap: wrap; }
.pos-grid > *, .pos-main > *, .pos-rail > * { min-width: 0; }
.pos-cust-head > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.pos-batch-tbl .btn.sm { height: 24px; }
.pos-expired-row td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.pos-subs { display: flex; flex-wrap: wrap; gap: 6px; }
.pos-sub { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 5px 9px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600; }
.pos-sub:hover:not(:disabled) { border-color: var(--brand); }
.pos-sub:disabled { opacity: 0.55; cursor: not-allowed; }
.pos-sub .subtle { font-size: 11px; font-weight: 500; }
.pos-other { display: flex; flex-wrap: wrap; gap: 5px; }
.pos-br-chip { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--brand-50); color: var(--brand); font-variant-numeric: tabular-nums; }
.pos-br-chip.none { background: var(--slate-100); color: var(--text-3); }
[data-theme='dark'] .pos-br-chip.none { background: #1e2a26; }

/* cart */
.pos-cart { min-height: 160px; }
.pos-cart-scroll { overflow-x: auto; }
.pos-cart-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 34px 16px 40px; color: var(--text-3); }
.pos-cart-empty b { color: var(--text-2); }
.pos-cart-tbl { margin-top: 6px; }
.pos-cart-tbl th:first-child, .pos-cart-tbl td:first-child { padding-left: 16px; }
.pos-cart-tbl td { padding: 8px 8px; }
.pos-idx { color: var(--text-3); font-variant-numeric: tabular-nums; width: 28px; }
.pos-batch-sel.select { height: 30px; font-size: 12px; width: 190px; max-width: 100%; padding: 0 6px; }
.pos-qty-wrap { display: flex; align-items: center; gap: 4px; font-size: 11.5px; white-space: nowrap; }
.pos-qty.input { flex: none; width: 44px; height: 30px; text-align: right; padding: 0 7px; font-variant-numeric: tabular-nums; }
.pos-disc-wrap { display: flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.pos-cart-tbl td:nth-child(2) { min-width: 150px; }
.pos-block-line .btn { flex: none; }
.pos-disc.input { flex: none; width: 42px; height: 30px; text-align: right; padding: 0 6px; }
.pos-rule { font-weight: 650; color: var(--brand); background: var(--brand-50); border-radius: 6px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.pos-net { font-weight: 700; font-size: 13.5px; }
.pos-subrow td { border-bottom: 1px solid var(--border); padding-top: 0; }
.pos-subrow.danger td { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.pos-block-line { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 12.5px; padding: 6px 0 4px; }
.pos-block-line > .ico { color: var(--danger); flex: none; }
.pos-block-line > div { flex: 1; }
.pos-override-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-2); padding: 2px 0 6px; }
.pos-override-line .select { height: 28px; font-size: 12px; }

/* rail: customer */
.pos-hint { margin-top: 8px; font-size: 11.5px; }
.linkbtn { background: none; border: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; text-align: left; }
.pos-cust-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.pos-cust-name { font-weight: 700; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.pos-cust-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 10px 0 4px; }
.pos-cust-stats > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px; display: flex; flex-direction: column; min-width: 0; }
.pos-cust-stats span { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.pos-cust-stats b { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-cust-stats b.warn { color: #b45309; }
.pos-refill { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.pos-refill:last-of-type { border-bottom: none; }
.pos-refill .subtle { font-size: 11px; }
.pos-hist { display: flex; gap: 8px; justify-content: space-between; align-items: center; width: 100%; padding: 5px 6px; border: none; background: none; border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
.pos-hist:hover { background: var(--surface-2); }

/* rail: Rx */
.pos-rx-card { border-color: #fecaca; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 8%, transparent); }
[data-theme='dark'] .pos-rx-card { border-color: #5b1c1c; }
.pos-rx-img { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.pos-rx-status { font-size: 12px; }
.pos-rx-ok { display: flex; gap: 6px; align-items: center; color: var(--success); font-weight: 600; }
.pos-rx-missing { color: #991b1b; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 8px 10px; }
.pos-rx-missing ul { margin: 4px 0 0 16px; padding: 0; }
[data-theme='dark'] .pos-rx-missing { background: #2b1111; border-color: #5b1c1c; color: #fca5a5; }

/* rail: totals & payment */
.pos-trow { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pos-trow.disc span:last-child { color: var(--success); }
.pos-total-big { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.pos-total-big span { font-weight: 650; color: var(--text-2); }
.pos-total-big b { font-size: 28px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); }
.pos-hsn { margin-top: 8px; font-size: 12px; }
.pos-hsn summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.pos-hsn table { margin-top: 6px; }
.pos-warns { margin-top: 8px; font-size: 11.5px; color: #92400e; display: grid; gap: 2px; }
[data-theme='dark'] .pos-warns { color: #fcd34d; }
.pos-modes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin-bottom: 10px; }
.pos-mode { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.pos-mode.active { border-color: var(--brand); background: var(--brand-50); color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.pos-tendered.input { height: 40px; font-size: 18px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.pos-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pos-pay-status { margin: 10px 0; display: grid; gap: 4px; }
.pos-pay-status:empty { margin: 4px 0; }
.pos-change { display: flex; justify-content: space-between; align-items: baseline; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: 10px; padding: 8px 12px; }
.pos-change b { font-size: 20px; color: var(--brand); font-variant-numeric: tabular-nums; }
.pos-issue { font-size: 11.5px; color: var(--text-2); }
.pos-charge { width: 100%; height: 48px; font-size: 15px; border-radius: 12px; }
.pos-charge .kbd { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.35); color: #fff; margin-left: 4px; }
.pos-change-chip { font-size: 13px; color: var(--text-2); }
.pos-change-chip b { color: var(--brand); font-size: 16px; }
.btn-group .btn.active { background: var(--brand-50); color: var(--brand); border-color: var(--brand-100); }

/* bill drawer */
.pos-bill-drawer { display: flex; flex-direction: column; gap: 10px; }
.pos-drawer-total { font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos-drawer-kv { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.pos-rx-box { border: 1px solid #fecaca; border-radius: 12px; padding: 2px 12px 10px; }
[data-theme='dark'] .pos-rx-box { border-color: #5b1c1c; }

/* invoice paper (80 mm / A5) */
.pos-preview { background: var(--slate-100); border-radius: 12px; padding: 16px; display: flex; justify-content: center; max-height: 62vh; overflow: auto; }
[data-theme='dark'] .pos-preview { background: #0b1210; }
.pos-drawer-paper { background: var(--slate-100); border-radius: 12px; padding: 14px; display: flex; justify-content: center; }
[data-theme='dark'] .pos-drawer-paper { background: #0b1210; }
.pos-inv { position: relative; background: #fff; color: #111; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); font-variant-numeric: tabular-nums; overflow: hidden; }
.pos-inv-80 { width: min(302px, 100%); padding: 12px 12px 16px; font-family: var(--mono); font-size: 10.5px; line-height: 1.4; }
.pos-inv-a5 { width: min(520px, 100%); padding: 20px 22px 22px; font-size: 11.5px; }
.pos-inv-head { text-align: center; border-bottom: 1px dashed #999; padding-bottom: 8px; margin-bottom: 6px; }
.pos-inv-a5 .pos-inv-head { text-align: left; border-bottom: 2px solid #006B43; }
.pos-inv-co { font-weight: 800; font-size: 1.35em; color: #006B43; letter-spacing: -0.01em; }
.pos-inv-small { font-size: 0.86em; color: #555; }
.pos-inv-flag { color: #b45309; font-weight: 700; }
.pos-inv-title { margin-top: 6px; font-weight: 800; letter-spacing: 0.12em; font-size: 0.95em; }
.pos-inv-row { display: flex; justify-content: space-between; gap: 8px; }
.pos-inv-row.strong { font-weight: 800; }
.pos-inv-meta { border-bottom: 1px dashed #999; padding-bottom: 6px; margin-bottom: 4px; }
.pos-inv-lines, .pos-inv-hsn { width: 100%; border-collapse: collapse; margin: 4px 0; }
.pos-inv-lines th, .pos-inv-hsn th { text-align: left; font-size: 0.85em; border-bottom: 1px solid #999; padding: 3px 2px; text-transform: uppercase; }
.pos-inv-lines td, .pos-inv-hsn td { padding: 3px 2px; border-bottom: 1px dotted #ddd; vertical-align: top; }
.pos-inv-lines .num, .pos-inv-hsn .num { text-align: right; white-space: nowrap; }
.pos-inv-80 .pos-inv-lines td:nth-child(2) { font-size: 0.86em; color: #555; }
.pos-inv-rx { color: #b91c1c; font-weight: 700; font-size: 0.85em; }
.pos-inv-totals { border-top: 1px dashed #999; padding-top: 4px; margin-top: 2px; }
.pos-inv-totals .pos-inv-row.strong { font-size: 1.25em; border-top: 1px solid #111; border-bottom: 1px solid #111; padding: 3px 0; margin: 4px 0; }
.pos-inv-hsn { font-size: 0.9em; }
.pos-inv-pay { border-top: 1px dashed #999; padding-top: 4px; }
.pos-inv-foot { border-top: 1px dashed #999; margin-top: 6px; padding-top: 6px; text-align: center; font-size: 0.9em; color: #333; display: grid; gap: 2px; }
.pos-inv-void { position: absolute; inset: 0; display: grid; place-items: center; font-size: 72px; font-weight: 900; color: rgba(220, 38, 38, 0.16); transform: rotate(-24deg); pointer-events: none; letter-spacing: 0.1em; }

@media print {
  .erp-print-host .pos-inv { box-shadow: none; margin: 0 auto; }
  .erp-print-host[data-size='80mm'] .pos-inv { width: 72mm; }
  .erp-print-host[data-size='A5'] .pos-inv { width: 138mm; }
}

/* ── responsive: tablet & phone (touch targets ≥ 40 px at ≤ 900 px) */
@media (max-width: 1180px) {
  .pos-find { max-height: none; }
  .pos-results { max-height: 320px; }
  .pos-detail { max-height: 360px; }
}
@media (max-width: 900px) {
  .pos-kbd-hint, .pos-scan-hint { display: none !important; }
  [data-screen='pos'] .page-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  [data-screen='pos'] .page-actions .select { grid-column: span 1; width: 100%; min-width: 0; height: 40px; }
  [data-screen='pos'] .page-actions .btn { height: 40px; }
  .pos-find { grid-template-columns: 1fr; }
  .pos-results { border-right: none; border-bottom: 1px solid var(--border); max-height: 280px; }
  .pos-res { padding: 10px 10px; min-height: 48px; }
  .pos-search-input.input { height: 46px; font-size: 16px; }
  .pos-sub { min-height: 44px; }
  .pos-batch-tbl .btn.sm { height: 36px; min-width: 56px; }
  .pos-rail .btn, .pos-main .btn, .pos-drawer-f .btn, .pos-preview-modal .modal-f .btn { min-height: 40px; }
  .pos-rail .btn.sm, .pos-main .btn.sm { height: 40px; }
  .pos-rail .input, .pos-rail .select { height: 40px; font-size: 16px; }
  .pos-mode { min-height: 52px; }
  .pos-charge { height: 54px; }
  .linkbtn { min-height: 40px; }
  .pos-hist { min-height: 40px; }

  /* cart → stacked cards */
  .pos-cart-scroll { overflow-x: visible; }
  .pos-cart-tbl, .pos-cart-tbl tbody { display: block; }
  .pos-cart-tbl thead { display: none; }
  .pos-cart-tbl tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .pos-cart-tbl tbody tr td { display: block; border: none; padding: 0 !important; min-width: 0; }
  .pos-cart-tbl tbody tr td.pos-idx { display: none; }
  .pos-cart-tbl tbody tr:not(.pos-subrow) td:nth-child(2) { grid-column: 1 / -1; padding-right: 44px !important; min-width: 0; }
  .pos-cart-tbl tbody tr td:nth-child(3), .pos-cart-tbl tbody tr td:nth-child(4) { grid-column: 1 / -1; }
  .pos-cart-tbl tbody tr:not(.pos-subrow) td:last-child { position: absolute; top: 8px; right: 8px; }
  .pos-cart-tbl tbody tr:not(.pos-subrow) td:last-child .btn { width: 40px; height: 40px; }
  .pos-cart-tbl tbody tr td.pos-net { text-align: right; align-self: end; font-size: 15px; }
  .pos-batch-sel.select { width: 100%; height: 40px; font-size: 14px; }
  .pos-cart-tbl .pos-qty.input, .pos-cart-tbl .pos-disc.input { height: 40px; width: 56px !important; min-width: 56px; max-width: 56px; font-size: 16px; }
  .pos-loose .subtle:first-child { width: 40px; }
  .pos-step.btn.sm.icon { width: 40px; height: 40px; }
  .pos-cart-tbl .pos-qty-wrap { flex-wrap: nowrap; }
  .pos-cart-tbl .pos-batch-sel.select { width: 100% !important; }
  .pos-cart-tbl tbody tr.pos-subrow { display: block; padding: 0 14px 12px; margin-top: -4px; }
  .pos-cart-tbl tbody tr.pos-subrow td:first-child { display: none; }
  .pos-block-line, .pos-override-line { flex-wrap: wrap; }
  .pos-block-line .btn, .pos-override-line .select { min-height: 40px; }
  .pos-override-line .select { width: 100%; }
}
@media (max-width: 600px) {
  [data-screen='pos'] .page-head h1 { font-size: 19px; }
  .pos-search { padding: 8px 10px; }
  .pos-cart-tbl tbody tr { grid-template-columns: 1fr; }
  .pos-cart-tbl tbody tr td.pos-net { text-align: left; }
  .pos-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pos-cust-stats { grid-template-columns: 1fr 1fr; }
  .pos-total-big b { font-size: 24px; }
  .pos-preview, .pos-drawer-paper { padding: 8px; }
  .pos-inv-a5 { padding: 14px 12px; }
  .pos-inv-lines, .pos-inv-hsn { font-size: 0.95em; }
  .pos-drawer-total { font-size: 20px; }
  .pos-drawer-f .btn, .pos-preview-modal .modal-f .btn { flex: 1 1 calc(50% - 8px); }
}
