.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #101426;
}

.auth-overlay[hidden] {
    display: none;
}

.auth-card {
    width: min(460px, 100%);
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background: #1a2038;
    color: #fff;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
}

.auth-card h1 {
    margin-bottom: 8px;
    font-size: 24px;
}

.auth-card > p {
    margin-bottom: 22px;
    color: rgba(255, 255, 255, 0.65);
}

.auth-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
}

.auth-method,
.auth-submit {
    padding: 11px 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    cursor: pointer;
}

.auth-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: #9daeff;
    cursor: pointer;
    text-align: left;
}

.auth-link:disabled {
    color: rgba(255, 255, 255, 0.45);
    cursor: wait;
}

.auth-reset-intro {
    margin: 0 0 18px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
}

.auth-method.active,
.auth-submit {
    border-color: #4361ee;
    background: #4361ee;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: grid;
    gap: 14px;
}

.auth-field {
    display: grid;
    gap: 6px;
}

.auth-field[hidden] {
    display: none !important;
}

.auth-field label {
    color: rgba(255, 255, 255, 0.72);
    font-size: 13px;
}

.auth-field input,
.auth-field select,
.user-form input,
.user-form select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.auth-field select option,
.user-form select option {
    background: #1a2038;
}

.auth-error {
    min-height: 20px;
    color: #ff6b7a;
    font-size: 13px;
}

.auth-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.auth-profile {
    position: relative;
}

.auth-profile-trigger {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--input-border);
    border-radius: 50%;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.auth-profile-trigger:hover,
.auth-profile-trigger[aria-expanded="true"] {
    border-color: var(--accent-blue);
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.auth-profile-icon {
    position: relative;
    display: block;
    width: 20px;
    height: 20px;
}

.auth-profile-icon::before,
.auth-profile-icon::after {
    position: absolute;
    left: 50%;
    content: "";
    background: currentColor;
    transform: translateX(-50%);
}

.auth-profile-icon::before {
    top: 1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.auth-profile-icon::after {
    bottom: 1px;
    width: 17px;
    height: 9px;
    border-radius: 9px 9px 4px 4px;
}

.auth-profile-menu {
    position: absolute;
    z-index: 300;
    top: calc(100% + 10px);
    right: 0;
    width: min(300px, calc(100vw - 28px));
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--modal-bg);
    color: var(--text-primary);
    box-shadow: 0 20px 55px rgba(4, 8, 20, 0.28);
    animation: profile-menu-in 180ms ease-out;
}

.auth-profile-menu[hidden] {
    display: none;
}

@keyframes profile-menu-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-profile-heading {
    display: grid;
    gap: 3px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.auth-profile-heading span,
.auth-profile-detail span {
    color: var(--text-secondary);
    font-size: 12px;
}

.auth-profile-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
}

.auth-profile-menu .auth-tenant-switch {
    margin-bottom: 12px;
}

.auth-profile-menu .auth-tenant-switch select,
.auth-profile-menu .auth-logout {
    width: 100%;
}

.auth-profile-menu .auth-logout {
    min-height: 40px;
    border-color: color-mix(in srgb, var(--accent-red) 35%, transparent);
    color: var(--accent-red);
}

.auth-user-meta {
    color: var(--text-secondary);
}

.auth-logout {
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
}

.auth-tenant-switch {
    display: grid;
    gap: 3px;
    color: var(--text-secondary);
    font-size: 11px;
}

.auth-tenant-switch select {
    padding: 7px 9px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-primary);
}

.user-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.user-form .full {
    grid-column: 1 / -1;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
}

.user-table th,
.user-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.user-delete {
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: var(--accent-red);
    color: #fff;
    cursor: pointer;
}

.user-email-editor {
    display: flex;
    gap: 6px;
    min-width: 260px;
}

.user-email {
    width: 100%;
    min-width: 0;
    padding: 7px 9px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.user-email-save {
    padding: 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
}

[data-theme="light"] .auth-overlay {
    background:
        radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--brand-red) 15%, transparent), transparent 34%),
        linear-gradient(145deg, #ffffff, #eceeef);
}

[data-theme="light"] .auth-card {
    border-color: color-mix(in srgb, var(--brand-red) 20%, transparent);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text-primary);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--brand-red-dark) 16%, transparent);
}

[data-theme="light"] .auth-card h1 {
    color: var(--brand-red-dark);
}

[data-theme="light"] .auth-card > p,
[data-theme="light"] .auth-reset-intro,
[data-theme="light"] .auth-field label {
    color: var(--text-secondary);
}

[data-theme="light"] .auth-method {
    border-color: var(--input-border);
    background: #fff;
    color: var(--text-secondary);
}

[data-theme="light"] .auth-method.active,
[data-theme="light"] .auth-submit {
    border-color: var(--brand-red);
    background: var(--brand-red);
    color: #fff;
}

[data-theme="light"] .auth-link {
    color: var(--brand-red-dark);
}

[data-theme="light"] .auth-field input,
[data-theme="light"] .auth-field select,
[data-theme="light"] .user-form input,
[data-theme="light"] .user-form select {
    border-color: var(--input-border);
    background-color: #fff;
    color: var(--text-primary);
}

[data-theme="light"] .auth-field select option,
[data-theme="light"] .user-form select option {
    background: #fff;
}

@media (max-width: 768px) {
    .auth-user {
        flex-wrap: wrap;
        justify-content: center;
    }

    .user-form {
        grid-template-columns: 1fr;
    }

    .user-form .full {
        grid-column: auto;
    }
}
