/* Sign in / signed out / session expired — standalone pages, no portal chrome.
 *
 * Colours follow the tenant's branding when one is applied: brandingCss()
 * (Settings → Branding) defines --cr-primary, --cr-primary-rgb, --cr-bg and
 * --cr-bg-deep, and --auth-on-accent is set per page for contrast. Without
 * them everything falls back to the Sphenica purple theme. */
:root {
    --auth-accent: var(--cr-primary, #a855f7);
    --auth-accent-rgb: var(--cr-primary-rgb, 168, 85, 247);
    --auth-on-accent: #fff;
    --auth-bg: var(--cr-bg-deep, #07080d);
    --auth-card: var(--cr-bg, #0b0f15);
    --auth-border: rgba(255, 255, 255, .07);
    --auth-text: #eeecf7;
    --auth-muted: #a9a6ba;
    --auth-faint: #7c7a92;
    --auth-green: #22c55e;
}

* { box-sizing: border-box; }

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

body.auth-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(900px 520px at 0% 0%, rgba(var(--auth-accent-rgb), .10), transparent 60%),
        radial-gradient(700px 480px at 100% 100%, rgba(var(--auth-accent-rgb), .05), transparent 60%),
        var(--auth-bg);
    color: var(--auth-text);
    font-family: "Red Hat Text", system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* the card's halo bleeds past narrow screens */
}

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem 1rem;
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 560px;
    background: var(--auth-card);
    border: 1px solid rgba(var(--auth-accent-rgb), .22);
    border-radius: 6px;
    padding: 2.75rem 3rem 2.25rem;
    text-align: center;
    box-shadow:
        0 0 0 1px rgba(var(--auth-accent-rgb), .06),
        0 0 60px rgba(var(--auth-accent-rgb), .22),
        0 0 140px rgba(var(--auth-accent-rgb), .14),
        0 30px 80px rgba(0, 0, 0, .5);
}

/* soft halo behind the card */
.auth-card::before {
    content: "";
    position: absolute;
    inset: -90px;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(var(--auth-accent-rgb), .20), rgba(var(--auth-accent-rgb), .06) 60%, transparent);
    filter: blur(20px);
    pointer-events: none;
}

/* ---- brand header ---- */
.auth-wordmark {
    display: block;
    width: 280px;
    max-width: 80%;
    height: auto;
    margin: 0 auto 1.75rem;
}

.auth-brand { margin: 0 auto 1.75rem; }

.auth-logo {
    display: block;
    max-width: 220px;
    max-height: 96px;
    width: auto;
    height: auto;
    margin: 0 auto .9rem;
    object-fit: contain;
}

.auth-initial {
    width: 72px;
    height: 72px;
    margin: 0 auto .9rem;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
    font-size: 2rem;
    background: rgba(var(--auth-accent-rgb), .16);
    border: 1px solid rgba(var(--auth-accent-rgb), .35);
    color: var(--auth-accent);
}

.auth-brand-name {
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: .01em;
    color: var(--auth-muted);
}

/* ---- text ---- */
.auth-title {
    font-family: "Red Hat Display", "Red Hat Text", system-ui, sans-serif;
    font-weight: 700;
    font-size: clamp(1.9rem, 5vw, 2.55rem);
    letter-spacing: -.02em;
    line-height: 1.1;
    margin: 0 0 .85rem;
}

.auth-sub {
    color: var(--auth-muted);
    font-size: 1rem;
    margin: 0 0 1.4rem;
}

.auth-sub strong { color: var(--auth-text); font-weight: 600; }

.auth-context {
    color: var(--auth-faint);
    font-size: .88rem;
    margin: 0 0 1.75rem;
}

.auth-context strong { color: var(--auth-muted); font-weight: 600; }

/* ---- buttons ---- */
.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .6rem;
    width: 100%;
    min-height: 48px;
    padding: .7rem 1rem;
    border: 0;
    border-radius: 4px;
    background: var(--auth-accent);
    color: var(--auth-on-accent);
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    box-shadow: 0 10px 30px rgba(var(--auth-accent-rgb), .25);
    transition: filter .15s ease, background-color .15s ease, transform .15s ease, box-shadow .15s ease;
}

.auth-btn:hover, .auth-btn:focus-visible {
    filter: brightness(1.1);
    color: var(--auth-on-accent);
    box-shadow: 0 12px 34px rgba(var(--auth-accent-rgb), .35);
}

.auth-btn:active { transform: translateY(1px); }

.auth-btn:focus-visible { outline: 2px solid var(--auth-text); outline-offset: 2px; }

.auth-btn .auth-btn-mark, .auth-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.auth-btn + .auth-btn { margin-top: .85rem; }

.auth-btn.discord {
    background: #262b5c;
    border: 1px solid #4a52a3;
    color: #fff;
    box-shadow: 0 10px 30px rgba(88, 101, 242, .18);
}

.auth-btn.discord:hover, .auth-btn.discord:focus-visible {
    filter: none;
    background: #5865f2;
    border-color: #5865f2;
    color: #fff;
    box-shadow: 0 12px 34px rgba(88, 101, 242, .32);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--auth-faint);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 1rem 0;
}

