/*
 * Экраны входа, настройки по ссылке и разрешения (холст «Team Next —
 * дизайн», компонент StartAuth): фон A, стеклянная карточка по центру,
 * блоки карточки — `tn-*` из `tokens.css` и `sta-*` здесь. Телефон (≤ 480 px)
 * — облегчённая панель от верха, как артборды `StM*` (390).
 *
 * Формы и секции внутри карточки — `display: contents`: их поля и кнопки —
 * блоки той же колонки с шагом 16, как в холсте.
 */

.tn-auth {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 96px;
  background: var(--auth-mesh);
}
.tn-auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  background: var(--surface-glass-card);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid var(--surface-glass-border);
  border-radius: var(--r-pop);
  box-shadow: var(--sh-modal);
}
.tn-auth-card--wide {
  max-width: 460px;
}
.tn-auth-card form,
.tn-auth-card section,
.tn-auth-card .sta-group {
  display: contents;
}
.tn-auth-card h1,
.tn-auth-card__title {
  margin: 0;
  font: 600 22px / 28px var(--font-sans);
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}
.tn-auth-card__lead {
  margin: -8px 0 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
  text-wrap: pretty;
}
/*
 * флажок формы (L21 «Это общий компьютер — не предлагать», согласие агента «Разрешить
 * изменения»): label оборачивает input — кликается вся строка. Флажок 16 на строке 18 —
 * отступ 1 сверху ставит его по центру первой строки и при переносе текста.
 */
.sta-check {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  margin-top: -6px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-2);
  cursor: pointer;
}
.sta-check input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}
/* кольцо фокуса — outline: тень у нативного флажка рисуется квадратом */
.sta-check input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* ритм формы: главная кнопка после поля, кода или заголовка — через 24 */
.tn-auth-card :is(.tn-field, h1) + .tn-btn--primary {
  margin-top: 8px;
}
.tn-auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}
.tn-auth-or::before,
.tn-auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-strong);
}
.tn-auth-link {
  align-self: center;
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: var(--r-md);
  color: var(--blue);
  font: 500 14px / 20px var(--font-sans);
  cursor: pointer;
  text-decoration: none;
}
.tn-auth-link:hover {
  background: var(--fill-3);
}
.tn-auth-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* «← Назад» слева вверху */
.sta-back {
  align-self: flex-start;
  margin: -8px 0 -4px -8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--blue);
  font: 500 13px / 18px var(--font-sans);
  cursor: pointer;
  text-decoration: none;
}
.sta-back:hover {
  background: var(--fill-3);
}
.sta-back:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* шаги настройки текстом: текущий — тёмный полужирный, пройденный — ✓ */
.sta-trail {
  margin-bottom: -8px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-muted);
}
.sta-trail-sep {
  flex: 0 1 16px;
  min-width: 8px;
  height: 1px;
  background: var(--line-strong);
}
.sta-trail-i {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text-muted);
}
.sta-trail-i.is-cur {
  color: var(--text);
  font-weight: 600;
}
button.sta-trail-i {
  cursor: pointer;
  color: var(--text-3);
}
button.sta-trail-i:hover {
  color: var(--blue);
}
button.sta-trail-i:focus-visible {
  outline: none;
  border-radius: 4px;
  box-shadow: var(--focus-ring);
}

/* карточка браузера (после проверки факторов) */
.sta-dev {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-xl);
  background: var(--fill-1);
}
.sta-dev > svg {
  flex: none;
  color: var(--text-icon);
}
.sta-dev b {
  display: block;
  font-weight: 600;
}
.sta-dev small {
  display: block;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-3);
}

/* приложение после входа (L20, L26) */
.sta-app {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 15px / 20px var(--font-sans);
  color: var(--text);
}
.sta-app-ic {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-grad);
  color: var(--on-accent);
  font: 700 16px / 1 var(--font-sans);
}

/* ожидание */
.sta-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-3);
}
.sta-timer.is-center {
  justify-content: center;
  padding: 24px 0;
}
.sta-busy {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-3);
}
.sta-spin-on {
  border-color: var(--on-accent-faint);
  border-top-color: var(--on-accent);
}

