:root {
  --bg: #f6f3ee;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e0d6;
  --card: #fffcf8;
  --blue: #1d4ed8;
  --blue-ink: #fff;
  --gold: #b45309;
  --ok: #166534;
  --bad: #b91c1c;
  --wait: #a16207;
  --shadow: 0 10px 30px rgba(28, 25, 23, .06);
  font-family: "Segoe UI", "Noto Sans", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.03em; }
h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
button, input, select, textarea { font: inherit; }
.kicker { margin: 0; color: var(--gold); font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
.muted { color: var(--muted); font-size: .9rem; }
.err { color: var(--bad); font-size: .9rem; }
.top, main, .stats, .tabs { width: min(1100px, calc(100% - 28px)); margin-inline: auto; }
.top { display: flex; justify-content: space-between; align-items: end; padding: 28px 0 8px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px auto; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: .78rem; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab, .btn, .ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; text-decoration: none;
}
.tab.on, .btn { background: var(--blue); color: var(--blue-ink); border-color: var(--blue); }
.btn.ghost, a.btn.ghost { background: transparent; color: var(--ink); }
.panel { padding-bottom: 48px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.row input, .row select, label input, label select, label textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 10px; width: 100%;
}
#qCust { min-width: 220px; flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow);
}
.class-card header, .person, .reg { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.code { font-weight: 700; }
.pill { font-size: .72rem; border-radius: 999px; padding: 3px 8px; background: #eef2ff; color: var(--blue); font-weight: 700; }
.pill.wait { background: #fef3c7; color: var(--wait); }
.pill.bad, .pill.cancelled, .pill.closed { background: #fee2e2; color: var(--bad); }
.pill.ok, .pill.confirmed, .pill.open { background: #dcfce7; color: var(--ok); }
.bar { height: 8px; background: #efeae3; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.low i { background: var(--gold); }
.bar.full i { background: var(--bad); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.actions button { border: 0; background: #f3efe8; border-radius: 8px; padding: 6px 8px; cursor: pointer; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate[hidden] { display: none !important; }
#app[hidden] { display: none !important; }
.gate-card, .dialog { width: min(460px, 100%); }
.gate-card h1, .dialog h2 { margin-bottom: 8px; }
#pin { font-size: 1.35rem; letter-spacing: .04em; font-weight: 700; }
#pinEcho { margin: 4px 0 12px; min-height: 1.2em; word-break: break-all; color: var(--ink); font-weight: 700; }
label { display: block; margin: 10px 0; font-size: .85rem; color: var(--muted); }
dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(28,25,23,.35); }
.log { white-space: pre-wrap; background: #1c1917; color: #f6f3ee; border-radius: 12px; padding: 12px; min-height: 48px; }
.note { margin: 8px 0 0; font-size: .85rem; color: var(--gold); }
@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .top { align-items: start; }
}