.auth-divider::before, .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

.auth-divider + .auth-btn { margin-top: 0; }

.auth-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--auth-muted);
    font-size: .88rem;
    text-decoration: none;
}

.auth-link:hover { color: var(--auth-text); text-decoration: underline; }

.auth-note {
    color: var(--auth-faint);
    font-size: .8rem;
    line-height: 1.55;
    margin: 1.5rem 0 0;
}

.auth-alert {
    display: flex;
    gap: .55rem;
    align-items: flex-start;
    text-align: left;
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .3);
    color: #fca5a5;
    border-radius: 4px;
    padding: .7rem .85rem;
    font-size: .86rem;
    margin: 0 0 1.5rem;
}

.auth-status {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 1.5rem;
}

.auth-status.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .3); color: var(--auth-green); }
.auth-status.warn { background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .3); color: #f5b84d; }

.auth-footer {
    text-align: center;
    color: var(--auth-faint);
    font-size: .85rem;
    padding: 1.5rem 1rem 2rem;
}

.auth-footer a { color: var(--auth-muted); text-decoration: none; }
.auth-footer a:hover { color: var(--auth-text); }

/* ---- tenant picker (/tenants) ---- */
.auth-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem .85rem;
    margin: 0 0 1.75rem;
    border: 1px solid var(--auth-border);
    border-radius: 6px;
    background: rgba(255, 255, 255, .02);
    text-align: left;
}

.auth-identity .who { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.auth-identity .min-w-0 { min-width: 0; }

.auth-identity .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: rgba(var(--auth-accent-rgb), .16);
    color: var(--auth-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
}

.auth-identity .name { font-weight: 600; font-size: .92rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-identity .handle { color: var(--auth-faint); font-size: .78rem; }

.auth-identity .not-you {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    flex-shrink: 0;
    padding: .4rem .7rem;
    border-radius: 4px;
    border: 1px solid rgba(239, 68, 68, .35);
    color: #fca5a5;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}

.auth-identity .not-you:hover { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .6); color: #fecaca; }

.tenant-list { display: flex; flex-direction: column; gap: .5rem; text-align: left; }

/* Each row may carry its tenant's accent (--t-accent / --t-accent-rgb from
   Settings → Branding, when its plan includes it); otherwise the page accent. */
.tenant-row {
    --t-c: var(--t-accent, var(--auth-accent));
    --t-rgb: var(--t-accent-rgb, var(--auth-accent-rgb));
    position: relative;
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .75rem .9rem;
    border-radius: 6px;
    border: 1px solid var(--auth-border);
    background: rgba(255, 255, 255, .015);
    color: var(--auth-text);
    text-decoration: none;
    overflow: hidden;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.tenant-row:hover, .tenant-row:focus-visible {
    background: rgba(var(--t-rgb), .07);
    border-color: rgba(var(--t-rgb), .45);
    box-shadow: 0 0 28px rgba(var(--t-rgb), .16);
    color: var(--auth-text);
    outline: none;
}

.tenant-row:active { transform: translateY(1px); }

/* accent bar for tenants with their own colour */
.tenant-row.has-accent::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--t-c);
}

.tenant-tile {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--t-rgb), .10);
    border: 1px solid rgba(var(--t-rgb), .28);
}

.tenant-tile img { width: 100%; height: 100%; object-fit: cover; }
.tenant-tile img.brand-logo { object-fit: contain; padding: 4px; } /* logos can be any shape */

.tenant-tile .fallback {
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--t-c);
}

.tenant-tile .fallback[hidden] { display: none; }

.tenant-meta { flex: 1; min-width: 0; }

.tenant-meta .t-name {
    font-family: "Red Hat Display", system-ui, sans-serif;
    font-weight: 700;
    font-size: .98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tenant-meta .t-id {
    color: var(--auth-faint);
    font-size: .74rem;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

.tenant-type {
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .06);
    color: var(--auth-muted);
}

.tenant-type.type-system { background: rgba(168, 85, 247, .12); color: #c084fc; }
.tenant-type.type-fivem { background: rgba(255, 166, 0, .10); color: #ffb020; }

.tenant-row .t-arrow {
    flex-shrink: 0;
    color: var(--auth-faint);
    font-size: 1rem;
    transition: transform .15s ease, color .15s ease;
}

.tenant-row:hover .t-arrow, .tenant-row:focus-visible .t-arrow { color: var(--t-c); transform: translateX(3px); }

.tenant-empty {
    padding: 1.75rem 1rem;
    border: 1px dashed var(--auth-border);
    border-radius: 6px;
    color: var(--auth-faint);
    font-size: .88rem;
}

.tenant-empty i { display: block; font-size: 1.6rem; margin-bottom: .5rem; opacity: .7; }

@media (max-width: 575.98px) {
    .auth-card { padding: 2rem 1.25rem 1.75rem; }
    .tenant-type { display: none; }
}
