/* ============================================================================
   AUTH SURFACES - login page and allauth account/MFA pages
   ============================================================================
   One quiet visual language for every pre-session screen: a white card on a
   soft neutral background, a single clear primary action, and system fonts.
   Both templates/login.html and templates/allauth/layouts/base.html load this
   file, so the sign-in step, the second-factor challenge, and the account
   pages never look like a different product. Deliberately no CDN dependency:
   these pages must paint before the application shell is available.
   ============================================================================ */

:root {
    --auth-bg: #f6f7f9;
    --auth-surface: #ffffff;
    --auth-text: #111827;
    --auth-body: #374151;
    --auth-muted: #6b7280;
    --auth-border: #e5e7eb;
    --auth-border-strong: #d1d5db;
    --auth-ink: #111827;
    --auth-ink-hover: #1f2937;
    --auth-focus: rgba(17, 24, 39, 0.14);
    --auth-danger: #b42318;
    --auth-radius: 16px;
    --auth-control-radius: 9px;
    --auth-shadow: 0 1px 2px rgba(16, 24, 40, 0.04),
        0 18px 40px -24px rgba(16, 24, 40, 0.24);
}

* {
    box-sizing: border-box;
}

body.auth-page {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--auth-text);
    background-color: var(--auth-bg);
    background-image: radial-gradient(
        90% 70% at 50% 0%,
        #ffffff 0%,
        rgba(255, 255, 255, 0) 62%
    );
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Layout ------------------------------------------------------------------ */

.auth-shell {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
}

.auth-shell--wide {
    max-width: 620px;
}

.auth-card {
    padding: 32px;
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
}

.auth-card--wide {
    padding: 28px 32px 32px;
}

@media (max-width: 520px) {
    body.auth-page {
        padding: 24px 14px;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: 14px;
    }
}

/* Brand and chrome -------------------------------------------------------- */

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px 2px;
    color: var(--auth-text);
    text-decoration: none;
}

.auth-brand img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}

.auth-brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.auth-topbar .auth-brand {
    margin: 0;
}

.auth-topbar-link {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--auth-muted);
    text-decoration: none;
}

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

/* Messages ---------------------------------------------------------------- */

.auth-messages {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-message {
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--auth-border);
    border-radius: 10px;
    background: var(--auth-surface);
    color: var(--auth-muted);
    font-size: 13.5px;
}

.auth-message.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.auth-message.warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.auth-message.error {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.auth-message.info {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
}

/* Typography ------------------------------------------------------------- */

.auth-card h1,
.auth-heading {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.auth-card h2 {
    margin: 24px 0 10px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-card h3 {
    margin: 18px 0 8px;
    font-size: 14px;
    font-weight: 600;
}

.auth-card p {
    margin: 0 0 16px;
    color: var(--auth-muted);
}

.auth-card > p:last-child,
.auth-card form > p:last-of-type {
    margin-bottom: 0;
}

.auth-subtitle {
    margin: 0 0 24px;
    font-size: 14.5px;
    color: var(--auth-muted);
}

.auth-note {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--auth-border);
    text-align: center;
    font-size: 12.5px;
    color: var(--auth-muted);
}

.auth-card a:not(.auth-btn) {
    color: var(--auth-text);
    text-underline-offset: 2px;
}

.auth-card a:not(.auth-btn):hover {
    color: var(--auth-muted);
}

.auth-alert {
    margin: 0 0 16px;
    padding: 10px 14px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
    font-size: 13.5px;
}

/* Buttons ----------------------------------------------------------------- */

.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--auth-control-radius);
    background: var(--auth-surface);
    color: var(--auth-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        box-shadow 0.15s ease, transform 0.1s ease;
}

.auth-btn:hover {
    text-decoration: none;
}

.auth-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--auth-focus);
}

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

.auth-btn--primary {
    background: var(--auth-ink);
    border-color: var(--auth-ink);
    color: #ffffff;
}

.auth-btn--primary:hover {
    background: var(--auth-ink-hover);
    border-color: var(--auth-ink-hover);
}

.auth-btn--provider,
.auth-btn--ghost {
    background: var(--auth-surface);
    border-color: var(--auth-border-strong);
    color: var(--auth-text);
}

.auth-btn--provider:hover,
.auth-btn--ghost:hover {
    background: #f9fafb;
    border-color: #b6bdc7;
}

.auth-btn--danger {
    background: var(--auth-surface);
    border-color: #f3c7c3;
    color: var(--auth-danger);
}

.auth-btn--danger:hover {
    background: #fef3f2;
    border-color: #efb3ad;
}

.auth-btn--link {
    width: auto;
    min-height: 0;
    padding: 4px 2px;
    border-color: transparent;
    background: transparent;
    color: var(--auth-muted);
    font-weight: 500;
}

