:root {
  --ink: #111827;
  --muted: #64748b;
  --surface: #ffffff;
  --line: #e5e7eb;
  --bg: #f4f6f8;
  --orange: #ff6b21;
  --green: #16a36a;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans TC", system-ui, sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.topbar {
  height: 78px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; color: inherit; text-decoration: none; }
.brand > span { margin-left: 12px; }
.brand-logo { width: 108px; height: 56px; flex: 0 0 auto; object-fit: contain; }
.brand strong, .brand small { display: block; line-height: 1.25; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; letter-spacing: .08em; }
.view-switcher { padding: 5px; background: #f1f5f9; border-radius: 12px; display: flex; }
.view-switcher a + a { margin-left: 4px; }
.view-switcher a { padding: 8px 14px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700; border-radius: 9px; }
.view-switcher a.active { color: var(--ink); background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.settings-link {
  width: 40px;
  height: 40px;
  display: none;
  place-items: center;
  margin-left: auto;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  transition: color .2s, border-color .2s, background .2s;
}
.settings-link:hover, .settings-link:focus-visible { color: var(--ink); border-color: #cbd5e1; background: #f8fafc; }
.settings-icon { width: 21px; height: 21px; fill: currentColor; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
body[data-view="tv"] .view-switcher { display: none; }
body[data-view="tv"] .settings-link { display: grid; }
.clock { min-width: 84px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.view { width: min(1480px, 100%); margin: 0 auto; padding: clamp(28px, 4vw, 56px) clamp(18px, 4vw, 64px); }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 12px; font-weight: 900; letter-spacing: .17em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 46px); letter-spacing: -.04em; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 34px; }
.live-pill { padding: 9px 13px; color: var(--green); background: #eaf9f2; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.live-pill span { width: 8px; height: 8px; display: inline-block; margin-right: 5px; background: currentColor; border-radius: 50%; animation: pulse 1.5s infinite; }
.tv-statuses { display: flex; align-items: center; gap: 10px; }
.bridge-tv-status { padding: 9px 13px; color: #166534; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 999px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.bridge-tv-status.stale, .bridge-tv-status.error { color: #b42318; background: #fff5f4; border-color: #fda29b; }
.bridge-tv-status.disabled { color: var(--muted); background: #f8fafc; border-color: var(--line); }
.speech-status { padding: 9px 13px; color: #2563eb; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 999px; font-size: 13px; font-weight: 800; }
.speech-status button { cursor: pointer; }
.speech-status[hidden] { display: none; }
.speech-status.error { color: #b42318; background: #fff5f4; border-color: #fda29b; }
@keyframes pulse { 50% { opacity: .3; } }

.tv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.stall-card { position: relative; min-height: 280px; padding: 28px; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.stall-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--accent); }
.stall-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stall-id { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.stall-head h2 { margin: 5px 0 0; font-size: clamp(20px, 2vw, 28px); }
.status-dot { padding: 6px 10px; color: var(--accent); background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 999px; font-size: 12px; font-weight: 800; }
.tv-stage { margin-top: 15px; }
.tv-stage + .tv-stage { padding-top: 12px; border-top: 1px solid var(--line); }
.tv-stage-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 900; }
.tv-stage-head strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.number-list { margin-top: 25px; display: flex; flex-wrap: wrap; gap: 12px; }
.pickup-number { min-width: 108px; padding: 12px 18px; color: var(--ink); background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px; text-align: center; font-size: clamp(28px, 3.2vw, 52px); font-weight: 900; letter-spacing: .02em; font-variant-numeric: tabular-nums; animation: pop .25s ease-out; }
.tv-production-stage .pickup-number { color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: scale(.88); } }
.empty-state { width: 100%; padding: 40px 10px; color: #94a3b8; text-align: center; }
.empty-state strong { display: block; color: #64748b; font-size: 18px; margin-bottom: 6px; }
.tv-note { margin: 28px 0 0; color: var(--muted); text-align: center; font-size: 14px; }

.kitchen-view { max-width: 1100px; }
.kitchen-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.kitchen-heading > div > p:last-child { margin: 12px 0 0; color: var(--muted); }
.kitchen-actions { display: flex; }
.kitchen-actions button + button { margin-left: 8px; }
.ghost-btn { padding: 10px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; }
.stall-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stall-tab { padding: 15px 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #fff; font-weight: 800; }
.stall-tab.active { color: white; border-color: var(--tab-color); background: var(--tab-color); box-shadow: 0 8px 20px rgba(15, 23, 42, .18); }
.console-card { padding: clamp(22px, 4vw, 38px); background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.console-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.stall-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.console-top h2 { margin: 4px 0 0; font-size: 28px; }
.stall-name-row { display: flex; align-items: center; }
.stall-name-row .rename-btn { margin-left: 10px; }
.rename-btn { padding: 5px 9px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 700; }
.rename-btn:hover { color: var(--orange); border-color: #fdba8c; background: #fff7ed; }
.count-badge { padding: 7px 12px; border-radius: 999px; background: #fff2eb; color: #d94b0b; font-size: 13px; font-weight: 800; }
.bridge-panel {
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
}
.bridge-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bridge-eyebrow { color: #2563eb; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.bridge-panel h3 { margin: 3px 0 0; color: #1e3a8a; font-size: 16px; }
.bridge-connection { padding: 5px 9px; color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.bridge-connection.stale, .bridge-connection.error { color: #b42318; background: #fff5f4; border-color: #fda29b; }
.bridge-connection.disabled { color: var(--muted); background: #f8fafc; border-color: var(--line); }
.bridge-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.bridge-count { min-width: 0; padding: 9px 10px; border: 1px solid #dbeafe; border-radius: 10px; background: rgba(255, 255, 255, .72); }
.bridge-count strong, .bridge-count span { display: block; }
.bridge-count strong { color: #1e3a8a; font-size: 18px; line-height: 1; font-variant-numeric: tabular-nums; }
.bridge-count span { margin-top: 4px; color: #475569; font-size: 11px; font-weight: 700; }
.bridge-unmatched { margin: 9px 0 0; color: #b45309; font-size: 11px; font-weight: 700; }
.bridge-summary { margin: 12px 0 0; color: #334155; font-size: 12px; line-height: 1.55; }
.bridge-last-success { margin: 4px 0 0; color: #64748b; font-size: 11px; }
.bridge-error { min-height: 0; margin: 6px 0 0; color: #b42318; font-size: 12px; }
.manual-fallback { margin-top: 16px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #f8fafc; }
.manual-fallback summary { padding: 11px 13px; color: #475569; cursor: pointer; font-size: 13px; font-weight: 800; }
.manual-fallback[open] summary { border-bottom: 1px dashed #cbd5e1; }
.manual-fallback-copy { margin: 12px 13px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.manual-fallback .order-form { margin: 16px 13px 15px; }
.order-form { margin: 26px 0 34px; }
.order-form label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 800; }
.input-row { display: flex; }
.input-row .primary-btn { margin-left: 10px; }
.input-row input { min-width: 0; flex: 1; padding: 15px 17px; border: 2px solid #dbe2ea; border-radius: 12px; outline: none; text-transform: uppercase; font-size: 20px; font-weight: 800; }
.input-row input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px #ff6b2118; }
.primary-btn { padding: 0 24px; border: 0; border-radius: 12px; color: #fff; background: var(--orange); font-weight: 900; }
.order-form small { display: block; margin-top: 8px; color: var(--muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title h3 { margin: 0; font-size: 16px; }
.text-btn { padding: 5px; color: var(--muted); border: 0; background: none; font-size: 13px; font-weight: 700; }
.text-btn:disabled { opacity: .45; cursor: not-allowed; }
.kitchen-orders { min-height: 100px; margin-top: 13px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.production-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.stage-count { color: var(--muted); font-size: 12px; font-weight: 800; }
.kitchen-production { min-height: 70px; margin-top: 13px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.production-chip { min-height: 68px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 1px solid #cbd5e1; border-radius: 12px; background: #f8fafc; text-align: center; }
.production-number { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.production-item-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; font-weight: 700; }
.order-chip { position: relative; min-height: 82px; padding: 10px 8px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px solid #e2e8f0; border-radius: 14px; color: var(--ink); background: #f8fafc; font-size: 27px; font-weight: 900; }
.order-chip.bridge-order { border-color: #93c5fd; background: #eff6ff; }
.order-chip.readonly { cursor: default; }
.order-chip.readonly:hover { color: var(--ink); border-color: #93c5fd; background: #eff6ff; }
.order-chip:hover { color: #b42318; border-color: #fda29b; background: #fff5f4; }
.order-chip .order-number { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.order-chip .order-item-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; font-weight: 700; }
.order-chip::after { content: "點擊完成"; display: block; color: var(--muted); font-size: 10px; font-weight: 600; }
.order-chip.readonly::after { content: "訂單系統同步"; }
.mini-empty { grid-column: 1 / -1; padding: 30px; color: #94a3b8; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 13px; text-align: center; }
.history-section { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.history-list { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.history-item { padding: 7px 10px; color: #64748b; background: #f1f5f9; border-radius: 8px; font-size: 13px; text-decoration: line-through; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 25px; padding: 11px 18px; color: #fff; background: #111827; border-radius: 10px; box-shadow: 0 12px 30px #0003; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.pin-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .56);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.pin-overlay[hidden] { display: none; }
.pin-card {
  width: min(390px, 100%);
  padding: 32px;
  border: 1px solid #dbe2ea;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
  text-align: center;
}
.pin-lock-icon { width: 42px; height: 42px; fill: var(--orange); }
.pin-eyebrow { margin: 12px 0 5px; color: var(--orange); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.pin-card h2 { margin: 0; font-size: 24px; }
.pin-copy { margin: 8px 0 20px; color: var(--muted); font-size: 13px; }
.pin-stall-label { margin: 18px 0 8px; color: var(--ink); font-size: 13px; font-weight: 800; }
.pin-stall-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.pin-stall-choice { padding: 10px 8px; color: var(--muted); border: 1px solid #dbe2ea; border-radius: 10px; background: #f8fafc; font-size: 12px; font-weight: 800; }
.pin-stall-choice.active { color: #fff; border-color: var(--choice-color); background: var(--choice-color); }
.pin-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #dbe2ea;
  border-radius: 12px;
  outline: none;
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: .55em;
}
.pin-input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px #ff6b2118; }
.pin-error { min-height: 20px; margin: 7px 0 5px; color: #b42318; font-size: 12px; }
.pin-submit { width: 100%; min-height: 46px; }
.pin-submit:disabled { opacity: .6; cursor: wait; }
.pin-back { display: inline-block; margin-top: 14px; color: var(--muted); font-size: 12px; text-decoration: none; }
.pin-links { display: flex; justify-content: center; }
.pin-links .pin-back + .pin-back { margin-left: 18px; }
body.pin-locked { overflow: hidden; }

.admin-view { max-width: 1100px; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin-heading > div > p:last-child { margin: 10px 0 0; color: var(--muted); }
.ghost-link { padding: 10px 15px; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 700; text-decoration: none; }
.admin-login-card {
  width: min(460px, 100%);
  margin: 60px auto 0;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}
.admin-login-card h2 { margin-bottom: 6px; }
.admin-login-card form > p:not(.admin-error) { margin-bottom: 20px; color: var(--muted); }
.admin-login-card label, .admin-pin-card label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 800; }
.admin-login-card input, .admin-pin-card input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #dbe2ea;
  border-radius: 11px;
  outline: none;
  font-size: 18px;
  font-weight: 800;
}
.admin-login-card input:focus, .admin-pin-card input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px #ff6b2118; }
.admin-error { min-height: 20px; margin: 6px 0; color: #b42318; font-size: 12px; }
.admin-primary { width: 100%; min-height: 46px; }
.admin-primary:disabled { opacity: .6; cursor: wait; }
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  background: #f0fdf4;
}
.admin-toolbar strong, .admin-toolbar span { display: block; }
.admin-toolbar span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.admin-theme-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.admin-theme-copy h2 { margin: 4px 0 6px; font-size: 20px; }
.admin-theme-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.admin-theme-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.admin-theme-controls label { grid-column: 1 / -1; font-size: 13px; font-weight: 800; }
.admin-theme-controls select {
  min-width: 0;
  padding: 11px 12px;
  border: 2px solid #dbe2ea;
  border-radius: 11px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}
.admin-theme-controls select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px #ff6b2118; }
.admin-theme-controls .primary-btn { min-height: 44px; white-space: nowrap; }
.admin-theme-card > .admin-pin-status { position: absolute; left: 22px; bottom: 5px; }
.admin-setting-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}
.admin-setting-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.admin-setting-controls label { grid-column: 1 / -1; font-size: 13px; font-weight: 800; }
.minutes-input-row { min-width: 0; display: flex; align-items: center; gap: 8px; }
.minutes-input-row input { width: 100%; min-width: 0; padding: 11px 12px; border: 2px solid #dbe2ea; border-radius: 11px; outline: none; font-size: 18px; font-weight: 800; }
.minutes-input-row input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px #ff6b2118; }
.minutes-input-row span { color: var(--muted); font-size: 13px; font-weight: 800; white-space: nowrap; }
.admin-setting-controls .primary-btn { min-height: 44px; white-space: nowrap; }
.admin-setting-card > .admin-pin-status { position: absolute; left: 22px; bottom: 5px; }
.admin-pin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-pin-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .06); }
.admin-pin-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.admin-pin-card-head h2 { margin: 0; font-size: 20px; }
.admin-stall-number { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
.admin-pin-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-pin-card .admin-primary { margin-top: 14px; }
.admin-pin-status { min-height: 20px; margin: 7px 0 0; color: var(--green); font-size: 12px; }
.admin-pin-status.error { color: #b42318; }

@media (min-width: 1500px) { .tv-grid { grid-template-columns: repeat(4, 1fr); } .stall-card { min-height: 420px; } }
@media (max-width: 720px) {
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; }
  .brand-logo { width: 88px; height: 46px; }
  .view-switcher { order: 3; width: 100%; }
  .view-switcher a { flex: 1; text-align: center; }
  .clock { min-width: 0; }
  .tv-grid { grid-template-columns: 1fr; }
  .stall-card { min-height: 225px; }
  .hero-row { align-items: start; }
  .kitchen-heading { align-items: start; }
  .stall-tabs { grid-template-columns: repeat(2, 1fr); }
  .input-row { flex-direction: column; }
  .input-row .primary-btn { margin: 10px 0 0; padding: 14px; }
  .kitchen-orders { grid-template-columns: repeat(2, 1fr); }
  .kitchen-production { grid-template-columns: repeat(2, 1fr); }
  .bridge-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bridge-count { padding: 8px 6px; }
  .bridge-count strong { font-size: 16px; }
  .admin-heading { align-items: flex-start; }
  .admin-heading .ghost-link { margin-left: 12px; white-space: nowrap; }
  .admin-theme-card, .admin-setting-card { grid-template-columns: 1fr; align-items: stretch; }
  .admin-theme-controls { grid-template-columns: 1fr; }
  .admin-theme-controls label { grid-column: auto; }
  .admin-theme-controls .primary-btn { width: 100%; }
  .admin-theme-card > .admin-pin-status { position: static; grid-column: 1 / -1; }
  .admin-setting-controls { grid-template-columns: 1fr; }
  .admin-setting-controls label { grid-column: auto; }
  .admin-setting-controls .primary-btn { width: 100%; }
  .admin-setting-card > .admin-pin-status { position: static; grid-column: 1 / -1; }
  .admin-pin-grid { grid-template-columns: 1fr; }
  .admin-pin-fields { grid-template-columns: 1fr; }
}

@media (display-mode: fullscreen) {
  .topbar .view-switcher { display: none; }
  .tv-view { padding-top: 28px; }
}

/* TV layout: reserve pixels for pickup numbers, then fit every row inside its card. */
@media (min-width: 721px) {
  body[data-view="tv"] {
    --tv-header-height: 78px;
    overflow: hidden;
  }
  body[data-view="tv"] .topbar {
    height: var(--tv-header-height);
    padding: 0 clamp(14px, 2.5vw, 36px);
    gap: 12px;
  }
  body[data-view="tv"] .brand > span { margin-left: 8px; }
  body[data-view="tv"] .brand-logo { width: 84px; height: 54px; }
  body[data-view="tv"] .brand strong { font-size: 16px; }
  body[data-view="tv"] .brand small { display: none; }
  body[data-view="tv"] .settings-link { width: 34px; height: 34px; border-radius: 10px; }
  body[data-view="tv"] .settings-icon { width: 18px; height: 18px; }
  body[data-view="tv"] .clock {
    min-width: 190px;
    font-size: clamp(24px, 2.2vw, 42px);
    line-height: 1;
    font-weight: 900;
    letter-spacing: .02em;
  }
  body[data-view="tv"] main {
    height: calc(100vh - var(--tv-header-height));
    overflow: hidden;
  }
  body[data-view="tv"] .tv-view {
    width: min(3600px, 100%);
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px clamp(14px, 2.5vw, 36px);
  }
  body[data-view="tv"] .hero-row {
    min-height: 30px;
    flex: 0 0 auto;
    align-items: center;
    margin-bottom: 10px;
  }
  body[data-view="tv"] .hero-row > div:first-child,
  body[data-view="tv"] .stall-head > div { min-width: 0; }
  body[data-view="tv"] .eyebrow { display: none; }
  body[data-view="tv"] h1 {
    font-size: clamp(20px, 2vw, 28px);
    line-height: 1.15;
    letter-spacing: -.02em;
  }
  body[data-view="tv"] .live-pill,
  body[data-view="tv"] .bridge-tv-status,
  body[data-view="tv"] .speech-status { padding: 5px 8px; font-size: 10px; }
  body[data-view="tv"] .live-pill span { width: 6px; height: 6px; margin-right: 3px; }
  body[data-view="tv"] .tv-grid {
    min-height: 0;
    flex: 1 1 auto;
    gap: 12px;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  body[data-view="tv"] .stall-card {
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: 16px;
    border: 2px solid #cbd5e1;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .13);
  }
  body[data-view="tv"] .stall-card::before { width: 5px; }
  body[data-view="tv"] .stall-head {
    position: relative;
    display: block;
    flex: 0 0 auto;
    text-align: center;
  }
  body[data-view="tv"] .stall-id { display: none; }
  body[data-view="tv"] .stall-head h2 {
    margin: 0;
    font-size: var(--stall-name-font, clamp(64px, 6vw, 128px));
    font-weight: 900;
    line-height: 1.05;
    white-space: nowrap;
  }
  body[data-view="tv"] .status-dot { display: none; }
  body[data-view="tv"] .tv-stage {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body[data-view="tv"] .tv-ready-stage { flex: 2 1 0; }
  body[data-view="tv"] .tv-production-stage { flex: 1 1 0; }
  body[data-view="tv"] .tv-stage-head { flex: 0 0 auto; padding: 0 3px; font-size: 11px; }
  body[data-view="tv"] .number-list {
    --number-columns: 4;
    --number-rows: 2;
    --number-gap: 4px;
    min-height: 0;
    flex: 1 1 auto;
    margin-top: 4px;
    overflow: hidden;
  }
  body[data-view="tv"] .tv-production-stage .number-list { --number-rows: 1; }
  body[data-view="tv"] .number-list.has-orders {
    display: grid;
    grid-template-columns: repeat(var(--number-columns, 1), minmax(0, 1fr));
    grid-template-rows: repeat(var(--number-rows, 1), minmax(0, 1fr));
    grid-auto-flow: row;
    gap: var(--number-gap, 4px);
  }
  body[data-view="tv"] .pickup-number {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    padding: 2px 3px;
    border-radius: 10px;
    overflow: hidden;
    white-space: nowrap;
    font-size: var(--number-font, 32px);
    line-height: 1;
    letter-spacing: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--ink);
  }
  body[data-view="tv"] .empty-state {
    align-self: center;
    padding: 8px;
  }
  body[data-view="tv"] .empty-state strong { margin-bottom: 3px; font-size: 14px; }
  body[data-view="tv"] .empty-state span { font-size: 11px; }
  body[data-view="tv"] .tv-note { display: none; }
}

@supports (height: 100dvh) {
  @media (min-width: 721px) {
    body[data-view="tv"] main { height: calc(100dvh - var(--tv-header-height)); }
  }
}

@media (min-width: 1500px) {
  body[data-view="tv"] .tv-grid { grid-template-rows: minmax(0, 1fr); }
  body[data-view="tv"] .tv-ready-stage .number-list {
    --number-columns: 2;
    --number-rows: 4;
  }
  body[data-view="tv"] .tv-production-stage .number-list { --number-columns: 2; --number-rows: 2; }
}

@media (min-width: 721px) and (max-height: 520px) {
  body[data-view="tv"] { --tv-header-height: 52px; }
  body[data-view="tv"] .brand-logo { width: 62px; height: 38px; }
  body[data-view="tv"] .brand strong { font-size: 13px; }
  body[data-view="tv"] .clock { min-width: 120px; font-size: 22px; }
  body[data-view="tv"] .tv-view { padding-top: 8px; padding-bottom: 8px; }
  body[data-view="tv"] .hero-row { min-height: 24px; margin-bottom: 6px; }
  body[data-view="tv"] h1 { font-size: 20px; }
  body[data-view="tv"] .tv-grid { gap: 8px; }
  body[data-view="tv"] .stall-card { padding: 7px 9px; }
  body[data-view="tv"] .stall-id { display: none; }
  body[data-view="tv"] .stall-head h2 {
    font-size: min(var(--stall-name-font, 40px), clamp(30px, 9vh, 40px));
    line-height: .95;
  }
  body[data-view="tv"] .tv-stage { margin-top: 2px; }
  body[data-view="tv"] .tv-stage + .tv-stage { padding-top: 2px; }
  body[data-view="tv"] .tv-stage-head { font-size: 9px; line-height: 1; }
  body[data-view="tv"] .number-list { min-height: 18px; margin-top: 2px; }
  body[data-view="tv"] .empty-state { padding: 1px; }
  body[data-view="tv"] .empty-state strong { margin: 0; font-size: 10px; }
  body[data-view="tv"] .empty-state span { display: none; }
}

/* Night / McDonald's-inspired TV theme. The setting is global and also styles admin/kitchen surfaces. */
body[data-theme="mcdonalds"] {
  --ink: #ffd400;
  --muted: #f0c94a;
  --surface: #090909;
  --line: #5a4500;
  --bg: #030303;
  --orange: #ffd400;
  --green: #ffd400;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  background: var(--bg);
  color: var(--ink);
}
body[data-theme="mcdonalds"] .topbar,
body[data-theme="mcdonalds"] .stall-card,
body[data-theme="mcdonalds"] .console-card,
body[data-theme="mcdonalds"] .admin-login-card,
body[data-theme="mcdonalds"] .admin-pin-card,
body[data-theme="mcdonalds"] .admin-theme-card,
body[data-theme="mcdonalds"] .admin-setting-card,
body[data-theme="mcdonalds"] .pin-card {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow);
}
body[data-theme="mcdonalds"] .bridge-panel,
body[data-theme="mcdonalds"] .manual-fallback {
  background: #121212;
  border-color: var(--line);
}
body[data-theme="mcdonalds"] .bridge-panel h3,
body[data-theme="mcdonalds"] .bridge-count strong,
body[data-theme="mcdonalds"] .bridge-summary,
body[data-theme="mcdonalds"] .manual-fallback summary { color: #ffd400; }
body[data-theme="mcdonalds"] .bridge-eyebrow,
body[data-theme="mcdonalds"] .bridge-count span,
body[data-theme="mcdonalds"] .bridge-last-success,
body[data-theme="mcdonalds"] .bridge-unmatched,
body[data-theme="mcdonalds"] .manual-fallback-copy { color: #f0c94a; }
body[data-theme="mcdonalds"] .bridge-count { background: #201800; border-color: var(--line); }
body[data-theme="mcdonalds"] .order-chip.bridge-order { border-color: var(--line); background: #201800; }
body[data-theme="mcdonalds"] .order-chip.readonly:hover { color: #ffd400; border-color: var(--line); background: #201800; }
body[data-theme="mcdonalds"] .production-chip { border-color: var(--line); background: #121212; }
body[data-theme="mcdonalds"] .manual-fallback[open] summary { border-bottom-color: var(--line); }
body[data-theme="mcdonalds"] .topbar { border-bottom-color: var(--line); }
body[data-theme="mcdonalds"] .brand strong,
body[data-theme="mcdonalds"] .clock,
body[data-theme="mcdonalds"] .tv-view h1,
body[data-theme="mcdonalds"] .stall-head h2 { color: #ffd400; }
body[data-theme="mcdonalds"] .stall-card::before { background: #ffd400; }
body[data-theme="mcdonalds"][data-view="tv"] .stall-card { border-color: #ffd400; }
body[data-theme="mcdonalds"] .pickup-number { color: #ffd400; }
body[data-theme="mcdonalds"] .empty-state,
body[data-theme="mcdonalds"] .empty-state strong { color: #f0c94a; }
body[data-theme="mcdonalds"] .live-pill { color: #080808; background: #ffd400; }
body[data-theme="mcdonalds"] .bridge-tv-status { color: #ffd400; background: #201800; border-color: var(--line); }
body[data-theme="mcdonalds"] .settings-link,
body[data-theme="mcdonalds"] .ghost-btn,
body[data-theme="mcdonalds"] .ghost-link {
  color: #ffd400;
  border-color: var(--line);
  background: #121212;
}
body[data-theme="mcdonalds"] .view-switcher { background: #201800; }
body[data-theme="mcdonalds"] .view-switcher a.active { color: #090909; background: #ffd400; }
body[data-theme="mcdonalds"] .primary-btn { color: #090909; background: #ffd400; }
body[data-theme="mcdonalds"] input,
body[data-theme="mcdonalds"] select {
  color: #ffd400;
  border-color: var(--line);
  background: #151515;
}
body[data-theme="mcdonalds"] .admin-toolbar { border-color: var(--line); background: #201800; }
body[data-theme="mcdonalds"] .admin-theme-copy p,
body[data-theme="mcdonalds"] .admin-toolbar span,
body[data-theme="mcdonalds"] .order-form small { color: var(--muted); }
