/* QueueLite web styles: staff page (mobile-first) + display page (TV).
   No framework, no build step. High contrast; every tap target >= 48px;
   the primary action is pinned to the bottom where a thumb lives. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --ok: #047857;
  --warn: #b45309;
  --danger: #b91c1c;
  --prio-bg: #fef3c7;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

.hidden { display: none !important; }

/* fixed red bar shown whenever realtime/polling is unhealthy */
.connbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--danger); color: #fff;
  text-align: center; padding: 10px; font-weight: 700;
}

/* ---------- views / login ---------- */
.view { max-width: 520px; margin: 0 auto; padding: 20px 16px 130px; }
#login-view h1, #denied-view h1 { text-align: center; }
#login-form { display: grid; gap: 16px; }
#login-form label { display: grid; gap: 6px; font-weight: 600; }
#login-form input {
  min-height: 48px; padding: 8px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.error { color: var(--danger); min-height: 1.2em; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  min-height: 48px; min-width: 64px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.big { min-height: 60px; font-size: 20px; flex: 1; }
.btn.small { min-height: 48px; min-width: 48px; font-size: 14px; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.prio-on { background: var(--prio-bg); border-color: var(--warn); color: var(--warn); }

/* ---------- app layout ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 4px 0 12px;
}
.loc-name { font-size: 20px; font-weight: 800; }
.stats { color: var(--muted); font-weight: 600; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  min-height: 48px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 16px; font-weight: 700; cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.panel { margin-bottom: 16px; }
.panel h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 8px 0;
}

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.row.prio { background: var(--prio-bg); }
.row.called { border-color: var(--primary); border-width: 2px; }
.row-info { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.row-info .code { font-size: 24px; font-weight: 800; }
.row-info .who {
  color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.row-info .wait { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-btns { display: flex; gap: 8px; flex-shrink: 0; }
.empty { color: var(--muted); padding: 12px; text-align: center; list-style: none; }

.settings { margin: 16px 0; color: var(--muted); }
.settings summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; }
.settings label { display: grid; gap: 6px; max-width: 280px; }
.settings input {
  min-height: 48px; padding: 8px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}

/* primary actions under the thumb */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; gap: 12px; max-width: 520px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}

/* ---------- modal + toast ---------- */
.modal {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  background: var(--card); border-radius: 16px; padding: 24px;
  text-align: center; width: 100%; max-width: 360px; display: grid; gap: 12px;
}
.huge-code { font-size: 72px; font-weight: 900; letter-spacing: 2px; }
.toast {
  position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%);
  z-index: 120; background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px; font-weight: 600;
  max-width: 90vw;
}

/* ---------- display page (wall TV, dark, huge) ---------- */
body.display {
  background: #0b1220; color: #f8fafc;
  min-height: 100vh; display: grid;
  grid-template-rows: auto 1fr auto; text-align: center;
}
.display-head {
  display: flex; justify-content: space-between; padding: 3vh 4vw;
  font-size: 3.5vmin; color: #94a3b8; font-weight: 700;
}
.display-main { align-self: center; }
.display-label {
  font-size: 4vmin; letter-spacing: 0.3em;
  color: #94a3b8; font-weight: 700;
}
.display-code { font-size: 28vmin; font-weight: 900; line-height: 1.05; }
.display-counter {
  font-size: 6vmin; color: #38bdf8; font-weight: 800; min-height: 1.2em;
}
.display-also {
  font-size: 4vmin; color: #94a3b8; font-weight: 700;
  min-height: 1.2em; margin-top: 1.5vh;
}
.display-next { padding: 3vh 4vw 5vh; }
.display-next ol {
  list-style: none; display: flex; justify-content: center; gap: 6vmin;
  margin: 1vh 0 0; padding: 0;
  font-size: 9vmin; font-weight: 800; color: #cbd5e1;
}

/* Phase 5: owners-only stats tab */
.topbar-btns { display: flex; gap: 8px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th, .stats-table td {
  padding: 10px 6px; text-align: right;
  border-bottom: 1px solid rgba(127, 127, 127, 0.35);
}
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }

/* Phase 7: branch selector (business owners with multiple branches) */
#branch-switch { margin: 2px 0 4px; }
.branch-label { font-size: 13px; opacity: 0.85; }
#branch-select { min-height: 36px; font-size: 15px; margin-left: 6px; }

/* ---- shop types: workers panel + NEXT picker (Phase 8) ---- */
.worker-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.worker-form input { flex: 1 1 120px; min-width: 0; }
.duty-toggle { display: flex; align-items: center; gap: 6px; }
.badge { font-size: 0.8rem; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.badge.free { background: #d9f2e3; color: #14532d; }
.badge.busy { background: #fde8d7; color: #7c2d12; }
.badge.off { background: #e5e7eb; color: #4b5563; }
.picker-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.picker-btn { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.picker-btn .badge { pointer-events: none; }
