/* Вход, регистрация, сброс пароля и подтверждение почты (v12).
   Только токены из fc-tokens.css. Страницы не грузят app.css. */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body.fc-auth {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(900px 420px at 50% -120px, rgba(49, 94, 251, .13), transparent 70%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}

.fc-auth a { color: var(--accent); text-decoration: none; }
.fc-auth a:hover { color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px; }
.fc-auth [hidden] { display: none !important; }

.auth-icon { width: 18px; height: 18px; flex: none; }

/* Шапка */
.auth-header {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -.01em;
    color: var(--text) !important;
    text-decoration: none !important;
}
.auth-logo img { width: 30px; height: 30px; border-radius: 9px; }
.auth-header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text) !important;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none !important;
    transition: border-color var(--d1) var(--ease), box-shadow var(--d1) var(--ease);
}
.auth-header-link:hover { border-color: var(--line-strong); box-shadow: var(--e1); }
.auth-header-link span { color: var(--text-3); font-weight: 600; }

/* Карточка */
.auth-main {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px 16px 40px;
}
.auth-panel {
    width: 100%;
    max-width: 440px;
    align-self: flex-start;
    margin-top: clamp(8px, 6vh, 64px);
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}
.auth-panel-wide { max-width: 560px; }
.auth-head { margin-bottom: 22px; }
.auth-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.02em;
}
.auth-lead {
    margin: 8px 0 0;
    color: var(--text-2);
    font-size: 15px;
}
/* Тариф, выбранный на сайте: регистрация сразу на нём (агентство — кабинет агентства) */
.auth-plan { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3); margin: var(--sp-3) 0 0; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--blue-soft); color: var(--text-2); font-size: var(--fs-sm); }
.auth-plan-name { color: var(--text); font-weight: var(--fw-strong); }
.auth-plan a { margin-left: auto; font-weight: var(--fw-strong); }

.auth-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 600;
}
.auth-badge .auth-icon { width: 14px; height: 14px; color: var(--success); }

/* Мессенджеры */
.auth-providers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.auth-providers.is-single { grid-template-columns: 1fr; }
.auth-provider {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text) !important;
    text-decoration: none !important;
    font: inherit;
    cursor: pointer;
    transition: border-color var(--d1) var(--ease), box-shadow var(--d1) var(--ease), transform var(--d1) var(--ease);
}
.auth-provider:hover { border-color: var(--line-strong); box-shadow: var(--e2); transform: translateY(-1px); }
.auth-provider:active { transform: translateY(0); box-shadow: var(--e1); }
.auth-provider:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.auth-provider-tg:hover { border-color: #2AABEE; }
.auth-provider-max:hover { border-color: #7B5CFF; }
.auth-provider-logo {
    width: 34px;
    height: 34px;
    flex: none;
    display: block;
}
.auth-provider-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.auth-provider-name { font-weight: 800; font-size: 15px; }
.auth-provider-note { margin-top: 3px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }

/* Ожидание подтверждения в мессенджере */
.auth-wait {
    display: flex;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: var(--accent-soft-2);
    border: 1px solid var(--accent-line);
}
.auth-wait-spinner {
    width: 22px;
    height: 22px;
    flex: none;
    margin-top: 2px;
    border-radius: 50%;
    border: 2.5px solid var(--accent-line);
    border-top-color: var(--accent);
    animation: auth-spin .8s linear infinite;
}
.auth-wait-title { margin: 0; font-weight: 800; font-size: 15px; }
.auth-wait-text { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.auth-wait-actions { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 14px; font-weight: 700; }
.auth-wait-actions button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-2);
    font: inherit;
    cursor: pointer;
}
.auth-wait-actions button:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* Разделитель */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0 18px;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 700;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Форма */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.auth-label { font-size: 13.5px; font-weight: 700; color: var(--text); }
.auth-label-row a { font-size: 13.5px; font-weight: 700; }
.auth-optional { color: var(--text-3); font-weight: 600; }
.auth-input-wrap { position: relative; }
.auth-input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    transition: border-color var(--d1) var(--ease), box-shadow var(--d1) var(--ease);
}
.auth-input::placeholder { color: var(--text-3); }
.auth-input:hover { border-color: var(--line-strong); }
.auth-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.auth-input[aria-invalid="true"] { border-color: var(--danger); }
.auth-input-wrap .auth-input { padding-right: 48px; }
.auth-input-code { letter-spacing: .32em; font-weight: 800; font-size: 20px; text-align: center; }
.auth-input-code::placeholder { font-weight: 600; color: var(--line-strong); }
.auth-eye {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
}
.auth-eye:hover { color: var(--text); background: var(--surface-muted); }
.auth-eye:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-eye .auth-icon-hide { display: none; }
.auth-eye[aria-pressed="true"] .auth-icon-show { display: none; }
.auth-eye[aria-pressed="true"] .auth-icon-hide { display: block; }
.auth-field-note { margin: 0; font-size: 13px; color: var(--text-3); }
.auth-field-note.is-warn { color: var(--warning); font-weight: 700; }

