/* The sign-in pages (login.html, reset.html; 2.45.0). Loaded last, on these
   two pages only; every rule is scoped to .auth-body, so nothing here reaches
   the dialer or the admin page. Three themes: Glass (light), Graphite (dark)
   and Minimal (flat), through the tokens below. Mobile first: at phone
   widths the card is the page. */

/* ---- Tokens --------------------------------------------------------------- */
.auth-body {
    --af-page: #f4f7fb;
    --af-glow-a: rgba(37, 99, 235, 0.14);
    --af-glow-b: rgba(168, 85, 247, 0.10);
    --af-surface: #ffffff;
    --af-surface-border: rgba(15, 23, 42, 0.08);
    --af-surface-shadow: 0 24px 60px -28px rgba(15, 23, 42, 0.35), 0 1px 2px rgba(15, 23, 42, 0.04);
    --af-text: #0f172a;
    --af-muted: #5b6472;
    --af-label: #1e293b;
    --af-field-bg: #ffffff;
    --af-field-border: #cfd8e3;
    --af-field-border-hover: #a9b6c6;
    --af-field-text: #0f172a;
    --af-placeholder: #8c99ab;
    --af-accent: #2563eb;
    --af-accent-strong: #1d4ed8;
    --af-accent-soft: rgba(37, 99, 235, 0.12);
    --af-track: #e8edf5;
    --af-tab-text: #475569;
    --af-tab-active-bg: #ffffff;
    --af-tab-active-text: #0f172a;
    --af-tab-active-shadow: 0 1px 2px rgba(15, 23, 42, 0.10), 0 4px 12px -6px rgba(15, 23, 42, 0.25);
    --af-primary-bg: linear-gradient(180deg, #2a63e6 0%, #1d4ed8 100%);
    --af-primary-text: #ffffff;
    --af-primary-shadow: 0 12px 24px -12px rgba(29, 78, 216, 0.7);
    --af-soft-bg: #edf2fb;
    --af-soft-border: #d3deef;
    --af-soft-text: #1e3a8a;
    --af-danger: #b91c1c;
    --af-danger-bg: #fef2f2;
    --af-danger-border: #fecaca;
    --af-success: #166534;
    --af-success-bg: #ecfdf3;
    --af-success-border: #bbf7d0;
    --af-divider: rgba(15, 23, 42, 0.14);
    --af-radius: 16px;
    --af-radius-card: 28px;
    --af-control: 56px;
    --af-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="graphite"] .auth-body {
    --af-page: #090c12;
    --af-glow-a: rgba(96, 165, 250, 0.16);
    --af-glow-b: rgba(45, 212, 191, 0.08);
    --af-surface: #121926;
    --af-surface-border: rgba(148, 163, 184, 0.16);
    --af-surface-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(222, 239, 255, 0.06);
    --af-text: #f1f5fc;
    --af-muted: #a5b3c7;
    --af-label: #dbe5f3;
    --af-field-bg: #0b111a;
    --af-field-border: #2b3a4e;
    --af-field-border-hover: #46587a;
    --af-field-text: #eaf3ff;
    --af-placeholder: #6d7f99;
    --af-accent: #8ec5ff;
    --af-accent-strong: #b6d9f2;
    --af-accent-soft: rgba(142, 197, 255, 0.16);
    --af-track: #0d141e;
    --af-tab-text: #aab8cc;
    --af-tab-active-bg: #1f2b3c;
    --af-tab-active-text: #f1f5fc;
    --af-tab-active-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 14px -6px rgba(0, 0, 0, 0.8);
    --af-primary-bg: linear-gradient(180deg, #bfe0ff 0%, #8fc3f5 100%);
    --af-primary-text: #07131f;
    --af-primary-shadow: 0 14px 28px -14px rgba(142, 197, 255, 0.45);
    --af-soft-bg: #172232;
    --af-soft-border: #2e4160;
    --af-soft-text: #cfe4ff;
    --af-danger: #fecaca;
    --af-danger-bg: #3a1515;
    --af-danger-border: #7f1d1d;
    --af-success: #86efac;
    --af-success-bg: #0f2a1a;
    --af-success-border: #166534;
    --af-divider: rgba(148, 163, 184, 0.28);
}

[data-theme="minimal"] .auth-body {
    --af-page: #f8f9fa;
    --af-glow-a: transparent;
    --af-glow-b: transparent;
    --af-surface: #ffffff;
    --af-surface-border: #dce1e7;
    --af-surface-shadow: none;
    --af-accent: #22344a;
    --af-accent-strong: #111821;
    --af-accent-soft: rgba(34, 52, 74, 0.10);
    --af-track: #eef1f4;
    --af-tab-active-shadow: 0 0 0 1px #d5dbe2;
    --af-primary-bg: #22344a;
    --af-primary-shadow: none;
    --af-soft-bg: #eef1f4;
    --af-soft-border: #d5dbe2;
    --af-soft-text: #22344a;
    --af-field-border: #cfd6de;
    --af-radius: 14px;
    --af-radius-card: 20px;
}

/* ---- Page and card -------------------------------------------------------- */
body.auth-body,
html[data-theme] body.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    color: var(--af-text);
    background:
        radial-gradient(900px 600px at 12% -12%, var(--af-glow-a), transparent 60%),
        radial-gradient(700px 520px at 108% 82%, var(--af-glow-b), transparent 60%),
        var(--af-page);
}

.auth-body .auth-shell {
    width: min(100%, 440px);
}

.auth-body .auth-card {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 32px 28px 24px;
    border-radius: var(--af-radius-card);
    border: 1px solid var(--af-surface-border);
    background: var(--af-surface);
    box-shadow: var(--af-surface-shadow);
    color: var(--af-text);
}

/* ---- Brand ---------------------------------------------------------------- */
.auth-body .auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.auth-body .logo-shell-large {
    width: 72px;
    height: 72px;
    padding: 6px;
    border-radius: 24px;
    box-shadow: 0 10px 24px -12px rgba(37, 99, 235, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.auth-body .section-topline {
    margin: 0 0 6px;
    color: var(--af-accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.auth-body .auth-copy h1 {
    margin: 0 0 6px;
    font-size: clamp(1.35rem, 4.2vw + 0.55rem, 1.8rem);
    font-weight: 700;
    line-height: 1.18;
    letter-spacing: -0.03em;
    color: var(--af-text);
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.auth-body .auth-copy p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--af-muted);
}

/* ---- Login / Join switch: a segmented control -------------------------------- */
.auth-body .auth-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: calc(var(--af-radius) + 2px);
    background: var(--af-track);
}

.auth-body .auth-tabs .auth-tab {
    min-height: 48px;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--af-radius);
    background: transparent;
    box-shadow: none;
    color: var(--af-tab-text);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s var(--af-ease), color 0.2s var(--af-ease), box-shadow 0.2s var(--af-ease);
}

.auth-body .auth-tabs .auth-tab:hover {
    color: var(--af-tab-active-text);
}

.auth-body .auth-tabs .auth-tab.active {
    background: var(--af-tab-active-bg);
    color: var(--af-tab-active-text);
    box-shadow: var(--af-tab-active-shadow);
    font-weight: 700;
}

.auth-body .auth-tab.auth-tab-register {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.auth-body .auth-tab-register .tab-paren {
    display: block;
    margin: 0;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--af-tab-text);
}

.auth-body .auth-tab.active .tab-paren {
    color: var(--af-tab-text);
}

/* ---- Forms and fields ------------------------------------------------------- */
.auth-body .auth-form,
.auth-body .auth-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-body .join-step {
    display: grid;
    gap: 16px;
}

.auth-body .af-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--af-text);
}

