:root {
  /* Светлая шкала с лёгким холодным оттенком (~215°): страница, белые панели, заливки.
     Обводок нет: поля, кнопки и подложки отделяются заливкой. */
  --bg: #f1f4f8;            /* страница и подложка служебных данных */
  --surface: #ffffff;       /* карточки */
  --fill: #eef1f6;          /* поля ввода и кнопки сумм */
  --fill-hover: #e5e9f0;

  --text: #111827;          /* основной, 17.7:1 на белом */
  --text-2: #4b5565;        /* вторичный, 7.5:1 */
  --muted: #636d7f;         /* подсказки и мета, 4.6:1 и на странице */
  --placeholder: #7d8698;

  /* Один акцент */
  --accent: #2466dc;        /* кнопка (белый текст 5.2:1), выбор */
  --accent-hover: #1f5bc8;
  --accent-soft: rgba(36, 102, 220, 0.10);
  --accent-ring: rgba(36, 102, 220, 0.18);

  --error: #d92d20;
  --error-soft: rgba(217, 45, 32, 0.08);
  --positive: #16a34a;
  --positive-soft: rgba(22, 163, 74, 0.10);

  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.04);

  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 150ms;
}

* { box-sizing: border-box; }

/* hidden всегда прячет, даже если у элемента свой display */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); }

.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* =========================================================================
   Раскладка: слева баннер и текущий шаг, справа панель оплаты
   ========================================================================= */

.page {
  min-height: 100vh;
  padding: 40px 24px 64px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  align-items: start;
  max-width: 1040px;
  margin: 0 auto;
}

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

.card {
  padding: 28px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

/* =========================================================================
   Баннер — единственная насыщенная вещь на экране
   ========================================================================= */

/* Тёмно-синий слева, к правому краю светлеет до нашего акцента */
.banner {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 112px;
  padding: 24px 32px;
  border-radius: 20px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 50%),
    linear-gradient(90deg, #0a1733 0%, #0c1f4a 48%, #1a4fbd 82%, #2f78f2 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 1px 2px rgba(17, 24, 39, 0.08),
    0 16px 32px -20px rgba(10, 23, 51, 0.5);
}

.banner__logo {
  display: block;
  flex: none;
  width: 56px;
  height: 56px;
  fill: #fff;
}

.banner__body { min-width: 0; }

.banner__title {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 500;
}

.banner__text {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: #bac5d9; /* не ниже 4.9:1 там, где кончается строка */
}

/* =========================================================================
   Шаги
   ========================================================================= */

.step { animation: step-in 300ms var(--ease); }

@keyframes step-in {
  from { opacity: 0; transform: translateY(6px); }
}

.step__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.step__title {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 500;
}

/* Заголовок получает фокус программно при смене шага, с клавиатуры до него не дойти */
.step__title:focus { outline: none; }

/* Поля */

.field + .field { margin-top: 28px; }

.field__label {
  display: block;
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
}

.field__control { position: relative; }

.field__input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--fill);
  border: 0;
  border-radius: 14px;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* не меньше 16, иначе iOS зумит при фокусе */
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.field__input::placeholder { color: var(--placeholder); }
.field__input:hover { background: var(--fill-hover); }

/* Кольцо только у поля в фокусе и у поля с ошибкой — это смысл, а не украшение */
.field__input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-ring);
}

/* Логин — точный идентификатор: моноширинный, чтобы l/I/1 и 0/O не путались */
.field__input--mono { font-family: var(--font-mono); }
.field__input--mono::placeholder { font-family: var(--font); }

.field__input--help { padding-right: 136px; }
.field__input--suffixed { padding-right: 40px; }
.field.has-value .field__input--suffixed { padding-right: 76px; }

/* «Где найти?» — белая плашка внутри серого поля */
.field__help {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}

.field__help:hover { color: var(--text); }
.field__help[aria-expanded="true"] { color: var(--accent); }

.help {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 20px;
  color: var(--text-2);
  animation: step-in 200ms var(--ease);
}

.help p { margin: 0; }
.help p + p { margin-top: 4px; }

.field__suffix {
  position: absolute;
  top: 50%;
  right: 16px;
  margin-top: -11px;
  font-size: 16px;
  line-height: 22px;
  color: var(--muted);
  pointer-events: none;
  transition: transform var(--dur) var(--ease);
}

/* Когда есть крестик, ₽ отходит левее */
.field.has-value .field__suffix { transform: translateX(-36px); }

