/* MintyPOS — one stylesheet for tills, waiter phones and kitchen screens.
   Layout: sticky brand bar, one working column; order screen splits menu | bill on wide screens. */
:root {
  /* MintyPOS brand (guidelines v1.0): mint for actions, deep green for brand and navigation,
     charcoal text on white / light-mint surfaces, slate for secondary text */
  --bg: #F3FAF7; --surface: #FFFFFF; --sunk: #E6F9F1; --ink: #1F2937; --muted: #64748B;
  --line: #D6E6DE; --accent: #22C55E; --accent-ink: #10231A; --accent-text: #0F6B4F; --focus: #0F6B4F; --cream: #FFF8ED;
  --good: #1D7448; --good-bg: #E3F2E9; --bad: #B42318; --bad-bg: #FBE9E7; --warn: #8A5300; --warn-bg: #FBF0DC;
  --info: #2F5DA8; --info-bg: #E5EDFA;
  /* kitchen order steps: one colour each, used on tickets, chips and step buttons */
  --st-new: #B54708; --st-new-bg: #FEF0C7; --st-accepted: #1D4ED8; --st-accepted-bg: #E0EAFF;
  --st-preparing: #6D28D9; --st-preparing-bg: #EDE9FE; --st-ready: #067647; --st-ready-bg: #D3F8DF;
  --st-done: #5C6964; --st-done-bg: #EBEFEB; --on-st: #FFFFFF;
  --brand: #0F6B4F;
  --mp-leaf1: #0F6B4F; --mp-leaf2: #22C55E; --mp-word: #1F2937; --mp-pos: #22C55E;
  --display: "Poppins", Arial, Helvetica, sans-serif;
  --body: "Inter", Arial, Helvetica, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1512; --surface: #16211C; --sunk: #111A16; --ink: #E8F0EC; --muted: #9AA8B8;
  --line: #27362F; --accent: #22C55E; --accent-ink: #06150D; --accent-text: #65E59A; --focus: #65E59A; --cream: #1E1B14;
  --mp-leaf1: #E6F9F1; --mp-leaf2: #22C55E; --mp-word: #FFFFFF; --mp-pos: #65E59A;
  --good: #63C795; --good-bg: #13291E; --bad: #F2786C; --bad-bg: #2E1714; --warn: #E6AA4E; --warn-bg: #2D2212;
  --info: #8FB1EA; --info-bg: #17243A;
  --st-new: #F5B544; --st-new-bg: #33240A; --st-accepted: #84ADFF; --st-accepted-bg: #132042;
  --st-preparing: #B69CFF; --st-preparing-bg: #24183F; --st-ready: #5FD992; --st-ready-bg: #0E2A1B;
  --st-done: #98A6A0; --st-done-bg: #121A17; --on-st: #0B100E;
  color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1512; --surface: #16211C; --sunk: #111A16; --ink: #E8F0EC; --muted: #9AA8B8;
  --line: #27362F; --accent: #22C55E; --accent-ink: #06150D; --accent-text: #65E59A; --focus: #65E59A; --cream: #1E1B14;
  --mp-leaf1: #E6F9F1; --mp-leaf2: #22C55E; --mp-word: #FFFFFF; --mp-pos: #65E59A;
  --good: #63C795; --good-bg: #13291E; --bad: #F2786C; --bad-bg: #2E1714; --warn: #E6AA4E; --warn-bg: #2D2212;
  --info: #8FB1EA; --info-bg: #17243A;
  --st-new: #F5B544; --st-new-bg: #33240A; --st-accepted: #84ADFF; --st-accepted-bg: #132042;
  --st-preparing: #B69CFF; --st-preparing-bg: #24183F; --st-ready: #5FD992; --st-ready-bg: #0E2A1B;
  --st-done: #98A6A0; --st-done-bg: #121A17; --on-st: #0B100E;
  color-scheme: dark }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--brand); color: var(--on-brand);
  padding: calc(env(safe-area-inset-top, 0px) + 8px) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); }
