:root {
  --paper: #1b1d19;
  --paper-raised: #24261f;
  --paper-card: #2a2c24;
  --ink: #f4f1ea;
  --ink-dim: #a9a89c;
  --accent: #d97022;
  --accent-soft: #3a2c1a;
  --ready: #3fa66b;
  --ready-soft: #163325;
  --alert: #e94b4b;
  --alert-soft: #3a1616;
  --line: #38392f;
  --radius: 14px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  overscroll-behavior-y: contain;
}
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Center screens (loading / no table) ---------- */
.center-screen {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px; text-align: center;
}
.center-screen h1 { font-family: var(--font-display); font-size: 26px; margin: 0; }
.center-screen p { color: var(--ink-dim); max-width: 320px; margin: 0; line-height: 1.5; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: relative; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: var(--paper-raised); flex-shrink: 0; gap: 12px;
}
.brand { font-family: var(--font-display); font-size: 20px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
.brand small { font-family: var(--font-body); font-size: 12px; color: var(--accent); font-weight: 700; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-dim); padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,0.04); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-dim); }
.status-pill.live .status-dot { background: var(--ready); box-shadow: 0 0 0 3px var(--ready-soft); }
.status-pill.down .status-dot { background: var(--alert); box-shadow: 0 0 0 3px var(--alert-soft); }

.icon-btn { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 14px; min-height: 44px; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,0.06); }

/* ---------- Menu view ---------- */
.menu-view { flex: 1; overflow-y: auto; padding-bottom: 90px; -webkit-overflow-scrolling: touch; }

.category-nav {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px;
  position: sticky; top: 0; background: var(--paper); z-index: 5;
  border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch;
}
.category-chip {
  flex-shrink: 0; border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink-dim);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 36px;
}
.category-chip.active { background: var(--accent); border-color: var(--accent); color: #241505; }

.menu-list { padding: 4px 14px 14px; }
.category-heading {
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
  margin: 22px 0 10px; padding-top: 4px; scroll-margin-top: 64px;
}
.category-heading:first-child { margin-top: 12px; }

.menu-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px; width: 100%; text-align: left; cursor: pointer;
}
.menu-card:active { background: var(--paper-raised); }
.menu-card.sold-out { opacity: 0.5; cursor: default; }
.menu-card-photo { width: 68px; height: 68px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--paper-raised); }
.menu-card-body { flex: 1; min-width: 0; }
.menu-card-name-row { display: flex; align-items: center; gap: 6px; }
.menu-card-name { font-weight: 700; font-size: 15px; }
.chef-badge { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); border: 1px solid var(--accent); border-radius: 5px; padding: 2px 5px; }
.sold-out-badge { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-dim); border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px; }
.menu-card-desc { font-size: 12px; color: var(--ink-dim); margin: 3px 0 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.menu-card-price { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--accent); }
.menu-empty { color: var(--ink-dim); text-align: center; padding: 40px 20px; }

/* ---------- Cart bar ---------- */
.cart-bar {
  position: absolute; left: 14px; right: 14px; bottom: 16px;
  background: var(--accent); color: #241505; border: none; border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; cursor: pointer; min-height: 52px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35); z-index: 20;
}
.cart-bar-count { background: rgba(0,0,0,0.18); border-radius: 999px; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.cart-bar-label { flex: 1; text-align: left; }
.cart-bar-total { font-family: var(--font-mono); }

/* ---------- Sheets (cart / item detail) ---------- */
.sheet {
  position: fixed; inset: 0; background: var(--paper); z-index: 30;
  display: flex; flex-direction: column;
  animation: sheetIn 0.22s ease-out;
}
.sheet[hidden] { display: none; }
@keyframes sheetIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.sheet-inner { flex: 1; overflow-y: auto; padding: 14px 18px 24px; -webkit-overflow-scrolling: touch; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; position: sticky; top: 0; background: var(--paper); padding: 4px 0 10px; }
.sheet-head h2 { font-family: var(--font-display); font-size: 19px; margin: 0; }

.cart-items { display: flex; flex-direction: column; gap: 10px; }
.cart-item { display: flex; gap: 10px; align-items: flex-start; background: var(--paper-card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.cart-item-main { flex: 1; }
.cart-item-name { font-weight: 700; font-size: 14px; }
.cart-item-notes { font-size: 12px; color: var(--ink-dim); font-style: italic; margin-top: 2px; }
.cart-item-price { font-family: var(--font-mono); font-size: 13px; color: var(--accent); margin-top: 4px; }
.cart-item-controls { display: flex; align-items: center; gap: 8px; }
.cart-qty-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink); font-size: 16px; cursor: pointer; }
.cart-qty-val { font-family: var(--font-mono); min-width: 16px; text-align: center; }

.ticket-perf { border-top: 1px dashed var(--line); margin: 14px 0; }
.cart-total-row, .track-total-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; margin-bottom: 16px; }
.cart-total-row span:last-child, .track-total-row span:last-child { font-family: var(--font-mono); color: var(--accent); }
.cart-empty-hint { color: var(--ink-dim); text-align: center; font-size: 13px; margin-top: 30px; }

.btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; width: 100%; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #241505; }
.btn.big { min-height: 52px; font-size: 15px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.item-photo { width: 100%; height: 190px; object-fit: cover; border-radius: 14px; background: var(--paper-raised); margin-bottom: 12px; }
.item-description { color: var(--ink-dim); font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
.notes-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.notes-input { width: 100%; min-height: 64px; background: var(--paper-card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); padding: 10px; font-family: inherit; font-size: 14px; resize: vertical; margin-bottom: 16px; }
.qty-row { display: flex; align-items: center; justify-content: center; gap: 22px; margin-bottom: 18px; }
.qty-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink); font-size: 20px; cursor: pointer; }
#qty-value { font-family: var(--font-mono); font-size: 20px; font-weight: 700; min-width: 24px; text-align: center; }

/* ---------- Order tracking ---------- */
.tracking-view { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 22px; -webkit-overflow-scrolling: touch; }
.confirm-ticket { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; }
.ticket-order-no { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.ticket-table { font-size: 12px; color: var(--ink-dim); }
.ticket-items { display: flex; flex-direction: column; gap: 8px; }
.ticket-items .row { display: flex; gap: 8px; font-size: 14px; }
.ticket-items .row .qty { font-family: var(--font-mono); font-weight: 700; min-width: 24px; }
.ticket-items .row .name { flex: 1; }
.ticket-items .row .notes { font-size: 12px; color: var(--ink-dim); font-style: italic; }

.progress-track { display: flex; justify-content: space-between; position: relative; padding: 0 6px; }
.progress-track::before { content: ''; position: absolute; top: 9px; left: 24px; right: 24px; height: 2px; background: var(--line); }
.progress-step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; position: relative; z-index: 1; }
.progress-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--paper-raised); border: 2px solid var(--line); }
.progress-label { font-size: 11px; color: var(--ink-dim); font-weight: 600; text-align: center; }
.progress-step.done .progress-dot { background: var(--ready); border-color: var(--ready); }
.progress-step.done .progress-label { color: var(--ink); }
.progress-step.current .progress-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: pulseDot 1.4s ease-in-out infinite; }
.progress-step.current .progress-label { color: var(--accent); }
@keyframes pulseDot { 0%, 100% { box-shadow: 0 0 0 4px var(--accent-soft); } 50% { box-shadow: 0 0 0 8px transparent; } }

.track-hint { text-align: center; color: var(--ink-dim); font-size: 14px; line-height: 1.5; margin: 0; }

@media (max-width: 360px) {
  .brand { font-size: 17px; }
  .progress-label { font-size: 10px; }
}