.field__clear {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.field__clear:hover {
  background: var(--fill-hover);
  color: var(--text);
}

.field__msg {
  min-height: 16px;
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 16px;
  color: var(--muted);
}

.field.is-invalid .field__input { box-shadow: inset 0 0 0 1.5px var(--error); }
.field.is-invalid .field__input:focus { box-shadow: inset 0 0 0 1.5px var(--error), 0 0 0 4px var(--error-soft); }
.field.is-invalid .field__msg { color: var(--error); }

/* Быстрый выбор суммы */

.presets {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.preset {
  flex: 1 1 0;
  min-width: 0;
  height: 40px;
  padding: 0 4px;
  background: var(--fill);
  border: 0;
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.preset:hover { background: var(--fill-hover); }
.preset.is-active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 500; }
.preset:active { transform: scale(0.97); }

/* Кнопки */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 20px;
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.btn--lg {
  height: 56px;
  font-size: 16px;
}

.btn:hover { background: var(--accent-hover); }
.btn:not(:disabled):active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn--secondary {
  background: var(--fill);
  color: var(--text);
}

.btn--secondary:hover { background: var(--fill-hover); }

/* Кнопка-иконка «Назад» */

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin-left: -8px; /* иконка встаёт на край контента */
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--fill);
  color: var(--text);
}

/* Текстовая кнопка */

.link-btn {
  display: block;
  width: 100%;
  height: 40px;
  margin-top: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--accent);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.link-btn:hover { color: var(--accent-hover); background: var(--accent-soft); }

.preset:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
.link-btn:focus-visible,
.field__help:focus-visible,
.field__clear:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =========================================================================
   Панель оплаты справа
   ========================================================================= */

.checkout {
  position: sticky;
  top: 24px;
  padding: 28px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
}

.checkout__label {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
}

/* Выбранный способ — заливкой, без рамки */
.method {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--accent-soft);
}

.method__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
}

.method__logo {
  display: block;
  width: 23px;
  height: 28px;
}

.method__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.method__name {
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
}

.method__text {
  font-size: 13px;
  line-height: 16px;
  color: var(--text-2);
}

.method__check {
  margin: 0 4px 0 auto;
  color: var(--accent);
}

.checkout__list { margin: 24px 0 0; }

.checkout__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 15px;
  line-height: 20px;
}

.checkout__row + .checkout__row { margin-top: 12px; }

.checkout__row dt { flex: none; color: var(--text-2); }

.checkout__row dd {
  min-width: 0;
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.checkout .is-empty { color: var(--placeholder); }

.checkout__row dd,
.checkout__sum { transition: color var(--dur) var(--ease); }

/* Итог отделён тонкой линией цвета заливки */
.checkout__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  background: linear-gradient(var(--fill), var(--fill)) top / 100% 1px no-repeat;
  color: var(--text-2);
}

.checkout__sum {
  font-size: 32px;
  line-height: 40px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.checkout__action { margin-top: 24px; }

.checkout__note {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  color: var(--muted);
}

.checkout__legal {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: var(--muted);
}

.checkout__legal a,
.footer-links a {
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: rgba(75, 85, 101, 0.35);
  text-underline-offset: 2px;
  border-radius: 4px;
  transition: color var(--dur) var(--ease), text-decoration-color var(--dur) var(--ease);
}

.checkout__legal a:hover,
.footer-links a:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

/* Ссылки внутри документов (почта поддержки) — акцентом, чтобы их было видно в тексте */
.doc a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(36, 102, 220, 0.35);
  text-underline-offset: 2px;
  border-radius: 4px;
  transition: text-decoration-color var(--dur) var(--ease);
}

.doc a:hover { text-decoration-color: currentColor; }

.status {
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  color: var(--muted);
}

.status:empty { display: none; }
.status.is-error { color: var(--error); }

/* После создания платежа вместо кнопки — его дата и номер */
.checkout__meta {
  margin: 24px 0 0;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg);
}

.checkout__meta .checkout__row {
  font-size: 13px;
  line-height: 20px;
}

.checkout__meta .checkout__row + .checkout__row { margin-top: 8px; }

.checkout__row--stack { display: block; }

.checkout__row--stack dd {
  margin-top: 4px;
  text-align: left;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
}

/* =========================================================================
   Шаг 2. Оплата через СБП
   ========================================================================= */

/* Знак СБП, состояние, кнопка и таймер — по центру, как на экране результата.
   data-state="creating": вместо знака индикатор, кнопка неактивна, таймера нет */
.pay {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 360px;
  margin: 0 auto;
  padding: 8px 0 4px;
  text-align: center;
}

.pay__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 20px;
  background: var(--accent-soft);
}

/* Индикатор и знак лежат в одной ячейке и сменяют друг друга */
.pay__logo,
.pay__spinner {
  grid-area: 1 / 1;
  transition: opacity 200ms var(--ease), scale 200ms var(--ease);
}

.pay__logo {
  display: block;
  width: 27px;
  height: 33px;
}

.pay__spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(36, 102, 220, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pay-spin 800ms linear infinite;
}

@keyframes pay-spin {
  to { rotate: 1turn; }
}

.pay[data-state="creating"] .pay__logo { opacity: 0; scale: 0.8; }

.pay[data-state="ready"] .pay__spinner {
  opacity: 0;
  scale: 0.8;
  animation-play-state: paused;
}

.pay__title {
  margin: 0;
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
}

.pay__text {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 22px;
  color: var(--text-2);
  text-wrap: balance; /* на телефоне без одинокого «банка» на второй строке */
}

.pay__link {
  gap: 8px;
  margin-top: 24px;
}

