:root {
    --auth-page-bg: linear-gradient(180deg, #eef3f7 0%, #f8fafc 100%);
    --auth-page-text: #1f2937;
    --auth-page-muted: #4b5563;
    --auth-surface: rgba(255,255,255,0.92);
    --auth-surface-solid: rgba(255,255,255,0.96);
    --auth-border: #e5e7eb;
    --auth-danger: #dc2626;
    --auth-shadow-lg: 0 24px 80px rgba(15, 23, 42, 0.14);
}

.auth-page,
.auth-state-page {
    margin: 0;
    min-height: 100vh;
    background: var(--auth-page-bg);
    color: var(--auth-page-text);
    font-family: system-ui, sans-serif;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1.2fr) minmax(320px, 0.8fr);
}

.auth-hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: #fff;
    overflow: hidden;
}

.auth-hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.3;
}

.auth-hero-content {
    position: relative;
    z-index: 1;
    max-width: 520px;
    text-align: center;
}

.auth-kicker {
    display: inline-block;
    margin-bottom: 16px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.18);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-hero h1 {
    margin: 0 0 12px;
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1.05;
}

.auth-hero p {
    margin: 0;
    font-size: 18px;
    line-height: 1.5;
}

.auth-logo {
    width: 96px;
    height: 96px;
    margin: 0 auto 18px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(2, 37, 78, 0.95);
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 999px;
}

.auth-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
    padding: 48px;
    background: var(--auth-surface);
    backdrop-filter: blur(8px);
}

.auth-card h2 {
    margin: 0;
    font-size: 32px;
}

.auth-copy {
    margin: 0;
    color: var(--auth-page-muted);
    line-height: 1.5;
}

.auth-email-row {
    display: flex;
    width: 100%;
    max-width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-sizing: border-box;
}

.auth-email-row input {
    flex: 1;
    min-width: 0;
    border: 0;
    padding: 14px 16px;
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
}

.auth-email-domain {
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #f3f4f6;
    border-left: 1px solid #e5e7eb;
    color: #4b5563;
    white-space: nowrap;
}

.auth-link-btn {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--auth-primary);
    text-align: left;
    cursor: pointer;
    font-size: 14px;
}

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

.auth-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #374151;
}

.auth-challenge {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.auth-challenge p {
    margin: 0;
}

.auth-challenge input,
.auth-code-box input {
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;
}

.auth-challenge button,
.auth-code-box button,
.auth-submit {
    border: 0;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.auth-submit,
.auth-challenge button,
.auth-code-box button {
    background: var(--auth-primary);
    color: #fff;
}

.auth-code-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.auth-code-box p {
    margin: 0;
}

.auth-code-box input {
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.22em;
    font: 700 24px/1.2 Consolas, Monaco, monospace;
}

.auth-resend {
    align-self: flex-start;
}

.auth-submit[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-status {
    min-height: 20px;
    font-size: 14px;
    color: #4b5563;
}

.auth-status.error {
    color: #b91c1c;
}

.auth-status.success {
    color: #047857;
}

.auth-state-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--auth-page-bg);
    color: var(--auth-page-text);
}

.auth-state-card {
    width: min(100%, 560px);
    padding: 28px;
    border-radius: 24px;
    background: var(--auth-surface-solid);
    box-shadow: var(--auth-shadow-lg);
}

.auth-state-card h1 {
    margin: 0 0 12px;
    font-size: clamp(28px, 6vw, 40px);
    line-height: 1.05;
}

.auth-state-card p {
    margin: 0 0 16px;
    color: var(--auth-page-muted);
    line-height: 1.6;
}

.auth-state-status {
    min-height: 24px;
    margin-bottom: 16px;
    color: #047857;
}

.auth-state-status.error {
    color: #b91c1c;
}

.auth-state-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.auth-state-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: 0;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
}

.auth-state-btn--primary {
    background: var(--auth-danger);
    color: #fff;
}

.auth-state-btn--secondary {
    background: #e5e7eb;
    color: #111827;
}

.auth-org-list {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.auth-org-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--auth-border);
    border-radius: 18px;
    background: #fff;
}

.auth-org-logo,
.auth-org-logo-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 16px;
}

.auth-org-logo {
    object-fit: cover;
    background: #fff;
}

.auth-org-logo-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--auth-primary);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
}

.auth-org-info {
    min-width: 0;
}

.auth-org-title {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.2;
}