.auth-body .auth-intro {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--af-muted);
    opacity: 1;
}

.auth-body .af-field {
    display: grid;
    gap: 7px;
}

.auth-body .af-label {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--af-label);
}

.auth-body .af-label .field-paren {
    font-size: 0.78rem;
    font-weight: 500;
    font-style: normal;
    color: var(--af-muted);
}

.auth-body .af-control {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.auth-body .af-control input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: var(--af-control);
    padding: 0 16px;
    border: 1.5px solid var(--af-field-border);
    border-radius: var(--af-radius);
    background: var(--af-field-bg);
    color: var(--af-field-text);
    font-size: max(16px, 1rem);
    font-weight: 500;
    line-height: 1.3;
    box-shadow: none;
    transition: border-color 0.15s var(--af-ease), background 0.15s var(--af-ease);
}

.auth-body .af-control input::placeholder {
    color: var(--af-placeholder);
    font-weight: 400;
}

.auth-body .af-control input:hover {
    border-color: var(--af-field-border-hover);
}

.auth-body .af-control input:focus {
    border-color: var(--af-accent);
}

.auth-body .af-control input[aria-invalid="true"] {
    border-color: var(--af-danger);
}

.auth-body .af-control input[readonly] {
    background: var(--af-soft-bg);
    border-color: var(--af-soft-border);
}

