/*
 * Sign-in screens (includes/auth_layout.php). Always light. The brand panel
 * is mixed from --color-brand, so a white-label portal gets its own colour.
 */
body.auth .hidden { display: none !important; }
body.auth { margin: 0; background: var(--color-surface-raised); color: var(--color-text-primary); }
.auth-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Brand header (phones) / panel (wide screens) ---------- */
.auth-hero {
    position: relative; isolation: isolate; overflow: hidden; color: #fff;
    padding: calc(1.25rem + env(safe-area-inset-top)) 1.5rem 3.5rem;
    background-color: var(--color-brand);
    background-color: color-mix(in srgb, var(--color-brand) 42%, #060c1c);
    background-image:
        radial-gradient(90% 80% at 100% 0%, rgb(var(--color-accent-rgb) / 0.5), transparent 62%),
        radial-gradient(110% 90% at 0% 100%, rgb(var(--color-brand-rgb) / 0.85), transparent 66%);
}
/* A fine dot grid and a slow-moving glow keep the panel alive. */
.auth-hero::before { content: ""; position: absolute; z-index: -1; inset: 0; background-image: radial-gradient(rgb(255 255 255 / 0.16) 1px, transparent 1.4px); background-size: 22px 22px; -webkit-mask: linear-gradient(150deg, #000, transparent 70%); mask: linear-gradient(150deg, #000, transparent 70%); }
.auth-hero::after { content: ""; position: absolute; z-index: -1; width: 22rem; height: 22rem; right: -9rem; bottom: -11rem; border-radius: 50%; background: radial-gradient(circle, rgb(255 255 255 / 0.2), transparent 68%); animation: auth-drift 12s ease-in-out infinite alternate; }

.auth-brand { display: flex; align-items: center; gap: 0.75rem; }
.auth-logo { display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; width: 2.875rem; height: 2.875rem; border-radius: 1rem; background: #fff; box-shadow: 0 12px 24px -10px rgb(0 0 0 / 0.55); }
.auth-logo img { max-width: 78%; max-height: 78%; width: auto; height: auto; object-fit: contain; }
.auth-logo b { font-size: 1.25rem; font-weight: 800; color: var(--color-brand); }
.auth-brand-text { min-width: 0; line-height: 1.2; }
.auth-brand-name { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.auth-brand-tag { display: block; margin-top: 0.125rem; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: rgb(255 255 255 / 0.7); }

.auth-pitch { margin-top: 1.5rem; }
.auth-headline { max-width: 30rem; font-size: 1.625rem; line-height: 1.18; font-weight: 800; letter-spacing: -0.03em; text-wrap: balance; }
.auth-lead { max-width: 27rem; margin-top: 0.5rem; font-size: 0.875rem; line-height: 1.55; color: rgb(255 255 255 / 0.78); }
.auth-cards, .auth-copy { display: none; }

/* ---------- Form sheet ---------- */
.auth-main { position: relative; flex: 1; display: flex; justify-content: center; margin-top: -1.75rem; padding: 1.75rem 1.5rem calc(2rem + env(safe-area-inset-bottom)); border-radius: 1.75rem 1.75rem 0 0; background: var(--color-surface-raised); animation: auth-rise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.auth-panel { width: 100%; max-width: 25rem; }
.auth-title { font-size: 1.75rem; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; }
.auth-sub { margin-top: 0.375rem; font-size: 0.9375rem; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.auth-sub strong { color: var(--color-text-primary); }
.auth-badge { display: inline-flex; align-items: center; gap: 0.375rem; margin-bottom: 0.875rem; padding: 0.3125rem 0.75rem; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--color-danger); background: var(--color-danger-bg); }
.auth-form { display: grid; gap: 0.875rem; margin-top: 1.5rem; }

.auth-field { position: relative; display: flex; align-items: center; height: 3.625rem; border: 1.5px solid var(--color-border-default); border-radius: 1.125rem; background: var(--color-surface-muted); transition: border-color var(--duration-instant), box-shadow var(--duration-instant), background-color var(--duration-instant); }
.auth-field:focus-within { border-color: var(--color-brand); background: var(--color-surface-raised); box-shadow: 0 0 0 4px rgb(var(--color-brand-rgb) / 0.14); }
.auth-field:has(input[aria-invalid="true"]) { border-color: var(--color-danger); }
.auth-field-icon { display: flex; flex-shrink: 0; padding-left: 1rem; color: var(--color-text-secondary); }
.auth-field:focus-within .auth-field-icon { color: var(--color-brand); }
.auth-field input { flex: 1; min-width: 0; height: 100%; padding: 1.25rem 0.75rem 0.25rem; border: 0; outline: none; background: transparent; font-size: 1rem; font-weight: 500; color: var(--color-text-primary); }
.auth-field input:focus-visible { outline: none; }
.auth-field input:-webkit-autofill { -webkit-background-clip: text; background-clip: text; }
.auth-field label { position: absolute; left: 3rem; top: 50%; transform: translateY(-50%); font-size: 0.9375rem; color: var(--color-text-secondary); pointer-events: none; white-space: nowrap; transition: top var(--duration-instant), font-size var(--duration-instant); }
.auth-field input:focus ~ label, .auth-field input:not(:placeholder-shown) ~ label { top: 1.0625rem; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.02em; }
.auth-field input:-webkit-autofill ~ label { top: 1.0625rem; font-size: 0.6875rem; font-weight: 600; }
.auth-eye { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.75rem; height: 2.75rem; margin-right: 0.375rem; border-radius: 0.875rem; color: var(--color-text-secondary); }
.auth-eye:hover { background: var(--color-brand-muted); color: var(--color-brand); }
.auth-eye .auth-eye-hide, .auth-eye[aria-pressed="true"] .auth-eye-show { display: none; }
.auth-eye[aria-pressed="true"] .auth-eye-hide { display: block; }

.auth-hint { font-size: 0.8125rem; color: var(--color-text-secondary); }
.auth-warn { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; font-weight: 600; color: var(--color-warning); }
.auth-alert { display: flex; align-items: flex-start; gap: 0.625rem; padding: 0.75rem 0.875rem; border-radius: 0.875rem; background: var(--color-danger-bg); font-size: 0.875rem; font-weight: 600; color: var(--color-danger); animation: auth-shake 320ms ease; }
.auth-alert::before { content: ""; flex-shrink: 0; width: 1.125rem; height: 1.125rem; margin-top: 0.0625rem; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 8v5M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat; }
.auth-form > .auth-alert, .auth-panel > .auth-alert { margin: 0; }
.auth-panel > .auth-alert { margin-top: 1.25rem; }

.auth-submit { position: relative; display: flex; align-items: center; justify-content: center; gap: 0.625rem; width: 100%; height: 3.5rem; margin-top: 0.25rem; border: 0; border-radius: 1.125rem; cursor: pointer; font-size: 1rem; font-weight: 700; color: #fff; background-color: var(--color-brand); background-image: linear-gradient(120deg, rgb(255 255 255 / 0), rgb(255 255 255 / 0.18)); box-shadow: 0 16px 28px -14px rgb(var(--color-brand-rgb) / 0.95); transition: transform 90ms, background-color var(--duration-instant), box-shadow var(--duration-instant); }
.auth-submit:hover { background-color: var(--color-brand-emphasis); }
.auth-submit:active { transform: scale(0.985); }
.auth-submit svg { transition: transform var(--duration-instant); }
.auth-submit:hover svg { transform: translateX(3px); }
.auth-submit:disabled { cursor: progress; color: transparent; box-shadow: none; }
.auth-submit:disabled svg { visibility: hidden; }
.auth-submit:disabled::after { content: ""; position: absolute; left: 50%; top: 50%; width: 1.25rem; height: 1.25rem; margin: -0.625rem 0 0 -0.625rem; border: 2.5px solid rgb(255 255 255 / 0.4); border-top-color: #fff; border-radius: 50%; animation: auth-spin 700ms linear infinite; }
.auth-link-button { width: 100%; height: 3rem; border-radius: 1rem; font-size: 0.9375rem; font-weight: 600; color: var(--color-text-secondary); }
.auth-link-button:hover { background: var(--color-surface-muted); color: var(--color-text-primary); }
a.auth-submit { text-decoration: none; margin-top: 1.5rem; }

.auth-note { display: flex; align-items: flex-start; gap: 0.75rem; margin-top: 1.5rem; padding: 0.875rem 1rem; border-radius: 1rem; border: 1px dashed var(--color-border-strong); font-size: 0.8125rem; line-height: 1.5; color: var(--color-text-secondary); }
.auth-note svg { flex-shrink: 0; color: var(--color-brand); }
.auth-note a, .auth-sub a { font-weight: 700; color: var(--color-brand); overflow-wrap: anywhere; }
.auth-note a:hover, .auth-sub a:hover { text-decoration: underline; }
.auth-below { margin-top: 1.25rem; text-align: center; font-size: 0.8125rem; color: var(--color-text-secondary); }
.auth-below a { font-weight: 700; color: var(--color-brand); }

/* Two-factor: the code in wide, evenly spaced digits. */
.auth-code input { padding: 0 3.25rem 0 0; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.5em; }
.auth-code input::placeholder { color: var(--color-border-strong); }
.auth-secret { width: 100%; padding: 0.75rem 1rem; border: 1.5px dashed var(--color-border-strong); border-radius: 1rem; background: var(--color-surface-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.875rem; font-weight: 600; text-align: center; color: var(--color-text-primary); text-overflow: ellipsis; }

/* Status screens (suspended, link expired, portal not ready). */
.auth-status-icon { display: flex; align-items: center; justify-content: center; width: 4rem; height: 4rem; margin-bottom: 1.25rem; border-radius: 1.5rem; }
.auth-status-icon.is-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.auth-status-icon.is-warning { background: var(--color-warning-bg); color: var(--color-warning); }

@media (min-width: 640px) and (max-width: 1023px) {
    .auth-hero { padding-inline: 2.5rem; padding-block-end: 4.5rem; }
    .auth-brand, .auth-pitch { width: 100%; max-width: 30rem; margin-inline: auto; }
    .auth-main { width: calc(100% - 3rem); max-width: 33rem; margin-inline: auto; margin-top: -2.5rem; margin-bottom: 2rem; flex: 0 0 auto; padding: 2.5rem; border-radius: 1.75rem; box-shadow: 0 30px 60px -30px rgb(14 26 47 / 0.35); border: 1px solid var(--color-border-default); }
    body.auth { background: var(--color-surface-base); }
}

@media (min-width: 1024px) {
    .auth-shell { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); padding: 1rem; gap: 1rem; }
    .auth-hero { display: flex; flex-direction: column; padding: 2.5rem 3rem 2rem; border-radius: 2rem; }
    .auth-pitch { margin-top: auto; padding-top: 2.5rem; }
    .auth-headline { font-size: clamp(2rem, 3vw, 2.75rem); }
    .auth-lead { margin-top: 0.875rem; font-size: 1rem; }
    .auth-cards { display: grid; gap: 0.75rem; max-width: 30rem; margin: 2rem 0 auto; padding: 0; list-style: none; }
    .auth-cards li { display: flex; align-items: center; gap: 0.875rem; padding: 0.875rem 1.125rem; border: 1px solid rgb(255 255 255 / 0.16); border-radius: 1.25rem; background: rgb(255 255 255 / 0.09); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 20px 40px -28px rgb(0 0 0 / 0.7); animation: auth-float 7s ease-in-out infinite; }
    .auth-cards li:nth-child(2) { margin-left: 2.25rem; animation-delay: -2.4s; }
    .auth-cards li:nth-child(3) { margin-left: 0.75rem; margin-right: 1.5rem; animation-delay: -4.6s; }
    .auth-cards b { display: block; font-size: 0.9375rem; font-weight: 700; }
    .auth-cards small { display: block; font-size: 0.8125rem; color: rgb(255 255 255 / 0.72); }
    .auth-card-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.75rem; height: 2.75rem; border-radius: 0.875rem; background: #fff; color: var(--color-brand); }
    .auth-card-bars { display: flex; align-items: flex-end; gap: 0.25rem; height: 2rem; margin-left: auto; }
    .auth-card-bars i { width: 0.3125rem; height: 40%; border-radius: 999px; background: rgb(255 255 255 / 0.55); transform-origin: bottom; animation: auth-bars 2.8s ease-in-out infinite alternate; }
    .auth-card-bars i:nth-child(2) { height: 70%; animation-delay: -0.6s; }
    .auth-card-bars i:nth-child(3) { height: 55%; animation-delay: -1.2s; }
    .auth-card-bars i:nth-child(4) { height: 100%; animation-delay: -1.8s; }
    .auth-card-bars i:nth-child(5) { height: 80%; animation-delay: -2.4s; }
    .auth-copy { display: block; margin-top: 2rem; font-size: 0.75rem; color: rgb(255 255 255 / 0.6); }
    .auth-main { align-items: center; margin: 0; padding: 2rem; border-radius: 0; }
}
@media (min-width: 1024px) and (max-height: 700px) {
    .auth-hero { padding-block: 1.75rem 1.25rem; }
    .auth-cards { display: none; }
    .auth-pitch { margin-bottom: auto; }
}

@keyframes auth-rise { from { opacity: 0; transform: translateY(1.25rem); } }
@keyframes auth-float { 50% { transform: translateY(-8px); } }
@keyframes auth-bars { to { transform: scaleY(0.55); } }
@keyframes auth-drift { to { transform: translate(-3rem, -2rem) scale(1.15); } }
@keyframes auth-spin { to { transform: rotate(360deg); } }
@keyframes auth-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@media (prefers-reduced-motion: reduce) {
    .auth *, .auth *::before, .auth *::after { animation: none !important; transition: none !important; }
}
