/* ==========================================================================
   Pinakexa POS - application stylesheet
   Light, minimal, material: near-white canvas, white cards on hairline
   borders, one rich blue accent, pill navigation, tabular money.
   ========================================================================== */

:root {
  /* accent - rich blue */
  --primary: #1d4ed8;
  --primary-hover: #1a43bd;
  --primary-press: #16389c;
  --on-primary: #ffffff;
  --primary-soft: #e8eefe;
  --primary-soft-2: #d5e1fd;
  --on-primary-soft: #16368f;
  --primary-grad: linear-gradient(135deg, #2563eb 0%, #1d4ed8 55%, #1e3a8a 100%);
  --glow: 0 10px 26px -12px rgba(29, 78, 216, .55);

  /* money semantics - cash and UPI must never look alike */
  --cash: #b45309;
  --cash-soft: #fdf0dc;
  --upi: #7c3aed;
  --upi-soft: #efe8fd;
  --ok: #047857;
  --ok-soft: #d6f3e6;
  --warn: #b45309;
  --warn-soft: #fdf0dc;
  --bad: #be123c;
  --bad-soft: #fce7ec;
  --info: #0369a1;

  /* surfaces - cool, faintly blue tinted greys */
  --bg: #e9eef7;
  --shell: #f6f8fd;
  --panel: #ffffff;
  --panel-2: #f3f6fc;
  --raise: #eaf0fa;
  --well: #f2f5fc;
  --line: #e0e7f2;
  --line-soft: #edf1f8;

  --text: #101728;
  --text-2: #57627a;
  --text-3: #8590a6;

  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --pill: 999px;

  --shadow-1: 0 1px 2px rgba(20, 35, 26, .05);
  --shadow-2: 0 2px 6px rgba(20, 35, 26, .06), 0 1px 2px rgba(20, 35, 26, .04);
  --shadow-3: 0 12px 32px -14px rgba(20, 35, 26, .30);
  --shadow-4: 0 28px 60px -22px rgba(20, 35, 26, .38);

  --topbar: 68px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}

html[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-hover: #7cb6fb;
  --primary-press: #4b93e8;
  --on-primary: #06152e;
  --primary-soft: #16233f;
  --primary-soft-2: #1d3055;
  --on-primary-soft: #bfdbfe;
  --primary-grad: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1e40af 100%);
  --glow: 0 10px 30px -12px rgba(59, 130, 246, .55);

  --cash: #f0a742;
  --cash-soft: #38290f;
  --upi: #c4b5fd;
  --upi-soft: #2a2350;
  --ok: #4ade80;
  --ok-soft: #12301f;
  --warn: #fbbf24;
  --warn-soft: #35290d;
  --bad: #fb7185;
  --bad-soft: #3a1620;

  --bg: #070b14;
  --shell: #0c111c;
  --panel: #111827;
  --panel-2: #172033;
  --raise: #1e293b;
  --well: #151d2e;
  --line: #22304a;
  --line-soft: #1a2437;

  --text: #e6ecf7;
  --text-2: #a3b0c7;
  --text-3: #76839c;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .5);
  --shadow-3: 0 14px 34px -16px rgba(0, 0, 0, .75);
  --shadow-4: 0 30px 60px -20px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
::selection { background: var(--primary-soft-2); }

.num, .money, td.num, th.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.tiny { font-size: 11.5px; }
.sm { font-size: 12.5px; }
.big { font-size: 20px; }
.bold { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.ic { width: 18px; height: 18px; flex: none; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ============================================================ app shell == */
.app {
  min-height: 100dvh;
  padding: 14px;
  display: flex;
}
.shell {
  flex: 1;
  min-width: 0;
  background: var(--shell);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ----------------------------------------------------------- top nav bar - */
.topbar {
  height: var(--topbar);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 30;
}
/* Scoped to the top bar: `.brand` would otherwise also match `.kpi.brand`. */
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  background: var(--primary-grad); display: grid; place-items: center;
  box-shadow: var(--glow);
  color: var(--on-primary); font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
/* The logo artwork is transparent; a white plate keeps it legible in dark mode. */
img.brand-mark {
  display: block; object-fit: contain; padding: 3px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-sub { font-size: 10px; color: var(--text-3); letter-spacing: .1em; text-transform: uppercase; }

.topnav { display: flex; align-items: center; gap: 4px; margin: 0 auto; }
.topnav a, .topnav button.navlink {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--pill);
  color: var(--text-2); font-weight: 550; font-size: 13.5px;
  border: 1px solid transparent; background: none; cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.topnav a:hover, .topnav button.navlink:hover { background: var(--panel-2); color: var(--text); }
.topnav a.on {
  background: var(--primary-grad); color: var(--on-primary); font-weight: 600;
  box-shadow: var(--glow);
}
.topnav a.on .ic { color: var(--on-primary); }
.topnav .pill { margin-left: 2px; }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 700; font-size: 13px;
  border: 1px solid var(--line);
}

/* dropdown menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  min-width: 230px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-4);
  display: none;
}
.menu.open { display: block; animation: menuIn .14s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text-2); background: none; border: 0;
  cursor: pointer; text-align: left; font-weight: 500;
}
.menu a:hover, .menu button:hover { background: var(--panel-2); color: var(--text); }
.menu a.on { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 600; }
.menu-sep { height: 1px; background: var(--line-soft); margin: 6px 4px; }
.menu-label { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding: 8px 11px 4px; font-weight: 650; }

.page-head { padding: 18px 20px 0; display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.page-sub { font-size: 12.5px; color: var(--text-3); }
.content { padding: 16px 20px 24px; flex: 1; min-width: 0; }
.content.tight { padding: 0; }

.tabbar { display: none; }
.burger { display: none; }

/* phone navigation drawer (opened by the burger) */
.drawer {
  position: fixed; z-index: 80; top: 0; bottom: 0; left: 0;
  width: min(300px, 86vw); background: var(--panel);
  border-right: 1px solid var(--line); box-shadow: var(--shadow-4);
  display: flex; flex-direction: column;
  transform: translateX(-102%); visibility: hidden;
  transition: transform .24s cubic-bezier(.2,.9,.3,1), visibility 0s linear .24s;
  padding-top: env(safe-area-inset-top);
}
.drawer.open { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.2,.9,.3,1); }
.drawer-back { position: fixed; inset: 0; z-index: 79; background: rgba(10, 16, 30, .45); }
.drawer-back[hidden] { display: none; }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px; border-bottom: 1px solid var(--line-soft);
}
.drawer-head .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
.drawer-body {
  flex: 1; overflow-y: auto; padding: 6px 8px calc(16px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.drawer-body a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border-radius: var(--radius-sm);
  font-size: 14.5px; color: var(--text-2); font-weight: 500;
}
.drawer-body a:active, .drawer-body a:hover { background: var(--panel-2); color: var(--text); }
.drawer-body a.on { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 600; }
body.drawer-open { overflow: hidden; }
@media (min-width: 901px) { .drawer, .drawer-back { display: none !important; } }

/* ============================================================= components = */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
}
.card-h { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.card-h h3 { font-size: 15px; font-weight: 600; }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }
.card-f { padding: 14px 18px; border-top: 1px solid var(--line-soft); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
/* Page level two panel layouts. These exist as classes rather than inline
   styles precisely so the media queries below can collapse them - an inline
   grid-template-columns silently wins over every breakpoint. */
.g-half { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.g-main { grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); }
.g-side { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }

/* buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--pill);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
  user-select: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary-grad); border-color: transparent; color: var(--on-primary); box-shadow: var(--glow); }
.btn-primary:hover { background: var(--primary-hover); border-color: transparent; filter: brightness(1.05); }
.btn-tonal { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }
.btn-tonal:hover { background: var(--primary-soft-2); border-color: transparent; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-cash { background: var(--cash); border-color: var(--cash); color: #fff; }
.btn-upi { background: var(--upi); border-color: var(--upi); color: #fff; }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-xl { padding: 17px 24px; font-size: 16.5px; border-radius: var(--radius); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-icon { padding: 9px; border-radius: 50%; }
.btn-block { width: 100%; }

/* inputs --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--text-3); }
.inp, select.inp, textarea.inp {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--well); border: 1px solid var(--line); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.inp:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: var(--panel); }
.inp::placeholder { color: var(--text-3); }
textarea.inp { resize: vertical; min-height: 76px; }
select.inp {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%238a9490' stroke-width='1.6' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
.inp-lg { padding: 13px 15px; font-size: 16px; }
.inp-xl { padding: 15px 16px; font-size: 22px; font-weight: 650; }
.inp-money { font-variant-numeric: tabular-nums; text-align: right; }
.help { font-size: 11.5px; color: var(--text-3); }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

/* a labelled read-only well, like the reference order panel */
.well-box { background: var(--well); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; }
.well-box .lbl { display: block; margin-bottom: 1px; }
.well-box .val { font-size: 14px; font-weight: 600; }

.search-wrap { position: relative; flex: 1; min-width: 0; }
.search-wrap .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-wrap .inp { padding-left: 38px; border-radius: var(--pill); }

/* badges --------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--pill); font-size: 11px; font-weight: 650;
  border: 1px solid transparent; white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.mute { background: var(--panel-2); color: var(--text-2); border-color: var(--line); }
.pill.cash { background: var(--cash-soft); color: var(--cash); }
.pill.upi { background: var(--upi-soft); color: var(--upi); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* tables --------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .03em;
  color: var(--text-3); padding: 11px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--panel); z-index: 1;
}
table.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tbl tbody tr:hover td { background: var(--panel-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tfoot td { padding: 13px 16px; font-weight: 700; border-top: 1px solid var(--line); }
table.tbl.compact td, table.tbl.compact th { padding: 9px 12px; }
.tbl a.link { color: var(--primary); font-weight: 600; }
html[data-theme="dark"] .tbl a.link { color: var(--primary); }

/* KPI tiles ------------------------------------------------------------ */
.kpi { padding: 16px 18px; border-radius: var(--radius-lg); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.kpi .k-lbl { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.kpi .k-val { font-size: 26px; font-weight: 700; letter-spacing: -.025em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.kpi.cash { border-left: 3px solid var(--cash); }
.kpi.upi { border-left: 3px solid var(--upi); }
.kpi.bad { border-left: 3px solid var(--bad); }
.kpi.ok { border-left: 3px solid var(--ok); }
.kpi.brand { border-left: 3px solid var(--primary); }
.kpi.warn { border-left: 3px solid var(--warn); }

/* alerts --------------------------------------------------------------- */
.alert { padding: 12px 15px; border-radius: var(--radius); font-size: 13px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.alert.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert.info { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }
.alert.success { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }

/* toasts --------------------------------------------------------------- */
#toasts { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 250px; max-width: 400px;
  background: var(--text); color: var(--panel);
  border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--shadow-4);
  font-size: 13.5px; font-weight: 500; animation: toastIn .22s cubic-bezier(.2,.9,.3,1.2);
  border-left: 4px solid var(--primary);
}
.toast.ok { border-left-color: #4ade80; }
.toast.bad { border-left-color: #f87171; }
.toast.warn { border-left-color: #fbbf24; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }

/* modal ---------------------------------------------------------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 150; background: rgba(16, 26, 20, .42);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 18px;
  animation: fade .16s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: 92dvh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-4);
  animation: pop .2s cubic-bezier(.2,.9,.3,1.15);
}
.modal.wide { width: min(920px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.modal-h h3 { font-size: 17px; }
.modal-b { padding: 22px; }
.modal-f { padding: 16px 22px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }
.x-btn { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 22px; line-height: 1; padding: 4px 8px; border-radius: 50%; }
.x-btn:hover { background: var(--panel-2); color: var(--text); }

/* ==================================================================== POS = */
.pos {
  display: grid; grid-template-columns: minmax(0,1fr) 400px;
  gap: 16px; padding: 16px 20px 20px;
  height: calc(100dvh - var(--topbar) - 28px);
}
.pos-left {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow: hidden;
}
.pos-bar { display: flex; gap: 10px; padding: 16px 18px 12px; align-items: center; flex-wrap: wrap; }
.pos-bar h3 { font-size: 17px; margin-right: auto; }
.scan-box { position: relative; flex: 1 1 240px; min-width: 190px; }
.pos-search { max-width: 260px; }
.scan-box .inp { padding-left: 40px; border-radius: var(--pill); font-family: var(--mono); letter-spacing: .03em; }
.scan-box .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--primary); }

.cats { display: flex; gap: 8px; padding: 4px 18px 14px; overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat {
  padding: 8px 15px; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--panel); font-size: 13px; font-weight: 550; white-space: nowrap;
  cursor: pointer; color: var(--text-2); transition: border-color .15s, color .15s, background .15s;
}
.cat:hover { background: var(--panel-2); }
.cat.on { border-color: var(--primary); color: var(--primary); background: var(--panel); font-weight: 650; }

/* product cards, mirroring the reference layout */
.tiles {
  flex: 1; overflow-y: auto; padding: 4px 18px 18px; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  /* This grid scrolls inside a fixed height flex column. Without an explicit
     content based row size Chrome sizes the auto rows against the available
     height instead of the cards, and the cards get clipped. */
  grid-auto-rows: min-content;
  align-content: start;
}
.tile {
  position: relative; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 0; overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s, transform .07s;
}
.tile:hover { border-color: var(--primary); box-shadow: var(--shadow-2); }
.tile:active { transform: scale(.985); }
.tile-art {
  height: 84px; display: grid; place-items: center; position: relative;
  background: var(--well); border-bottom: 1px solid var(--line-soft);
  flex: none; width: 100%;
}
.tile-art .glyph {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  color: #fff; box-shadow: 0 6px 14px -8px currentColor;
}
.tile-art .glyph svg { width: 26px; height: 26px; }
.tile:hover .tile-art .glyph { transform: translateY(-1px) scale(1.04); }
.tile-art .glyph { transition: transform .16s cubic-bezier(.2,.9,.3,1.2); }
.pic { display: block; }

/* icon chip used in lists, pickers and the order panel */
.ichip {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.ichip svg { width: 19px; height: 19px; }
.ichip.sm { width: 26px; height: 26px; border-radius: 8px; }
.ichip.sm svg { width: 15px; height: 15px; }

/* icon picker in the item editor */
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px; max-height: 260px; overflow-y: auto; padding: 4px;
}
.icon-opt {
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel); display: grid; place-items: center; cursor: pointer;
  color: var(--text-2); transition: border-color .14s, background .14s, color .14s;
}
.icon-opt:hover { border-color: var(--primary); color: var(--primary); }
.icon-opt.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.icon-opt svg { width: 22px; height: 22px; }
.t-badge {
  position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: var(--pill);
  font-size: 10.5px; font-weight: 700; letter-spacing: .01em;
}
.t-badge.ok { background: var(--ok-soft); color: var(--ok); }
.t-badge.warn { background: var(--warn-soft); color: var(--warn); }
.t-badge.bad { background: var(--bad-soft); color: var(--bad); }
.tile-body { display: block; width: 100%; padding: 11px 13px 6px; }
.t-name {
  display: block; font-size: 13.5px; font-weight: 600; line-height: 1.3;
  min-height: 2.6em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.t-meta {
  display: block; font-size: 11px; color: var(--text-3); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-foot {
  margin-top: auto; width: 100%; padding: 8px 12px 12px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
}
.t-price-wrap { line-height: 1.2; text-align: left; }
.t-price-lbl { display: block; font-size: 10px; color: var(--text-3); }
.t-price { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.t-add {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 7px 11px; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--panel); font-size: 11.5px; font-weight: 650; color: var(--text-2);
}
.tile:hover .t-add { border-color: var(--primary); color: var(--primary); }
.tile.out { opacity: .55; }
.tile.out .t-add { visibility: hidden; }

/* order panel ---------------------------------------------------------- */
.cart {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden;
}
.cart-h { padding: 16px 18px 12px; display: flex; align-items: center; gap: 8px; }
.cart-h h3 { font-size: 17px; }
.cart-meta { padding: 0 18px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cart-count { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.cart-clear { margin-left: auto; font-size: 12px; color: var(--bad); font-weight: 600; background: none; border: 0; cursor: pointer; text-decoration: underline; }
/* ------------------------- gaming sessions inside the order panel ------- */
.sess-block { padding: 0 18px 10px; }
.sess-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 11.5px; font-weight: 650; color: var(--text-3);
  background: none; border: 0; width: 100%; padding: 0; cursor: pointer;
}
.sess-head:hover { color: var(--text); }

/* Sessions waiting to be billed live behind this badge, beside the customer
   button, rather than as a list that crowds the bill out of the panel. */
.ready-btn {
  position: relative; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--primary-grad); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: var(--glow);
}
.ready-btn svg { width: 20px; height: 20px; position: relative; z-index: 1; }
.ready-btn:hover { filter: brightness(1.08); }
.ready-btn:active { transform: scale(.94); }
.ready-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--primary);
  animation: readyPulse 1.8s ease-out infinite;
}
@keyframes readyPulse {
  0%   { transform: scale(1);    opacity: .85; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .ready-ring { animation: none; opacity: .3; } }
.ready-count {
  position: absolute; top: -4px; right: -4px; z-index: 2;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  background: var(--warn); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 19px; text-align: center;
  border: 2px solid var(--panel); box-sizing: content-box;
}
.sess {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 11px; margin-bottom: 6px; cursor: pointer;
  background: var(--well); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .14s, background .14s;
}
.sess:hover { border-color: var(--primary); background: var(--panel); }
.sess.live { background: var(--primary-soft); border-color: transparent; cursor: default; }
.sess-ic {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--primary-grad); color: var(--on-primary);
}
.sess.live .sess-ic { background: var(--ok); color: #fff; }
.sess-main { min-width: 0; flex: 1; }
.sess-station { font-size: 13.5px; font-weight: 650; }
.sess-user { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-right { text-align: right; flex: none; }
.sess-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sess-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sess-time.over { color: var(--bad); font-weight: 700; }
.sess-add { font-size: 11px; font-weight: 700; color: var(--primary); }

/* ------------------------------------------------------- udhaar / credit -- */
.credit-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 18px 10px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 600;
}
.credit-bar b { font-variant-numeric: tabular-nums; }
.cust-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 12px; margin-bottom: 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
}
.cust-row:hover { border-color: var(--primary); background: var(--panel-2); }
.cust-av {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 700;
}
.cust-main { flex: 1; min-width: 0; }
.cust-name { font-size: 13.5px; font-weight: 650; }
.cust-sub { font-size: 11.5px; color: var(--text-3); }

/* Everything above the totals shares one scroller, so the bill summary and the
   pay button stay pinned no matter how long the tray or the item list gets. */
.cart-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.cart-items { padding: 0 12px 6px; }

.ci {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center; gap: 2px 9px;
  padding: 9px 6px; border-bottom: 1px solid var(--line-soft);
}
.ci:last-child { border-bottom: 0; }
.ci-ic {
  grid-row: 1 / 3; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; color: #fff;
}
.ci-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.ci-x { color: var(--primary); font-weight: 700; white-space: nowrap; }
.ci-meta { font-size: 11px; color: var(--text-3); grid-column: 2; }
.ci-amt { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; grid-column: 3; }
.ci-ctl { display: flex; align-items: center; gap: 4px; grid-column: 3; justify-content: flex-end; }
.ci-ctl .btn-sm { padding: 4px 8px; min-height: 0; }
.qty-step { display: inline-flex; align-items: center; gap: 2px; background: var(--well); border-radius: var(--pill); padding: 2px; }
.qty-btn {
  width: 28px; height: 28px; border-radius: 50%; border: 0; background: transparent;
  cursor: pointer; font-size: 16px; line-height: 1; display: grid; place-items: center; color: var(--text-2);
}
.qty-btn:hover { background: var(--panel); }
.qty-btn.plus { background: var(--primary-grad); color: var(--on-primary); }
.qty-btn.plus:hover { background: var(--primary-hover); }
.qty-in { width: 42px; height: 28px; text-align: center; border: 0; background: transparent; font-variant-numeric: tabular-nums; font-weight: 600; }
.ci-del { margin-left: auto; color: var(--text-3); background: none; border: 0; cursor: pointer; padding: 5px 7px; border-radius: 50%; }
.ci-del:hover { color: var(--bad); background: var(--bad-soft); }

/* live machines badge next to the panel title */
.mach-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px; border-radius: var(--pill);
  border: 1px solid transparent; background: var(--ok-soft); color: var(--ok);
  font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mach-btn:hover { background: var(--ok); color: #fff; }
.mach-btn:hover .mach-pulse { background: #fff; }
.mach-btn:hover .mach-pulse::after { border-color: #fff; }
.mach-lbl { font-weight: 600; letter-spacing: .02em; }
.mach-pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.mach-pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--ok); animation: machPulse 1.8s ease-out infinite;
}
@keyframes machPulse {
  0%   { transform: scale(.6); opacity: .9; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .mach-pulse::after { animation: none; opacity: .35; } }

/* bill summary: every line stays on screen, zeros included */
.cart-sum { border-top: 1px solid var(--line); padding: 12px 18px 4px; display: flex; flex-direction: column; gap: 6px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-2); }
.sum-row b { color: var(--text); font-weight: 600; }
.sum-row.muted-row { color: var(--text-3); }
.sum-row.muted-row b { color: var(--text-3); font-weight: 500; }
.sum-row .pill { margin-left: 6px; }
.sum-row.total {
  font-size: 14px; font-weight: 700; color: var(--on-primary);
  padding: 14px 16px; margin-top: 4px; border-radius: var(--radius);
  background: var(--primary-grad); font-variant-numeric: tabular-nums;
  box-shadow: var(--glow);
}
.sum-row.total span:last-child { font-size: 21px; letter-spacing: -.02em; }
.idle-nudge {
  display: flex; align-items: center; gap: 10px; margin: 0 18px 8px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--bad-soft); color: var(--bad);
  font-size: 12.5px; font-weight: 650;
  animation: idleFlash 1.1s ease-in-out infinite alternate;
}
.idle-nudge span { flex: 1; }
@keyframes idleFlash { from { opacity: .72; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .idle-nudge { animation: none; } }

.sum-save { font-size: 11.5px; font-weight: 650; color: var(--ok); text-align: center; padding-top: 2px; }
.cart-actions { padding: 10px 18px 18px; display: grid; gap: 8px; grid-template-columns: repeat(3, 1fr); }
.cart-actions .pay { grid-column: 1 / -1; }

/* ------------------------------------------------------------- payment -- */
.pay-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pay-total { font-size: 34px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pay-items { font-size: 22px; font-weight: 650; }
.pay-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pay-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; background: var(--panel); }
.pay-card header { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.pay-card header h4 { font-size: 14px; font-weight: 650; }
.pay-card .pay-clear { margin-left: auto; padding: 4px 9px; font-size: 11.5px; }
.pay-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.pay-card.cash { border-color: color-mix(in srgb, var(--cash) 35%, var(--line)); }
.pay-card.cash .pay-ic { background: var(--cash-soft); color: var(--cash); }
.pay-card.cash h4 { color: var(--cash); }
.pay-card.upi { border-color: color-mix(in srgb, var(--upi) 30%, var(--line)); }
.pay-card.upi .pay-ic { background: var(--upi-soft); color: var(--upi); }
.pay-card.upi h4 { color: var(--upi); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  padding: 7px 12px; border-radius: var(--pill); border: 1px solid var(--line);
  background: var(--panel); font-size: 12.5px; font-weight: 650; cursor: pointer;
  font-variant-numeric: tabular-nums; color: var(--text-2);
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip-alt { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }

.upi-qr {
  margin-top: 14px; display: flex; gap: 14px; align-items: center;
  padding: 12px; border-radius: var(--radius); background: var(--well); border: 1px solid var(--line);
}
.upi-qr-img { width: 118px; height: 118px; flex: none; background: #fff; border-radius: 10px; padding: 6px; display: grid; place-items: center; }
.upi-qr-img img { width: 100%; height: 100%; display: block; }
.upi-qr-skel { width: 100%; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #eee, #f7f7f7, #eee); animation: shimmer 1.2s linear infinite; background-size: 200% 100%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.upi-qr-meta { min-width: 0; }
.upi-qr-amt { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }

/* the headline the cashier actually needs */
.pay-status {
  margin-top: 18px; padding: 18px 22px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--well); border: 2px solid var(--line);
}
.pay-status-lbl { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.pay-status-amt { font-size: 32px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.pay-status.change { background: var(--ok-soft); border-color: var(--ok); }
.pay-status.change .pay-status-lbl, .pay-status.change .pay-status-amt { color: var(--ok); }
.pay-status.short { background: var(--bad-soft); border-color: var(--bad); }
.pay-status.short .pay-status-lbl, .pay-status.short .pay-status-amt { color: var(--bad); }
.pay-status.exact { background: var(--primary-soft); border-color: var(--primary); }
.pay-status.exact .pay-status-lbl, .pay-status.exact .pay-status-amt { color: var(--on-primary-soft); }
.pay-status.credit { background: var(--warn-soft); border-color: var(--warn); }
.pay-status.credit .pay-status-lbl, .pay-status.credit .pay-status-amt { color: var(--warn); }

.change-hero {
  text-align: center; padding: 26px 20px; border-radius: var(--radius-lg);
  background: var(--ok-soft); border: 2px solid var(--ok);
}
.change-hero.exact { background: var(--primary-soft); border-color: var(--primary); }
.change-lbl { font-size: 13px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ok); }
.change-hero.exact .change-lbl { color: var(--on-primary-soft); }
.change-amt { font-size: 52px; font-weight: 800; letter-spacing: -.04em; line-height: 1.05; margin: 6px 0 4px; color: var(--ok); }
.change-hero.exact .change-amt { color: var(--on-primary-soft); }
.change-sub { font-size: 12.5px; color: var(--text-2); }

/* closing time notice --------------------------------------------------- */
.closing-hero { text-align: center; padding: 8px 4px 4px; }
.closing-clock { font-size: 46px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--warn); }
.closing-title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.closing-sub { font-size: 13.5px; color: var(--text-2); margin-top: 6px; }
.closing-strip {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--warn-soft); color: var(--warn); font-weight: 650; font-size: 13px;
  border-bottom: 1px solid var(--line);
}

/* stations -------------------------------------------------------------- */
.st-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); }
.st {
  border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--panel);
  padding: 16px; display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-1);
}
.st::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--text-3); }
.st.free::before { background: var(--ok); }
.st.busy::before { background: var(--warn); }
.st.maintenance::before, .st.offline::before { background: var(--bad); }
.st-name { font-weight: 700; font-size: 15.5px; }
.st-timer { font-family: var(--mono); font-size: 27px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.st-timer.over { color: var(--warn); }
.st-amt { font-size: 13px; color: var(--text-2); }

/* login ----------------------------------------------------------------- */
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, var(--primary-soft), transparent 60%),
    radial-gradient(700px 420px at 110% 110%, var(--primary-soft-2), transparent 62%),
    var(--bg);
}
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-xl); padding: 32px; box-shadow: var(--shadow-3); }