.top-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.top b { font-family: var(--display); font-size: 1.15rem; }
.top .who { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.top button { background: rgb(var(--on-brand-rgb) / 0.16); border: 1px solid rgb(var(--on-brand-rgb) / 0.35); color: var(--on-brand); border-radius: 8px; padding: 4px 10px; font-weight: 600; font-size: 0.85rem; }
.top .logo { height: 28px; width: auto; border-radius: 4px; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: rgb(255 255 255 / 0.16); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #7CF0B0; }
.live.off i { background: #FF9C8F; }
nav.tabs { max-width: 1200px; margin: 6px auto 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
nav.tabs button { background: transparent; border: 0; color: rgb(var(--on-brand-rgb) / 0.8); padding: 6px 10px; border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap; }
nav.tabs button[aria-current="page"] { color: var(--on-brand); border-bottom-color: var(--on-brand); }
main { max-width: 1200px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 48px) max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 9px; font-weight: 600; min-height: 42px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.brand { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.wide { flex: 1; }
.linkbtn { border: 0; background: none; padding: 0 2px; color: var(--accent-text); font-weight: 600; text-decoration: underline; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); width: 100%; min-height: 42px; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.msg { padding: 10px 12px; border-radius: 9px; font-size: 0.9rem; }
.msg.ok { background: var(--good-bg); color: var(--good); }
.msg.err { background: var(--bad-bg); color: var(--bad); }
.msg.info { background: var(--sunk); color: var(--muted); }
.msg.warn { background: var(--warn-bg); color: var(--ink); border: 1px solid var(--warn); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 14px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }

/* ---------- toasts & modal ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); z-index: 50; display: grid; gap: 8px; width: min(92vw, 480px); pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 10px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); font-weight: 500; }
.toast.err { background: var(--bad); color: #fff; }
.overlay { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.45); display: grid; place-items: end center; padding: 16px; }
@media (min-width: 700px) { .overlay { place-items: center; } }
.dialog { background: var(--surface); border-radius: 14px; padding: 18px; width: min(100%, 520px); max-height: 88vh; overflow: auto; display: grid; gap: 14px; }

/* ---------- pairing & PIN ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { width: min(100%, 440px); display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.codebox { font-family: var(--mono); font-size: 2rem; letter-spacing: 0.3em; text-align: center; }
.people { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.person { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px; text-align: left; display: grid; gap: 2px; min-height: 64px; }
.person[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.dots { display: flex; gap: 12px; justify-content: center; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--ink); border-color: var(--ink); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { min-height: 56px; font-size: 1.3rem; font-weight: 600; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }

/* ---------- floor ---------- */
.area { display: grid; gap: 8px; }
.tables { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.tbl { display: grid; gap: 2px; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); min-height: 80px; }
.tbl b { font-family: var(--display); font-size: 1.1rem; }
.tbl .mono { white-space: nowrap; font-size: 0.78rem; }
.tbl.free { border-color: var(--good); }
.tbl.free .state { color: var(--good); font-weight: 600; }
.tbl.occupied { background: var(--warn-bg); border-color: var(--warn); }
.tbl.bill_requested { background: var(--info-bg); border-color: var(--info); }
.tbl.bill_requested .state { color: var(--info); font-weight: 600; }
.tbl.mine { box-shadow: inset 0 0 0 2px var(--ink); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.8rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid; }

/* ---------- order ---------- */
.pos { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .pos { grid-template-columns: minmax(0, 1fr); } }
.catbar { position: relative; display: flex; align-items: center; min-width: 0; }
.cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; flex: 1; min-width: 0; scroll-behavior: smooth; }
.cats::-webkit-scrollbar { display: none; }
.catbar.fade-l .cats { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 36px); mask-image: linear-gradient(to right, transparent 0, #000 36px); }
.catbar.fade-r .cats { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 36px); mask-image: linear-gradient(to left, transparent 0, #000 36px); }
.catbar.fade-l.fade-r .cats { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%); }
.catarrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 1.3rem; line-height: 1; box-shadow: 0 2px 6px rgb(0 0 0 / 0.15); }
.catarrow.left { left: -4px; } .catarrow.right { right: -4px; }
.catarrow[hidden] { display: none; }
.cats button { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 999px; font-weight: 600; }
.cats button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.cats .outn { font-size: 0.72rem; padding: 0 6px; border-radius: 999px; background: var(--bad-bg); color: var(--bad); }
.menu { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.item { text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 2px; min-height: 80px; background: var(--surface); }
.item.in { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.item.in .stock { color: var(--good); }
.item.out { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.item.out .stock { color: var(--bad); font-weight: 600; }
.item.editing { outline: 2px dashed var(--muted); outline-offset: -4px; }
.item .p { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.receipt { font-family: var(--mono); font-size: 0.85rem; background: var(--sunk); border-radius: 10px; padding: 12px; display: grid; gap: 6px; }
.receipt .l { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; align-items: flex-start; }
.receipt .l > span:last-child { white-space: nowrap; }
.receipt .l.total { border-top: 1px dashed var(--muted); padding-top: 6px; font-weight: 500; font-size: 1rem; }
.receipt .struck { text-decoration: line-through; color: var(--muted); }
.receipt .sub { color: var(--muted); font-size: 0.78rem; }
.receipt .tag { font-family: var(--body); font-size: 0.7rem; font-weight: 600; padding: 0 6px; border-radius: 999px; white-space: nowrap; }
.tag.sent { background: var(--good-bg); color: var(--good); }
.tag.counter { background: var(--info-bg); color: var(--info); }
.tag.pending { background: var(--warn-bg); color: var(--warn); }
.tag.free { background: var(--st-preparing-bg); color: var(--st-preparing); }
.tag.refunded { background: var(--bad-bg); color: var(--bad); }
.receipt .l.disc > span:last-child { color: var(--good); }
.receipt .lbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; font-size: 0.75rem; padding: 0 6px; margin-left: 6px; }
.kswitch { padding: 8px 10px; border-radius: 9px; background: var(--sunk); }
.paybox { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.methods { display: flex; flex-wrap: wrap; gap: 6px; }
.methods button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.phonebar { display: none; }
@media (max-width: 820px) {
  .phonebar { display: flex; position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); z-index: 5; justify-content: space-between; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 -6px 18px rgb(0 0 0 / 0.12); }
}
.mods { display: grid; gap: 12px; }
.mods fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; margin: 0; }
.mods legend { font-weight: 600; padding: 0 4px; }
.mods label { display: flex; gap: 8px; align-items: center; min-height: 36px; }

/* ---------- kitchen ---------- */
.kds { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ticket { --c: var(--line); --cbg: var(--surface); border: 2px solid var(--c); border-top-width: 10px; border-radius: 12px; padding: 12px;
  display: grid; gap: 8px; background: var(--cbg); align-content: start; }
[data-status="new"] { --c: var(--st-new); --cbg: var(--st-new-bg); }
[data-status="accepted"] { --c: var(--st-accepted); --cbg: var(--st-accepted-bg); }
[data-status="preparing"] { --c: var(--st-preparing); --cbg: var(--st-preparing-bg); }
[data-status="ready"] { --c: var(--st-ready); --cbg: var(--st-ready-bg); }
[data-status="done"] { --c: var(--st-done); --cbg: var(--st-done-bg); }
.ticket[data-status="new"] { animation: newpulse 1.6s ease-in-out infinite; }
@keyframes newpulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--st-new) 35%, transparent); } }
@media (prefers-reduced-motion: reduce) { .ticket[data-status="new"] { animation: none; } }
.stchip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--c); color: var(--on-st); white-space: nowrap; }
.btn.step { background: var(--c); border-color: var(--c); color: var(--on-st); }
.kds-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ticket header { display: flex; justify-content: space-between; gap: 8px; }
.ticket header b { font-family: var(--display); font-size: 1.2rem; }
.ticket ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.ticket li .sub { color: var(--muted); font-size: 0.85rem; }
.ticket li.struck { text-decoration: line-through; color: var(--muted); }
.avail { display: grid; gap: 10px; }
.availchip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 0.85rem; font-weight: 600; }
.availchip.in { background: var(--good-bg); color: var(--good); }
.availchip.out { background: var(--bad-bg); color: var(--bad); }

