/* Auth modal */
body.auth-modal-open {
    overflow: hidden;
}

.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-modal[hidden] {
    display: none !important;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 24, 40, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.auth-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(880px, 100%);
    max-height: min(92vh, 760px);
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 28px 80px rgba(16, 24, 40, 0.28);
    animation: authModalIn 0.28s ease;
}

@keyframes authModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.auth-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #101828;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 24, 40, 0.12);
}

.auth-modal-close:hover {
    background: #fff;
}

.auth-modal-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.9fr) minmax(0, 1.15fr);
    min-height: 520px;
    max-height: min(92vh, 760px);
}

.auth-modal-aside {
    position: relative;
    color: #fff;
    overflow: hidden;
    background: linear-gradient(160deg, #0168E0 0%, #0177FF 42%, #0B4FBF 100%);
}

.auth-modal-aside-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.auth-modal-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
}

.auth-modal-orb-1 {
    width: 180px;
    height: 180px;
    top: -40px;
    right: -30px;
    background: rgba(255, 255, 255, 0.18);
}

.auth-modal-orb-2 {
    width: 140px;
    height: 140px;
    bottom: 40px;
    left: -40px;
    background: rgba(0, 200, 83, 0.22);
}

.auth-modal-aside-grid {
    position: absolute;
    inset: 0;
    opacity: 0.12;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: radial-gradient(circle at 30% 20%, #000 20%, transparent 70%);
}

.auth-modal-aside-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    padding: 28px 24px 32px;
}

.auth-modal-brand {
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: auto;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-modal-aside-title {
    margin: 0 0 18px;
    font-size: clamp(1.35rem, 2.2vw, 1.7rem);
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-modal-aside-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.auth-modal-aside-points li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.92);
}

.auth-modal-aside-points i {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.78rem;
}

.auth-modal-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 28px 28px 22px;
    overflow: auto;
}

.auth-modal-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    border-radius: 12px;
    background: #F2F4F7;
}