/* misc widgets ---------------------------------------------------------- */
.seg { display: inline-flex; background: var(--well); border: 1px solid var(--line); border-radius: var(--pill); padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 7px 15px; border-radius: var(--pill); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-1); }
.bar { height: 6px; border-radius: var(--pill); background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--pill); background: var(--primary-grad); }
.split-bar { display: flex; height: 10px; border-radius: var(--pill); overflow: hidden; background: var(--line); }
.split-bar i { display: block; height: 100%; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.spark i { flex: 1; background: var(--primary-grad); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .9; }
.spark i:hover { opacity: 1; }

.stat-line { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.stat-line:last-child { border-bottom: 0; }
.stat-line b { font-variant-numeric: tabular-nums; }

.due-line { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--well); border: 1px solid var(--line); font-size: 15px; font-weight: 700; }
.due-line.short { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.due-line.change { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }

/* camera scanner ------------------------------------------------------- */
.scanner-view { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 4/3; object-fit: cover; display: block; }
.scanbox { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; }
.scanbox-frame {
  position: absolute; left: 8%; right: 8%; top: 28%; height: 44%;
  border: 2px solid rgba(255,255,255,.85); border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.38);
  pointer-events: none;
}
.scanbox-line {
  position: absolute; left: 4px; right: 4px; height: 2px; top: 0;
  background: #ff4d5e; box-shadow: 0 0 10px 1px rgba(255,77,94,.9);
  animation: scanSweep 2s ease-in-out infinite;
}
@keyframes scanSweep { 0%,100% { top: 4px; } 50% { top: calc(100% - 6px); } }
@media (prefers-reduced-motion: reduce) { .scanbox-line { animation: none; top: 50%; } }
.scanbox-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: #fff; font-size: 12.5px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.9);
  padding: 0 12px; pointer-events: none;
}
.receipt-frame { background: #fff; color: #000; border-radius: 8px; padding: 14px; font-family: var(--mono); font-size: 12px; }

.qr-preview { background: #fff; padding: 10px; border-radius: var(--radius); display: inline-block; border: 1px solid var(--line); }

/* ============================================================== responsive */
@media (max-width: 1240px) {
  .topnav a span, .topnav button.navlink span { display: none; }
  .topnav a, .topnav button.navlink { padding: 10px 13px; }
  .pos { grid-template-columns: minmax(0,1fr) 350px; }
}

@media (max-width: 900px) {
  .app { padding: 0; }
  .shell { border-radius: 0; box-shadow: none; }
  .topnav { display: none; }
  .burger { display: inline-flex; }
  .brand-sub { display: none; }
  .content { padding: 14px 14px 88px; }
  .page-head { padding: 14px 14px 0; }
  .g4, .g5, .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-half, .g-main, .g-side { grid-template-columns: 1fr; }

  .tabbar {
    display: grid; grid-auto-flow: column; position: fixed; z-index: 45;
    left: 0; right: 0; bottom: 0; background: var(--panel);
    border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 4px; font-size: 10.5px; color: var(--text-3); font-weight: 600;
  }
  .tabbar a .tab-ic { padding: 5px 16px; border-radius: var(--pill); display: grid; place-items: center; }
  .tabbar a.on { color: var(--primary); }
  .tabbar a.on .tab-ic { background: var(--primary-soft); }

  .pos { grid-template-columns: 1fr; height: auto; padding: 12px; gap: 12px; }
  .pos-left { height: calc(100dvh - var(--topbar) - 150px); }
  /* Stack the toolbar so nothing pushes the panel wider than the screen. */
  .pos-bar { padding: 12px 12px 8px; }
  .pos-bar h3 { flex: 1 0 100%; margin-right: 0; }
  .scan-box { flex: 1 1 100%; min-width: 0; }
  .pos-search { flex: 1 1 auto; max-width: none; }
  .closing-strip { flex-wrap: wrap; padding: 9px 12px; }
  .cats { padding-left: 12px; padding-right: 12px; }
  .cart {
    position: fixed; z-index: 60; inset: auto 0 0 0; height: 88dvh;
    border-radius: 24px 24px 0 0; border-bottom: 0;
    box-shadow: var(--shadow-4);
    transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.9,.3,1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .cart.open { transform: none; }
  .cart-handle { display: block; width: 44px; height: 4px; border-radius: var(--pill); background: var(--line); margin: 10px auto 2px; }
  .cart-fab {
    display: flex !important; position: fixed; z-index: 46; left: 12px; right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom)); align-items: center; gap: 10px;
    padding: 15px 18px; border-radius: var(--radius); background: var(--primary-grad); color: var(--on-primary);
    font-weight: 700; box-shadow: var(--shadow-4); border: 0; cursor: pointer; font-size: 14.5px;
  }
  .pay-split { grid-template-columns: 1fr; }
  .pay-total { font-size: 28px; }
  .modal { width: 100%; border-radius: 24px 24px 0 0; align-self: end; max-height: 94dvh; }
  .modal-back { padding: 0; align-items: end; }
  table.tbl th, table.tbl td { padding: 10px 11px; }
  .upi-qr-img { width: 100px; height: 100px; }
}
.cart-fab { display: none; }
.cart-handle { display: none; }

@media (max-width: 480px) {
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; padding: 4px 12px 14px; }
  .tile-art { height: 66px; }
  .kpi .k-val { font-size: 22px; }
  .change-amt { font-size: 42px; }
  .pay-status-amt { font-size: 26px; }
}