/* The username field of the sign-in: numbers read best a little larger. */
.auth-body .af-control #loginUsername,
.auth-body .af-control #forgotNumber,
.auth-body .af-control #registerPhone {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.auth-body .af-control .af-mono,
.auth-body .af-control #registerInvite {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 17px;
    letter-spacing: 0.08em;
}

.auth-body .af-control #recoverCode {
    text-transform: uppercase;
}

.auth-body .af-control #recoverCode::placeholder {
    text-transform: none;
}

/* Autofilled by the browser: the same field, lightly tinted. */
.auth-body .af-control input:-webkit-autofill,
.auth-body .af-control input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--af-field-text);
    -webkit-box-shadow: 0 0 0 1000px var(--af-field-bg) inset;
    box-shadow: 0 0 0 1000px var(--af-field-bg) inset;
    caret-color: var(--af-field-text);
}

.auth-body .af-control input:autofill {
    border-color: var(--af-accent);
}

/* The show/hide toggle inside a password field. */
.auth-body .af-control.has-eye input {
    padding-right: 56px;
}

.auth-body .af-eye {
    position: absolute;
    inset: 6px 6px 6px auto;
    width: 44px;
    height: auto;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--af-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background 0.15s var(--af-ease), color 0.15s var(--af-ease);
}

.auth-body .af-eye:hover,
.auth-body .af-eye[aria-pressed="true"] {
    background: var(--af-accent-soft);
    color: var(--af-accent);
}

.auth-body .af-eye svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-body .af-eye .af-eye-shut,
.auth-body .af-eye[aria-pressed="true"] .af-eye-open {
    display: none;
}

.auth-body .af-eye[aria-pressed="true"] .af-eye-shut {
    display: block;
}

/* The line under a field: a hint, red for what is wrong, green once right. */
.auth-body .af-hint {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--af-muted);
    transition: color 0.15s var(--af-ease);
}

.auth-body .af-hint:empty {
    display: none;
}

.auth-body .af-hint[data-kind="bad"],
.auth-body .auth-card #registerInviteStatus[data-kind="bad"] {
    color: var(--af-danger);
    font-weight: 500;
}

.auth-body .af-hint[data-kind="good"],
.auth-body .auth-card #registerInviteStatus[data-kind="good"] {
    color: var(--af-success);
    font-weight: 500;
}

.auth-body .af-hint[data-kind="wait"],
.auth-body .auth-card #registerInviteStatus[data-kind="wait"] {
    color: var(--af-muted);
    opacity: 1;
}

/* A username the manager needs but the person has already typed above. */
.auth-body .af-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

.auth-body .honeypot {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

/* ---- Buttons --------------------------------------------------------------- */
.auth-body .auth-card .primary-button,
.auth-body .auth-card .soft-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--af-control);
    padding: 0 20px;
    border-radius: var(--af-radius);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s var(--af-ease), box-shadow 0.2s var(--af-ease), filter 0.2s var(--af-ease), background 0.2s var(--af-ease);
}

.auth-body .auth-card .primary-button {
    border: 0;
    background: var(--af-primary-bg);
    color: var(--af-primary-text);
    box-shadow: var(--af-primary-shadow);
}

.auth-body .auth-card .primary-button:hover {
    filter: brightness(1.06);
    box-shadow: var(--af-primary-shadow), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.auth-body .auth-card .primary-button:active {
    transform: scale(0.985);
    filter: brightness(0.98);
}

.auth-body .auth-card .soft-button {
    border: 1.5px solid var(--af-soft-border);
    background: var(--af-soft-bg);
    color: var(--af-soft-text);
    box-shadow: none;
}

.auth-body .auth-card .soft-button:hover {
    border-color: var(--af-accent);
    background: var(--af-accent-soft);
}

.auth-body .auth-card .soft-button:active {
    transform: scale(0.985);
}

.auth-body .auth-card .primary-button:disabled,
.auth-body .auth-card .soft-button:disabled {
    opacity: 0.72;
    box-shadow: none;
    transform: none;
    filter: none;
    cursor: progress;
}

/* The action beside a field (Paste, Copy): shorter than a submit, same height as the field. */
.auth-body .auth-card .af-action {
    flex: 0 0 auto;
    min-width: 84px;
    min-height: var(--af-control);
    padding: 0 14px;
    font-size: 0.92rem;
}

.auth-body .auth-card .af-action svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* While a request is out: the spinner takes the place of the icon. */
.auth-body .auth-card .is-busy::before {
    content: "";
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    opacity: 0.9;
    animation: af-spin 0.8s linear infinite;
}

/* The quiet links of a form (Forgot password, Back): a full tap target. */
.auth-body .text-button,
.auth-body .join-back {
    align-self: center;
    justify-self: center;
    min-height: 44px;
    margin: -4px 0;
    padding: 0 12px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--af-accent);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    opacity: 1;
    cursor: pointer;
}

