:root {
  --paper: #eceff0;
  --card: #ffffff;
  --ink: #14211f;
  --muted: #5a6a66;
  --line: #d2dad8;
  --teal: #0b5d57;
  --teal-d: #08423e;
  --gold: #f5b41c;
  --gold-d: #d99a08;
  --bad: #b42318;
  --bad-bg: #fde7e4;
  --warn-bg: #fff2d1;
  --ok-bg: #dff3e8;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--font); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
input, select, textarea { width: 100%; min-height: 46px; padding: 9px 12px; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px rgba(11,93,87,.18); }
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--teal); flex: none; }
textarea { min-height: 84px; resize: vertical; }
label { display: block; font-size: .875rem; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--ink); font-weight: 400; }
label.check { display: flex; gap: 10px; align-items: center; font-size: 1rem; color: var(--ink); font-weight: 500; min-height: 44px; }
.btn { min-height: 46px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--teal); color: #fff; font-weight: 700; cursor: pointer; }
.btn:hover { background: var(--teal-d); }
.btn.ghost { background: #fff; color: var(--teal); border: 1.5px solid var(--teal); }
.btn.ghost:hover { background: #eef6f5; }
.btn.danger { background: var(--bad); }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.btn:disabled, .pay:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--teal); font-weight: 600; cursor: pointer; padding: 6px 4px; min-height: 36px; }
.link.bad { color: var(--bad); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline > input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: grid; gap: 12px; }
.err { color: var(--bad); font-weight: 600; min-height: 1.2em; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--line); }
.badge.low { background: var(--warn-bg); color: #8a5a00; }
.badge.out, .badge.void { background: var(--bad-bg); color: var(--bad); }
.badge.ok { background: var(--ok-bg); color: #14683a; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--ink); color: #fff; min-height: 56px; }
.brand { font-weight: 800; letter-spacing: .01em; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.brand img { height: 30px; width: auto; border-radius: 4px; background: #fff; }
.top nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.top nav a { color: #c9d6d3; text-decoration: none; padding: 16px 12px; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
.top nav a:hover { color: #fff; }
.top nav a.on { color: #fff; border-color: var(--gold); }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; white-space: nowrap; }
.who .link { color: var(--gold); }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.page-h { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar > * { flex: 0 1 auto; } .toolbar .grow { flex: 1 1 220px; }
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f5f7f6; color: var(--muted); font-size: .8rem; font-weight: 700; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr[data-act] { cursor: pointer; } tr[data-act]:hover td { background: #f3f8f7; }
.r { text-align: right; } .c { text-align: center; }
tr.voided td { color: var(--muted); text-decoration: line-through; }
tr.voided td:last-child, tr.voided td .badge { text-decoration: none; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--paper); display: grid; place-items: center; font-weight: 800; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat small { display: block; }
.stat b { font-size: 1.35rem; }
.stat.gold { background: var(--gold); border-color: var(--gold-d); }
.stat.gold small { color: #4b3600; }

/* ---------- modal / toast ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(12,24,22,.55); display: grid; place-items: center; padding: 12px; overflow-y: auto; }
.dlg { background: #fff; border-radius: 16px; width: min(560px, 100%); padding: 20px; max-height: calc(100vh - 24px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dlg.wide { width: min(760px, 100%); }
.dlg-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dlg-f { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast.bad { background: var(--bad); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 28px; display: grid; gap: 14px; border: 1px solid var(--line); border-top: 6px solid var(--gold); }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.catalog .searchbar { position: sticky; top: 56px; z-index: 5; background: var(--paper); padding-bottom: 10px; }
.searchbar input { min-height: 54px; font-size: 1.1rem; border-radius: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 99px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.pcard { display: grid; gap: 4px; text-align: left; align-content: start; padding: 10px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; min-height: 132px; }
.pcard:hover { border-color: var(--teal); }
.pcard:active { transform: scale(.98); }
.pcard img, .pcard .ph { width: 100%; height: 64px; border-radius: 8px; object-fit: cover; background: var(--paper); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: #9aa8a4; }
.pcard b { font-size: .95rem; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pcard .pr { font-weight: 800; color: var(--teal); }
.pcard .st { font-size: .78rem; color: var(--muted); }
.pcard.low .st { color: #8a5a00; font-weight: 700; }
.pcard.out .st { color: var(--bad); font-weight: 700; }
.cart { position: sticky; top: 72px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 10px; max-height: calc(100vh - 88px); overflow-y: auto; }
.cart-h { display: flex; justify-content: space-between; align-items: center; }
.lines { display: grid; gap: 6px; max-height: 32vh; overflow-y: auto; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.line .nm { font-weight: 600; line-height: 1.25; }
.line .tot { font-weight: 800; text-align: right; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.qty input { width: 64px; text-align: center; min-height: 40px; padding: 4px; font-weight: 700; }
.line .warn { color: var(--bad); font-size: .8rem; font-weight: 700; }
.member { display: grid; gap: 6px; padding: 10px; border: 1.5px dashed var(--line); border-radius: 10px; }
.member.ok { grid-template-columns: 1fr auto; align-items: center; border-style: solid; border-color: var(--teal); background: #eef6f5; }
.member.ok small { display: block; }
.disc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.totalbox { background: var(--gold); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.totalbox .row { font-size: .95rem; color: #4b3600; }
.grand { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid rgba(0,0,0,.18); padding-top: 6px; margin-top: 2px; }
.grand strong { font-size: 2rem; line-height: 1.1; letter-spacing: -.01em; }
.methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg { min-height: 48px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; cursor: pointer; padding: 4px; }
.seg.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { min-height: 40px; padding: 0 12px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.pay { min-height: 60px; border: 0; border-radius: 12px; background: var(--teal); color: #fff; font-size: 1.15rem; font-weight: 800; cursor: pointer; }
.pay:not(:disabled):hover { background: var(--teal-d); }
.shiftbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); padding: 0 2px 10px; }
.open-shift { max-width: 420px; margin: 8vh auto; }
.diff-ok { color: #14683a; } .diff-bad { color: var(--bad); }

@media (max-width: 960px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; gap: 10px; }
  main { padding: 10px; }
  .who span { display: none; }
}
@media (max-width: 760px) {
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; max-height: none; }
  .grid2 { grid-template-columns: 1fr; }
  .top { gap: 8px; padding: 0 8px; } .brand span { display: none; }
}

/* ---------- receipt (A6: 105 x 148.5 mm) ---------- */
#print-area { display: none; }
.rc { width: 95mm; margin: 0 auto; font: 11pt/1.3 Arial, Helvetica, sans-serif; color: #000; }
.rc .head { text-align: center; padding-bottom: 3mm; border-bottom: 0.3mm solid #000; }
.rc .head img { max-height: 16mm; max-width: 40mm; margin-bottom: 1mm; }
.rc .head .sn { font-size: 14pt; font-weight: 700; }
.rc .meta { padding: 2mm 0; border-bottom: 0.3mm dashed #000; }
.rc .meta div, .rc .sum div { display: flex; justify-content: space-between; gap: 4mm; }
.rc table { width: 100%; border-collapse: collapse; font-size: 11pt; margin: 2mm 0; }
.rc td { border: 0; padding: 1mm 0; vertical-align: top; }
.rc tr { break-inside: avoid; }
.rc .qtyline { font-size: 10pt; }
.rc .sum { border-top: 0.3mm solid #000; padding-top: 2mm; }
.rc .sum .gt { font-size: 13pt; font-weight: 700; }
.rc .foot { text-align: center; margin-top: 4mm; font-size: 10pt; }
.rc .void { text-align: center; font-weight: 700; border: 0.5mm solid #000; margin: 2mm 0; padding: 1mm; }
@page { size: 105mm 148.5mm; margin: 5mm; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }