:root {
  /* Palau BRT brand: Navy (ink), Blue (primary accent), Yellow (spotlight — used sparingly) */
  --paper: #EEF1F7;
  --card: #FFFFFF;
  --ink: #212766;
  --ink-soft: #5C5F92;
  --line: #CBD1E4;
  --accent: #0099FF;
  --accent-strong: #0075C4;
  --accent-wash: #E1F3FF;
  --gold: #FFE600;
  --gold-border: #8A7500;
  --gold-wash: #FFF9CC;
  --queue: #2E6E63;
  --queue-wash: #E1EEEA;
  --danger: #B23B2E;
  --danger-wash: #F7E3DF;
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12131F;
    --card: #1B1D33;
    --ink: #E9ECF7;
    --ink-soft: #9CA3C9;
    --line: #2E3155;
    --accent: #3DAFFF;
    --accent-strong: #0075C4;
    --accent-wash: #163049;
    --gold: #FFE600;
    --gold-border: #E6C700;
    --gold-wash: #332E10;
    --queue: #5FB6A5;
    --queue-wash: #17302B;
    --danger: #E0574A;
    --danger-wash: #3A1E1B;
  }
}
:root[data-theme="dark"] {
  --paper: #12131F;
  --card: #1B1D33;
  --ink: #E9ECF7;
  --ink-soft: #9CA3C9;
  --line: #2E3155;
  --accent: #3DAFFF;
  --accent-strong: #0075C4;
  --accent-wash: #163049;
  --gold: #FFE600;
  --gold-border: #E6C700;
  --gold-wash: #332E10;
  --queue: #5FB6A5;
  --queue-wash: #17302B;
  --danger: #E0574A;
  --danger-wash: #3A1E1B;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100vh; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 3px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0.85rem 1.3rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--card); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-wash); }
.btn-treasury { background: var(--queue); color: #fff; }
.btn-treasury:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

.status-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-display); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.3rem 0.7rem 0.3rem 0.55rem;
}
.status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--ink-soft); }
.status-pill.is-live .status-dot { background: var(--queue); box-shadow: 0 0 0 3px var(--queue-wash); }
.window-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-display); font-size: 0.78rem; font-weight: 700;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.3rem 0.5rem 0.3rem 0.85rem;
}
.window-badge button { background: none; border: none; color: var(--ink-soft); font-size: 0.72rem; cursor: pointer; text-decoration: underline; font-family: var(--font-body); padding: 0.2rem 0.4rem; }

/* ---------- Home ---------- */
.home-shell {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 6vh 1.5rem 4rem; gap: 3.4rem; text-align: center;
}
.home-shell h1 { font-size: clamp(2.1rem, 5vw, 3rem); letter-spacing: -0.01em; }
.home-shell .eyebrow { margin-bottom: 0.6rem; }
.home-brand { display: flex; flex-direction: column; align-items: center; }
.home-seal { width: 88px; height: auto; margin-bottom: 1.1rem; }
.office-block { width: min(920px, 100%); text-align: left; }
.office-block h2 { font-size: 1.05rem; margin-bottom: 1rem; padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.6rem 1.5rem; text-align: left; text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: 0.6rem; transition: transform 0.12s ease, border-color 0.12s ease;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent-strong); }
.tile .tile-kicker { font-family: var(--font-mono); color: var(--accent-strong); font-size: 0.78rem; }
.tile h3 { font-size: 1.2rem; font-family: var(--font-display); }
.tile p { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.5; }

/* ---------- Shared view chrome ---------- */
.view-shell { min-height: 100vh; padding: 1.4rem clamp(1rem, 3vw, 2.2rem) 3rem; }
.view-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 1.2rem; margin-bottom: 1.6rem; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.view-header h1 { font-size: 1.4rem; }
.back-link { font-size: 0.82rem; color: var(--ink-soft); text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.back-link:hover { color: var(--ink); }
.header-left { display: flex; flex-direction: column; gap: 0.3rem; }
.header-right { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.clock { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink-soft); }

/* ---------- Counter ---------- */
.window-prompt { max-width: 26rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.8rem 1.7rem; display: flex; flex-direction: column; gap: 1rem; }
.window-prompt input { font-size: 1.4rem; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); width: 6rem; font-family: var(--font-mono); }

.serving-card {
  background: var(--card); border: 1.5px solid var(--gold-border); border-radius: 10px;
  padding: 1.4rem 1.5rem; margin-bottom: 1.4rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.serving-card.is-empty { border-color: var(--line); }
.serving-name { font-size: 1.5rem; font-weight: 700; font-family: var(--font-display); }
.serving-meta { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.2rem; }
.serving-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.counter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.cat-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; }
.cat-name { font-size: 1.05rem; font-weight: 700; }
.cat-stats { display: flex; gap: 1.4rem; }
.cat-stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.cat-stat-label { font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 0.3rem; display: block; }
.cat-stat.waiting .cat-stat-value { color: var(--queue); }
.cat-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.queue-panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.6rem 1.7rem; display: flex; flex-direction: column; gap: 1rem; }
.queue-panel-main { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.queue-count { font-size: 2.6rem; font-weight: 700; line-height: 1; color: var(--queue); }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.queue-next-hint { font-size: 0.85rem; color: var(--ink-soft); }
.cat-breakdown { display: flex; gap: 0.6rem; flex-wrap: wrap; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.cat-chip { font-size: 0.82rem; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.8rem; color: var(--ink-soft); }
.cat-chip b { font-family: var(--font-mono); color: var(--ink); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.3rem 1.4rem; margin-top: 1.6rem; }
.panel summary { cursor: pointer; font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::before { content: '+'; color: var(--accent-strong); font-size: 1.1rem; width: 1rem; }
.panel[open] summary::before { content: '\2212'; }
.panel-body { padding-top: 1.1rem; display: flex; flex-direction: column; gap: 1rem; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.cat-row:last-child { border-bottom: none; }
.add-cat-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0.05em; text-transform: uppercase; }
.field input {
  font-family: var(--font-body); font-size: 0.92rem; padding: 0.6rem 0.7rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink);
}
.field input:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 1px; }
.field.name input { width: 14rem; }
.inline-msg { font-size: 0.82rem; color: var(--danger); min-height: 1.1em; }
.confirm-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.confirm-text { font-size: 0.85rem; color: var(--ink-soft); }
.log-textarea {
  width: 100%; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.4;
  padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); resize: vertical;
}