.auth-modal-tab {
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    background: transparent;
    color: var(--text-secondary, #475467);
    font: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.auth-modal-tab.is-active {
    background: #fff;
    color: var(--text, #1D2635);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

.auth-modal-tab:hover:not(.is-active) {
    color: var(--text, #1D2635);
}

.auth-modal-head {
    margin-bottom: 16px;
}

.auth-modal-head h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.auth-modal-head p {
    margin: 0;
    color: var(--text-secondary, #667085);
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-modal-panel[hidden] {
    display: none !important;
}

.auth-modal-alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.4;
}

.auth-modal-alert[hidden] {
    display: none !important;
}

.auth-modal-alert.is-error {
    background: #FFF1F0;
    color: #D92D20;
    border: 1px solid rgba(217, 45, 32, 0.15);
}

.auth-modal-alert.is-success {
    background: #ECFDF3;
    color: #027A48;
    border: 1px solid rgba(2, 122, 72, 0.15);
}

.auth-modal-form {
    display: grid;
    gap: 14px;
}

.auth-modal-field {
    display: grid;
    gap: 6px;
}

.auth-modal-field > label,
.auth-modal-field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text, #1D2635);
}

.auth-modal-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.auth-modal-link-btn {
    border: none;
    background: none;
    padding: 0;
    color: var(--primary, #0177FF);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-modal-link-btn:hover {
    text-decoration: underline;
}

.auth-modal-input {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-modal-input > i:first-child {
    position: absolute;
    left: 14px;
    color: var(--text-muted, #98A2B3);
    font-size: 0.85rem;
    pointer-events: none;
}

.auth-modal-input input {
    width: 100%;
    height: 46px;
    padding: 0 42px 0 40px;
    border: 1.5px solid var(--border, #EAECF0);
    border-radius: 12px;
    background: #FCFCFD;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text, #1D2635);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-modal-input input:hover {
    border-color: #D0D5DD;
}

.auth-modal-input input:focus {
    outline: none;
    border-color: var(--primary, #0177FF);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(1, 119, 255, 0.12);
}

.auth-modal-eye {
    position: absolute;
    right: 8px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted, #98A2B3);
    cursor: pointer;
}

.auth-modal-eye:hover {
    color: var(--text, #1D2635);
    background: rgba(16, 24, 40, 0.04);
}

.auth-modal-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.auth-modal-roles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.auth-modal-role {
    cursor: pointer;
}

.auth-modal-role input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.auth-modal-role > span {
    display: grid;
    gap: 2px;
    min-height: 86px;
    padding: 12px;
    border: 1.5px solid var(--border, #EAECF0);
    border-radius: 12px;
    background: #FCFCFD;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.auth-modal-role i {
    color: var(--primary, #0177FF);
    margin-bottom: 4px;
}

.auth-modal-role strong {
    font-size: 0.86rem;
    line-height: 1.25;
}

.auth-modal-role small {
    color: var(--text-muted, #98A2B3);
    font-size: 0.75rem;
}

.auth-modal-role input:checked + span {
    border-color: var(--primary, #0177FF);
    background: var(--primary-light, #E8F2FF);
    box-shadow: 0 0 0 3px rgba(1, 119, 255, 0.12);
}

.auth-modal-hint {
    margin: -4px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted, #98A2B3);
}

.auth-modal-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    border-radius: 12px;
    font-weight: 700;
}

.auth-modal-submit.is-loading {
    opacity: 0.75;
    pointer-events: none;
}

.auth-modal-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 12px;
    color: var(--text-muted, #98A2B3);
    font-size: 0.78rem;
}

.auth-modal-divider::before,
.auth-modal-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border, #EAECF0);
}

.auth-modal-providers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.auth-modal-provider {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    border-radius: 11px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.auth-modal-provider:hover {
    transform: translateY(-1px);
}

.auth-modal-provider-vk {
    background: #0077FF;
    color: #fff;
}

.auth-modal-provider-google {
    background: #fff;
    color: var(--text, #1D2635);
    border: 1.5px solid var(--border, #EAECF0);
}

.auth-modal-telegram {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.auth-modal-footer-note {
    margin: 14px 0 0;
    text-align: center;
    color: var(--text-muted, #98A2B3);
    font-size: 0.78rem;
}

.auth-modal-page-link {
    display: block;
    margin-top: 10px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary, #667085);
    text-decoration: none;
}

.auth-modal-page-link:hover {
    color: var(--primary, #0177FF);
}

.auth-modal-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    border: none;
    background: none;
    padding: 0;
    color: var(--primary, #0177FF);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-modal-back:hover {
    text-decoration: underline;
}

@media (max-width: 760px) {
    .auth-modal {
        padding: 0;
        align-items: stretch;
        /* iOS Safari address bar */
        height: 100%;
        height: 100dvh;
    }

    .auth-modal-dialog {
        width: 100%;
        height: 100%;
        max-height: 100%;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .auth-modal-grid {
        flex: 1;
        min-height: 0;
        max-height: none;
        height: 100%;
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        align-content: stretch;
    }

    .auth-modal-aside {
        min-height: 0;
        flex-shrink: 0;
    }

    .auth-modal-aside-content {
        padding: 14px 16px 12px;
        justify-content: center;
        min-height: 72px;
    }

    .auth-modal-aside-title {
        margin: 6px 0 0;
        font-size: 1.05rem;
    }

    .auth-modal-aside-points {
        display: none;
    }

    .auth-modal-brand {
        margin-bottom: 0;
    }

    .auth-modal-main {
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px));
    }

    .auth-modal-row,
    .auth-modal-roles,
    .auth-modal-providers {
        grid-template-columns: 1fr;
    }

    .auth-modal-close {
        top: 8px;
        right: 8px;
        background: rgba(255, 255, 255, 0.95);
    }

    /* Register form is long — keep submit reachable after scroll */
    .auth-modal-panel[data-auth-panel="register"] {
        padding-bottom: 8px;
    }
}
