:root {
  --brand: #2f5bea;
  --brand-ink: #ffffff;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #161b26;
  --muted: #5d6475;
  --line: #d6dbe6;
  --error: #c62828;
  --error-bg: #fdecea;
  --warn-bg: #fff4d6;
  --ok: #1b8a4b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7c9bff;
    --brand-ink: #0b1020;
    --bg: #0e121b;
    --surface: #171c28;
    --ink: #e8ebf2;
    --muted: #9aa3b5;
    --line: #2c3344;
    --error: #ff8a80;
    --error-bg: #3a1c1c;
    --warn-bg: #3a3218;
    --ok: #5fd08f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar__inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar__logo { border-radius: 8px; flex: none; }
.topbar__text { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 1.1rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar p { margin: 0; font-size: 0.8rem; color: var(--muted); }
.topbar p:empty { display: none; }

.pill { font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.pill--offline { display: none; background: var(--warn-bg); color: var(--ink); }
.is-offline .pill--offline { display: inline-block; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }

/* ---------- layout ---------- */
.container { max-width: 680px; margin: 0 auto; padding: 16px; outline: none; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.center { text-align: center; display: grid; justify-items: center; gap: 12px; padding: 40px 20px; }
.center p { margin: 0; max-width: 46ch; color: var(--muted); }

.status { max-width: 680px; margin: 0 auto; padding: 12px 16px 0; display: grid; gap: 8px; }
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  font-size: 0.9rem;
}
.banner--offline { background: var(--warn-bg); }
.banner--error { background: var(--error-bg); }

/* ---------- form ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.label { font-weight: 600; font-size: 0.92rem; padding: 0; }
.req { color: var(--error); }
.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  appearance: none;
  -webkit-appearance: none;
}
textarea.input { resize: vertical; min-height: 96px; }
select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.input:disabled { opacity: 0.6; }
.has-error .input { border-color: var(--error); }
.error { margin: 0; color: var(--error); font-size: 0.84rem; }
.warn { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); font-size: 0.88rem; }

.affix { position: relative; }
.affix .input { padding-right: 36px; }
.suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input, .chip input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  cursor: pointer;
  font-size: 0.92rem;
}
.chip input { margin: 0; width: 16px; height: 16px; }
.chip:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
.has-error .chip { border-color: var(--error); }

.subgrid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 520px) {
  .subgrid--name { grid-template-columns: 1fr 1fr; }
  .subgrid--address { grid-template-columns: 1fr 1fr; }
  .subgrid--address .sub:nth-child(-n + 2) { grid-column: 1 / -1; }
}
.sub { display: grid; gap: 4px; }
.sublabel { font-size: 0.8rem; color: var(--muted); }

.actions { display: grid; gap: 8px; margin-top: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:hover { filter: brightness(1.06); }
.btn--outline { background: transparent; color: var(--brand); border-color: currentColor; }
.btn--text { background: transparent; color: var(--brand); padding: 0 10px; min-height: 36px; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 0.85rem; }
.btn--block { width: 100%; min-height: 52px; font-size: 1.02rem; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- states ---------- */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.icon-circle {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 1.9rem;
  font-weight: 700;
}
.icon-circle--ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.icon-circle--warn { background: var(--warn-bg); }
.icon-circle--error { background: var(--error-bg); color: var(--error); }
.result h2 { margin: 4px 0 0; outline: none; }
.booking-id { display: grid; gap: 2px; padding: 12px 20px; border-radius: 10px; background: var(--bg); color: var(--ink) !important; }
.booking-id span { font-size: 0.8rem; color: var(--muted); }
.booking-id strong { font-size: 1.15rem; letter-spacing: 0.02em; word-break: break-all; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px;
  border-radius: 10px;
  background: #1f2433;
  color: #fff;
  font-size: 0.92rem;
  box-shadow: 0 8px 24px rgb(0 0 0 / 25%);
}
.toast .btn--text { color: #9db4ff; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