/* ---------- Access gate (staff login) ---------- */
.gate-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.gate-card { width: min(360px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 2.2rem 1.9rem; text-align: center; }
.gate-card h1 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.gate-card p { color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 1.4rem; }
.gate-card input { width: 100%; font-size: 1.1rem; padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-family: var(--font-body); text-align: center; margin-bottom: 1rem; }

/* ---------- Kiosk ---------- */
.kiosk-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 3.5vh 1.5rem 3rem; }
.kiosk-header { text-align: center; margin-bottom: 2.5rem; }
.kiosk-header h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.kiosk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.2rem; width: min(880px, 100%); }
.kiosk-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 2.2rem 1.6rem; text-align: center; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 0.8rem;
  font-family: inherit; transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.kiosk-card:hover { transform: translateY(-3px); border-color: var(--accent-strong); background: var(--accent-wash); }
.kiosk-card .kiosk-mark {
  width: 3.2rem; height: 3.2rem; border-radius: 999px; background: var(--accent-wash); color: var(--accent-strong);
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
}
.kiosk-card h2 { font-size: 1.1rem; }
.kiosk-card .kiosk-wait { font-size: 0.82rem; color: var(--ink-soft); }

.name-wrap { width: min(420px, 100%); margin-top: 1rem; }
.name-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 2rem 1.8rem; }
.name-card label { display: block; font-size: 0.78rem; color: var(--ink-soft); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 0.6rem; }
.name-card input {
  width: 100%; font-size: 1.3rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); color: var(--ink); font-family: var(--font-body);
}
.name-actions { display: flex; gap: 0.7rem; margin-top: 1.3rem; }
.name-actions .btn { flex: 1; }

.ticket-wrap { width: min(420px, 100%); margin-top: 1rem; }
.ticket {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 2.4rem 1.8rem; text-align: center; position: relative;
}
.ticket-eyebrow { color: var(--ink-soft); }
.ticket-name { font-size: clamp(2rem, 7vw, 2.8rem); font-weight: 700; font-family: var(--font-display); color: var(--accent-strong); line-height: 1.15; margin: 0.7rem 0 1.2rem; text-wrap: balance; }
.ticket-divider { border: none; border-top: 2px dashed var(--line); margin: 1.3rem 0; }
.ticket-ahead { font-size: 1rem; color: var(--ink-soft); }
.ticket-ahead b { color: var(--ink); font-family: var(--font-mono); }
.ticket-actions { margin-top: 1.6rem; }

/* ---------- Display (fixed dark-navy board, explicit palette — Palau Navy/Blue/Yellow) ---------- */
.board {
  min-height: 100vh; background: #12142B; color: #F0F2FB;
  padding: 2rem clamp(1rem, 3vw, 3rem) 2.5rem; display: flex; flex-direction: column; gap: 1.8rem;
}
.board-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.6rem; }
.board-title { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; letter-spacing: 0.02em; }
.board-clock { font-family: var(--font-mono); font-size: 1rem; color: #8286B8; }
.board-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: #6E71A0; font-size: 1.1rem; text-align: center; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; }
.board-card {
  background: #191B36; border: 1px solid #2C2F55; border-radius: 10px;
  padding: 1.5rem 1.6rem 1.7rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.board-card.is-fresh { animation: board-pulse 1.8s ease-in-out 2; border-color: #FFE600; }
@keyframes board-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,230,0,0); }
  50% { box-shadow: 0 0 0 8px rgba(255,230,0,0.16); }
}
.board-window-label { font-family: var(--font-display); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #4FB6FF; }
.board-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.9rem, 4.4vw, 2.6rem); line-height: 1.1; color: #FFE600; text-wrap: balance; }
.board-cat-label { font-size: 0.9rem; color: #A6ABD6; }
.board-queue-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.board-chip { font-size: 0.85rem; background: #191B36; border: 1px solid #2C2F55; border-radius: 999px; padding: 0.35rem 0.85rem; color: #C3C7E8; }
.board-chip b { font-family: var(--font-mono); color: #4FB6FF; }
.board-recent { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: #6E71A0; }
.board-recent b { color: #A6ABD6; font-weight: 500; }
.board-footer { text-align: center; color: #5C5F8F; font-size: 0.78rem; }
.board-section-label { font-size: 0.72rem; color: #6E71A0; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.7rem; }

/* ---------- Loading ---------- */
.loading-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 0.9rem; }