.auth-org-meta {
    margin: 0;
    color: var(--auth-page-muted);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

html.auth-theme-root,
body.auth-state-page--scrollable {
    height: auto;
    max-height: none;
    overflow: auto;
}

.auth-state-page--themed {
    background: var(--color-bg, var(--auth-page-bg));
    color: var(--color-text, var(--auth-page-text));
}

.auth-state-card--directory {
    width: min(100%, 1400px);
    padding: clamp(18px, 2.2vw, 28px);
    border: 1px solid var(--color-border, var(--auth-border));
    border-radius: var(--radius-md, 10px);
    background: var(--color-surface, var(--auth-surface-solid));
    box-shadow: none;
}

.auth-state-card--directory h1 {
    color: var(--color-text, var(--auth-page-text));
}

.auth-state-card--directory p {
    color: var(--color-text-light, var(--auth-page-muted));
}

.auth-state-status--directory {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: auto;
    margin-bottom: 18px;
    padding: 8px 14px;
    border: 1px solid var(--color-border, var(--auth-border));
    border-radius: var(--radius-sm, 6px);
    background: var(--color-surface-alt, #f3f4f6);
    color: var(--color-text-light, var(--auth-page-muted));
    font-size: 13px;
    font-weight: 600;
}

.auth-state-status--directory.error {
    background: color-mix(in srgb, #dc2626 8%, var(--color-surface-alt, #f3f4f6));
    border-color: color-mix(in srgb, #dc2626 18%, var(--color-border, var(--auth-border)));
    color: #dc2626;
}

.auth-org-list--directory {
    grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
    justify-content: center;
    gap: 14px;
    margin-top: 22px;
}

.auth-org-card--directory {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border-radius: var(--radius-md, 10px);
    border-color: var(--color-border, var(--auth-border));
    background: var(--color-surface, #fff);
    box-shadow: none;
    color: inherit;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.auth-org-card--directory,
.auth-org-card--directory:hover,
.auth-org-card--directory:focus-visible,
.auth-org-card--directory * {
    text-decoration: none;
}

.auth-org-card--directory:hover,
.auth-org-card--directory:focus-visible {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--auth-org-accent, var(--color-primary, var(--auth-primary))) 18%, var(--color-border-strong, var(--auth-border)));
    background: color-mix(in srgb, var(--color-surface, #fff) 92%, var(--color-surface-alt, #f3f4f6));
}

.auth-org-card--directory:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--auth-org-accent, var(--color-primary, var(--auth-primary))) 28%, transparent);
    outline-offset: 2px;
}

.auth-org-card__banner {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--auth-org-accent, var(--color-primary, var(--auth-primary)));
}

.auth-org-card__banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(15, 23, 42, 0.16));
}

.auth-org-card__banner img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.auth-org-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 12px;
    padding: 0 14px 14px;
    min-height: 124px;
}

.auth-org-card__header {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: -24px;
    position: relative;
    z-index: 1;
}

.auth-org-logo--directory,
.auth-org-logo-placeholder--directory {
    flex: 0 0 auto;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm, 6px);
    border: 2px solid var(--color-surface, #fff);
    background: var(--color-surface, #fff);
    box-shadow: none;
}

.auth-org-info--directory {
    min-width: 0;
    display: grid;
    gap: 3px;
    padding-bottom: 2px;
}

.auth-org-title--directory {
    margin: 0;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--color-text, var(--auth-page-text));
    font-weight: 600;
}

.auth-org-meta--directory {
    margin: 0;
    color: var(--color-text-light, var(--auth-page-muted));
    font-size: 0.82rem;
    line-height: 1.35;
}

.auth-org-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.auth-org-badge,
.auth-org-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--color-border, var(--auth-border));
    border-radius: var(--radius-sm, 6px);
    background: var(--color-surface-alt, #f3f4f6);
    font-size: 12px;
    line-height: 1;
}

.auth-org-badge {
    min-height: 28px;
    padding: 0 10px;
    color: var(--color-text-light, var(--auth-page-muted));
    font-weight: 500;
}

.auth-org-action {
    color: var(--color-text, var(--auth-page-text));
    font-size: 13px;
    font-weight: 600;
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-hero,
    .auth-card {
        padding: 28px 22px;
    }

    .auth-state-page {
        padding: 20px;
    }

    .auth-state-card {
        padding: 24px;
    }

    .auth-org-card {
        grid-template-columns: 1fr;
        justify-items: start;
    }
}

@media (max-width: 768px) {
    .auth-state-card--directory {
        padding: 20px;
    }

    .auth-org-list--directory {
        grid-template-columns: 1fr;
        gap: 16px;
        justify-content: stretch;
    }

    .auth-org-card__body {
        padding: 0 16px 16px;
    }

    .auth-org-card__header {
        gap: 12px;
        margin-top: -24px;
    }

    .auth-org-logo--directory,
    .auth-org-logo-placeholder--directory {
        width: 64px;
        height: 64px;
    }

    .auth-org-card__footer {
        flex-direction: column;
        align-items: stretch;
    }

    .auth-org-action {
        width: 100%;
    }
}