/* Согласие */
.auth-consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--text-2);
    cursor: pointer;
    transition: border-color var(--d1) var(--ease), background var(--d1) var(--ease);
}
.auth-consent input {
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    flex: none;
    accent-color: var(--accent);
    cursor: pointer;
}
.auth-consent.is-error { border-color: var(--danger); background: var(--danger-bg); }
.auth-consent + .auth-providers,
.auth-consent + .auth-providers-wrap { margin-top: 14px; }

/* Кнопки */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: inherit;
    font-size: 15.5px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none !important;
    transition: background var(--d1) var(--ease), box-shadow var(--d1) var(--ease), transform var(--d1) var(--ease), opacity var(--d1) var(--ease);
}
.auth-btn-primary { background: var(--accent); color: var(--on-accent) !important; box-shadow: var(--shadow-blue); }
.auth-btn-primary:hover { background: var(--accent-2); }
.auth-btn-primary:active { transform: translateY(1px); }
.auth-btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text) !important; }
.auth-btn-ghost:hover { border-color: var(--line-strong); box-shadow: var(--e1); }
.auth-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.auth-btn[disabled] { opacity: .6; cursor: default; transform: none; }
.auth-btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.auth-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: auth-spin .8s linear infinite;
}
.auth-btn-ghost.is-loading::after { border-color: var(--accent-line); border-top-color: var(--accent); }

/* Сообщения */
.auth-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
}
.auth-alert .auth-icon { margin-top: 1px; }
.auth-alert-error { background: var(--danger-bg); color: var(--danger); }
.auth-alert-ok { background: var(--success-bg); color: var(--success); }
.auth-alert-info { background: var(--accent-soft-2); color: var(--text-2); }
.auth-section-alert { margin-top: 12px; }

.auth-foot {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--text-2);
    font-size: 14.5px;
}
.auth-foot a { font-weight: 800; }
.auth-note { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--text-3); }

.auth-legal {
    padding: 0 16px 28px;
    text-align: center;
    font-size: 13px;
    color: var(--text-3);
}
.auth-legal a { color: var(--text-3); }
.auth-legal a:hover { color: var(--text-2); }
.auth-legal span { margin: 0 6px; }

/* Подтверждение почты */
.verify-steps { display: flex; flex-direction: column; gap: 12px; }
.verify-step {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--surface);
}
.verify-step-main { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft-2); }
.verify-step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.verify-step-icon {
    width: 36px;
    height: 36px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
}
.verify-step-icon .auth-icon { width: 20px; height: 20px; }
.verify-step-title { margin: 0; font-size: 16px; font-weight: 800; }
.verify-step-kicker { display: block; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.verify-step-text { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.verify-code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.verify-code-row .auth-btn { width: auto; }
.verify-resend {
    margin-top: 10px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.verify-resend[disabled] { color: var(--text-3); cursor: default; }
.verify-optional { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.verify-optional .auth-provider { min-height: 54px; }
.verify-skip { margin-top: 18px; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
    .auth-header { padding: 14px 16px; }
    .auth-header-link span { display: none; }
    .auth-main { padding: 0 12px 28px; }
    .auth-panel { margin-top: 4px; padding: 22px 18px; border-radius: var(--radius-lg); }
    .auth-title { font-size: 23px; }
    .auth-providers,
    .verify-optional { grid-template-columns: 1fr; }
    .verify-code-row { grid-template-columns: 1fr; }
    .verify-code-row .auth-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-provider,
    .auth-btn { transition: none; }
    .auth-wait-spinner,
    .auth-btn.is-loading::after { animation-duration: 2s; }
}
