/* ============================================================================
   Fifty Bucks POS — app stylesheet
   Layout scales: phone (<820px, bottom tab bar) · tablet (<1180px, icon rail)
   · desktop (full sidebar). Light + dark, both deliberately stepped.
   ========================================================================== */

/* ------------------------------------------------------------- tokens ----
   Palette sampled straight from the 50 Bucks Café logo:
     orange #FA8107 · green #5CC531 · plate #090909
   The pure logo hues stay for artwork, gradients and dark-mode fills. Solid
   controls that carry text use a deeper step of the same hue so white (light)
   or near-black (dark) label text clears WCAG AA.                            */
:root {
  color-scheme: light;

  --page:        #f2f1ed;
  --surface:     #fcfcfb;
  --surface-2:   #f7f5f1;
  --surface-3:   #edeae3;
  --line:        #e3e0d8;
  --line-strong: #cbc8be;

  --ink:         #14130f;
  --ink-2:       #53514b;
  --ink-3:       #8a877f;

  --logo-orange: #FA8107;   /* the logo's own orange — artwork & gradients   */
  --logo-green:  #5CC531;   /* the logo's own green                          */

  --brand:       #AF5A05;   /* solid fills · white text = 4.90:1             */
  --brand-hi:    #914B04;
  --brand-soft:  #FFF2E6;
  --brand-line:  #F0C9A0;
  --brand-ink:   #ffffff;

  --accent:      #3B7E1F;   /* logo green, stepped for text · 4.88:1         */
  --accent-soft: #EFF9EA;

  --good:        #0ca30c;
  --warn:        #fab219;
  --serious:     #ec835a;
  --crit:        #d03b3b;
  --good-text:   #006300;

  /* categorical slots — brand-led, CVD-validated in both modes */
  --s1: #C96706;
  --s2: #2a78d6;
  --s3: #3B7E1F;
  --s4: #e87ba4;

  --rail:        #141312;
  --rail-2:      #232120;
  --rail-ink:    #f4f1ea;
  --rail-ink-2:  #a9a59b;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --shadow-1: 0 1px 2px rgba(11,11,11,.06), 0 1px 3px rgba(11,11,11,.05);
  --shadow-2: 0 4px 12px rgba(11,11,11,.08), 0 2px 4px rgba(11,11,11,.04);
  --shadow-3: 0 18px 48px rgba(11,11,11,.18);
  --ring: 0 0 0 3px rgba(250,129,7,.32);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --side-w: 232px;
  --top-h: 60px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page:        #0b0b0a;
  --surface:     #1a1a19;
  --surface-2:   #212120;
  --surface-3:   #2c2c2a;
  --line:        #2c2c2a;
  --line-strong: #3d3d3a;

  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-3:       #8a877f;

  --logo-orange: #FA8107;
  --logo-green:  #5CC531;

  /* on the dark plate the logo orange itself is the fill — it carries
     near-black label text at 7.26:1, so the brand reads at full strength */
  --brand:       #FA8107;
  --brand-hi:    #FF9128;
  --brand-soft:  #2c1c0a;
  --brand-line:  #6b3d0d;
  --brand-ink:   #141310;

  --accent:      #5CC531;
  --accent-soft: #16250e;

  --good-text:   #0ca30c;

  --s1: #D26C06;
  --s2: #3987e5;
  --s3: #4A9E27;
  --s4: #d55181;

  --rail:        #0c0c0b;
  --rail-2:      #1a1a18;
  --rail-ink:    #f4f1ea;
  --rail-ink-2:  #908d85;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 14px rgba(0,0,0,.45);
  --shadow-3: 0 18px 48px rgba(0,0,0,.6);
  --ring: 0 0 0 3px rgba(250,129,7,.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1,h2,h3,h4,p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.dim { color: var(--ink-2); }

/* ============================================================== shell ==== */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100dvh; }

.side {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
}
/* the emblem always sits on its own dark plate, the way the logo is drawn */
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--rail-2);
  display: grid; place-items: center; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
}
.brand-mark img { width: 90%; height: 90%; object-fit: contain; display: block; }
.topbar .brand-mark { display: none; background: var(--rail); }
.login-lockup { display: block; width: min(260px, 68%); height: auto; }
.brand-txt { min-width: 0; }
.brand-txt b { display: block; font-size: 14px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-txt span { display: block; font-size: 11px; color: var(--rail-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 10px; }
.nav-group { margin-top: 14px; }
.nav-group > h4 {
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--rail-ink-2); padding: 0 8px 6px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--rail-ink-2); text-decoration: none;
  font-weight: 500; position: relative;
}
.nav a:hover { background: var(--rail-2); color: var(--rail-ink); }
.nav a.on { background: var(--rail-2); color: #fff; }
.nav a.on::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav a .pill {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 99px; background: var(--brand); color: var(--brand-ink); min-width: 20px; text-align: center;
}
.nav a .pill.q { background: var(--s1); }

.side-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.server-chip {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px;
  background: var(--rail-2); border-radius: var(--r-sm); font-size: 11.5px; color: var(--rail-ink-2);
}
.server-chip b { color: var(--rail-ink); font-weight: 600; display: block; font-size: 12px; }
.dotlive { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; box-shadow: 0 0 0 3px rgba(12,163,12,.2); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.topbar .sub { font-size: 12px; color: var(--ink-3); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.iconbtn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; position: relative;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn .badge-dot {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--crit); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}

.userchip {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  border: 1px solid var(--line); border-radius: 99px; background: var(--surface); cursor: pointer;
}
.userchip:hover { background: var(--surface-2); }
.avatar {
  width: 27px; height: 27px; border-radius: 50%; flex: none;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.userchip .who { text-align: left; line-height: 1.15; }
.userchip .who b { font-size: 12.5px; font-weight: 600; display: block; }
.userchip .who span { font-size: 10.5px; color: var(--ink-3); text-transform: capitalize; }

.view { flex: 1; padding: 18px; min-width: 0; }
.view.flush { padding: 0; }

.tabbar { display: none; }

/* ============================================================ primitives = */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 550; cursor: pointer; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--page); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer;
  padding: 6px 12px; border-radius: 7px; font-weight: 550; font-size: 13px; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.input, .select, textarea.input {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink);
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 66px; }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.input::placeholder { color: var(--ink-3); }
.select { appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.search {
  position: relative; flex: 1; min-width: 0; max-width: 420px;
}
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--surface); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i {
  width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong);
  position: relative; transition: background .15s; flex: none;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + i { background: var(--good); }
.switch input:checked + i::after { transform: translateX(16px); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14px; font-weight: 650; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 15px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.badge .bdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: rgba(12,163,12,.13); color: var(--good-text); }
.badge.warn { background: rgba(250,178,25,.18); color: #8a5a00; }
.badge.info { background: rgba(42,120,214,.13); color: #1c5cab; }
.badge.crit { background: rgba(208,59,59,.13); color: #a52a2a; }
.badge.brand { background: var(--brand-soft); color: var(--brand-hi); }
:root[data-theme="dark"] .badge.warn { color: #fab219; }
:root[data-theme="dark"] .badge.info { color: #6da7ec; }
:root[data-theme="dark"] .badge.crit { color: #e66767; }
:root[data-theme="dark"] .badge.brand { color: #e1743d; }

.veg-dot, .nonveg-dot {
  width: 13px; height: 13px; border: 1.5px solid var(--good); border-radius: 3px;
  display: inline-grid; place-items: center; flex: none;
}
.veg-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.nonveg-dot { border-color: var(--crit); }
.nonveg-dot::after { content: ""; width: 0; height: 0; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-bottom: 6px solid var(--crit); }

.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 8px; }
.empty h3 { font-size: 15px; color: var(--ink-2); margin-bottom: 4px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 650; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }

/* ============================================================== charts === */
.chart { background: var(--surface); }
.chart-head { display: flex; align-items: flex-start; gap: 12px; padding: 0 0 10px; flex-wrap: wrap; }
.chart-titles h3 { font-size: 14px; font-weight: 650; }
.chart-titles p { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-2); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.chart-tbl-btn {
  margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 7px; cursor: pointer;
}
.chart-tbl-btn:hover, .chart-tbl-btn.on { color: var(--ink); background: var(--surface-2); }
.chart-plot { position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax-base { stroke: var(--line-strong); stroke-width: 1; }
.chart .ax-lab { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .val-lab { font-size: 11.5px; fill: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hit { cursor: crosshair; }
.chart .hit.on { fill: var(--ink); fill-opacity: .045; }
.chart-tip {
  position: absolute; width: 150px; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
  box-shadow: var(--shadow-2); padding: 8px 10px; font-size: 12px;
}
.chart-tip b { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 4px; font-weight: 600; }
.chart-tip .tr { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.chart-tip .tr em { margin-left: auto; font-style: normal; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 12px; max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.chart-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 7px 10px; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.chart-table td { padding: 7px 10px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.chart-table td:not(:first-child) { text-align: right; }
.chart-note { font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }
.spark { display: block; }

/* ============================================================= stat tiles = */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 15px; box-shadow: var(--shadow-1); }
.kpi .lbl { font-size: 12px; color: var(--ink-3); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 6px; min-height: 28px; }
.kpi .delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.kpi .delta.up { color: var(--good-text); }
.kpi .delta.down { color: var(--crit); }
.kpi .delta span { color: var(--ink-3); font-weight: 500; }
.hero { font-size: 48px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }

.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.grid-2-1 { display: grid; gap: 14px; grid-template-columns: 2fr 1fr; }
.stack { display: grid; gap: 14px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* =============================================================== tables === */
.floor { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.tablecard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px; cursor: pointer; position: relative; text-align: left;
  box-shadow: var(--shadow-1); transition: transform .1s, box-shadow .1s;
}
.tablecard:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tablecard::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; border-radius: var(--r) 0 0 var(--r); background: var(--good); }
.tablecard.occupied::before { background: var(--warn); }
.tablecard.billing::before { background: var(--s1); }
.tablecard .tt { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tablecard .tname { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.tablecard .seats { font-size: 11.5px; color: var(--ink-3); }
.tablecard .tmeta { margin-top: 10px; display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.tablecard .amt { font-weight: 700; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.area-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 4px 0 10px; }

/* ================================================================== POS === */
/* The single grid row is explicitly 1fr so each column scrolls inside itself
   rather than stretching the page. min-height:0 lets the flex children shrink. */
.pos {
  display: grid; grid-template-columns: 104px 1fr 372px; grid-template-rows: minmax(0, 1fr);
  height: calc(100dvh - var(--top-h)); overflow: hidden;
}
.pos > * { min-height: 0; }
.pos-cats { border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 10px 8px; }
.pos-cats button {
  width: 100%; border: 1px solid transparent; background: transparent; cursor: pointer;
  border-radius: 10px; padding: 10px 4px; display: grid; gap: 4px; justify-items: center;
  color: var(--ink-2); font-size: 11px; font-weight: 600; line-height: 1.2; text-align: center;
}
.pos-cats button em { font-size: 21px; font-style: normal; }
.pos-cats button:hover { background: var(--surface-2); }
.pos-cats button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-hi); }

.pos-mid { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--page); }
.pos-tools { display: flex; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); align-items: center; flex-wrap: wrap; }
.pos-grid {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px;
  display: grid; gap: 11px; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  /* max-content rows: the cards clip their own overflow, which would otherwise
     let the tracks collapse instead of letting the grid scroll */
  grid-auto-rows: max-content; align-content: start;
}
.pcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; overflow: hidden; text-align: left; display: flex; flex-direction: column;
  box-shadow: var(--shadow-1); transition: transform .08s, box-shadow .1s; position: relative;
}
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.pcard:active { transform: translateY(0); }
.pcard .thumb {
  height: 74px; flex: none; display: grid; place-items: center; font-size: 32px;
  background: linear-gradient(150deg, var(--surface-3), var(--surface-2));
}
.pcard .pinfo { padding: 9px 10px 10px; flex: none; display: grid; gap: 3px; }
.pcard .pname { font-size: 13px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .prow { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.pcard .price { font-weight: 700; font-variant-numeric: tabular-nums; }
.pcard .vtag { font-size: 10px; color: var(--ink-3); }
.pcard.out { opacity: .5; }
.pcard .oos { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .05em; }

.pos-cart { border-left: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.cart-top { padding: 11px 13px; border-bottom: 1px solid var(--line); display: grid; gap: 9px; }
.cart-type { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.cart-type button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px; padding: 7px 4px;
  font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: grid; gap: 3px; justify-items: center;
}
.cart-type button.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.cart-meta { display: flex; gap: 7px; align-items: center; font-size: 12px; }
.cart-cust {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px;
  background: var(--surface-2); border: 1px dashed var(--line-strong); cursor: pointer; width: 100%; text-align: left;
}
.cart-cust.has { border-style: solid; background: var(--brand-soft); border-color: var(--brand); }
.cart-cust > span { min-width: 0; }
.cart-cust .cname { font-weight: 620; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-cust .cpts { font-size: 11.5px; color: var(--ink-3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-cust .right { margin-left: auto; text-align: right; flex: none; }
.cart-cust .right b { display: block; font-size: 15px; line-height: 1.1; }

.cart-lines { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 0; }
.cline { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.cline:last-child { border-bottom: 0; }
.cline .cl-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cline .cl-sub { font-size: 11.5px; color: var(--ink-3); }
.cline .cl-amt { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.cline .cl-ctl { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty button { width: 28px; height: 28px; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.qty button:hover { background: var(--surface-3); color: var(--ink); }
.qty b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
.cline .sent { font-size: 10.5px; color: var(--s1); font-weight: 650; }
.cline.locked { background: var(--surface-2); }

.cart-foot { border-top: 1px solid var(--line); padding: 11px 13px 13px; background: var(--surface); }
.totals { display: grid; gap: 5px; font-size: 13px; margin-bottom: 10px; }
.totals .t { display: flex; justify-content: space-between; color: var(--ink-2); }
.totals .t b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.totals .t.discount b, .totals .t.discount { color: var(--good-text); }
.totals .grand { display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px dashed var(--line-strong); margin-top: 5px; padding-top: 8px; font-size: 15px; font-weight: 650; }
.totals .grand b { font-size: 22px; letter-spacing: -.02em; }
.cart-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 8px; }
.cart-pay { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.cartbar { display: none; }

/* ================================================================= KDS ==== */
.kds { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); align-items: start; }
.kds-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); min-height: 140px; }
.kds-col > header {
  display: flex; align-items: center; gap: 8px; padding: 11px 13px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2);
}
.kds-col > header .n { margin-left: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; font-size: 12px; }
.kds-col .body { padding: 10px; display: grid; gap: 10px; }
.kot {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ink-3);
  border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-1);
}
.kot.pending { border-left-color: var(--warn); }
.kot.preparing { border-left-color: var(--s1); }
.kot.ready { border-left-color: var(--good); }
.kot.served { border-left-color: var(--ink-3); opacity: .65; }
.kot.late { animation: pulseLate 1.6s ease-in-out infinite; }
@keyframes pulseLate { 0%,100% { box-shadow: var(--shadow-1); } 50% { box-shadow: 0 0 0 3px rgba(208,59,59,.22); } }
.kot .kh { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kot .kno { font-weight: 700; font-size: 15px; }
.kot .kwhere { font-size: 12px; color: var(--ink-3); }
.kot .ktime { margin-left: auto; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kot .ktime.over { color: var(--crit); }
.kot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kot li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.kot li .kq { font-weight: 700; min-width: 24px; }
.kot li .kv { font-size: 11.5px; color: var(--ink-3); display: block; }
.kot .kacts { display: flex; gap: 7px; margin-top: 10px; }

/* ============================================================== QR page === */
.qr-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.qr-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: center; box-shadow: var(--shadow-1); }
.qr-card .qbox { background: #fff; border-radius: 10px; padding: 8px; border: 1px solid var(--line); }
.qr-card h4 { font-size: 16px; margin-top: 10px; font-weight: 700; }
.qr-card p { font-size: 11px; color: var(--ink-3); word-break: break-all; margin-top: 3px; }

/* ============================================================== modals === */
.scrim {
  position: fixed; inset: 0; background: rgba(11,11,11,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 18px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  width: 100%; max-width: 460px; max-height: calc(100dvh - 36px); display: flex; flex-direction: column;
  border: 1px solid var(--line); animation: pop .16s ease-out;
}
.modal.wide { max-width: 720px; }
.modal.xwide { max-width: 940px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.modal > header { display: flex; align-items: center; gap: 10px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.modal > header h3 { font-size: 16px; font-weight: 650; }
.modal > header .x { margin-left: auto; }
.modal > .mbody { padding: 17px; overflow-y: auto; }
.modal > footer { display: flex; gap: 9px; padding: 13px 17px; border-top: 1px solid var(--line); }
.modal > footer .grow { flex: 1; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); }
body.modal-open .toasts { bottom: auto; top: 18px; }
.toast {
  background: var(--ink); color: var(--page); padding: 11px 14px; border-radius: 11px;
  box-shadow: var(--shadow-3); font-size: 13.5px; display: flex; align-items: center; gap: 9px;
  animation: slideUp .18s ease-out;
}
.toast.good { background: #0d7a3a; color: #fff; }
.toast.bad { background: var(--crit); color: #fff; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }

/* ============================================================== login ==== */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 600px at 12% -10%, rgba(184,80,31,.16), transparent 60%), var(--page); }
.login {
  width: 100%; max-width: 940px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-3); overflow: hidden;
  display: grid; grid-template-columns: 1fr 1fr;
}
.login-side { background: var(--rail); color: var(--rail-ink); padding: 34px; display: flex; flex-direction: column; gap: 18px; }
.login-side .lgo { display: flex; align-items: center; gap: 11px; }
.login-side h2 { font-size: 25px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.login-side p { color: var(--rail-ink-2); font-size: 13.5px; }
.login-side ul { list-style: none; padding: 0; margin: auto 0 0; display: grid; gap: 9px; }
.login-side li { display: flex; gap: 9px; align-items: center; font-size: 13px; color: var(--rail-ink-2); }
.login-side li .ic { color: var(--brand); }
.login-main { padding: 30px; display: flex; flex-direction: column; }
.role-list { display: grid; gap: 8px; margin: 14px 0 16px; }
.role {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; width: 100%;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left;
}
.role:hover { background: var(--surface-2); }
.role.on { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--ring); }
.role > span { min-width: 0; }
.role .rn { display: block; font-weight: 620; font-size: 13.5px; }
.role .rr { display: block; font-size: 11.5px; color: var(--ink-3); }
.role .pinhint { margin-left: auto; flex: none; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pinpad button { height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); font-size: 17px; font-weight: 600; cursor: pointer; }
.pinpad button:hover { background: var(--surface-3); }
.pindots { display: flex; gap: 9px; justify-content: center; margin: 12px 0 14px; }
.pindots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line-strong); }
.pindots i.on { background: var(--brand); }

/* ============================================================= printing == */
.print-only { display: none; }
@media print {
  body * { visibility: hidden !important; }
  #print-area, #print-area * { visibility: visible !important; }
  #print-area { display: block !important; position: absolute; inset: 0; width: 76mm; margin: 0; padding: 0; }
  @page { size: 80mm auto; margin: 3mm; }
}
#print-area { display: none; font-family: "SF Mono", Menlo, Consolas, monospace; color: #000; background: #fff; font-size: 11px; line-height: 1.35; }
#print-area .pc { text-align: center; }
#print-area .pb { font-weight: 700; }
#print-area hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; }
#print-area table { width: 100%; border-collapse: collapse; }
#print-area td { padding: 1px 0; vertical-align: top; }
#print-area .r { text-align: right; }
#print-area .big { font-size: 15px; font-weight: 700; }
#print-area .xl { font-size: 19px; font-weight: 800; }

.receipt-preview {
  background: #fff; color: #000; font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.4; width: 300px; margin: 0 auto; padding: 14px;
  border-radius: 6px; box-shadow: var(--shadow-2);
}
.receipt-preview hr { border: 0; border-top: 1px dashed #999; margin: 6px 0; }
.receipt-preview table { width: 100%; border-collapse: collapse; }
.receipt-preview .r { text-align: right; }
.receipt-preview .pc { text-align: center; }
.receipt-preview .pb { font-weight: 700; }
.receipt-preview .xl { font-size: 19px; font-weight: 800; }

/* ========================================================== responsive === */
@media (max-width: 1320px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .pos { grid-template-columns: 96px 1fr 340px; }
}

@media (max-width: 1180px) {           /* ---------------- tablet: icon rail */
  :root { --side-w: 74px; }
  .brand { justify-content: center; padding: 14px 8px; }
  .brand-txt { display: none; }
  .nav a { justify-content: center; padding: 11px 8px; }
  .nav a span.lbl { display: none; }
  .nav a .pill { position: absolute; top: 4px; right: 6px; margin: 0; font-size: 10px; padding: 0 5px; }
  .nav-group > h4 { display: none; }
  .nav-group { margin-top: 8px; border-top: 1px solid rgba(255,255,255,.07); padding-top: 8px; }
  .server-chip { justify-content: center; }
  .server-chip .stxt { display: none; }
  .grid-2, .grid-2-1, .grid-3 { grid-template-columns: 1fr; }
  .kds { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {           /* ------------- cart becomes a panel */
  .pos { grid-template-columns: 92px 1fr; }
  .pos-cart {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 92vw); z-index: 60;
    box-shadow: var(--shadow-3); transform: translateX(101%); transition: transform .22s ease;
  }
  .pos-cart.open { transform: none; }
  .cartbar {
    display: flex; align-items: center; gap: 12px; position: sticky; bottom: 0; z-index: 20;
    padding: 10px 14px; background: var(--brand); color: var(--brand-ink); cursor: pointer; border: 0; width: 100%;
    font-weight: 650; font-size: 15px;
  }
  .cartbar .cb-n { background: rgba(255,255,255,.22); border-radius: 99px; padding: 1px 9px; font-size: 13px; }
  .cartbar .cb-amt { margin-left: auto; font-variant-numeric: tabular-nums; }
}

@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .login { grid-template-columns: 1fr; max-width: 460px; }
  .login-side { display: none; }
}

@media (max-width: 820px) {            /* ------------------ phone: tab bar  */
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .view { padding: 14px 12px 78px; }
  .pos { height: calc(100dvh - var(--top-h) - 58px); grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .pos-tools { padding: 10px 12px; gap: 8px; }
  .pos-tools .search { flex: 1 1 100%; max-width: none; order: -1; }
  .pos-tools > .muted { display: none; }
  .pos-cats {
    border-right: 0; border-bottom: 1px solid var(--line);
    display: flex; gap: 7px; overflow-x: auto; overflow-y: hidden; padding: 9px 12px; scrollbar-width: none;
  }
  .pos-cats::-webkit-scrollbar { display: none; }
  .pos-cats button { width: auto; flex: none; flex-direction: row; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; }
  .pos-cats button em { font-size: 15px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 9px; padding: 11px; }
  .pcard .thumb { height: 58px; font-size: 26px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 14px rgba(11,11,11,.06);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 9px;
    color: var(--ink-3); text-decoration: none; font-size: 10.5px; font-weight: 600; position: relative;
  }
  .tabbar a.on { color: var(--brand); background: var(--brand-soft); }
  .tabbar a .pill {
    position: absolute; top: 1px; right: 14px; background: var(--crit); color: #fff;
    font-size: 9.5px; font-weight: 700; border-radius: 99px; padding: 0 4px; min-width: 15px; text-align: center;
  }
  .kds { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .topbar .sub { display: none; }
  .topbar .brand-mark { display: grid; width: 32px; height: 32px; border-radius: 9px; }
  .userchip .who { display: none; }
  .userchip { padding: 4px; }
  .floor { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .cart-actions { grid-template-columns: repeat(3, 1fr); }
  .modal { max-width: 100%; }
  .page-head h2 { font-size: 17px; }
  .qr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi { padding: 11px 12px; }
  .kpi .val { font-size: 21px; }
  .hero { font-size: 38px; }
  .scrim { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .seg button { padding: 6px 9px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