.auth-body .text-button:hover,
.auth-body .join-back:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ---- Terms, divider, message, links ---------------------------------------- */
.auth-body .terms-consent {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0;
    padding: 12px 14px;
    border: 1.5px solid var(--af-field-border);
    border-radius: var(--af-radius);
    color: var(--af-muted);
    font-size: 0.86rem;
    line-height: 1.5;
    cursor: pointer;
}

.auth-body .terms-consent:has(input:checked) {
    border-color: var(--af-accent);
    background: var(--af-accent-soft);
}

.auth-body .terms-consent input {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 1px 0 0;
    accent-color: var(--af-accent);
}

.auth-body .terms-consent input[aria-invalid="true"] {
    outline: 2px solid var(--af-danger);
    outline-offset: 2px;
}

.auth-body .terms-consent a,
.auth-body .legal-links a {
    color: var(--af-accent);
}

.auth-body .forgot-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--af-muted);
    opacity: 1;
}

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

.auth-body .auth-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-height: 0;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--af-muted);
}

.auth-body .auth-message:empty {
    display: none;
}

.auth-body .auth-message::before {
    content: "";
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 6px;
    border-radius: 50%;
    background: currentColor;
}

.auth-body .auth-message.error {
    background: var(--af-danger-bg);
    border-color: var(--af-danger-border);
    color: var(--af-danger);
}

.auth-body .auth-message.success {
    background: var(--af-success-bg);
    border-color: var(--af-success-border);
    color: var(--af-success);
}

.auth-body .legal-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 12px;
    margin: -6px 0 0;
    font-size: 0.8rem;
}

.auth-body .legal-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 4px;
    color: var(--af-muted);
    font-weight: 500;
    text-decoration: none;
}

.auth-body .legal-links a:hover {
    color: var(--af-accent);
    text-decoration: underline;
}

/* ---- Motion ---------------------------------------------------------------- */
@keyframes af-spin {
    to { transform: rotate(360deg); }
}

@keyframes af-step-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.auth-body .af-enter {
    animation: af-step-in 0.32s var(--af-ease) both;
}

@media (prefers-reduced-motion: reduce) {
    .auth-body *,
    .auth-body *::before,
    .auth-body *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Phones: the card is the page ------------------------------------------- */
@media (max-width: 480px) {
    body.auth-body,
    html[data-theme] body.auth-body {
        padding: 0;
        place-items: start center;
    }

    .auth-body .auth-shell {
        width: 100%;
    }

    .auth-body .auth-card {
        min-height: 100vh;
        min-height: 100dvh;
        gap: 20px;
        padding: calc(28px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .auth-body .legal-links {
        margin-top: auto;
        padding-top: 8px;
    }
}

@media (max-width: 340px) {
    .auth-body .auth-card {
        padding-left: 16px;
        padding-right: 16px;
    }

    .auth-body .auth-tabs .auth-tab {
        padding: 6px 4px;
        font-size: 0.9rem;
    }

    .auth-body .auth-tab-register .tab-paren {
        font-size: 0.66rem;
        letter-spacing: -0.01em;
    }

    .auth-body .auth-card .af-action {
        min-width: 72px;
        padding: 0 10px;
    }

    .auth-body .auth-card .af-action span {
        display: none;
    }
}

/* ---- Short screens (a phone on its side) ------------------------------------- */
@media (max-height: 540px) and (orientation: landscape) {
    body.auth-body,
    html[data-theme] body.auth-body {
        place-items: start center;
        padding: 12px 16px;
    }

    .auth-body .auth-shell {
        width: min(100%, 560px);
    }

    .auth-body .auth-card {
        min-height: 0;
        gap: 16px;
        padding: 18px 22px 16px;
    }

    .auth-body .auth-brand {
        flex-direction: row;
        align-items: center;
        gap: 14px;
        text-align: left;
    }

    .auth-body .auth-copy {
        text-align: left;
    }

    .auth-body .logo-shell-large {
        width: 52px;
        height: 52px;
        padding: 4px;
        border-radius: 16px;
    }

    .auth-body .auth-copy h1 {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }

    .auth-body .auth-copy p {
        font-size: 0.85rem;
    }

    .auth-body .section-topline {
        display: none;
    }
}
