:root {
  --bg: #f5f5f2; --panel: #fff; --panel-2: #f0efea; --line: #e3e1da; --text: #1c1b19; --muted: #6d6b64;
  --accent: #0f766e; --accent-2: #0d5f59; --accent-soft: #dff3f0; --warm: #ea580c; --warm-soft: #fdecdf;
  --good: #15803d; --good-soft: #e1f4e7; --bad: #c2410c; --bad-soft: #fde8de; --warn: #a16207; --warn-soft: #fbf0d3;
  --radius: 12px; --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 14px rgb(0 0 0 / .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312; --panel: #1c1c1a; --panel-2: #262623; --line: #34342f; --text: #ecebe5; --muted: #9c9a92;
    --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #123b37; --warm: #fb923c; --warm-soft: #3b2312;
    --good: #4ade80; --good-soft: #15301f; --bad: #fb923c; --bad-soft: #3b2014; --warn: #facc15; --warn-soft: #332a0f; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100dvh; }
.sidebar { background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 16px; font-size: 18px; }
.brand { flex-direction: column; align-items: flex-start; gap: 6px; }
.brand small { display: block; font-size: 13px; font-weight: 600; }
/* the CDC logo is black on transparent; dark mode turns it white */
.logo-img { display: block; height: 36px; width: auto; }
.gate-card .logo-img { height: 54px; margin: 0 auto 6px; }
@media (prefers-color-scheme: dark) { .logo-img { filter: invert(1); } }
.plan-chip { width: 100%; display: flex; align-items: center; gap: 6px; padding: 8px 10px; margin-bottom: 10px; border-radius: 10px; border: 1px dashed var(--line);
  background: var(--panel-2); cursor: pointer; font-size: 13px; text-align: start; }
.plan-chip span { margin-inline-start: auto; color: var(--accent); font-weight: 700; }
.locked { display: grid; place-items: center; text-align: center; gap: 6px; min-height: 140px; color: var(--muted); border-style: dashed; }
.locked b { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
nav a:hover { background: var(--panel-2); }
nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav .sep { border-top: 1px solid var(--line); margin: 8px 6px; }
.side-foot { margin-top: auto; padding: 10px 6px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side-foot .me small { display: block; }
.side-foot select { width: auto; flex: 1; padding: 5px 8px; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.support-bar { position: sticky; top: 0; z-index: 60; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 16px; background: #7c3aed; color: #fff; font-size: 14px; }
.support-bar .btn { background: #fff; color: #4c1d95; border-color: transparent; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 58px; }
.topbar h1 { font-size: 18px; margin: 0; }
.actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.view { flex: 1; overflow-y: auto; padding: 18px 20px; min-height: 0; }
.menu-btn { display: none; }
.banner { padding: 8px 16px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-radius: 8px; margin-bottom: 10px; }
/* kitchen screen gets the full width; the menu slides in from ☰ instead of disappearing */
body.kiosk .shell { grid-template-columns: minmax(0, 1fr); }
body.kiosk .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 260px; z-index: 40; transform: translateX(110%); transition: transform .2s; box-shadow: 0 0 40px rgb(0 0 0 / .2); }
[dir=ltr] body.kiosk .sidebar { transform: translateX(-110%); }
body.kiosk .sidebar.open { transform: none !important; }
body.kiosk .menu-btn { display: inline-flex; }

/* ---------- controls ---------- */
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 10px; }
button:hover { background: var(--panel-2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.primary:hover { background: var(--accent-2); }
button.warm { background: var(--warm); color: #fff; border-color: transparent; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.danger { color: var(--bad); }
button.danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
button.icon { padding: 6px 10px; }
button.big { padding: 13px 18px; font-size: 16px; font-weight: 600; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--text); }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field small { display: block; margin-top: 3px; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
label.check small { display: block; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); } .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.accent { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 13px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.active { background: var(--accent); color: #fff; border-color: transparent; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.cards > * { min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 15px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 700; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
th.sel, td.sel { width: 36px; padding-inline: 6px; }
td.sel .sel-box { display: grid; place-items: center; cursor: pointer; min-height: 28px; }
tr.selected td { background: var(--accent-soft) !important; }
.sel-item { position: relative; }
.sel-item > .sel-box { position: absolute; top: 4px; inset-inline-end: 4px; z-index: 1; padding: 4px; cursor: pointer; line-height: 0; }
.sel-item > .tbl { width: 100%; }
.sel-item.selected > .tbl { outline: 2px solid var(--accent); background: var(--accent-soft); }
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 8px;
  border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent); }
.table-wrap { overflow-x: auto; }
.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 14px; color: var(--muted); white-space: nowrap; }
.tabs button.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* ---------- gate: login, PIN, onboarding ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 40%), var(--bg); }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 28px 26px; width: min(400px, 100%); text-align: center; box-shadow: 0 20px 60px rgb(0 0 0 / .08); }
.gate-card h1 { margin: 4px 0; font-size: 22px; }
.gate-card form, .gate-card label { text-align: start; }
.gate-logo { font-size: 46px; }
.pin-dots { display: flex; justify-content: center; gap: 10px; margin: 14px 0 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); }
.pin-dots i.opt { opacity: .45; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; direction: ltr; }
.keypad button { font-size: 24px; padding: 14px 0; border-radius: 14px; }

.wizard { width: min(860px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 60px rgb(0 0 0 / .08); overflow: hidden; }
.wiz-head { padding: 20px 26px 12px; border-bottom: 1px solid var(--line); }
.wiz-head h1 { margin: 0; font-size: 21px; }
.wiz-steps { display: flex; gap: 4px; margin-top: 12px; }
.wiz-steps i { flex: 1; height: 5px; border-radius: 99px; background: var(--panel-2); }
.wiz-steps i.done { background: var(--accent); }
.wiz-body { padding: 20px 26px; max-height: calc(100dvh - 230px); overflow-y: auto; }
.wiz-body h2 { margin: 0 0 4px; font-size: 18px; }
.wiz-body > p.muted { margin-top: 0; }
.wiz-foot { display: flex; gap: 10px; padding: 14px 26px; border-top: 1px solid var(--line); background: var(--panel-2); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 10px; margin: 12px 0; }
.opt-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 2px solid var(--line); border-radius: 14px; cursor: pointer; background: var(--panel); text-align: start; }
.opt-card:hover { border-color: var(--accent); }
.opt-card.on { border-color: var(--accent); background: var(--accent-soft); }
.opt-card .ico { font-size: 28px; }
.opt-card small { color: var(--muted); }
.opt-card input { position: absolute; top: 10px; inset-inline-end: 10px; }
.summary-list li b { min-width: 150px; display: inline-block; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; height: 100%; min-height: 0; }
.pos-menu { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.cat-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; flex: none; }
.cat-bar button { white-space: nowrap; padding: 10px 16px; border-radius: 12px; }
.cat-bar button.active { background: var(--accent); color: #fff; border-color: transparent; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; overflow-y: auto; align-content: start; padding-bottom: 10px; }
.item-btn { display: flex; flex-direction: column; justify-content: space-between; gap: 6px; min-height: 96px; padding: 12px; border-radius: 14px; text-align: start; background: var(--panel); border: 1px solid var(--line); }
.item-btn:hover { border-color: var(--accent); background: var(--panel); }
.item-btn .nm { font-weight: 600; line-height: 1.35; }
.item-btn .pr { color: var(--accent); font-weight: 700; }
.item-btn.off { opacity: .4; }
.item-btn img { width: 100%; height: 70px; object-fit: cover; border-radius: 9px; }
.cart { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.cart-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.type-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 11px; }
.type-tabs button { border: 0; background: transparent; padding: 7px 4px; border-radius: 8px; font-size: 14px; }
.type-tabs button.active { background: var(--panel); box-shadow: var(--shadow); font-weight: 600; color: var(--accent); }
.cart-lines { flex: 1; overflow-y: auto; padding: 6px 14px; }
.cart-line { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cart-line .opts { font-size: 12px; color: var(--muted); }
.cart-line .st { font-size: 11px; }
.qty { display: flex; align-items: center; gap: 2px; }
.qty button { padding: 2px 9px; border-radius: 8px; }
.cart-foot { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.tot-row { display: flex; justify-content: space-between; font-size: 14px; }
.tot-row.big { font-size: 20px; font-weight: 700; }
.cart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.open-strip { display: flex; gap: 8px; overflow-x: auto; flex: none; }
.open-strip button { white-space: nowrap; font-size: 13px; padding: 6px 12px; }
.open-strip button.cur { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.pay-methods button { padding: 12px 6px; font-weight: 600; }
.pay-methods button.on { background: var(--accent); color: #fff; border-color: transparent; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pay-lines li { font-size: 14px; }
.opt-group { margin-bottom: 14px; }
.opt-group h4 { margin: 0 0 6px; font-size: 14px; }
.opt-choice { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 0 0 6px 6px; cursor: pointer; }
.opt-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* tables map */
.area-title { margin: 16px 0 8px; font-size: 14px; color: var(--muted); }
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.tbl { aspect-ratio: 1.15; border-radius: 16px; border: 2px solid var(--line); background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; }
.tbl b { font-size: 20px; }
.tbl.busy { border-color: var(--warm); background: var(--warm-soft); }
.tbl.ready { border-color: var(--good); background: var(--good-soft); }
.tbl.pending { border-color: var(--bad); background: var(--bad-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

/* ---------- KDS ---------- */
.kds-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.kds { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; align-items: start; }
.ticket { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.ticket.late { border-color: var(--warn); } .ticket.very-late { border-color: var(--bad); }
.ticket-head { padding: 9px 12px; background: var(--panel-2); display: flex; align-items: center; gap: 8px; }
.ticket-head b { font-size: 20px; }
.ticket.late .ticket-head { background: var(--warn-soft); } .ticket.very-late .ticket-head { background: var(--bad-soft); }
.tk-items { padding: 6px 12px; }
.tk-item { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); cursor: pointer; font-size: 16px; }
.tk-item:last-child { border-bottom: 0; }
.tk-item .q { font-weight: 700; min-width: 28px; }
.tk-item.preparing { color: var(--warn); }
.tk-item.ready { color: var(--good); text-decoration: line-through; }
.tk-item small { display: block; color: var(--muted); font-size: 13px; }
.ticket button.bump { border-radius: 0; border: 0; border-top: 1px solid var(--line); padding: 12px; font-size: 16px; font-weight: 700; background: var(--accent); color: #fff; }

/* modal, toasts */
.modal { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: center; z-index: 50; padding: 14px; }
.modal .box { background: var(--panel); border-radius: 16px; width: min(560px, 100%); max-height: 92dvh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgb(0 0 0 / .3); }
.modal .box.wide { width: min(860px, 100%); }
.box-head { display: flex; align-items: center; padding: 14px 18px 8px; }
.box-head h2 { margin: 0; font-size: 18px; flex: 1; }
.box-body { padding: 6px 18px; overflow-y: auto; }
.foot { display: flex; gap: 8px; padding: 12px 18px 16px; }
.foot .spacer { flex: 1; }
.form-err { margin: 4px 18px 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 14px; }
/* top-center: bottom corners hide behind the Windows taskbar and phone gesture bars */
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 70; width: max-content; max-width: calc(100vw - 24px); }
.toast { background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 11px; font-size: 14px; max-width: 380px; box-shadow: var(--shadow); animation: up .2s ease; }
.toast.err { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warm); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* print sheet of table QR codes */
.qr-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.qr-tag { border: 1px dashed var(--line); border-radius: 14px; padding: 14px; text-align: center; background: #fff; color: #111; }
.qr-tag img { width: 100%; max-width: 180px; }
.qr-tag b { font-size: 22px; display: block; }
@media print {
  body * { visibility: hidden; }
  .qr-sheet, .qr-sheet * { visibility: visible; }
  .qr-sheet { position: absolute; inset: 0; grid-template-columns: repeat(3, 1fr); }
  .qr-tag { break-inside: avoid; }
}

/* ---------- responsive: tablets and phones ---------- */
.bottom-nav, .cart-peek, .cart-scrim, .cart-close { display: none; }

/* touch screens: every control comfortably tappable */
@media (pointer: coarse) {
  button, .btn { min-height: 42px; }
  button.small, .btn.small { min-height: 36px; }
  .chip { min-height: 38px; padding: 7px 15px; }
  nav a { padding: 12px 12px; }
  input, select { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .qty button { min-width: 38px; min-height: 38px; font-size: 18px; }
  .item-btn:active, .tbl:active, .chip:active, button:active { transform: scale(.97); }
}

/* small laptops and landscape tablets */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 214px minmax(0, 1fr); }
  .pos { grid-template-columns: minmax(0, 1fr) 320px; }
}

/* portrait tablets and phones: drawer menu + bottom bar */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(290px, 84vw); z-index: 46; transform: translateX(110%); transition: transform .22s ease; box-shadow: 0 0 40px rgb(0 0 0 / .25);
    padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  [dir=ltr] .sidebar { transform: translateX(-110%); }
  .sidebar.open { transform: none !important; }
  /* dim the page behind the open drawer; a tap on it closes the drawer */
  .sidebar.open ~ .main::after { content: ""; position: fixed; inset: 0; background: rgb(0 0 0 / .38); z-index: 45; }
  .menu-btn { display: inline-flex; }

  .main { height: 100dvh; }
  .topbar { padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; min-height: 54px; gap: 8px; position: sticky; top: 0; z-index: 20; }
  .topbar h1 { font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* page buttons stay on one row that scrolls sideways instead of stacking */
  .actions { width: 100%; order: 3; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline-start: 0; }
  .actions::-webkit-scrollbar { display: none; }
  .actions > * { flex: none; }
  .actions select, .actions input { width: auto !important; min-width: 0; }
  .actions .chips { flex-wrap: nowrap; }
  .view { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }

  .bottom-nav { display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line);
    padding: 4px 4px max(6px, env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgb(0 0 0 / .05); }
  .bottom-nav a, .bottom-nav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border: 0; border-radius: 12px;
    background: none; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; position: relative; min-height: 54px; }
  .bottom-nav .bn-ico { font-size: 21px; line-height: 1.2; }
  .bottom-nav .bn-txt { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bottom-nav a.active { color: var(--accent); background: var(--accent-soft); }
  .bottom-nav .badge { position: absolute; top: 2px; inset-inline-end: 18%; }
  body.kiosk .bottom-nav { display: none; }
  body.kiosk .view { padding-bottom: 14px; }

  .support-bar { padding: 4px 12px; font-size: 12.5px; }
  .support-bar .btn { min-height: 30px; padding: 3px 10px; font-size: 12px; }
  .support-bar .sb-more { display: none; }

  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .cards { gap: 12px; }
  .card { padding: 14px; }
  .wiz-body { max-height: none; padding: 16px; }
  .wiz-head, .wiz-foot { padding-inline: 16px; }
  .wizard { border-radius: 16px; }
  .modal { padding: 0; place-items: end center; }
  .modal .box, .modal .box.wide { width: 100%; border-radius: 20px 20px 0 0; max-height: 94dvh; padding-bottom: env(safe-area-inset-bottom); animation: sheet .22s ease; }
  .box-head { padding: 16px 16px 8px; position: relative; }
  .box-head::before { content: ""; position: absolute; top: 6px; inset-inline: 0; margin: auto; width: 40px; height: 4px; border-radius: 99px; background: var(--line); }
  .box-body { padding: 6px 16px; }
  /* sticky save bar so the main button is always reachable above the keyboard */
  .foot { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px 14px; }
  .foot button[type=submit] { flex: 1; }
  input, select, textarea { font-size: 16px; }
  .toasts { top: max(10px, env(safe-area-inset-top)); }
  .tabs { margin-inline: -12px; padding-inline: 12px; scrollbar-width: none; }

  /* POS on a portrait tablet: menu and a slimmer cart side by side */
  .pos { grid-template-columns: minmax(0, 1fr) 290px; gap: 10px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .cart-head, .cart-foot { padding: 10px 12px; }
  .cart-lines { padding: 4px 12px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .4; } }

/* phones */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .view { padding-inline: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .kpi { padding: 10px 12px; }
  .kpi .label { font-size: 12.5px; }
  .kpi .value { font-size: 18px; }
  .card h3 { font-size: 15.5px; }
  /* chip filters scroll sideways in one line instead of filling half the screen */
  .view .chips, .cat-bar, .open-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -10px; padding-inline: 10px; }
  .view .chips::-webkit-scrollbar, .cat-bar::-webkit-scrollbar, .open-strip::-webkit-scrollbar { display: none; }
  .view .chips > * { flex: none; }
  .view > .row { gap: 8px; }
  .view > .row > input, .view > .row > select { max-width: none !important; flex: 1 1 140px; }
  .tables-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .tbl b { font-size: 18px; }
  .kds { grid-template-columns: minmax(0, 1fr); }
  .pay-methods { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot { flex-wrap: wrap; }

  /* list tables become cards: the first cell is the title, the rest are "label — value" rows */
  .card:has(> .table-wrap > table.rtable), .card:has(> .bulk-bar + .table-wrap > table.rtable) { background: none; border: 0; box-shadow: none; padding: 0; }
  .table-wrap { overflow: visible; }
  table.rtable, table.rtable tbody { display: block; }
  table.rtable thead { display: none; }
  /* two columns of "label over value"; the title row spans both */
  table.rtable tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; position: relative; padding: 12px 14px; margin-bottom: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
  table.rtable td { display: block; padding: 0; border: 0; font-size: 14px; text-align: start; min-width: 0; overflow-wrap: anywhere; }
  table.rtable td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-bottom: 1px; }
  table.rtable td[data-label=""]::before { content: none; }
  table.rtable td[data-label=""] { grid-column: 1 / -1; }
  table.rtable td:empty { display: none; }
  table.rtable tr > td:first-child:not(.sel), table.rtable td.sel + td { grid-column: 1 / -1; font-size: 15.5px; font-weight: 600; padding-inline-end: 34px; }
  table.rtable tr > td:first-child:not(.sel)::before, table.rtable td.sel + td::before { content: none; }
  /* a picture cell sits beside the name that follows it */
  table.rtable tr:has(> td > img) { grid-template-columns: 56px repeat(2, minmax(0, 1fr)); }
  table.rtable tr > td:has(> img), table.rtable tr > td.sel + td:has(> img) { grid-column: 1; grid-row: 1 / span 2; width: 56px; padding-inline-end: 0; }
  table.rtable tr > td:has(> img) img { width: 56px !important; height: 56px !important; }
  table.rtable tr > td:has(> img) + td { grid-column: 2 / -1; grid-row: 1; font-size: 15.5px; font-weight: 600; padding-inline-end: 34px; }
  table.rtable tr > td:has(> img) + td::before { content: none; }
  table.rtable td.sel { position: absolute; top: 8px; inset-inline-end: 8px; width: auto; padding: 0; }
  table.rtable td.sel::before { content: none; }
  table.rtable tr.click:hover td { background: none; }
  table.rtable tr.click:active { background: var(--panel-2); }
  table.rtable tr.selected { border-color: var(--accent); background: var(--accent-soft); }
  table.rtable tr.selected td { background: none !important; }
  .bulk-bar { top: 0; border-radius: 12px; }

  /* POS: full-width menu, the cart opens as a sheet from the summary bar */
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; }
  .pos-menu { min-height: auto; }
  .pos-menu .row-tight input { max-width: none !important; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .item-btn { min-height: 84px; padding: 10px; }
  .item-btn img { height: 88px; }
  .cart { position: fixed; inset-inline: 0; bottom: 0; height: 88dvh; z-index: 48; border-radius: 22px 22px 0 0; border: 0; box-shadow: 0 -10px 40px rgb(0 0 0 / .25);
    transform: translateY(105%); transition: transform .24s ease; padding-bottom: env(safe-area-inset-bottom); }
  .cart.open { transform: none; }
  .cart-close { display: inline-flex; font-size: 20px; }
  .cart-scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 47; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .cart-scrim.on { opacity: 1; pointer-events: auto; }
  .cart-peek { display: flex; position: fixed; inset-inline: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 29; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: 16px; border: 0; background: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 10px 28px rgb(15 118 110 / .35); text-align: start; }
  .cart-peek .peek-n { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 99px; background: rgb(255 255 255 / .22); font-weight: 700; }
  .cart-peek .pill { background: rgb(255 255 255 / .9); }
  .cart-peek .num, .cart-peek small { color: inherit; }
  .cart-peek.hidden { display: none; }
  .cart-peek.bump { animation: bump .3s ease; }
  .view-pos { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .cart-actions { grid-template-columns: 1fr 1.3fr; }
  @media (prefers-color-scheme: dark) { .cart-peek { color: #062421; } }
}
@keyframes bump { 40% { transform: scale(1.03); } }