/* ============================================== touch, tablet and phone == */

/* Momentum scrolling and contained overscroll everywhere it matters. */
.tiles, .cart-items, .tbl-wrap, .cats, .menu, .modal, .content, .icon-grid {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.cats { scroll-snap-type: x proximity; }
.cat { scroll-snap-align: start; }

@media (hover: none) {
  /* No hover on touch, so give press feedback instead. */
  .tile:hover { border-color: var(--line); box-shadow: none; }
  .tile:active { border-color: var(--primary); transform: scale(.97); }
  .btn:active { transform: scale(.97); }
  .cat:active { background: var(--primary-soft); }
  .sess:active { border-color: var(--primary); }
  /* Comfortable minimum target size. */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .qty-btn { width: 34px; height: 34px; }
  .qty-in { height: 34px; width: 46px; }
  .ci-del { padding: 9px 11px; }
  .inp, select.inp { min-height: 46px; }
  .chip { padding: 10px 14px; }
  .cat { padding: 10px 16px; }
  table.tbl td, table.tbl th { padding: 13px 14px; }
}

/* ------- tablet: keep both panels, tighten the spacing ------------------ */
@media (min-width: 901px) and (max-width: 1240px) {
  :root { --topbar: 62px; }
  .app { padding: 10px; }
  .pos { grid-template-columns: minmax(0,1fr) 340px; gap: 12px; padding: 12px 14px 14px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  /* Heading on its own line so the scan and search boxes never get clipped. */
  .pos-bar { padding: 14px 16px 10px; }
  .pos-bar h3 { flex: 1 0 100%; margin-right: 0; }
  .scan-box { flex: 2 1 200px; }
  .pos-search { flex: 1 1 150px; max-width: none; }
  .content { padding: 14px 16px 20px; }
  .page-head { padding: 14px 16px 0; }
  .kpi { padding: 14px 15px; }
  .kpi .k-val { font-size: 23px; }
}

/* ------- tablet portrait: cart becomes the sheet, tiles get roomier ----- */
@media (min-width: 601px) and (max-width: 900px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); }
  .pos-left { height: calc(100dvh - var(--topbar) - 160px); }
  .cart { height: 82dvh; }
  .g4, .g5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .modal { width: min(620px, 100%); border-radius: var(--radius-xl); align-self: center; margin: 0 auto; }
  .modal-back { padding: 20px; align-items: center; }
  .tabbar a { font-size: 11.5px; }
}

