:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --text: #111827;
  --muted: #4B5563;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --blue: #1D4ED8;
  --blue-dark: #1E3A8A;
  --blue-soft: #EFF4FF;
  --orange: #C2410C;
  --orange-text: #9A3412;
  --orange-deep: #7C2D12;
  --orange-soft: #FFF4EC;
  --gray-card: #E5E7EB;
  --danger: #B91C1C;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input { font-family: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
a { color: var(--blue); }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- generic ---------- */
.center-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn {
  height: 60px; width: 100%; border: 0; border-radius: 16px;
  font-size: 18px; font-weight: 700; color: #FFFFFF; background: var(--blue);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:active { filter: brightness(0.92); }
.btn.big { height: 64px; border-radius: 18px; }
.btn.orange { background: var(--orange); }
.btn.ghost { background: transparent; color: var(--muted); height: 48px; font-size: 15px; font-weight: 600; }
.btn.outline { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); height: 52px; font-size: 16px; }
.btn.danger-text { background: transparent; color: var(--danger); height: 48px; font-size: 15px; font-weight: 600; }

.pill-btn {
  height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; font-weight: 600; }
.field input {
  height: 54px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: 14px;
  background: var(--surface); font-size: 17px; color: var(--text); width: 100%;
}
.field input:focus { outline: none; border: 2px solid var(--blue); padding: 0 15px; }
.field input.code-input { font-size: 20px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 1em; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
}
.switch-row .t { display: flex; flex-direction: column; gap: 2px; }
.switch-row .t b { font-size: 16px; font-weight: 600; }
.switch-row .t span { font-size: 13px; color: var(--muted); }
.switch-row input { width: 26px; height: 26px; accent-color: var(--blue); flex-shrink: 0; }

/* ---------- avatars ---------- */
.avatar {
  border-radius: 50%; color: #FFFFFF; font-weight: 700; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  width: 40px; height: 40px; font-size: 14px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.md { width: 48px; height: 48px; font-size: 16px; }
.avatar.xl { width: 112px; height: 112px; font-size: 38px; font-weight: 800; }
button.avatar { border: 0; padding: 0; }

/* ---------- onboarding ---------- */
.onboard { flex: 1; display: flex; flex-direction: column; gap: 24px; padding: 64px 24px 32px; }
.logo {
  width: 72px; height: 72px; border-radius: 22px; background: var(--blue); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
}
.onboard h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.1; }
.onboard p.lead { margin: 8px 0 0; font-size: 17px; line-height: 1.5; color: var(--muted); }
.card-box {
  display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border);
}
.card-box .center { text-align: center; font-size: 15px; color: var(--muted); }
.spacer { flex: 1; }

/* ---------- main layout ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 100dvh; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 20px 14px; }
.topbar .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar .team { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.content { flex: 1; padding-bottom: 12px; }
.actions {
  position: sticky; bottom: 68px; padding: 12px 16px 8px;
  background: linear-gradient(to bottom, rgba(246,247,249,0), var(--bg) 18px);
  display: flex; flex-direction: column; gap: 2px;
}
nav.tabs {
  position: sticky; bottom: 0; display: flex; justify-content: space-around; height: 68px;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: 500;
}
nav.tabs button.on { color: var(--blue); font-weight: 700; }

/* ---------- status cards ---------- */
.status { margin: 0 16px; padding: 20px; border-radius: 20px; display: flex; align-items: center; gap: 16px; }
.status.queue { background: var(--blue); color: #FFFFFF; justify-content: space-between; }
.status.queue .l { display: flex; flex-direction: column; gap: 4px; }
.status.queue .small { font-size: 14px; font-weight: 500; opacity: 0.9; }
.status.queue .pos { font-size: 60px; font-weight: 800; line-height: 1; letter-spacing: -2px; }
.status.queue .msg { font-size: 15px; font-weight: 500; }
.status.queue .code {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 16px;
  border-radius: 14px; background: rgba(255,255,255,0.16);
}
.status.queue .code span { font-size: 12px; font-weight: 500; }
.status.queue .code b { font-size: 26px; font-weight: 800; }
.status.trip { background: var(--orange-soft); border: 2px solid var(--orange); }
.status.off { background: var(--surface); border: 1px solid var(--border); }
.status .ico {
  width: 56px; height: 56px; border-radius: 16px; color: #FFFFFF; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.status.trip .ico { background: var(--orange); }
.status.off .ico { background: var(--muted); }
.status .txt { display: flex; flex-direction: column; gap: 4px; }
.status .txt b { font-size: 20px; font-weight: 800; }
.status.trip .txt b { color: var(--orange-text); }
.status.trip .txt span { color: var(--orange-deep); font-size: 15px; }
.status.off .txt span { color: var(--muted); font-size: 15px; }

/* ---------- lists ---------- */
h2.section {
  margin: 0; padding: 22px 20px 10px; font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.list { margin: 0 16px; background: var(--surface); border-radius: 16px; border: 1px solid var(--border); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--border); }
.row.me { background: var(--blue-soft); }
.row .num { width: 24px; font-size: 17px; font-weight: 800; color: var(--muted); text-align: center; flex-shrink: 0; }
.row .num.first { color: var(--blue); }
.row .info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row .info b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.me .info b { font-weight: 700; }
.row .info span { font-size: 13px; color: var(--muted); }
.row .dur { font-size: 13px; font-weight: 600; color: var(--muted); flex-shrink: 0; }
.tag { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; flex-shrink: 0; }
.tag.blue { color: var(--blue); background: var(--blue-soft); }
.tag.orange { color: var(--orange-text); background: var(--orange-soft); }
.empty { padding: 20px 16px; text-align: center; color: var(--muted); font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 16px; }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.chip b { font-size: 14px; font-weight: 600; }
.chip span { font-size: 13px; color: var(--muted); }

.filters { display: flex; gap: 8px; padding: 0 16px 4px; flex-wrap: wrap; }
.filters button {
  height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
}
.filters button.on { background: var(--text); color: #FFFFFF; border-color: var(--text); }

/* ---------- profile ---------- */
.profile { display: flex; flex-direction: column; gap: 18px; padding: 8px 20px 24px; }
.photo-box { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0 4px; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.team-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.team-card .code-big { font-size: 24px; font-weight: 800; letter-spacing: 1px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.install-banner {
  margin: 0 16px 12px; padding: 12px 14px; border-radius: 14px; background: var(--blue-soft);
  display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--blue-dark); font-weight: 500;
}
.install-banner span { flex: 1; }
.install-banner button { height: 40px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--blue); color: #FFFFFF; font-weight: 700; font-size: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 160px; transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 32px); background: var(--text); color: #FFFFFF; padding: 12px 18px;
  border-radius: 12px; font-size: 15px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 10;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
