: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, input, textarea { 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 screen / login ---------- */
.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; }
.login-form { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 320px; margin-top: 8px; text-align: left; }
.field-label { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.field-label:first-child { margin-top: 0; }
.text-input {
  width: 100%; background: var(--paper-card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); padding: 12px; font-size: 15px; min-height: 46px;
}
.text-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.login-error, .form-error { color: var(--alert); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.form-success { color: var(--ready); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- Buttons ---------- */
.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%; margin-top: 10px; }
.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.danger { background: transparent; border-color: var(--alert); color: var(--alert); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 13px; min-height: 40px; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,0.06); }
.icon-btn.accent-btn { border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* ---------- 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: 10px; }
.brand { font-family: var(--font-display); font-size: 19px; 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; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.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); }

/* ---------- Views + tab bar ---------- */
.view { flex: 1; overflow-y: auto; padding: 14px 14px 90px; -webkit-overflow-scrolling: touch; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.view-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; }
.category-chip { flex-shrink: 0; border: 1px solid var(--line); background: var(--paper-raised); color: var(--ink-dim); border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600; cursor: pointer; min-height: 32px; }
.category-chip.active { background: var(--accent); border-color: var(--accent); color: #241505; }

.tab-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--paper-raised); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 15;
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: transparent; border: none; color: var(--ink-dim); font-size: 11px; font-weight: 600;
  padding: 6px 2px; cursor: pointer; min-height: 48px; border-radius: 10px;
}
.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 18px; line-height: 1; }

.list-scroll { display: flex; flex-direction: column; gap: 10px; }
.list-empty { color: var(--ink-dim); text-align: center; padding: 40px 20px; }

/* ---------- Admin cards (generic) ---------- */
.admin-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.admin-card + .admin-card { margin-top: 14px; }
.admin-card h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.muted { color: var(--ink-dim); font-size: 13px; margin: 0 0 10px; }

.admins-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.admin-row-info { display: flex; flex-direction: column; min-width: 0; }
.admin-row-name { font-weight: 700; font-size: 14px; }
.admin-row-email { color: var(--ink-dim); font-size: 12px; font-family: var(--font-mono); }
.you-tag { font-family: var(--font-body); font-weight: 600; font-size: 10px; color: var(--accent); border: 1px solid var(--accent); border-radius: 6px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }
.admin-row .btn { width: auto; min-height: 36px; margin-top: 0; padding: 0 12px; font-size: 12px; flex-shrink: 0; }

#add-admin-details summary { list-style: none; }
#add-admin-details summary::-webkit-details-marker { display: none; }
#add-admin-details summary.btn { display: flex; align-items: center; justify-content: center; }
.admin-add-form { padding-top: 6px; }

/* ---------- Menu admin list ---------- */
.menu-admin-card { display: flex; gap: 12px; align-items: center; background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; cursor: pointer; }
.menu-admin-card:active { background: var(--paper-raised); }
.menu-admin-card.sold-out { opacity: 0.6; }
.menu-admin-photo { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--paper-raised); }
.menu-admin-body { flex: 1; min-width: 0; }
.menu-admin-name-row { display: flex; align-items: center; gap: 6px; }
.menu-admin-name { font-weight: 700; font-size: 14px; }
.menu-admin-cat { font-size: 11px; color: var(--ink-dim); }
.menu-admin-price { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--accent); flex-shrink: 0; }
.badge-sm { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; border-radius: 5px; padding: 2px 5px; }
.badge-sm.priority { color: var(--accent); border: 1px solid var(--accent); }
.badge-sm.sold-out { color: var(--ink-dim); border: 1px solid var(--line); }

/* ---------- Tables admin list ---------- */
.table-admin-card { display: flex; justify-content: space-between; align-items: center; background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; }
.table-admin-card:active { background: var(--paper-raised); }
.table-admin-name { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.table-admin-sub { font-size: 12px; color: var(--ink-dim); font-family: var(--font-mono); margin-top: 2px; }
.chevron { color: var(--ink-dim); font-size: 18px; }

/* ---------- Orders admin list ---------- */
.order-admin-card { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; }
.order-admin-card:active { background: var(--paper-raised); }
.order-admin-card.has-priority { border-color: var(--accent); }
.order-admin-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.order-admin-no { font-family: var(--font-mono); font-size: 17px; font-weight: 700; }
.order-admin-table { font-size: 12px; color: var(--ink-dim); }
.order-admin-summary { font-size: 13px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.order-admin-foot { display: flex; justify-content: space-between; align-items: center; }
.status-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 8px; border-radius: 999px; }
.status-tag.New { background: var(--accent-soft); color: var(--accent); }
.status-tag.Preparing { background: #3a3116; color: #d9b622; }
.status-tag.Ready { background: var(--ready-soft); color: var(--ready); }
.status-tag.Completed { background: rgba(255,255,255,0.06); color: var(--ink-dim); }
.order-admin-total { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }

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

.item-photo { width: 100%; height: 160px; object-fit: cover; border-radius: 14px; background: var(--paper-raised); margin: 8px 0 4px; }
.file-input { width: 100%; color: var(--ink-dim); font-size: 13px; }
.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; }
.toggle-row { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 6px; }
.toggle-label { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
.toggle-label input { width: 18px; height: 18px; accent-color: var(--accent); }

.ticket-perf { border-top: 1px dashed var(--line); margin: 14px 0; }
.track-total-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; }
.track-total-row span:last-child { font-family: var(--font-mono); color: var(--accent); }

.confirm-ticket { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.ticket-head { display: flex; justify-content: space-between; align-items: baseline; }
.ticket-order-no { font-family: var(--font-mono); font-size: 20px; 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; }
.ticket-items .row .item-status { font-size: 10px; color: var(--ink-dim); font-weight: 700; text-transform: uppercase; }

.status-btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-btn-row .btn { width: auto; flex: 1 1 45%; margin-top: 0; }

/* ---------- QR block ---------- */
.qr-block { text-align: center; }
.qr-canvas-wrap { display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 12px; padding: 14px; margin: 8px 0; min-height: 172px; }
.qr-fallback { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #1b1d19; }
.qr-fallback .qr-glyph { font-size: 46px; }
.qr-fallback .qr-note { font-size: 11px; max-width: 200px; color: #555; }
.qr-url { font-family: var(--font-mono); font-size: 11px; color: var(--ink-dim); word-break: break-all; margin: 0 0 8px; }
.qr-actions { display: flex; gap: 8px; }
.qr-actions .btn { margin-top: 0; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-tile { background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat-tile .stat-value { font-family: var(--font-mono); font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-tile .stat-label { font-size: 11px; color: var(--ink-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

.stats-section-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin: 18px 0 10px; }
.stats-section-title:first-child { margin-top: 0; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .bar-label { width: 108px; flex-shrink: 0; font-size: 12px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 10px; background: var(--paper-raised); border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-row .bar-value { width: 64px; flex-shrink: 0; text-align: right; font-family: var(--font-mono); font-size: 12px; }

.volume-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-bottom: 6px; }
.volume-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.volume-bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.volume-date { font-size: 9px; color: var(--ink-dim); writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }

@media (max-width: 360px) {
  .brand { font-size: 17px; }
  .status-btn-row .btn { flex-basis: 100%; }
}