/* план настройки S0 */
.sta-plan {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: var(--r-xl);
  background: var(--fill-1);
}
.sta-plan > li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.sta-plan > li + li {
  border-top: 1px solid var(--line);
}
.sta-plan i {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-ring-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 12px / 1 var(--font-sans);
  font-style: normal;
  color: var(--text-3);
}

/* QR и ключ TOTP */
.sta-qr {
  display: flex;
  gap: 16px;
  align-items: center;
}
.sta-qrg {
  flex: none;
  width: 132px;
  height: 132px;
  padding: 8px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-ring-strong);
}
.sta-qrg svg {
  display: block;
  width: 100%;
  height: 100%;
}
.sta-qr-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.sta-qr-side .tn-btn {
  align-self: flex-start;
}
.sta-secret {
  font: 500 13px / 18px var(--font-mono);
  color: var(--text-2);
  word-break: break-all;
}
.sta-small {
  font-size: 13px;
  line-height: 18px;
  color: var(--text-3);
}

/* код подтверждения S7 */
.sta-big {
  font: 600 40px / 48px var(--font-mono);
  letter-spacing: 0.08em;
  text-align: center;
  padding: 8px 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/*
 * 6 цифр: одно поле one-time-code поверх нарисованных ячеек (вставка
 * целиком, автоподстановка, Backspace). Без JS (`.is-live` нет) — обычное поле.
 */
.sta-otp {
  position: relative;
}
.sta-otp > .tn-code {
  display: none;
}
.sta-otp.is-live > .tn-code {
  display: flex;
}
.sta-otp.is-live > .sta-otp-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  letter-spacing: 0;
  outline: none;
  cursor: text;
}
.sta-otp.is-live > .sta-otp-input::selection {
  background: transparent;
}
.sta-otp:focus-within .tn-code > span.is-next {
  background: var(--surface);
  box-shadow: var(--focus-ring);
}
.sta-otp:focus-within .tn-code > span.is-bad.is-next {
  background: var(--surface);
  box-shadow: var(--focus-ring-danger);
}

/* телефон: панель от верха, облегчённое стекло, компактная карточка (StM*, 390) */
@media (max-width: 480px) {
  .tn-auth {
    justify-content: flex-start;
    padding: calc(48px + env(safe-area-inset-top, 0px)) 16px
      calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .tn-auth-card,
  .tn-auth-card--wide {
    padding: 22px 20px;
    background: var(--surface-glass-phone);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    backdrop-filter: blur(24px) saturate(1.3);
    border-radius: var(--r-panel);
    box-shadow: var(--sh-bubble);
  }
  .tn-auth-card h1,
  .tn-auth-card__title {
    font-size: 20px;
    line-height: 26px;
  }
  .tn-auth-card .tn-code {
    gap: 6px;
  }
  .tn-auth-card .tn-code > span {
    height: 50px;
  }
  .sta-qr {
    flex-direction: column;
    align-items: flex-start;
  }
}

/*
 * «Подробнее» на отказах «не в офисе» (decisions.md 2026-11-16): `<details>`
 * под кнопками — адрес клиента, время проверки и код строки журнала.
 */
.sta-details {
  display: block;
  margin-top: -4px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-3);
}
.sta-details summary {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
  margin-left: -2px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.sta-details summary::-webkit-details-marker {
  display: none;
}
.sta-details summary:hover {
  background: var(--fill-3);
}
.sta-details summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.sta-details summary svg {
  flex: none;
  color: var(--text-icon);
}
.sta-details[open] summary svg {
  transform: rotate(90deg);
}
.sta-details p {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-lg);
  background: var(--fill-1);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.sta-details p > span,
.sta-details code {
  white-space: nowrap;
}
.sta-details code {
  font: 500 13px / 18px var(--font-mono);
  color: var(--text);
  letter-spacing: 0.02em;
  user-select: all;
}
@media (prefers-reduced-motion: no-preference) {
  .sta-details summary svg {
    transition: transform 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}