/* ---------- tables, day end, devices ---------- */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pair { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.pair .code { font-family: var(--mono); font-size: 2.2rem; letter-spacing: 0.15em; font-weight: 600; }
.qr { width: 180px; height: 180px; max-width: 100%; background: #fff; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; }
.empty { color: var(--muted); padding: 8px 0; }

@media (prefers-reduced-motion: no-preference) { .toast { animation: rise 0.2s ease-out; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.keypad .okkey { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }

/* ---------- round 1 fixes: kitchen progress, day end, printing ---------- */
.kchip { display: inline-block; width: fit-content; font-family: var(--body); font-size: 0.72rem; font-weight: 600; padding: 0 7px; border-radius: 999px; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.kchip[data-status] { background: var(--cbg); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); }
.kchip[data-status="ready"] { background: var(--c); color: var(--on-st); }
.tbl .kchip { margin-top: 2px; white-space: normal; max-width: 100%; line-height: 1.35; border-radius: 8px; }
.receipt .l.sub { color: var(--muted); }
.receipt .l.diff > span:last-child { color: var(--bad); }
.receipt .grp { display: grid; gap: 4px; border-top: 1px dashed var(--line); padding-top: 6px; }
fieldset.settle { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 10px; margin: 0; }
fieldset.settle legend { font-weight: 600; padding: 0 4px; }
pre.preview { white-space: pre-wrap; font-family: var(--mono); font-size: 0.8rem; background: var(--sunk); border-radius: 10px; padding: 12px; margin: 8px 0 0; }
.linkbtn.muted { color: var(--muted); }
#print-root { display: none; }
.rc { font: 12px/1.35 var(--mono); color: #000; } .rc hr { border: 0; border-top: 1px dashed #000; margin: 4px 0; }
.rc-l { display: flex; justify-content: space-between; gap: 8px; } .rc-l span:first-child { white-space: pre-wrap; } .rc-l span:last-child { white-space: nowrap; }
.rc .b { font-weight: 700; } .rc .big { font-size: 1.25em; } .rc-logo { text-align: center; } .rc-logo img { max-width: 60%; max-height: 22mm; }
@media print {
  body { background: #fff; color: #000; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; font: 12px/1.4 var(--body); color: #000; }
  #print-root[data-size="receipt"] { width: 72mm; font-size: 11px; }
  .pz h1 { font-size: 1.4em; margin: 0 0 4px; } .pz h2 { font-size: 1.1em; margin: 14px 0 4px; border-top: 1px dashed #000; padding-top: 8px; }
  .pz p { margin: 0 0 8px; } .pz table { width: 100%; border-collapse: collapse; font-size: 1em; }
  .pz td { padding: 1px 0; border: 0; } .pz td.r { text-align: right; font-family: var(--mono); white-space: nowrap; } .pz tr.b td { font-weight: 700; }
  .pz .sig { display: grid; gap: 22px; margin-top: 28px; } .pz .sig span { display: block; border-bottom: 1px solid #000; height: 22px; }
  #print-root[data-size="a4"] .pz .sig { grid-template-columns: repeat(3, 1fr); gap: 24px; }
}
.item .thumb { width: 100%; height: 64px; object-fit: cover; border-radius: 7px; margin-bottom: 2px; }

/* split bills: the bills of one table as tabs */
.billtabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 4px 0 10px; }
.billtabs button { flex: none; border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-weight: 600; }
.billtabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
/* a combo's parts under it on the bill */
.receipt .l.part { padding-left: 14px; font-size: 0.9em; color: var(--muted); margin-top: -2px; }
/* trial ended: read-only */
.readonly { background: var(--bad-bg, #fbebeb); color: var(--bad, #a33); border-top: 1px solid currentColor; padding: 8px 16px; font-size: 0.9rem; line-height: 1.35; }

/* ================================================================ polish layer
   Same palette and faces; depth, motion and finish. Tokens first, for both themes. */
:root {
  --shadow-1: 0 1px 2px rgb(22 32 29 / 0.06), 0 2px 8px rgb(22 32 29 / 0.05);
  --shadow-2: 0 2px 4px rgb(22 32 29 / 0.06), 0 10px 24px rgb(22 32 29 / 0.10);
  --hairline: color-mix(in srgb, var(--line) 80%, var(--ink) 8%);
  --glass: color-mix(in srgb, var(--surface) 82%, transparent);
  --paper: #FFFDF8; --paper-ink: #1B1B18; --paper-muted: #6B6A63; --paper-line: #D5D2C6;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.35), 0 2px 8px rgb(0 0 0 / 0.25);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 0.4), 0 12px 28px rgb(0 0 0 / 0.45);
  --paper: #EFEBE1;
} }
:root[data-theme="dark"] {
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.35), 0 2px 8px rgb(0 0 0 / 0.25);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 0.4), 0 12px 28px rgb(0 0 0 / 0.45);
  --paper: #EFEBE1;
}
html.theme-swap, html.theme-swap * { transition: background-color .35s var(--ease), color .35s var(--ease), border-color .35s var(--ease) !important; }

/* page: a soft wash of the restaurant's colour */
body { background: radial-gradient(1200px 380px at 50% -140px, color-mix(in srgb, var(--brand) 13%, transparent), transparent 70%), var(--bg);
  background-attachment: fixed; -webkit-font-smoothing: antialiased; }

/* top bar: the brand colour as a lit band */
.top { background: linear-gradient(120deg, color-mix(in srgb, var(--brand) 90%, #fff) 0%, var(--brand) 45%, color-mix(in srgb, var(--brand) 72%, #000) 100%);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 28%, transparent); }
.top::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .1;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0); background-size: 14px 14px;
  -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000); mask-image: linear-gradient(90deg, transparent 35%, #000); }
.top > * { position: relative; z-index: 1; }
.top button { border-radius: 999px; transition: background .2s var(--ease); }
.top button:hover { background: rgb(var(--on-brand-rgb) / 0.26); }
.top .logo { border-radius: 50%; box-shadow: 0 0 0 2px rgb(var(--on-brand-rgb) / 0.55); }
.live i { box-shadow: 0 0 0 0 rgb(124 240 176 / 0.6); animation: live 2.4s ease-out infinite; }
.live.off i { animation: none; }
@keyframes live { 70%, 100% { box-shadow: 0 0 0 7px rgb(124 240 176 / 0); } }
nav.tabs { gap: 2px; }
nav.tabs button { border: 0; border-radius: 999px; padding: 5px 12px; transition: background .2s var(--ease), color .2s; }
nav.tabs button:hover { background: rgb(var(--on-brand-rgb) / 0.14); color: var(--on-brand); }
nav.tabs button[aria-current="page"] { background: #fff; color: var(--brand-ink); border: 0; }

/* panels, dialogs, cards */
.panel { border-color: var(--hairline); border-radius: 16px; box-shadow: var(--shadow-1); padding: 18px; }
.card { border-color: var(--hairline); border-radius: 20px; box-shadow: var(--shadow-2); }
.overlay { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog { border-radius: 18px; box-shadow: var(--shadow-2); }
@media (prefers-reduced-motion: no-preference) { .dialog { animation: pop .22s var(--ease); } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.toast { border-radius: 12px; }

/* controls */
.field input, .field select, .field textarea { border-radius: 10px; transition: border-color .15s, box-shadow .15s, background .15s; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--focus); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
.btn { border-radius: 10px; border-color: var(--hairline); box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 6%, transparent);
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s, filter .2s; }
.btn:not(:disabled):hover { transform: translateY(-1px); box-shadow: var(--shadow-1); border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.btn:not(:disabled):active { transform: scale(.98); box-shadow: none; }
.btn.brand { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff), var(--brand)); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.22), 0 2px 6px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn.primary { background: var(--accent); box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 28%, transparent); }   /* flat mint: no decorative gradient (brand guide) */
.btn.danger { background: linear-gradient(180deg, color-mix(in srgb, var(--bad) 88%, #fff), var(--bad)); }
.btn.brand:not(:disabled):hover, .btn.primary:not(:disabled):hover, .btn.danger:not(:disabled):hover { filter: brightness(1.05); border-color: transparent; }
.btn.ghost, .btn.ghost:not(:disabled):hover { box-shadow: none; }
.btn.ghost:not(:disabled):hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.btn.dark { border-radius: 999px; padding-inline: 16px; }
.seg { border-color: transparent; background: var(--sunk); padding: 3px; gap: 2px; border-radius: 12px; }
.seg button { border-radius: 9px; transition: background .2s var(--ease), color .2s; }
.seg button[aria-pressed="true"] { box-shadow: var(--shadow-1); }
.methods .btn { border-radius: 999px; }

/* messages carry a small marker */
.msg { border-radius: 12px; padding: 11px 14px 11px 40px; position: relative; border: 1px solid transparent; }
.msg::before { content: "i"; position: absolute; left: 12px; top: 11px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  font: 700 0.72rem/1 var(--body); background: color-mix(in srgb, currentColor 16%, transparent); }
.msg.ok { border-color: color-mix(in srgb, var(--good) 25%, transparent); } .msg.ok::before { content: "✓"; }
.msg.err { border-color: color-mix(in srgb, var(--bad) 25%, transparent); } .msg.err::before { content: "!"; }
.msg.warn::before { content: "!"; color: var(--warn); }

/* pairing and PIN */
.person { border-color: var(--hairline); background: var(--surface); box-shadow: var(--shadow-1); transition: transform .12s var(--ease), box-shadow .2s; }
.person:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.keypad button { background: var(--surface); border-color: var(--hairline); box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 8%, transparent); transition: transform .08s, background .15s; }
.keypad button:active { transform: scale(.95); background: var(--sunk); }
.keypad .okkey { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff), var(--brand)); }
.dots i { transition: background .15s, transform .15s; } .dots i.on { transform: scale(1.1); }

/* floor plan: a status stripe on each table */
.tables { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.tbl { position: relative; overflow: hidden; border-radius: 14px; padding: 14px 12px 10px; min-height: 92px; border-color: var(--hairline);
  box-shadow: var(--shadow-1); transition: transform .15s var(--ease), box-shadow .2s var(--ease); }
.tbl::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--line); }
.tbl:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tbl b { font-size: 1.2rem; letter-spacing: -0.01em; }
.tbl.free { border-color: var(--hairline); }
.tbl.free::before { background: var(--good); }
.tbl.free .state { display: inline-flex; align-items: center; gap: 5px; }
.tbl.free .state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tbl.occupied { background: linear-gradient(180deg, var(--warn-bg), var(--surface) 150%); border-color: color-mix(in srgb, var(--warn) 30%, var(--line)); }
.tbl.occupied::before { background: var(--warn); }
.tbl.bill_requested { background: linear-gradient(180deg, var(--info-bg), var(--surface) 150%); border-color: color-mix(in srgb, var(--info) 35%, var(--line)); }
.tbl.bill_requested::before { background: var(--info); animation: shimmer 1.8s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: .35; } }
.tbl.mine { box-shadow: inset 0 0 0 2px var(--ink), var(--shadow-1); }
.area h3 { font-family: var(--body); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.legend i { border-radius: 4px; }

/* menu: cards with a price pill */
.cats button { border-color: var(--hairline); box-shadow: var(--shadow-1); transition: background .2s, color .2s, transform .12s; }
.cats button:hover { transform: translateY(-1px); }
.cats button[aria-selected="true"] { box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 35%, transparent); }
.menu { gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.item { border-radius: 14px; padding: 12px; gap: 4px; min-height: 92px; align-content: start; box-shadow: var(--shadow-1);
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.item > span:first-of-type { font-weight: 600; line-height: 1.25; }
.item .p { justify-self: start; color: var(--ink); font-size: 0.8rem; border: 1px solid var(--hairline); border-radius: 999px; padding: 1px 8px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.item .thumb { border-radius: 10px; height: 72px; }
.item.in { background: var(--surface); border-color: var(--hairline); }
.item.in:not(:disabled):hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.item.in:not(:disabled):active { transform: scale(.97); }
.item .stock { font-size: 0.75rem; }
.item.out { background-image: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--bad) 8%, transparent) 8px 9px); }

/* the bill as a till roll: paper with a torn bottom edge */
#bill .receipt { background: var(--paper); color: var(--paper-ink); border-radius: 10px 10px 0 0; padding: 16px 16px 22px; box-shadow: var(--shadow-1);
  -webkit-mask: radial-gradient(7px 6px at 7px 100%, #0000 98%, #000) 0 0 / 14px 100% repeat-x;
          mask: radial-gradient(7px 6px at 7px 100%, #0000 98%, #000) 0 0 / 14px 100% repeat-x; }
#bill .receipt .sub, #bill .receipt .struck, #bill .receipt .l.sub, #bill .receipt .l.part, #bill .receipt .muted { color: var(--paper-muted); }
#bill .receipt .l.total { border-top: 1.5px dashed #9A988E; font-family: var(--display); font-size: 1.15rem; }
#bill .receipt .lbtn { border-color: var(--paper-line); background: #fff; color: var(--paper-ink); transition: background .15s; }
#bill .receipt .lbtn:hover { background: #F1EEE3; }
#bill .receipt .tag.sent { background: #E3F2E9; color: #1D7448; } #bill .receipt .tag.counter { background: #E5EDFA; color: #2F5DA8; }
#bill .receipt .tag.pending { background: #FBF0DC; color: #8A5300; } #bill .receipt .tag.free { background: #EDE9FE; color: #6D28D9; }
#bill .receipt .kchip[data-status] { --cbg: #fff; }
.receipt { border-radius: 12px; }
.paybox { border-radius: 14px; border-color: var(--hairline); background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.billtabs button { box-shadow: var(--shadow-1); transition: background .2s, color .2s; }

/* kitchen tickets: lift and arrive */
.kds { gap: 12px; }
.ticket { box-shadow: var(--shadow-1); border-radius: 14px; }
.ticket ul { font-family: var(--mono); font-size: 0.9rem; }
@media (prefers-reduced-motion: no-preference) { .ticket { animation: arrive .45s var(--ease); } .ticket[data-status="new"] { animation: arrive .45s var(--ease), newpulse 1.6s ease-in-out .45s infinite; } }
@keyframes arrive { from { transform: translateY(-6px); opacity: 0; } }

/* data tables */
th { background: color-mix(in srgb, var(--sunk) 60%, transparent); }
th:first-child { border-top-left-radius: 8px; } th:last-child { border-top-right-radius: 8px; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--brand) 5%, transparent); }
td { border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent); }
.qr { box-shadow: var(--shadow-1); border-radius: 12px; }
.phonebar { border-radius: 16px; background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.readonly { border-top: 0; background: color-mix(in srgb, var(--bad-bg) 92%, transparent); }

/* screen theme switch: Auto · Light · Dark */
.themesw { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--hairline); }
.themesw button { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; color: var(--muted); border-radius: 999px;
  padding: 4px 8px; font-size: 0.8rem; font-weight: 600; min-height: 0; box-shadow: none; transition: background .2s var(--ease), color .2s; }
.themesw.labels button { padding: 5px 12px; }
.themesw svg { width: 15px; height: 15px; flex: none; }
.themesw button:hover { color: var(--ink); }
.themesw button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.top .themesw { background: rgb(var(--on-brand-rgb) / 0.14); border-color: rgb(var(--on-brand-rgb) / 0.28); }
.top .themesw button { background: transparent; border: 0; color: rgb(var(--on-brand-rgb) / 0.8); padding: 3px 7px; }
.top .themesw button[aria-checked="true"] { background: #fff; color: var(--brand-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn:hover, .tbl:hover, .item:hover, .cats button:hover, .person:hover { transform: none !important; }
}

/* ================================================================ menu colour
   One colour for every category: the restaurant's own (Branding; MintyPOS green by default).
   A dot on its tab, a tint and stripe on its items, a letter badge where there is no photo.
   Mixed with the surface, so it suits both themes. Items already on the bill show how many. */
:root { --hue: var(--brand); --on-hue: var(--on-brand, #fff); --tint: 7%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --tint: 12%; } }
:root[data-theme="dark"] { --tint: 12%; }

.cats button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px 7px 11px; }
.cats .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--hue, var(--brand)); flex: none; }
.cats button[aria-selected="true"] { background: color-mix(in srgb, var(--hue) 16%, var(--surface)); color: var(--ink);
  border-color: var(--hue); box-shadow: 0 0 0 1px var(--hue) inset, 0 3px 10px color-mix(in srgb, var(--hue) 30%, transparent); }
.cats button[aria-selected="true"] .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 28%, transparent); }

.menu { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
.menu .item { position: relative; overflow: hidden; min-height: 0; padding: 12px 12px 12px 16px; gap: 6px;
  grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "badge name" "badge price" "hint hint"; align-items: center; column-gap: 10px; }
.menu .item::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--hue, var(--brand)); }
.menu .item.in { background: linear-gradient(160deg, color-mix(in srgb, var(--hue) var(--tint), var(--surface)), var(--surface) 70%);
  border-color: color-mix(in srgb, var(--hue) 22%, var(--hairline)); }
.menu .item.in:not(:disabled):hover { border-color: var(--hue); box-shadow: 0 8px 22px color-mix(in srgb, var(--hue) 22%, transparent); }
.menu .item .nm { grid-area: name; font-weight: 650; line-height: 1.25; align-self: end; }
.menu .item .p { grid-area: price; align-self: start; font-weight: 600; border: 0; padding: 2px 9px;
  background: color-mix(in srgb, var(--hue) 14%, var(--surface)); color: var(--ink); }
.menu .item .stock { grid-area: hint; color: var(--muted); font-size: 0.74rem; }
.menu .item.out .stock { color: var(--bad); }
.mono-badge { grid-area: badge; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font: 700 1.1rem/1 var(--display); color: var(--on-hue); background: linear-gradient(140deg, var(--hue), color-mix(in srgb, var(--hue) 70%, #000));
  box-shadow: 0 3px 8px color-mix(in srgb, var(--hue) 35%, transparent); }
.menu .item .thumb { grid-column: 1 / -1; height: 84px; margin: -2px 0 2px; }
.menu .item:has(.thumb) { grid-template-areas: "name name" "price price" "hint hint"; }
.menu .item.out { filter: saturate(.35); }
.menu .item.out .mono-badge { opacity: .55; }
.onbill-n { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; font: 700 0.8rem/1 var(--body); color: var(--on-hue); background: var(--hue, var(--brand));
  box-shadow: 0 2px 6px color-mix(in srgb, var(--hue) 40%, transparent); }
.menu .item.onbill { border-color: var(--hue); }
@media (prefers-reduced-motion: no-preference) { .onbill-n { animation: pop .25s var(--ease); } }
.menu .item .p { border-radius: 8px; white-space: normal; line-height: 1.35; }
.menu .item.onbill .nm { padding-right: 26px; }
/* phones: two narrow columns, so the name and price get the width; the stripe keeps the colour */
@media (max-width: 520px) {
  .menu { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .menu .item { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "price" "hint"; padding: 10px 10px 10px 14px; }
  .mono-badge { display: none; }
}
/* a delivery app's order button on the till */
.app-btn { border-color: color-mix(in srgb, var(--info) 45%, var(--line)); color: var(--info); font-weight: 650; }
/* offline: the till carries on, and says so */
.offbar { background: var(--warn-bg); color: var(--warn); border-top: 1px solid currentColor; padding: 8px 16px; font-size: 0.9rem; line-height: 1.35; }
/* a payment due on the subscription: before the grace days run out */
.duebar { background: var(--warn-bg); color: var(--warn); border-top: 1px solid currentColor; padding: 8px 16px; font-size: 0.9rem; line-height: 1.35; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- Add to home screen ---------- */
.install-btn { display: none; align-items: center; gap: 6px; }
html[data-installable] .install-btn { display: inline-flex; }
.card .install-btn { background: var(--surface, #fff); border: 1px solid var(--line, #d8ddd6); color: inherit; border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
@media (max-width: 520px) { .top .install-btn span { display: none; } .top .install-btn { padding: 4px 8px; } }
.install-help { position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / 0.45); display: grid; align-items: end; justify-items: center; padding: 16px; }
.install-card { background: var(--surface, #fff); color: var(--ink, #1b1f1c); border-radius: 16px; padding: 20px; width: min(420px, 100%); box-shadow: 0 12px 40px rgb(0 0 0 / 0.25); }
.install-card h3 { margin: 0 0 8px; font-family: var(--display); }
.install-card ol { margin: 0 0 10px; padding-left: 20px; line-height: 1.7; }
.install-card svg { vertical-align: -3px; }
.install-card .btn { width: 100%; }

/* sample menu items (added at sign-up) */
.item .samplechip { position: absolute; bottom: 8px; right: 8px; font-size: .62rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 999px; background: var(--warn-bg, #FFF1D6); color: var(--warn, #8A5A00); border: 1px solid color-mix(in srgb, var(--warn, #8A5A00) 35%, transparent); }
/* a combo part's own options, under the part */
.partopts { margin: 6px 0 2px 26px; padding: 8px 10px; border-left: 3px solid var(--line); display: grid; gap: 6px; }
.partopts .partgroup { display: grid; gap: 2px; }

/* brand colours that are light (pale blue, yellow): dark text on them; --brand-ink is the brand
   colour deep enough to read on white. Set by applyBrand() in theme.js. */
:root { --on-brand: #fff; --on-brand-rgb: 255 255 255; --brand-ink: var(--brand); }
