:root {
    --color-primary: #3366cc;
    --color-primary-dark: #1f4f81;
    --color-primary-light: #5b8def;
    --color-success: #22c55e;
    --color-warning: #f2bf27;
    --color-info: #0ea5e9;
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;
    --color-danger: #ee5a52;
    --color-danger-light: #fee2e2;
    --color-success-light: #dcfce7;
    --color-success-dark: #166534;
}

* { box-sizing: border-box; }

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

body.auth-body {
    font-family: 'Outfit', 'Poppins', ui-sans-serif, system-ui, sans-serif;
    color: var(--color-text-primary);
    background: var(--color-bg);
    overflow-x: hidden;
}

.auth-font-display {
    font-family: 'Outfit', 'Poppins', ui-sans-serif, system-ui, sans-serif;
}

.auth-screen {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding:
        max(0.75rem, env(safe-area-inset-top, 0px))
        max(0.75rem, env(safe-area-inset-right, 0px))
        max(0.75rem, env(safe-area-inset-bottom, 0px))
        max(0.75rem, env(safe-area-inset-left, 0px));
    overflow-x: hidden;
    overflow-y: auto;
}

@media (min-width: 1024px) {
    .auth-screen {
        align-items: center;
        padding: 2.5rem;
        overflow: hidden;
    }
}

.auth-blob {
    position: fixed;
    border-radius: 9999px;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    animation: pulseSoft 5s ease-in-out infinite;
}

.auth-blob--a {
    top: 8%;
    right: -4%;
    width: 36vw;
    height: 36vw;
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}

.auth-blob--b {
    bottom: -6%;
    right: 14%;
    width: 26vw;
    height: 26vw;
    background: color-mix(in srgb, var(--color-info) 10%, transparent);
    animation-delay: 1s;
}

.auth-card {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1600px;
    min-width: 0;
    min-height: calc(100dvh - 1.5rem);
    border-radius: 1.25rem;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15);
}

@media (min-width: 640px) {
    .auth-card { border-radius: 1.75rem; }
}

@media (min-width: 1024px) {
    .auth-card {
        flex-direction: row;
        min-height: min(92vh, 900px);
        height: min(92vh, 900px);
        border-radius: 2.5rem;
    }
}

.auth-pill {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 0.75rem;
    padding: 0.375rem 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    outline: 1px solid rgba(255, 255, 255, 0.9);
}

.auth-theme-row {
    position: relative;
    z-index: 30;
    margin-bottom: 1.5rem;
}

.theme-switcher-end-wrap {
    display: flex;
}

@media (min-width: 1024px) {
    .theme-switcher-end-wrap {
        display: none;
    }
}

.auth-left {
    display: none;
    position: relative;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    color: #fff;
    background-color: var(--color-primary-dark);
    overflow: visible;
}

@media (min-width: 1024px) {
    .auth-left {
        display: flex;
        width: 41.666667%;
        max-width: 42%;
    }
}

.auth-start-grid {
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
}

.auth-start-mesh {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0.22;
    mix-blend-mode: screen;
    background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.28) 0%, transparent 55%);
    animation: slowSpin 22s linear infinite;
    pointer-events: none;
}

.auth-brand-row {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.auth-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.auth-brand-icon img {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: contain;
}

.auth-brand-icon--sm {
    width: 3rem;
    height: 3rem;
    border-radius: 0.85rem;
}

.auth-brand-icon--sm img {
    width: 2rem;
    height: 2rem;
}

.auth-brand-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
    margin: 0;
}

.auth-headline {
    position: relative;
    z-index: 10;
    font-size: clamp(2.25rem, 4vw, 3rem);
    font-weight: 800;
    line-height: 1.12;
    margin: 0 0 1.25rem;
    color: #fff;
}

.auth-tagline {
    position: relative;
    z-index: 10;
    max-width: 28rem;
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.65;
    color: color-mix(in srgb, #fff 78%, var(--color-primary-light));
    margin: 0 0 1.75rem;
}

.auth-features {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 32rem;
}

.auth-feature-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9999px;
}

.auth-feature-pill svg {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
}

.auth-left-footer {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-edition-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 9999px;
    width: fit-content;
}

.auth-edition-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 9999px;
    background: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.auth-panel-muted {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: color-mix(in srgb, #fff 55%, transparent);
}

.auth-secure {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-success);
}

.auth-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1.25rem 1rem 1.5rem;
    overflow-x: hidden;
    overflow-y: visible;
    background: color-mix(in srgb, var(--color-bg) 60%, var(--color-surface));
}

