/* Touch-first POS. Everything is >= 48px to tap, no hover dependencies. */
html, body { overscroll-behavior: none; height: 100%; overflow: hidden; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; font-size: 16px; }
button { border: 0; background: none; touch-action: manipulation; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; }
#app { height: 100%; }

.btn { min-height: 56px; padding: 0 22px; border-radius: 14px; font-weight: 700; font-size: 17px; background: var(--surface); border: 2px solid var(--line); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 72px; font-size: 21px; border-radius: 16px; }

/* ---------- login ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #2a211b 0%, #3b2c22 60%, #4a2b1f 100%); color: #fff; overflow: auto; }
.login .card { width: min(560px, 100%); text-align: center; }
.login h1 { font-size: 30px; margin-bottom: 4px; }
.login .sub { opacity: .7; margin-bottom: 28px; }
.users { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.user-tile { background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.14); border-radius: 18px; padding: 22px 12px; color: #fff; font-size: 18px; font-weight: 700; }
.user-tile .av { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); display: grid; place-items: center; font-size: 28px; margin: 0 auto 10px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 14px 0 20px; min-height: 22px; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); }
.pin-dots i.on { background: #fff; border-color: #fff; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 330px; margin: 0 auto; }
.pad button { height: 72px; border-radius: 18px; font-size: 28px; font-weight: 700; background: rgba(255,255,255,.1); color: #fff; border: 2px solid rgba(255,255,255,.14); }
.pad button.enter { background: var(--brand); border-color: var(--brand); font-size: 20px; }
.login .err { color: #ffb4a9; min-height: 24px; font-weight: 600; margin-top: 12px; }
.login .link { color: rgba(255,255,255,.75); margin-top: 18px; font-size: 16px; padding: 14px; text-decoration: underline; }

/* ---------- main layout ---------- */
.main { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 390px; grid-template-rows: 100%; }
.left { display: flex; flex-direction: column; min-width: 0; height: 100%; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--ink); color: #fff; }
.tabs { display: flex; gap: 8px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 52px; padding: 0 20px; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; font-weight: 700; font-size: 17px; border: 2px solid transparent; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tab.on { background: #fff; color: var(--ink); }
.tab .dot { margin: 0; width: 12px; height: 12px; }
.top .tool { flex: none; min-width: 52px; min-height: 52px; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; font-size: 15px; font-weight: 700; padding: 0 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.top .tool small { font-weight: 600; opacity: .75; font-size: 11px; }
.sync-ok { color: #9fe0b5; } .sync-wait { color: #ffd37a; } .sync-bad { color: #ffaba0; }
.chips { display: flex; gap: 8px; padding: 10px 12px 4px; overflow-x: auto; scrollbar-width: none; flex: none; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); font-weight: 700; font-size: 15px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; align-content: start; }
.tile { position: relative; text-align: left; background: var(--surface); border-radius: 14px; border: 2px solid var(--line); border-left: 8px solid var(--c, #999); padding: 10px 10px 10px 12px; min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); }
.tile .nm { font-weight: 700; font-size: 16px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .pr { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.tile .st { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tile .st.low { color: var(--warn); } .tile .st.out { color: var(--bad); }
.tile.out { opacity: .5; }
.tile .badge { position: absolute; top: -9px; right: -9px; min-width: 32px; height: 32px; border-radius: 16px; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; padding: 0 8px; border: 3px solid var(--bg); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 20px; font-size: 18px; }

/* ---------- cart ---------- */
.cart { background: var(--surface); border-left: 2px solid var(--line); display: flex; flex-direction: column; height: 100%; min-height: 0; }
.cart-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 2px solid var(--line); }
.cart-h h2 { font-size: 20px; }
.cart-h .btn { min-height: 44px; padding: 0 14px; font-size: 15px; }
.lines { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 12px; }
.line { padding: 10px 0; border-bottom: 1px solid var(--line); }
.line .r1 { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.line .nm { font-weight: 700; font-size: 16px; line-height: 1.2; }
.line .tot { font-weight: 800; font-size: 17px; white-space: nowrap; }
.line .r2 { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.pricebtn { min-height: 44px; padding: 0 12px; border-radius: 10px; background: var(--surface-2); border: 2px dashed var(--line); font-weight: 700; font-size: 15px; }
.pricebtn.chg { border-color: var(--gold); background: var(--warn-soft); }
.pricebtn.low { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); border: 2px solid var(--line); font-size: 26px; font-weight: 700; line-height: 1; }
.stepper .q { min-width: 52px; height: 48px; border-radius: 12px; font-weight: 800; font-size: 20px; background: #fff; border: 2px solid var(--ink); }
.line .rm { width: 44px; height: 44px; font-size: 20px; color: var(--bad); border-radius: 10px; }
.cart-empty { text-align: center; color: var(--muted); padding: 60px 18px; font-size: 17px; }
.cart-f { border-top: 2px solid var(--line); padding: 10px 14px 14px; background: var(--surface-2); }
.sumrow { display: flex; justify-content: space-between; font-size: 16px; padding: 3px 0; font-weight: 600; }
.sumrow.total { font-size: 28px; font-weight: 800; padding: 6px 0 10px; }
.disc-btn { min-height: 44px; padding: 0 12px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 15px; }
.charge { width: 100%; }
.cart-bar { display: none; }

/* ---------- overlays ---------- */
.ov { position: fixed; inset: 0; background: rgba(30,22,17,.62); display: grid; place-items: center; padding: 14px; z-index: 50; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: var(--surface); border-radius: 22px; width: min(var(--w, 460px), 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.sheet-h { padding: 16px 20px 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-h h2 { font-size: 21px; }
.sheet-b { padding: 8px 20px 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-f { padding: 12px 20px 20px; display: flex; gap: 10px; }
.sheet-f .btn { flex: 1; }
.x { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); font-size: 22px; flex: none; }

.kp-display { background: var(--surface-2); border: 2px solid var(--line); border-radius: 14px; font-size: 40px; font-weight: 800; text-align: right; padding: 8px 16px; min-height: 68px; margin-bottom: 12px; overflow: hidden; }
.kp-display small { font-size: 22px; opacity: .55; margin-right: 6px; }
.kp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kp button { height: 68px; border-radius: 14px; font-size: 28px; font-weight: 700; background: var(--surface-2); border: 2px solid var(--line); }
.kp button.fn { font-size: 20px; color: var(--muted); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.quick button { min-height: 48px; padding: 0 16px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 17px; border: 2px solid transparent; }
.quick button.on { border-color: var(--brand); }
.seg { display: flex; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 52px; font-weight: 800; font-size: 18px; background: #fff; }
.seg button.on { background: var(--ink); color: #fff; }

.pay-total { text-align: center; padding: 6px 0 14px; }
.pay-total .l { color: var(--muted); font-weight: 700; }
.pay-total .v { font-size: 52px; font-weight: 800; letter-spacing: -1px; }
.pays { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.pays button { min-height: 68px; border-radius: 14px; border: 2px solid var(--line); background: #fff; font-weight: 800; font-size: 18px; padding: 4px 6px; }
.pays button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.change-box { display: flex; justify-content: space-between; align-items: baseline; background: var(--good-soft); color: var(--good); border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: 20px; margin-bottom: 10px; }
.change-box.short { background: var(--bad-soft); color: var(--bad); }
.change-box b { font-size: 34px; }

.done { text-align: center; padding: 10px 0 4px; }
.done .tick { width: 84px; height: 84px; border-radius: 50%; background: var(--good); color: #fff; font-size: 48px; display: grid; place-items: center; margin: 4px auto 12px; }
.done .tick.wait { background: var(--gold); }
.done h2 { font-size: 26px; }
.done .big { font-size: 46px; font-weight: 800; margin: 6px 0; }
.done .chg { background: var(--good-soft); color: var(--good); border-radius: 14px; padding: 10px; margin-top: 10px; font-size: 22px; font-weight: 800; }

.sale-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; align-items: center; }
.sale-row .a { font-weight: 800; } .sale-row .b { color: var(--muted); font-size: 14px; }
.sale-row.void { opacity: .5; text-decoration: line-through; }
.sum-strip { display: flex; gap: 10px; margin-bottom: 8px; }
.sum-strip > div { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.sum-strip b { display: block; font-size: 22px; }
.menu-grid { display: grid; gap: 10px; }
.menu-grid .btn { text-align: left; display: block; text-decoration: none; line-height: 56px; }

/* receipt paper */
.paper { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; background: #fffef9; border: 1px dashed #bbb; padding: 14px; color: #111; }
.paper h3 { text-align: center; font-size: 16px; margin-bottom: 2px; }
.paper .c { text-align: center; }
.paper hr { border: 0; border-top: 1px dashed #777; margin: 8px 0; }
.paper .row { display: flex; justify-content: space-between; gap: 8px; }
.paper .row.b { font-weight: 800; font-size: 16px; }
#receipt-print { display: none; }
@media print {
  body > *:not(#receipt-print) { display: none !important; }
  #receipt-print { display: block !important; width: 72mm; margin: 0 auto; }
  html, body { overflow: visible; height: auto; }
  .paper { border: 0; background: #fff; }
}

/* ---------- narrower screens (phones / portrait tablets): cart becomes a slide-over ---------- */
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; }
  .cart { position: fixed; inset: 0; z-index: 40; transform: translateY(100%); transition: transform .2s ease; border: 0; }
  body.cart-open .cart { transform: none; }
  .cart-bar { display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; min-height: 66px; border-radius: 18px; background: var(--brand); color: #fff; font-weight: 800; font-size: 19px; align-items: center; justify-content: space-between; padding: 0 20px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
  .grid { padding-bottom: 90px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cart-close { display: inline-flex !important; }
  .top .tool.hide-sm { display: none; }
}
.cart-close { display: none; }
@media (min-width: 1280px) { .main { grid-template-columns: minmax(0, 1fr) 440px; } .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); } }