.auth-btn--link:hover {
    background: transparent;
    color: var(--auth-text);
}

.auth-btn[disabled] {
    opacity: 0.6;
    cursor: progress;
    transform: none;
}

.auth-provider-mark {
    width: 18px;
    height: 18px;
    flex: none;
}

.auth-provider-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-provider-list li {
    margin: 0;
}

/* Divider ----------------------------------------------------------------- */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--auth-muted);
    font-size: 12.5px;
}

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

/* Forms ------------------------------------------------------------------- */

.auth-field {
    margin: 0 0 14px;
}

.auth-field label,
.auth-card form > p > label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--auth-body);
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="number"],
.auth-card input[type="tel"],
.auth-card input[type="url"],
.auth-card input[type="search"],
.auth-card select,
.auth-card textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--auth-border-strong);
    border-radius: var(--auth-control-radius);
    background: var(--auth-surface);
    color: inherit;
    font: inherit;
    font-size: 14.5px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-card textarea {
    min-height: 132px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13.5px;
}

.auth-card input:focus,
.auth-card select:focus,
.auth-card textarea:focus {
    outline: none;
    border-color: var(--auth-ink);
    box-shadow: 0 0 0 3px var(--auth-focus);
}

.auth-card input:disabled,
.auth-card textarea:disabled {
    background: #f9fafb;
    color: var(--auth-muted);
}

.auth-card input[type="checkbox"],
.auth-card input[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0 8px 0 0;
    accent-color: var(--auth-ink);
    vertical-align: -2px;
}

.auth-card .helptext {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--auth-muted);
}

.auth-card .errorlist {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
    color: var(--auth-danger);
    font-size: 13px;
}

/* allauth renders every field as <p>{label}{input}</p>; give each one the
   same rhythm as .auth-field above. */
.auth-card form > p {
    margin: 0 0 14px;
}

/* Panels and tables (MFA index, recovery codes, account pages) ----------- */

.auth-card section {
    margin: 0 0 10px;
    padding: 16px 18px;
    border: 1px solid var(--auth-border);
    border-radius: 12px;
    background: var(--auth-surface);
}

.auth-card section:last-of-type {
    margin-bottom: 0;
}

.auth-card section h2 {
    margin: 0 0 4px;
    font-size: 15px;
}

.auth-card section p {
    margin: 0;
    font-size: 14px;
}

.auth-card section ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.auth-card section li {
    margin: 0;
}

.auth-card section .auth-btn {
    width: auto;
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
}

.auth-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.auth-card th {
    padding: 8px 10px;
    border-bottom: 1px solid var(--auth-border);
    color: var(--auth-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.auth-card td {
    padding: 10px;
    border-bottom: 1px solid #f1f2f4;
    text-align: left;
}

.auth-card tr:last-child td {
    border-bottom: none;
}

.auth-card ul:not(.auth-messages):not(.auth-provider-list),
.auth-card ol {
    margin: 0 0 16px;
    padding-left: 20px;
    color: var(--auth-muted);
}

.auth-card code {
    padding: 2px 6px;
    border: 1px solid var(--auth-border);
    border-radius: 6px;
    background: var(--auth-bg);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}

.auth-card img {
    display: block;
    max-width: 220px;
    height: auto;
    margin: 0 auto 16px;
}

/* Footer navigation ------------------------------------------------------ */

.auth-footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin: 20px 0 0;
    padding: 0 8px;
    font-size: 12.5px;
}

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

.auth-footer-nav a:hover {
    color: var(--auth-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Provider confirmation dialog (templates/login.html) -------------------- */

.auth-dialog {
    width: min(380px, calc(100vw - 32px));
    margin: auto;
    padding: 26px 26px 22px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    background: var(--auth-surface);
    color: var(--auth-text);
    box-shadow: 0 30px 70px -30px rgba(16, 24, 40, 0.45);
}

.auth-dialog[open] {
    animation: auth-dialog-in 0.18s ease-out;
}

.auth-dialog::backdrop {
    background: rgba(16, 24, 40, 0.42);
    backdrop-filter: blur(2px);
}

@keyframes auth-dialog-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-dialog__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
    border: 1px solid var(--auth-border);
    border-radius: 12px;
    background: var(--auth-surface);
}

.auth-dialog h2 {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-dialog p {
    margin: 0 0 22px;
    color: var(--auth-muted);
    font-size: 14px;
}

.auth-dialog__actions {
    display: flex;
    gap: 10px;
}

.auth-dialog__actions .auth-btn {
    flex: 1;
}

@media (prefers-reduced-motion: reduce) {
    .auth-btn,
    .auth-dialog[open] {
        animation: none;
        transition: none;
    }
}