@media (min-width: 640px) {
    .auth-right {
        padding: 1.75rem 1.5rem 2rem;
        justify-content: center;
    }
}

@media (min-width: 1024px) {
    .auth-right {
        padding: 2.5rem;
        overflow-y: auto;
    }
}

.auth-mobile-branding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

@media (min-width: 1024px) {
    .auth-mobile-branding { display: none; }
}

.auth-mobile-branding span {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-panel { width: 100%; max-width: 56rem; margin: 0 auto; }
.is-hidden { display: none !important; }

.auth-welcome-title {
    font-size: 1.75rem;
    font-weight: 900;
    margin: 0 0 0.5rem;
}

.auth-welcome-title em {
    font-style: normal;
    color: var(--color-primary);
}

.auth-portal-badge {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.35rem 1rem;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
    background: var(--color-primary);
    border-radius: 9999px;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.portal-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: minmax(0, 1fr);
    margin-top: 1.25rem;
}

@media (min-width: 560px) {
    .portal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
}

@media (min-width: 1280px) {
    .portal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.portal-card {
    position: relative;
    display: block;
    width: 100%;
    text-align: left;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    overflow: hidden;
    cursor: pointer;
    font: inherit;
    color: inherit;
    container-type: inline-size;
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}

.portal-card:hover {
    border-color: color-mix(in srgb, var(--portal-accent, var(--color-primary)) 35%, var(--color-border));
    box-shadow: 0 12px 32px -8px color-mix(in srgb, var(--portal-accent, var(--color-primary)) 18%, transparent);
    transform: translateY(-2px);
}

.portal-card:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.portal-card-accent {
    position: absolute;
    top: 0;
    right: 0;
    width: 0.375rem;
    height: 100%;
    background: var(--portal-accent, var(--color-primary));
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 0 0.75rem 0.75rem 0;
}

.portal-card:hover .portal-card-accent { opacity: 0.35; }

.portal-card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin-bottom: 0.375rem;
}

.portal-card-title {
    flex: 1;
    min-width: 0;
    font-size: clamp(0.8125rem, 5.8cqi, 1.0625rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.portal-card:hover .portal-card-title { color: var(--color-primary); }

.portal-card-subtitle {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.45;
    color: var(--color-text-secondary);
}

.portal-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    border-radius: 0.75rem;
    color: var(--portal-accent, var(--color-primary));
    background: color-mix(in srgb, var(--portal-accent, var(--color-primary)) 12%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--portal-accent, var(--color-primary)) 22%, transparent);
}

.portal-icon-wrap svg {
    width: 1.5rem;
    height: 1.5rem;
}

.portal-card:hover .portal-icon-wrap { transform: scale(1.06); }

.portal-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    border-radius: 9999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
}

.portal-card:hover .portal-chevron {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.portal-last-badge {
    font-size: 0.55rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: color-mix(in srgb, var(--color-primary) 12%, #fff);
    color: var(--color-primary-dark);
}

.auth-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 1rem;
    width: 100%;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

@media (min-width: 640px) {
    .auth-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
    }
    .auth-stat-item:nth-child(1) { text-align: start; }
    .auth-stat-item:nth-child(2),
    .auth-stat-item:nth-child(3) { text-align: center; }
    .auth-stat-item:nth-child(4) { text-align: end; }
}

.auth-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-primary);
}

.auth-stat-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
}

.auth-form-wrap { width: 100%; max-width: 28rem; margin: 0 auto; }

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    margin-bottom: 1.5rem;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    cursor: pointer;
}

.auth-back-link:hover { color: var(--color-primary); }

.auth-form-card {
    padding: 2rem;
    border-radius: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 20px 50px -15px color-mix(in srgb, var(--color-primary) 12%, transparent);
}

.portal-form-title {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin: 0;
}

.portal-form-header {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
}

.auth-label {
    display: block;
    padding-left: 0.25rem;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.auth-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-forgot-link,
.auth-text-link {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    text-decoration: none;
}

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

.auth-field { margin-bottom: 1.25rem; }

.auth-input-wrap { position: relative; }

.auth-input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--color-text-muted);
    pointer-events: none;
}

.auth-input-wrap:focus-within .auth-input-icon { color: var(--color-primary); }

.auth-input {
    width: 100%;
    max-width: 100%;
    padding: 0.9rem 1rem 0.9rem 3rem;
    border-radius: 1rem;
    border: none;
    outline: none;
    box-shadow: 0 0 0 1px var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
}

.auth-input--password { padding-right: 3.25rem; }

.auth-input:focus { box-shadow: 0 0 0 2px var(--color-primary); }

