/* Служебные страницы кабинета: вход, регистрация, подтверждение почты,
   восстановление пароля. Сверстаны по макетам new-pages: колонка 542px,
   заголовки — Google Sans, текст — Nunito. */

.auth {
    --auth-primary: #524fe5;
    --auth-primary-hover: #4643d6;
    --auth-primary-active: #3d3ac4;
    --auth-text: #182133;
    --auth-text-secondary: #464d5c;
    --auth-text-muted: #5d6370;
    --auth-text-hint: #6b717d;
    --auth-placeholder: #bcc0c6;
    --auth-field-bg: #f7f9fb;
    --auth-field-border: #e6e8ec;
    --auth-field-border-hover: #d5d8dd;
    --auth-outline-border: #dcdde0;
    --auth-disabled: #c8cace;
    --auth-error: #f04d4d;
    --auth-error-border: #f3a3a4;
    --auth-icon: #5d6370;
    --auth-font-title: 'Google Sans', 'Nunito', system-ui, sans-serif;
    --auth-font-text: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    display: flex;
    justify-content: center;
    padding: 64px 16px 80px;
    font-family: var(--auth-font-text);
    color: var(--auth-text);
    background: #fff;
}

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

.auth__box {
    width: 100%;
    max-width: 542px;
}

.auth__box--narrow {
    max-width: 416px;
}

.auth__box--center {
    text-align: center;
}

/* ── Заголовок и подзаголовок ─────────────────── */
.auth__title {
    margin: 0;
    font-family: var(--auth-font-title);
    font-size: 36px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: var(--auth-text);
    text-align: center;
}

.auth__title--left {
    text-align: left;
}

.auth__subtitle {
    margin: 12px 0 0;
    font-size: 16px;
    line-height: 1.2;
    color: var(--auth-text-secondary);
    text-align: center;
}

.auth__subtitle {
    overflow-wrap: anywhere;
}

.auth__subtitle--left {
    text-align: left;
}

.auth__rules {
    margin: 6px 0 0;
    padding: 0 0 0 24px;
    list-style: disc;
    font-size: 16px;
    line-height: 1.2;
    color: var(--auth-text-hint);
}

.auth__rules li::marker {
    font-size: 0.8em;
}

.auth__notice {
    margin: 16px 0 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: #eefaf2;
    color: #1f8b4c;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
}

/* ── Форма ─────────────────────────────────────── */
.auth__form {
    display: flex;
    flex-direction: column;
    gap: 22px;
    margin-top: 26px;
}

/* Форма под подзаголовком (восстановление пароля) */
.auth__form--after-subtitle {
    margin-top: 24px;
}

/* Форма под списком требований к паролю */
.auth__form--after-rules {
    margin-top: 25px;
}

.auth-field {
    display: flex;
    flex-direction: column;
}

.auth-field__label {
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    line-height: 16px;
    color: var(--auth-text);
}

.auth-field__control {
    position: relative;
}

.auth-field__input {
    display: block;
    width: 100%;
    height: 49px;
    margin: 0;
    padding: 0 16px;
    border: 1px solid var(--auth-field-border);
    border-radius: 10px;
    background: var(--auth-field-bg);
    font-family: var(--auth-font-text);
    font-size: 16px;
    font-weight: 400;
    color: var(--auth-text);
    outline: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.auth-field__input::placeholder {
    color: var(--auth-placeholder);
    opacity: 1;
}

.auth-field__input:hover {
    border-color: var(--auth-field-border-hover);
}

.auth-field__input:focus {
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgb(82 79 229 / 12%);
}

/* Автозаполнение браузера не должно красить поле в жёлтый */
.auth-field__input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 100px var(--auth-field-bg) inset;
    -webkit-text-fill-color: var(--auth-text);
}

/* Точки пароля мелкие, как в макете. Только на десктопе: на телефоне шрифт
   меньше 16px в поле заставляет iOS увеличивать страницу при фокусе */