/* ------- phone ---------------------------------------------------------- */
@media (max-width: 600px) {
  .pay-total { font-size: 26px; }
  .modal-b { padding: 16px; }
  .modal-h { padding: 15px 16px; }
  .modal-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; }
  .card-h { padding: 13px 14px; }
  .card-b { padding: 14px; }
  .kpi { padding: 13px 14px; }
}

/* Respect a reduced motion preference. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------ print */
@media print {
  .topbar, .tabbar, .no-print, #toasts, .cart-fab, .page-head { display: none !important; }
  body { background: #fff; color: #000; }
  .app { padding: 0; display: block; }
  .shell { box-shadow: none; border-radius: 0; background: #fff; }
  .content { padding: 0; }
  .card { border: 0; box-shadow: none; }
}

/* --- sale celebration ------------------------------------------------------
   The canvas sits above the modal so the confetti falls in front of the change
   amount, but pointer-events:none means it can never eat a click on the
   Print receipt button underneath it. */
.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

/* Congratulations header inside the sale-complete dialog. */
.congrats {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 14px;
}
.congrats-tick {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--ok);
  animation: tick-pop .45s cubic-bezier(.2, 1.5, .4, 1) both;
}
.congrats-tick svg { width: 22px; height: 22px; }
.congrats-txt {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .2px;
  animation: congrats-rise .45s .1s ease both;
}
@keyframes tick-pop {
  from { transform: scale(.2); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}
@keyframes congrats-rise {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: none;            opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .congrats-tick, .congrats-txt { animation: none; }
}