:root {
  --red: #AE3943;
  --red-deep: #8A2A33;
  --ink: #1c1c1e;
  --muted: #6c6c70;
  --line: #e5e5ea;
  --card: #ffffff;
  --bg: #f3f1ec;
  --offwhite: #F7F2EA;
  --amber: #9a6b00;
  --amber-bg: #fff3cc;
  --green: #1f7a3f;
  --green-bg: #e4f6ea;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --ticket-w: 340px;
  --groups-w: 168px;
  --topbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

#app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 12px 0 10px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 190px; }
.logo { width: 42px; height: 42px; object-fit: contain; }
.brand-name { font-weight: 750; letter-spacing: -.02em; font-size: 1.05rem; line-height: 1.1; }
.demo-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 16px;
  white-space: nowrap;
}
.loc-switch, .view-switch, .order-type { display: flex; background: var(--offwhite); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.loc-btn, .view-btn, .ot-btn {
  border: 0; background: transparent; color: var(--ink);
  padding: 8px 14px; font-weight: 650; font-size: .9rem;
}
.loc-btn.is-on, .view-btn.is-on, .ot-btn.is-on { background: var(--red); color: #fff; }
.view-switch { margin-left: auto; }
.top-right { display: flex; align-items: center; gap: 10px; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; white-space: nowrap; }
.text-btn { border: 0; background: none; color: var(--red); font-weight: 650; padding: 6px 8px; }

.view { flex: 1; min-height: 0; }
.view.hidden, .hidden { display: none !important; }
.register { display: flex; }

.groups {
  flex: 0 0 var(--groups-w);
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 6px;
}
.group-btn {
  display: block; width: 100%;
  text-align: left;
  border: 0; background: transparent;
  padding: 11px 10px;
  border-radius: 8px;
  font-weight: 650;
  font-size: .86rem;
  line-height: 1.2;
  margin-bottom: 2px;
  color: var(--ink);
}
.group-btn.is-on { background: var(--red); color: #fff; }
.group-btn .count { display: block; font-weight: 500; font-size: .72rem; opacity: .7; margin-top: 1px; }

.menu-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-tools { display: flex; gap: 8px; align-items: center; padding: 8px 10px; }
.search {
  flex: 1; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 12px; background: #fff;
}
.items {
  flex: 1; overflow-y: auto;
  padding: 0 10px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 8px;
  align-content: start;
}
.item-btn {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  color: var(--ink);
}
.item-btn:active { transform: scale(.98); }
.item-btn .iname { font-weight: 700; font-size: .92rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item-btn .iprice { margin-top: 8px; font-weight: 750; font-variant-numeric: tabular-nums; }
.item-btn .iprice.from { font-weight: 650; color: var(--muted); font-size: .9rem; }
.item-btn .needed { color: var(--amber); background: var(--amber-bg); display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: .75rem; font-weight: 750; }
.item-btn .mod-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.item-empty { grid-column: 1 / -1; color: var(--muted); padding: 24px 8px; }

.ticket-pane {
  flex: 0 0 var(--ticket-w);
  display: flex; flex-direction: column;
  background: #fff;
  border-left: 1px solid var(--line);
  min-width: 0;
}
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 12px 6px; }
.ticket-num { font-weight: 800; font-size: 1.05rem; }
.ticket-meta { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.order-type { margin: 0 12px 8px; }
.ot-btn { flex: 1; padding: 8px 6px; font-size: .84rem; }
.guest-row { padding: 0 12px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.guest-row input {
  flex: 1; min-width: 110px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px;
}
.ticket-lines { flex: 1; overflow-y: auto; padding: 0 4px 8px; }
.line {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 2px 8px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.line.is-on { background: var(--offwhite); }
.line .qty-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.qty-btn {
  width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
  font-weight: 700; line-height: 1; padding: 0;
}
.qty-num { font-weight: 750; font-variant-numeric: tabular-nums; font-size: .9rem; }
.line-name { font-weight: 700; font-size: .9rem; }
.line-mods { color: var(--muted); font-size: .78rem; line-height: 1.3; margin-top: 2px; }
.line-note { font-size: .78rem; color: var(--red-deep); font-style: italic; }
.line-needed { color: var(--amber); font-weight: 700; font-size: .78rem; }
.line-price { font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.line-actions { grid-column: 2 / -1; display: flex; gap: 8px; margin-top: 4px; }
.line-actions button { border: 0; background: none; color: var(--red); font-size: .78rem; font-weight: 650; padding: 0; }

.ticket-totals { padding: 8px 14px; border-top: 1px solid var(--line); font-size: .9rem; }
.t-row { display: flex; justify-content: space-between; margin: 3px 0; font-variant-numeric: tabular-nums; }
.t-row.muted { color: var(--muted); font-size: .8rem; }
.t-row.total { font-weight: 800; font-size: 1.15rem; margin-top: 6px; }
.t-row.due { font-weight: 800; color: var(--red); }
.ticket-actions { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; padding: 8px 10px calc(10px + var(--safe-b)); }
.act-btn {
  height: 48px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--offwhite); font-weight: 750;
}
.act-pay { background: var(--red); color: #fff; border-color: var(--red); }
.act-pay:disabled, .act-btn:disabled { opacity: .45; cursor: not-allowed; }

.ticket-fab {
  display: none;
  position: fixed; right: 14px; bottom: calc(14px + var(--safe-b));
  z-index: 25;
  height: 52px; padding: 0 18px;
  border: 0; border-radius: 999px;
  background: var(--red); color: #fff; font-weight: 750;
  box-shadow: 0 6px 18px rgba(174,57,67,.35);
}

/* Kitchen / orders / day */
.kitchen, .orders, .day { overflow: auto; padding: 12px; }
.kds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  align-items: start;
}
.kds-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; box-shadow: var(--shadow);
}
.kds-card.bumped { opacity: .55; }
.kds-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; }
.kds-time { color: var(--muted); font-weight: 600; font-size: .8rem; }
.kds-items { margin: 8px 0; font-size: .92rem; }
.kds-item { margin: 6px 0; }
.kds-item b { font-weight: 800; }
.bump-btn, .row-btn {
  width: 100%; height: 44px; border: 0; border-radius: 10px;
  background: var(--ink); color: #fff; font-weight: 750; margin-top: 8px;
}
.bump-btn.undo { background: var(--offwhite); color: var(--ink); border: 1px solid var(--line); }

.orders-list { display: flex; flex-direction: column; gap: 8px; max-width: 920px; margin: 0 auto; }
.order-row {
  display: grid; grid-template-columns: 90px 1fr auto auto;
  gap: 10px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.order-row .onum { font-weight: 800; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 750; background: var(--offwhite); }
.pill.paid { background: var(--green-bg); color: var(--green); }
.pill.open { background: #e8f0fe; color: #1a4a9c; }
.pill.voided, .pill.refunded { background: #f3e0e2; color: var(--red-deep); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar .is-on { background: var(--red); color: #fff; border-color: var(--red); }

.report { max-width: 860px; margin: 0 auto; }
.report h2 { margin: 0 0 8px; }
.report-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.report table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.report th, .report td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.report td.num, .report th.num { text-align: right; }
.note { color: var(--muted); font-size: .85rem; line-height: 1.4; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.modal.center { align-items: center; padding: 16px; }
.sheet {
  background: #fff;
  width: min(720px, 100%);
  max-height: min(92vh, 920px);
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-b));
}
.modal.center .sheet { border-radius: 16px; }
.sheet h2 { margin: 0 0 8px; font-size: 1.15rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.opt-btn {
  min-height: 64px; padding: 10px;
  border: 2px solid var(--line); border-radius: 10px;
  background: #fff; text-align: left; font-weight: 650;
}
.opt-btn.is-on { border-color: var(--red); background: #fbecee; }
.opt-btn .oprice { display: block; margin-top: 4px; color: var(--muted); font-size: .8rem; }
.req-tag { font-size: .75rem; font-weight: 750; color: var(--red); text-transform: uppercase; letter-spacing: .04em; }
.mod-section { margin: 12px 0; }
.mod-section h3 { margin: 0 0 8px; font-size: .95rem; }
.sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.sheet-actions .act-btn, .sheet-actions .act-pay { flex: 1; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.key { height: 56px; border: 1px solid var(--line); border-radius: 10px; background: var(--offwhite); font-size: 1.25rem; font-weight: 750; }
.tender { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; margin: 6px 0; }
.quick-tender { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.reason input, .reason textarea, .field {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 6px;
}
.tip-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.card-demo {
  text-align: center; padding: 24px 12px;
  background: var(--offwhite); border-radius: 12px; border: 2px dashed var(--red);
}
.card-demo .big { font-size: 1.4rem; font-weight: 800; margin: 8px 0; }
.warn { background: var(--amber-bg); color: #5c4000; padding: 8px 10px; border-radius: 8px; font-size: .88rem; }

/* Receipt — also used on screen and for Epson 80mm print */
.receipt {
  width: 80mm;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.35;
  padding: 8px 6px 16px;
}
.receipt .c { text-align: center; }
.receipt .b { font-weight: 800; }
.receipt pre { margin: 0; white-space: pre-wrap; font: inherit; }
.receipt .demo-line { font-weight: 800; text-align: center; margin: 6px 0; }

@media (max-width: 980px) {
  .topbar {
    flex: 0 0 auto;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--topbar-h);
    padding: 6px 10px 8px;
    gap: 8px;
    align-items: center;
  }
  .brand { min-width: 0; }
  .top-right { margin-left: auto; }
  .clock { display: none; }
  .view-switch { margin-left: 0; flex: 1 1 100%; }
  .register { flex-direction: column; }
  .groups {
    flex: 0 0 auto;
    display: flex; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    width: 100%; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 6px 8px;
    gap: 6px;
  }
  .group-btn { flex: 0 0 auto; width: auto; white-space: nowrap; margin: 0; padding: 10px 12px; }
  .group-btn .count { display: none; }
  .items { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); padding-bottom: 80px; }
  .ticket-pane {
    position: fixed; inset: auto 0 0 0; z-index: 30;
    height: min(78vh, 640px);
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform .16s ease-out;
  }
  .ticket-pane.open { transform: translateY(0); }
  .ticket-fab { display: inline-flex; align-items: center; gap: 8px; }
  body.ticket-open .ticket-fab { display: none; }
}

@media print {
  body { background: #fff; overflow: visible; }
  #app, .modal, .ticket-fab { display: none !important; }
  .print-root, .print-root .receipt { display: block !important; }
  .print-root { position: static; }
  @page { size: 80mm auto; margin: 3mm; }
  .receipt { width: 74mm; box-shadow: none; }
}
.print-root { display: none; }

.empty-hint { color: var(--muted); text-align: center; padding: 32px 12px; }

.qty-btn.is-on, .opt-btn.is-on { border-color: var(--red); background: #fbecee; }