@media (min-width: 768px) {
    .auth-field__input[type='password']:not(:placeholder-shown) {
        font-size: 10px;
        letter-spacing: 2.6px;
    }
}

/* Место под кнопки очистки и «глаза» справа */
.auth-field--password .auth-field__input {
    padding-right: 52px;
}

.auth-field.is-filled .auth-field__input {
    padding-right: 48px;
}

.auth-field--password.is-filled .auth-field__input {
    padding-right: 84px;
}

.auth-field__actions {
    position: absolute;
    top: 0;
    right: 14px;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-field__clear,
.auth-field__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: none;
    color: var(--auth-icon);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.auth-field__clear {
    width: 22px;
    height: 22px;
    border: 1px solid var(--auth-field-border-hover);
    border-radius: 50%;
    background: #fff;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.auth-field__clear:hover {
    border-color: #b5b8be;
    color: var(--auth-text);
}

.auth-field__clear[hidden] {
    display: none;
}

.auth-field__toggle {
    width: 24px;
    height: 24px;
    transition: color 0.2s ease;
}

.auth-field__toggle:hover {
    color: var(--auth-text);
}

.auth-field__clear:focus-visible,
.auth-field__toggle:focus-visible {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
    border-radius: 50%;
}

/* «Глаз»: пустое поле и открытый пароль — открытый глаз,
   введённый и скрытый пароль — перечёркнутый */
.auth-field__toggle .auth-icon-eye-off {
    display: none;
}

.auth-field.is-filled.is-masked .auth-field__toggle .auth-icon-eye {
    display: none;
}

.auth-field.is-filled.is-masked .auth-field__toggle .auth-icon-eye-off {
    display: block;
}

.auth-field__error {
    margin-top: 8px;
    font-size: 16px;
    line-height: 1.3;
    color: var(--auth-error);
}

.auth-field__error[hidden] {
    display: none;
}

.auth-field__error a {
    margin-left: 6px;
}

.auth-field.is-invalid .auth-field__input {
    border-color: var(--auth-error-border);
    color: var(--auth-error);
}

.auth-field.is-invalid .auth-field__input:focus {
    box-shadow: 0 0 0 3px rgb(240 77 77 / 12%);
}

.auth-field.is-invalid .auth-field__input[type='password'] {
    color: var(--auth-text);
}

/* ── Ссылки ─────────────────────────────────────── */
.auth-link {
    color: var(--auth-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

.auth-link:hover,
.auth-link:focus-visible {
    color: var(--auth-primary-active);
}

.auth-link--plain {
    text-decoration: none;
}

.auth-link--plain:hover {
    text-decoration: underline;
}

.auth__forgot {
    align-self: flex-start;
    margin: -12px 0 -2px;
    font-size: 16px;
    line-height: 1.3;
}

/* ── Чекбоксы ───────────────────────────────────── */
.auth-checks {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 2px;
}

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.auth-check__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.auth-check__box {
    position: relative;
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 1px solid var(--auth-field-border-hover);
    border-radius: 5px;
    background: var(--auth-field-bg);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-check__box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: center / 12px 12px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6.2 4.9 8.5 9.5 3.7' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.auth-check:hover .auth-check__box {
    border-color: #b5b8be;
}

.auth-check__input:checked + .auth-check__box {
    border-color: var(--auth-primary);
    background: var(--auth-primary);
}

.auth-check__input:checked + .auth-check__box::after {
    opacity: 1;
    transform: scale(1);
}

.auth-check__input:focus-visible + .auth-check__box {
    box-shadow: 0 0 0 3px rgb(82 79 229 / 20%);
}

.auth-check__text {
    max-width: 474px;
    padding-top: 1px;
    font-size: 12px;
    line-height: 14px;
    color: var(--auth-text-muted);
}

.auth-check__text--center {
    align-self: center;
    padding-top: 0;
    font-size: 14px;
    line-height: 20px;
}

/* :not([href]) — ссылка на ещё не загруженный документ: Bootstrap снимает
   с неё подчёркивание, а в макете оно есть */
.auth-check__text a,
.auth-check__text a:not([href]):not([class]) {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

.auth-check__text a:hover {
    color: var(--auth-primary);
}

.auth-check.is-invalid .auth-check__box {
    border-color: var(--auth-error-border);
}

.auth-check__error {
    margin: 6px 0 0 28px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--auth-error);
}

.auth-check__error[hidden] {
    display: none;
}

/* ── Кнопки ─────────────────────────────────────── */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 24px;
    border: 1px solid var(--auth-primary);
    border-radius: 12px;
    background: var(--auth-primary);
    font-family: var(--auth-font-text);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.auth-btn:hover,
.auth-btn:focus-visible {
    border-color: var(--auth-primary-hover);
    background: var(--auth-primary-hover);
    color: #fff;
}

.auth-btn:active {
    border-color: var(--auth-primary-active);
    background: var(--auth-primary-active);
    transform: scale(0.99);
}

.auth-btn:focus-visible {
    outline: 3px solid rgb(82 79 229 / 30%);
    outline-offset: 2px;
}

.auth-btn--block {
    width: 100%;
}

.auth-btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

.auth-btn.is-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid rgb(255 255 255 / 40%);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

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

.auth-btn--outline {
    border-color: var(--auth-outline-border);
    background: #fff;
    color: var(--auth-text-secondary);
}

.auth-btn--outline:hover,
.auth-btn--outline:focus-visible {
    border-color: #b5b8be;
    background: #fff;
    color: var(--auth-text);
}

.auth-btn--outline:active {
    border-color: #b5b8be;
    background: var(--auth-field-bg);
    color: var(--auth-text);
}

.auth-btn--outline:disabled {
    border-color: var(--auth-outline-border);
    background: #fff;
    color: var(--auth-disabled);
    cursor: default;
    transform: none;
}

.auth__submit {
    margin-top: 2px;
}

/* ── Нижняя подпись «Нет аккаунта? …» ────────────── */
.auth__footer {
    margin-top: 26px;
    font-size: 16px;
    line-height: 1.3;
    color: var(--auth-text-secondary);
    text-align: center;
}

.auth__footer a {
    margin-left: 4px;
}

/* ── Ввод кода ──────────────────────────────────── */
.auth-code {
    max-width: 412px;
    margin: 21px auto 0;
}

.auth-code__cells {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.auth-code__cell {
    flex: 0 1 54px;
    min-width: 0;
    width: 54px;
    height: 66px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--auth-field-border);
    border-radius: 10px;
    background: var(--auth-field-bg);
    font-family: var(--auth-font-text);
    font-size: 18px;
    font-weight: 700;
    color: var(--auth-text);
    text-align: center;
    caret-color: var(--auth-primary);
    outline: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.auth-code__cell:hover {
    border-color: var(--auth-field-border-hover);
}

.auth-code__cell:focus {
    border-color: var(--auth-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgb(82 79 229 / 12%);
}

.auth-code__cell::selection {
    background: transparent;
}

.auth-code.is-invalid .auth-code__cell {
    border-color: var(--auth-error-border);
    color: var(--auth-error);
}

.auth-code.is-invalid .auth-code__cell:focus {
    box-shadow: 0 0 0 3px rgb(240 77 77 / 12%);
}

.auth-code.is-invalid .auth-code__cells {
    animation: auth-shake 0.35s ease;
}

.auth-code.is-busy .auth-code__cell {
    opacity: 0.6;
}

@keyframes auth-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-code.is-invalid .auth-code__cells {
        animation: none;
    }
}

.auth-code__error {
    margin-top: 12px;
    font-size: 16px;
    line-height: 1.3;
    color: var(--auth-error);
}

.auth-code__error[hidden] {
    display: none;
}

.auth-code__resend {
    max-width: 412px;
    margin: 23px auto 0;
}

.auth-code__resend .auth-btn {
    width: 100%;
    font-variant-numeric: tabular-nums;
}

.auth__box--code .auth__footer {
    margin-top: 37px;
}

/* ── Пароль изменён ─────────────────────────────── */
.auth-done__image {
    display: block;
    width: 179px;
    height: auto;
    margin: 0 auto 34px;
}

.auth-done__text {
    margin: 8px auto 0;
    max-width: 290px;
    font-size: 16px;
    line-height: 22px;
    color: var(--auth-text-secondary);
}

.auth-done__btn {
    margin-top: 19px;
    padding: 0 36px;
}

/* ── Модальные окна ─────────────────────────────── */
.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.auth-modal.is-open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.auth-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgb(24 33 51 / 50%);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.auth-modal__dialog {
    position: relative;
    width: fit-content;
    min-width: 454px;
    max-width: 100%;
    padding: 48px 64px;
    border-radius: 24px;
    background: #fff;
    font-family: 'Nunito', system-ui, sans-serif;
    text-align: center;
    box-shadow: 0 24px 60px rgb(24 33 51 / 18%);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.auth-modal__dialog--wide {
    width: 502px;
}

.auth-modal.is-open .auth-modal__dialog {
    transform: none;
}

.auth-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid #dcdde0;
    border-radius: 50%;
    background: #fff;
    color: #464d5c;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.auth-modal__close:hover {
    border-color: #b5b8be;
    color: #182133;
}

/* Увеличенная зона нажатия для пальца */
.auth-modal__close::before {
    content: '';
    position: absolute;
    inset: -10px;
}

.auth-modal__image {
    display: block;
    width: 102px;
    height: auto;
    margin: -4px auto 0;
}

.auth-modal__title {
    margin: 22px 0 0;
    font-family: 'Google Sans', 'Nunito', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.25;
    color: #182133;
}

.auth-modal__text {
    margin: 7px 0 0;
    font-size: 16px;
    line-height: 18px;
    color: #464d5c;
}

.auth-modal__actions {
    margin-top: 24px;
}

.auth-modal .auth-btn {
    min-width: 117px;
}

body.auth-modal-open {
    overflow: hidden;
}

/* ── Телефоны ───────────────────────────────────── */
@media (max-width: 767px) {
    .auth {
        padding: 32px 16px 56px;
    }

    .auth__title {
        font-size: 28px;
    }

    .auth__subtitle,
    .auth__rules,
    .auth__footer,
    .auth-done__text,
    .auth-field__error,
    .auth-code__error {
        font-size: 15px;
    }

    .auth__subtitle br {
        display: none;
    }

    .auth__form {
        gap: 18px;
        margin-top: 24px;
    }

    .auth__forgot {
        margin-top: -8px;
        font-size: 15px;
    }

    /* 16px в полях — иначе iOS увеличивает страницу при фокусе */
    .auth-field__input {
        height: 52px;
    }

    .auth-btn {
        height: 52px;
    }

    .auth__footer,
    .auth__box--code .auth__footer {
        margin-top: 28px;
    }

    .auth-code {
        margin-top: 24px;
    }

    .auth-code__cells {
        gap: 8px;
    }

    .auth-code__cell {
        flex: 1 1 0;
        width: auto;
        max-width: 54px;
        height: 60px;
        font-size: 20px;
    }

    .auth-modal__dialog {
        width: 100%;
        min-width: 0;
        padding: 40px 24px 28px;
    }

    .auth-modal__title {
        font-size: 22px;
    }

    .auth-modal__text br {
        display: none;
    }

    .auth-modal .auth-btn {
        width: 100%;
    }
}

@media (max-width: 359px) {
    .auth__title {
        font-size: 24px;
    }

    .auth-code__cells {
        gap: 6px;
    }

    .auth-code__cell {
        height: 54px;
    }

    .auth-code__resend .auth-btn {
        padding: 0 12px;
        font-size: 14px;
    }
}
