/* Tablet POS styling — touch-first, dark, high-contrast. */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #334155;
  --line: #475569;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-press: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[x-cloak] { display: none !important; }

.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.card {
  background: var(--panel); border-radius: 18px; padding: 1.6rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.45); width: min(420px, 100%);
}
.brand { text-align: center; font-size: 1.4rem; font-weight: 700; margin-bottom: .25rem; }
.subtitle { text-align: center; color: var(--muted); margin-bottom: 1.2rem; }

/* PIN pad */
.pin-display {
  height: 56px; border-radius: 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 1rem; border: 1px solid var(--line);
}
.pin-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--line); }
.pin-dot.filled { background: var(--primary); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  font-size: 1.6rem; font-weight: 600; padding: 1.1rem 0; border: none;
  border-radius: 14px; background: var(--panel-2); color: var(--text);
  cursor: pointer; transition: transform .05s, background .1s;
}
.key:active { transform: scale(.96); background: var(--primary-press); }
.key.wide { grid-column: span 1; }
.key.action { background: #422; color: #fca5a5; }
.key.enter { background: var(--primary); }

.msg { min-height: 1.4rem; text-align: center; margin-top: .9rem; font-weight: 600; }
.msg.error { color: var(--danger); }

/* Home / clock screen */
.home { width: min(560px, 100%); }
.row { display: flex; gap: 12px; }
.btn {
  flex: 1; font-size: 1.1rem; font-weight: 600; padding: 1.1rem; border: none;
  border-radius: 14px; cursor: pointer; color: #fff; background: var(--primary);
}
.btn:active { transform: scale(.98); }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: var(--panel-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.status-pill {
  display: inline-block; padding: .35rem .8rem; border-radius: 999px;
  font-weight: 600; font-size: .85rem;
}
.status-pill.in { background: rgba(34,197,94,.18); color: #4ade80; }
.status-pill.out { background: rgba(148,163,184,.18); color: var(--muted); }

.stack > * + * { margin-top: 1rem; }
.muted { color: var(--muted); }
h2 { margin: .2rem 0 .6rem; }
.small { font-size: .82rem; }

/* ---- Floor view ---- */
.floor-view { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.floor-bar {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.floor-bar .who { margin-left: auto; color: var(--muted); font-weight: 600; }
.sections { display: flex; gap: .4rem; flex-wrap: wrap; }
.seg {
  padding: .5rem .9rem; border: none; border-radius: 9px; background: var(--panel-2);
  color: var(--text); font-weight: 600; cursor: pointer;
}
.seg.active { background: var(--primary); color: #fff; }

.canvas-wrap { flex: 1; overflow: auto; padding: 1rem; }
.canvas {
  position: relative; width: 1000px; height: 700px; margin: 0 auto;
  background:
    linear-gradient(#1e293b 1px, transparent 1px) 0 0 / 100% 40px,
    linear-gradient(90deg, #1e293b 1px, transparent 1px) 0 0 / 40px 100%,
    #131c2e;
  border-radius: 14px; border: 1px solid var(--line);
}
.table {
  position: absolute; border: 2px solid; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; gap: 2px; padding: 0; background: var(--panel-2);
}
.table.rect { border-radius: 12px; }
.table.round { border-radius: 50%; }
.table .tseats { font-size: .72rem; font-weight: 600; opacity: .85; }
.table .torder { font-size: .72rem; background: rgba(0,0,0,.35); padding: 0 .35rem; border-radius: 6px; }
.table:active { filter: brightness(1.15); }
/* status colors */
.st-available { background: #14532d; border-color: #22c55e; }
.st-occupied  { background: #1e3a8a; border-color: #3b82f6; }
.st-dirty     { background: #78350f; border-color: #f59e0b; }
.st-reserved  { background: #4c1d95; border-color: #a78bfa; }
.canvas .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

/* ---- Table action sheet ---- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 60; }
.sheet { background: var(--panel); border-radius: 16px; padding: 1.4rem; width: min(420px, 92vw); }
.sheet h2 { margin: 0 0 .3rem; }
.status-pill.sp-available { background: rgba(34,197,94,.2); color: #4ade80; }
.status-pill.sp-occupied  { background: rgba(59,130,246,.2); color: #93c5fd; }
.status-pill.sp-dirty     { background: rgba(245,158,11,.2); color: #fbbf24; }
.status-pill.sp-reserved  { background: rgba(167,139,250,.2); color: #c4b5fd; }
.status-pill.sp-open      { background: rgba(59,130,246,.2); color: #93c5fd; }
.status-pill.sp-sent      { background: rgba(34,197,94,.2); color: #4ade80; }

/* ---- Order screen ---- */
.order-view { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.order-bar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.order-title { display: flex; align-items: center; gap: .6rem; font-size: 1.1rem; }
.order-bar .guests { margin-left: auto; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.step { width: 34px; height: 34px; border: none; border-radius: 8px; background: var(--panel-2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.step:active { background: var(--primary); }

.order-body { flex: 1; display: flex; min-height: 0; }
.menu-pane { flex: 1.5; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); }
.cat-tabs { display: flex; gap: .4rem; padding: .7rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.item-grid { flex: 1; overflow: auto; padding: .7rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; align-content: start; }
.menu-item { display: flex; flex-direction: column; gap: .35rem; padding: 1rem .8rem; border: none; border-radius: 12px; background: var(--panel); color: var(--text); cursor: pointer; text-align: left; min-height: 78px; justify-content: space-between; }
.menu-item:active { background: var(--panel-2); }
.mi-name { font-weight: 600; line-height: 1.2; }
.mi-price { color: var(--muted); font-weight: 600; }

.order-pane { flex: 1; max-width: 420px; display: flex; flex-direction: column; min-width: 320px; }
.seat-row { display: flex; align-items: center; gap: .4rem; padding: .7rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.chip { padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--text); cursor: pointer; font-weight: 600; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.small { padding: .3rem .6rem; font-size: .85rem; }

.lines { flex: 1; overflow: auto; padding: .5rem .6rem; }
.seat-group { margin-bottom: .8rem; }
.seat-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .3rem .2rem; }
.line { background: var(--panel); border-radius: 10px; padding: .55rem .7rem; margin-bottom: .4rem; cursor: pointer; border-left: 3px solid var(--line); }
.line:active { background: var(--panel-2); }
.line.ls-sent { border-left-color: var(--ok); }
.line.ls-held { border-left-color: var(--warn); }
.line.ls-new { border-left-color: var(--primary); }
.line.ls-void { opacity: .5; text-decoration: line-through; border-left-color: var(--danger); }
.line.ls-comped { opacity: .7; border-left-color: #a78bfa; }
.line-main { display: flex; align-items: baseline; gap: .5rem; }
.line-main .qty { color: var(--muted); font-weight: 700; }
.line-main .lname { flex: 1; font-weight: 600; }
.line-main .lprice { font-weight: 700; }
.line-sub { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; font-size: .75rem; }
.course-badge, .st-badge { background: var(--panel-2); color: var(--muted); padding: .05rem .4rem; border-radius: 6px; }
.mod { background: rgba(59,130,246,.15); color: #93c5fd; padding: .05rem .4rem; border-radius: 6px; }
.note { color: var(--warn); font-style: italic; }

.totals { padding: .6rem .9rem; border-top: 1px solid var(--line); }
.trow { display: flex; justify-content: space-between; color: var(--muted); padding: .15rem 0; }
.trow.total { color: var(--text); font-size: 1.25rem; font-weight: 800; padding-top: .4rem; }
.order-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; padding: .6rem .9rem .2rem; }
.order-actions .btn { padding: .9rem .4rem; font-size: .95rem; }
.order-actions2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .2rem .9rem 0; }
.course-pick { display: flex; align-items: center; gap: .4rem; padding: .4rem .9rem; }
.dremove { color: var(--danger); cursor: pointer; font-weight: 700; margin-left: .3rem; }
.comp-box { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .2rem; }
.pos-toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--ok); color: #04210f; padding: .7rem 1.2rem; border-radius: 10px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); }

/* modifier / line sheets */
.sheet.wide { width: min(560px, 94vw); max-height: 88vh; overflow: auto; }
.mgroup { margin: .6rem 0; }
.mglabel { display: flex; justify-content: space-between; margin-bottom: .4rem; font-weight: 600; }
.mopts { display: flex; flex-wrap: wrap; gap: .4rem; }
.mrow { display: flex; gap: 1rem; margin: .6rem 0; }
.mrow label, .sheet label.full { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .85rem; }
.sheet label.full { margin: .5rem 0; }
.sheet input, .sheet select { padding: .5rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.stepper { display: flex; align-items: center; gap: .6rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .8rem; }

/* ---- Pay screen ---- */
.pay-body { flex: 1; overflow: auto; padding: 1rem; max-width: 760px; margin: 0 auto; width: 100%; }
.pay-split { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.evensplit { display: inline-flex; align-items: center; gap: .3rem; }
.evensplit select { padding: .4rem; border-radius: 8px; background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.check-card { background: var(--panel); border-radius: 12px; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; border: 1px solid var(--line); }
.check-card.paid { opacity: .6; border-color: var(--ok); }
.check-head { display: flex; justify-content: space-between; font-size: 1.05rem; }
.pay-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.quicktip { display: flex; gap: .4rem; margin: .4rem 0; }

/* ---- Cash-out ---- */
table.cashout { width: 100%; border-collapse: collapse; }
table.cashout td { padding: .5rem .2rem; border-bottom: 1px solid var(--line); }
table.cashout td:last-child { text-align: right; font-weight: 600; }
table.cashout tr.strong td { font-size: 1.1rem; color: var(--text); border-bottom: 2px solid var(--line); }
.turnin { display: flex; justify-content: space-between; align-items: center; background: rgba(34,197,94,.12); border: 1px solid var(--ok); border-radius: 12px; padding: 1rem 1.2rem; margin-top: 1rem; }
.turnin strong { font-size: 1.5rem; color: #4ade80; }

/* ---- Phone / narrow screens: stack the order screen vertically ---- */
@media (max-width: 820px) {
  /* Order screen: menu on top (scrolls), order panel below (scrolls) */
  .order-body { flex-direction: column; min-height: 0; }
  .menu-pane {
    flex: 0 0 42vh;            /* fixed-ish menu area on top */
    border-right: none;
    border-bottom: 2px solid var(--line);
    min-width: 0;
  }
  .order-pane { flex: 1 1 auto; max-width: none; min-width: 0; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

  /* Floor canvas: fit width, scroll within */
  .canvas { width: 900px; }   /* still scrollable in .canvas-wrap */

  /* Tighter action buttons so all four fit a phone row */
  .order-actions .btn { padding: .8rem .2rem; font-size: .85rem; }
}
