/* SmartMarket POS - built for speed: no animations beyond a short colour flash,
   large type, the TOTAL always dominant, works at 1024×768 and up. */
:root {
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #dbe2ea; --bg: #eef2f6; --card: #fff;
  --navy: #0f1b2d; --navy-2: #1b2a41; --accent: #2563eb; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --total-bg: #0b1220; --total-fg: #4ade80;
  --cash: #15803d; --momo: #b8860b; --card-c: #1d4ed8;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { user-select: none; -webkit-user-select: none; }
input, select, textarea { user-select: text; font: inherit; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.num, .r { text-align: right; font-variant-numeric: tabular-nums; }
kbd { font: 600 11px/1 Consolas, monospace; padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.08); border: 1px solid rgba(0,0,0,.12); margin-left: 6px; color: inherit; opacity: .8; }

.view { height: 100%; }
.center-view { display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle at 30% 0%, #1e3356, var(--navy) 60%); }
.card { background: var(--card); border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); width: 100%; }
.card.narrow { max-width: 460px; }
.brand-row { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; flex: none; }
.logo.sm { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }
label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 10px 0; }
label input, label select { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fff; color: var(--ink); }
label input:focus, label select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--bad); min-height: 20px; font-size: 14px; margin: 6px 0; font-weight: 600; }
.big-input { font-size: 26px !important; font-weight: 700; text-align: right; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-family: inherit; font-weight: 700; font-size: 14px; line-height: 1.1; cursor: pointer; background: #e2e8f0; color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; margin-top: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-wrap { width: 100%; max-width: 860px; }
.login-head { display: flex; align-items: center; gap: 14px; color: #fff; margin-bottom: 18px; }
.login-head .muted { color: #9fb0c8; margin: 0; }
.login-status { margin-left: auto; }
.login-body { background: #fff; border-radius: 14px; padding: 20px; min-height: 360px; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.user-tile { border: 2px solid var(--line); background: #f8fafc; border-radius: 12px; padding: 16px; text-align: left; cursor: pointer; font-family: inherit; }
.user-tile:hover, .user-tile:focus { border-color: var(--accent); outline: none; background: #fff; }
.user-tile .av { width: 42px; height: 42px; border-radius: 50%; background: var(--navy-2); color: #fff; display: grid; place-items: center; font-weight: 700; margin-bottom: 10px; }
.user-tile b { display: block; font-size: 15px; } .user-tile span { font-size: 12px; color: var(--muted); }
.pin-panel { max-width: 320px; margin: 0 auto; text-align: center; }
.pin-user { font-size: 18px; font-weight: 700; margin: 4px 0 12px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin-bottom: 16px; min-height: 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-2); }
.pin-dots i.on { background: var(--ink); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { padding: 18px 0; font-size: 22px; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: #f8fafc; cursor: pointer; font-family: inherit; }
.pinpad button:active { background: #e2e8f0; }

/* ---------- Sale screen ---------- */
.sale { display: grid; grid-template-rows: auto 1fr auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #e2e8f0; padding: 8px 14px; gap: 10px; }
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; }
.tb-left .sep { color: #475569; }
.clock { font-variant-numeric: tabular-nums; color: #94a3b8; min-width: 52px; text-align: right; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .3px; background: #1e293b; color: #cbd5e1; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.scanner::before { display: none; }
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.pill.s-ready { background: #052e1a; color: #4ade80; }
.pill.s-scanning { background: #0c2a4d; color: #7dd3fc; }
.pill.s-added { background: #15803d; color: #fff; }
.pill.s-notfound, .pill.s-disconnected, .pill.s-inactive { background: #7f1d1d; color: #fecaca; }
.pill.online { background: #052e1a; color: #4ade80; } .pill.pending { background: #3b2a05; color: #fcd34d; } .pill.offline { background: #4a1010; color: #fca5a5; }
.login-status .pill { background: rgba(255,255,255,.08); }

.sale-main { display: grid; grid-template-columns: 1fr 380px; gap: 12px; padding: 12px; min-height: 0; }
.left { display: flex; flex-direction: column; background: var(--card); border-radius: 12px; overflow: hidden; min-height: 0; border: 1px solid var(--line); }
.last-scan { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8fafc; min-height: 76px; }
.ls-label { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .8px; writing-mode: vertical-rl; transform: rotate(180deg); }
.ls-name { font-size: 22px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-detail { color: var(--ink-2); font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ls-state { font-weight: 800; font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.last-scan.ok { background: var(--ok-bg); } .last-scan.ok .ls-state { color: var(--ok); }
.last-scan.bad { background: var(--bad-bg); } .last-scan.bad .ls-state { color: var(--bad); }
.cart-head, .cart-line { display: grid; grid-template-columns: 1fr 120px 110px 120px; gap: 10px; padding: 0 16px; align-items: center; }
.cart-head { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cart { flex: 1; overflow-y: auto; min-height: 0; }
.cart-line { min-height: 50px; border-bottom: 1px solid #eef2f6; font-size: 16px; cursor: pointer; }
.cart-line .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-line .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.cart-line .q { font-weight: 800; font-size: 18px; }
.cart-line .t { font-weight: 700; }
.cart-line.sel { background: #e8f0fe; box-shadow: inset 4px 0 0 var(--accent); }
.cart-line.flash { background: #dcfce7; }
.cart-empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 16px; }
.cart-empty b { display: block; font-size: 20px; color: var(--ink-2); margin-bottom: 6px; }
.keyed { border-top: 1px solid var(--line); padding: 8px 16px; font: 600 16px Consolas, monospace; color: var(--ink-2); min-height: 38px; display: flex; gap: 10px; align-items: center; }
.keyed .k-label { font: 700 11px "Segoe UI", sans-serif; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; }
.keyed .k-mult { margin-left: auto; background: var(--warn-bg); color: var(--warn); padding: 2px 8px; border-radius: 6px; font-family: "Segoe UI", sans-serif; }
.keyed .k-mult:empty { display: none; }

.right { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.totals { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; }
.t-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.t-row b { color: var(--ink); }
.grand { background: var(--total-bg); color: #e2e8f0; border-radius: 12px; padding: 12px 16px 14px; }
.g-label { font-size: 13px; font-weight: 800; letter-spacing: 1.2px; color: #94a3b8; }
.g-value { font-size: 58px; line-height: 1.05; font-weight: 800; color: var(--total-fg); text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -1px; white-space: nowrap; overflow: hidden; }
.last-change { background: var(--warn-bg); color: #713f12; border-radius: 12px; padding: 10px 14px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.last-change b { font-size: 28px; color: #713f12; }
.paybtns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn.pay { flex-direction: column; padding: 14px 6px; color: #fff; font-size: 13px; min-height: 64px; }
.btn.pay kbd { margin: 6px 0 0; background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }
.btn.pay.cash { background: var(--cash); } .btn.pay.momo { background: var(--momo); } .btn.pay.card { background: var(--card-c); }
.fnbtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.fn { flex-direction: column; background: var(--card); border: 1px solid var(--line); min-height: 54px; font-size: 12px; }
.btn.fn kbd { margin: 5px 0 0; }
.btn.pay-main { margin-top: auto; background: var(--accent); color: #fff; font-size: 22px; padding: 18px; }
.btn.pay-main kbd { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.3); }
.hints { display: flex; gap: 18px; padding: 6px 14px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.hints kbd { margin: 0 3px 0 0; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal.wide { max-width: 860px; }
.modal h2 { margin: 0 0 12px; font-size: 20px; display: flex; justify-content: space-between; align-items: center; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .close-x { background: none; border: 0; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.search-input { width: 100%; padding: 14px; font-size: 18px; border: 2px solid var(--accent); border-radius: 10px; }
.results { margin-top: 10px; max-height: 50vh; overflow-y: auto; }
.res { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 11px 12px; border-radius: 8px; cursor: pointer; align-items: center; }
.res small { color: var(--muted); display: block; }
.res.sel, .res:hover { background: #e8f0fe; }
.res .stk { font-size: 12px; color: var(--muted); }
.notfound-code { font: 700 24px Consolas, monospace; background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 8px; margin: 8px 0 14px; word-break: break-all; }
.list-btns { display: grid; gap: 8px; }
.list-btns .btn { justify-content: flex-start; padding: 14px; font-size: 15px; }

/* Payment */
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pay-due { background: var(--total-bg); color: #94a3b8; border-radius: 12px; padding: 12px 16px; }
.pay-due b { display: block; color: var(--total-fg); font-size: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.pay-methods .btn { padding: 12px 4px; font-size: 12px; flex-direction: column; }
.pay-methods .btn.on { outline: 3px solid var(--ink); }
.pay-methods .cash { background: var(--cash); color: #fff; } .pay-methods .momo { background: var(--momo); color: #fff; } .pay-methods .card { background: var(--card-c); color: #fff; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.quick .btn { font-variant-numeric: tabular-nums; }
.pay-lines { border: 1px solid var(--line); border-radius: 10px; min-height: 90px; padding: 6px 10px; }
.pay-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.pay-line button { border: 0; background: none; color: var(--bad); cursor: pointer; font-weight: 700; }
.pay-sum { margin-top: 10px; }
.pay-sum .t-row { font-size: 16px; }
.pay-change { background: var(--warn-bg); border-radius: 10px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; font-weight: 700; color: #713f12; }
.pay-change b { font-size: 34px; font-variant-numeric: tabular-nums; }
.pay-change.short { background: var(--bad-bg); color: var(--bad); }
.offline-note { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; margin-top: 8px; }

table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.simple th { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
table.simple td.r, table.simple th.r { text-align: right; }

.toast { position: fixed; left: 50%; bottom: 52px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 600; z-index: 80; max-width: 80vw; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }
.focus-warn { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--bad); color: #fff; text-align: center; padding: 10px; font-weight: 700; cursor: pointer; }

/* ---------- Receipt print ---------- */
#print-host { display: none; }
@media print {
  @page { margin: 0; }
  body.printing-receipt > *:not(#print-host) { display: none !important; }
  body.printing-receipt #print-host { display: block !important; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; }
  body.printing-receipt { margin: 0 !important; padding: 0 !important; }
}
.receipt { box-sizing: border-box; font: 12px/1.4 "Consolas", "Courier New", monospace; color: #000; padding: 2mm 2mm 5mm; overflow-wrap: anywhere; background: #fff; }
.receipt.w80 { width: 72mm; margin: 0 auto; } .receipt.w58 { width: 48mm; margin: 0 auto; font-size: 10.5px; }
.r-c { text-align: center; } .r-b { font-weight: 700; } .r-big { font-size: 16px; } .r-small { font-size: 10px; }
.r-row { display: flex; justify-content: space-between; gap: 6px; }
.r-row span { min-width: 0; } .r-row span:last-child { text-align: right; }
.r-item { break-inside: avoid; margin: 2mm 0; } .r-name { font-weight: 700; }
.r-qr { text-align: center; margin: 3mm 0 1mm; break-inside: avoid; }
.r-qr svg { display: block; width: 32mm; height: 32mm; max-width: 100%; margin: 0 auto; shape-rendering: crispEdges; }
.r-sep { border-top: 1px dashed #000; margin: 4px 0; }
.r-item .r-row { padding-left: 8px; }
.r-total { font-size: 16px; font-weight: 700; margin-top: 2px; }

@media (max-width: 1100px) {
  .sale-main { grid-template-columns: 1fr 330px; }
  .g-value { font-size: 46px; }
  .cart-head, .cart-line { grid-template-columns: 1fr 90px 90px 100px; }
  .hints span:nth-child(n+6) { display: none; }
}
.login-wrap a { color: #93c5fd; }

.pill#pill-phone::before { display: none; }
.phone-tools { display:flex; align-items:center; gap:14px; padding:12px 18px; background:#eff6ff; border-bottom:1px solid #dbeafe; flex-wrap:wrap; }
.phone-tools span { color:#475569; font-size:14px; }
.phone-tools .btn { padding:10px 16px; white-space:nowrap; }
.cart-qty { cursor:pointer; font:inherit; font-weight:800; color:#1d4ed8; background:#eff6ff; border:1px solid #bfdbfe; border-radius:8px; padding:8px 10px; min-width:60px; }
.cart-qty small { font-size:12px; }
.cart-qty:hover { background:#dbeafe; }
.cart-remove { display:block; margin-top:5px; padding:3px 8px; border:1px solid #fecaca; border-radius:6px; background:#fff1f2; color:#b91c1c; font:inherit; font-size:12px; cursor:pointer; }
.modal svg { width: 100%; height: auto; display: block; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
