/* Страница входа: телефон-первый (360–430 px), светлая и тёмная темы, без внешних ресурсов. */

:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --text: #101828;
  --muted: #475467;
  --accent: #0a58ca;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fc;
  --code: #eef3fa;
  --line: #d0d7e2;
  --ok: #05603a;
  --warn: #8a4b00;
  --danger: #b42318;
  --focus: #0a58ca;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #131d30;
    --text: #e8eef8;
    --muted: #b3bfd1;
    --accent: #8ab8ff;
    --accent-ink: #061225;
    --accent-soft: #15243d;
    --code: #0b1a33;
    --line: #33415c;
    --ok: #6fd6a4;
    --warn: #f5c26b;
    --danger: #ff9b92;
    --focus: #8ab8ff;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #131d30;
  --text: #e8eef8;
  --muted: #b3bfd1;
  --accent: #8ab8ff;
  --accent-ink: #061225;
  --accent-soft: #15243d;
  --code: #0b1a33;
  --line: #33415c;
  --ok: #6fd6a4;
  --warn: #f5c26b;
  --danger: #ff9b92;
  --focus: #8ab8ff;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.page {
  display: grid;
  gap: 16px;
  padding: 16px;
  align-content: center;
  min-height: 100dvh;
}

.card {
  display: grid;
  gap: 20px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.card[data-state="waiting"] { max-width: 880px; }

.main-col { display: grid; gap: 20px; min-width: 0; }

.head { display: grid; gap: 6px; }
.eyebrow { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.title { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.title:focus { outline: none; }
.lead { margin: 0; color: var(--muted); }

.status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-weight: 500;
}

.spinner {
  flex: none;
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.card[data-state="approved"] .status { color: var(--ok); }
.card[data-state="denied"] .status,
.card[data-state="forbidden"] .status,
.card[data-state="error"] .status { color: var(--danger); }
.card[data-state="expired"] .status,
.card[data-state="rateLimited"] .status { color: var(--warn); }

.actions { display: grid; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }

.btn:disabled {
  cursor: default;
  background: var(--accent-soft);
  color: var(--muted);
  border-color: var(--line);
}

.btn:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.code-block {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--code);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.label { margin: 0; font-weight: 600; color: var(--muted); }

.code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hint, .countdown { margin: 0; min-height: 1.5em; color: var(--muted); font-variant-numeric: tabular-nums; }

.steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 1.4em;
  color: var(--muted);
}

.qr-col { display: grid; justify-items: center; gap: 10px; }

.qr {
  width: min(256px, 100%);
  padding: 12px;
  background: #ffffff;
  border-radius: 16px;
  line-height: 0;
}

.qr-svg { display: block; width: 100%; height: auto; }

.qr-caption { margin: 0; text-align: center; color: var(--muted); }

.footnote {
  margin: 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted);
}

@media (min-width: 880px) {
  .card[data-state="waiting"] {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
    column-gap: 32px;
    padding: 28px;
  }
  .card[data-state="waiting"] .qr-col { grid-column: 1; grid-row: 1; }
  .card[data-state="waiting"] .main-col { grid-column: 2; grid-row: 1; }
  .code { font-size: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
