: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; gap: 12px; color: inherit; text-decoration: none; }
.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; gap: 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; }
@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: color-mix(in srgb, var(--accent) 10%, white); border-radius: 999px; font-size: 12px; font-weight: 800; }
.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; }
@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); }
.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 color-mix(in srgb, var(--tab-color) 30%, transparent); }
.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; gap: 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; }
.order-form { margin: 26px 0 34px; }
.order-form label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 800; }
.input-row { display: flex; gap: 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; }
.kitchen-orders { min-height: 100px; margin-top: 13px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.order-chip { position: relative; min-height: 82px; border: 2px solid #e2e8f0; border-radius: 14px; color: var(--ink); background: #f8fafc; font-size: 27px; font-weight: 900; }
.order-chip:hover { color: #b42318; border-color: #fda29b; background: #fff5f4; }
.order-chip::after { content: "點擊完成"; display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 600; }
.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); }

@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; }
  .primary-btn { padding: 14px; }
  .kitchen-orders { grid-template-columns: repeat(2, 1fr); }
}

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