.auth-input.is-invalid { box-shadow: 0 0 0 2px var(--color-danger); }

.auth-input::placeholder {
    color: var(--color-text-muted);
    font-weight: 500;
}

.auth-password-toggle {
    position: absolute;
    right: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 0.375rem;
}

.auth-remember-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    margin-bottom: 1rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.auth-submit {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: none;
    border-radius: 1rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(to right, var(--color-primary), var(--color-primary-dark));
    box-shadow: 0 8px 24px color-mix(in srgb, var(--color-primary) 28%, transparent);
}

.auth-submit:hover:not(:disabled) { transform: translateY(-1px); }
.auth-submit:disabled { opacity: 0.7; cursor: not-allowed; }

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.45;
}

.auth-alert--success {
    background: var(--color-success-light);
    color: var(--color-success-dark);
}

.auth-alert--danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.auth-alert ul {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
}

.auth-footer-links {
    margin-top: 1.25rem;
    text-align: center;
}

.auth-mobile-footer,
.auth-form-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

@media (min-width: 1024px) {
    .auth-mobile-footer { display: none; }
}

@media (max-width: 1023px) {
    .auth-welcome-title { font-size: clamp(1.35rem, 6vw, 1.75rem); }

    .auth-mobile-branding {
        margin-bottom: 1.25rem;
    }

    .auth-mobile-branding span {
        font-size: clamp(1.05rem, 4.5vw, 1.25rem);
    }

    .portal-card {
        padding: 0.85rem;
    }

    .portal-chevron {
        display: none;
    }

    .portal-card-subtitle {
        font-size: 0.75rem;
    }

    .auth-form-wrap {
        max-width: 100%;
    }

    .auth-form-card {
        padding: 1.25rem;
    }

    .portal-form-header {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .portal-form-title {
        font-size: clamp(1.15rem, 5vw, 1.5rem);
    }

    .auth-label-row {
        flex-wrap: wrap;
        gap: 0.25rem 0.75rem;
    }

    .auth-mobile-footer,
    .auth-form-footer {
        margin-top: 1.25rem;
        text-transform: none;
        letter-spacing: 0.04em;
        font-weight: 600;
    }
}

@media (max-width: 559px) {
    .auth-blob--a {
        width: 28vw;
        height: 28vw;
        right: -8%;
    }

    .portal-card-head {
        gap: 0.5rem;
    }

    .portal-icon-wrap {
        width: 2.5rem;
        height: 2.5rem;
    }

    .portal-icon-wrap svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .portal-chevron {
        display: none;
    }

    .auth-stats {
        margin-top: 1.25rem;
        padding-top: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .auth-screen {
        padding:
            max(0.5rem, env(safe-area-inset-top, 0px))
            max(0.5rem, env(safe-area-inset-right, 0px))
            max(0.5rem, env(safe-area-inset-bottom, 0px))
            max(0.5rem, env(safe-area-inset-left, 0px));
    }

    .auth-card {
        min-height: calc(100dvh - 1rem);
        border-radius: 1rem;
    }

    .auth-right {
        padding: 1rem 0.85rem 1.25rem;
    }

    .auth-stats { display: none; }

    .auth-form-card { padding: 1rem; }

    .auth-portal-badge {
        font-size: 0.7rem;
        padding: 0.3rem 0.75rem;
    }
}

@media (max-width: 360px) {
    .auth-mobile-branding { margin-bottom: 0.75rem; }

    .portal-grid { gap: 0.5rem; }

    .portal-card { padding: 0.7rem; }

    .portal-last-badge { display: none; }
}

@media (max-width: 1023px) and (max-height: 520px) and (orientation: landscape) {
    .auth-screen {
        align-items: flex-start;
    }

    .auth-card {
        min-height: auto;
    }

    .auth-mobile-branding {
        margin-bottom: 0.75rem;
    }

    .auth-welcome-title {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .portal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 0.75rem;
        gap: 0.5rem;
    }

    .auth-stats { display: none; }
}

@media (min-width: 1024px) and (max-width: 1280px) {
    .auth-left { padding: 1.75rem; }

    .auth-headline { font-size: 2.15rem; }

    .auth-features {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth-right { padding: 1.75rem; }
}

@keyframes slowSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulseSoft {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.22; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.animate-fade-in-up { animation: fadeInUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@media (prefers-reduced-motion: reduce) {
    .animate-fade-in,
    .animate-fade-in-up,
    .auth-blob,
    .auth-start-mesh { animation: none !important; }
    .portal-card:hover,
    .auth-submit:hover:not(:disabled) { transform: none; }
}