/* Ссылки ещё нет: кнопка видна, но не нажимается */
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* Место под таймер занято заранее, чтобы при появлении ссылки ничего не прыгало */
.wait {
  align-self: stretch;
  margin-top: 20px;
  text-align: left;
  transition: opacity 200ms var(--ease);
}

.pay[data-state="creating"] .wait {
  opacity: 0;
  visibility: hidden;
}

.wait__row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 16px;
  color: var(--text-2);
}

/* Живой статус: точка дышит, пока сервер ждёт подтверждения от банка */
.wait__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--accent);
  animation: wait-pulse 1.6s ease-in-out infinite;
}

@keyframes wait-pulse {
  50% { opacity: 0.35; }
}

.wait__timer {
  margin-left: auto;
  font-family: var(--font-mono);
  color: var(--muted);
}

/* Сколько осталось от срока ссылки; app.js сжимает полосу через transform */
.wait__track {
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--fill);
}

.wait__bar {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: left center;
}

/* =========================================================================
   Шаг 3. Результат
   ========================================================================= */

.result {
  padding: 40px 28px;
  text-align: center;
}

.result__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 28px;
  background: var(--fill);
  color: var(--muted);
}

.result[data-tone="positive"] .result__icon {
  background: var(--positive-soft);
  color: var(--positive);
}

.result[data-tone="negative"] .result__icon {
  background: var(--error-soft);
  color: var(--error);
}

.result .step__title { margin-bottom: 8px; }

.result__text {
  max-width: 360px;
  margin: 0 auto 24px;
  font-size: 15px;
  line-height: 22px;
  color: var(--text-2);
}

.result__actions {
  max-width: 320px;
  margin: 0 auto;
}

/* =========================================================================
   Ссылки на документы внизу страницы
   ========================================================================= */

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  margin-top: 32px;
  font-size: 13px;
  line-height: 20px;
}

/* Текущий документ — без подчёркивания, просто текстом */
.footer-links a[aria-current="page"] {
  color: var(--muted);
  text-decoration: none;
  pointer-events: none;
}

.checkout__legal a:focus-visible,
.footer-links a:focus-visible,
.doc a:focus-visible,
.doc-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =========================================================================
   Страницы документов: политика и соглашение
   ========================================================================= */

.doc-shell {
  max-width: 760px;
  margin: 0 auto;
}

.doc-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  margin: 0 0 16px -6px;
  padding: 0 12px 0 6px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.doc-back:hover {
  background: var(--fill);
  color: var(--text);
}

.doc { padding: 40px; }

.doc__title {
  margin: 0;
  font-size: 28px;
  line-height: 36px;
  font-weight: 500;
}

.doc__date {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--muted);
}

/* Краткое содержание в начале и итоговая фраза в конце — на подложке */
.doc__lead {
  margin: 24px 0 0;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--bg);
  font-size: 15px;
  line-height: 24px;
  color: var(--text-2);
}

.doc__lead--end { margin-top: 32px; }

.doc h2 {
  margin: 32px 0 12px;
  font-size: 18px;
  line-height: 26px;
  font-weight: 500;
}

.doc p:not([class]),
.doc li {
  font-size: 15px;
  line-height: 24px;
}

.doc section p { margin: 0; }
.doc section p + p { margin-top: 8px; }

.doc ul {
  margin: 8px 0 0;
  padding-left: 24px;
}

.doc li + li { margin-top: 4px; }
.doc li::marker { color: var(--muted); }
.doc section ul + p { margin-top: 12px; }

.doc__num { color: var(--muted); }

/* =========================================================================
   Узкие экраны
   ========================================================================= */

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
  }

  .checkout { position: static; }
}

@media (max-width: 640px) {
  .page { padding: 16px 16px 32px; }

  .shell,
  .main { gap: 16px; }

  /* Подпись тянется почти до края, поэтому светлая часть уже, а текст светлее */
  .banner {
    gap: 16px;
    min-height: 0;
    padding: 20px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 50%),
      linear-gradient(90deg, #0a1733 0%, #0c1f4a 56%, #1a4fbd 92%, #2f78f2 100%);
  }

  .banner__text { color: #dbe3f0; }

  .banner__logo {
    width: 44px;
    height: 44px;
  }

  .banner__title {
    font-size: 20px;
    line-height: 28px;
  }

  .banner__text {
    font-size: 13px;
    line-height: 20px;
  }

  .card,
  .checkout { padding: 20px; }

  .result { padding: 32px 20px; }

  .doc { padding: 28px 20px; }

  .doc__title {
    font-size: 24px;
    line-height: 32px;
  }

  .doc__lead { padding: 16px; }

  .footer-links { margin-top: 24px; }
}

/* На узком телефоне пять кнопок сумм без знака ₽ */
@media (max-width: 420px) {
  .preset__cur { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .preset:active,
  .btn:not(:disabled):active { transform: none; }
  .step,
  .help,
  .wait__dot { animation: none; }
  .field__suffix,
  .pay__logo,
  .pay__spinner,
  .wait { transition: none; }
  /* Индикатор без вращения ничего не сообщает — оставляем, но медленнее */
  .pay__spinner { animation-duration: 1.6s; }
}
