/* ------------------------------------------------------------------------- *
 * Finnaro Auth – shared UI shell for every auth-facing page                  *
 * (login, logout, error, MFA, password change, location confirmation).       *
 * One token set, light + dark, no web fonts, no framework.                    *
 * Per-client theming: set --auth-accent on the <body> if a client wants its  *
 * own accent; everything else stays constant.                                *
 * ------------------------------------------------------------------------- */

:root {
    --auth-accent: #1f7a5c;
    --auth-accent-hover: #1a6b50;
    --auth-accent-ink: #ffffff;
    --auth-ring: rgba(31, 122, 92, 0.28);

    --auth-bg: #eef0f3;
    --auth-bg-glow: rgba(31, 122, 92, 0.10);
    --auth-surface: #ffffff;
    --auth-surface-sunken: #f6f7f9;

    --auth-text: #171a1f;
    --auth-text-muted: #5b636e;
    --auth-text-faint: #858d98;

    --auth-border: #dadee3;
    --auth-border-strong: #c3c9d1;

    --auth-danger: #b3261e;
    --auth-danger-solid: #c62f26;
    --auth-danger-bg: #fdeceb;
    --auth-danger-border: #f3c7c4;
    --auth-ok: #1f7a5c;
    --auth-ok-solid: #1f7a5c;
    --auth-ok-bg: #e7f4ef;
    --auth-ok-border: #bfe3d5;
    --auth-warn: #8a5a00;
    --auth-warn-bg: #fbf1dd;
    --auth-warn-border: #ecd6a8;
    --auth-info: #245c9e;
    --auth-info-bg: #e9f1fb;
    --auth-info-border: #c4daf1;

    --auth-radius: 14px;
    --auth-radius-sm: 9px;
    --auth-shadow:
        0 1px 2px rgba(16, 24, 40, 0.04),
        0 14px 38px -10px rgba(16, 24, 40, 0.16);
    --auth-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
    --auth-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --auth-accent: #2f9d75;
        --auth-accent-hover: #38b485;
        --auth-accent-ink: #04150f;
        --auth-ring: rgba(47, 157, 117, 0.38);

        --auth-bg: #0c0e11;
        --auth-bg-glow: rgba(47, 157, 117, 0.13);
        --auth-surface: #1a1e24;
        --auth-surface-sunken: #23272e;

        --auth-text: #f1f3f5;
        --auth-text-muted: #a3acb6;
        --auth-text-faint: #7c848f;

        --auth-border: #363d47;
        --auth-border-strong: #464f5b;

        --auth-danger: #f3b7b3;
        --auth-danger-solid: #d9534f;
        --auth-danger-bg: #3a201e;
        --auth-danger-border: #6b3a36;
        --auth-ok: #4cc79c;
        --auth-ok-solid: #2f9d75;
        --auth-ok-bg: #17281f;
        --auth-ok-border: #2f5044;
        --auth-warn: #e9c07a;
        --auth-warn-bg: #2f2716;
        --auth-warn-border: #574823;
        --auth-info: #8fbceb;
        --auth-info-bg: #16263a;
        --auth-info-border: #2d4a6b;

        --auth-shadow:
            0 1px 2px rgba(0, 0, 0, 0.5),
            0 18px 44px -14px rgba(0, 0, 0, 0.65);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.auth-body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    font-family: var(--auth-font);
    color: var(--auth-text);
    background-color: var(--auth-bg);
    background-image:
        radial-gradient(60rem 60rem at 15% -10%, var(--auth-bg-glow), transparent 60%),
        radial-gradient(50rem 50rem at 110% 110%, var(--auth-bg-glow), transparent 55%);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    padding: 34px 32px 30px;
}

.auth-card--wide {
    max-width: 460px;
}

/* --- heading --- */
.auth-title {
    margin: 0 0 22px;
    font-size: 1.45rem;
    font-weight: 640;
    letter-spacing: -0.01em;
}

.auth-title:has(+ .auth-subtitle) {
    margin-bottom: 8px;
}

.auth-subtitle {
    margin: 0 0 22px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--auth-text-muted);
}

.auth-subtitle:last-child {
    margin-bottom: 0;
}

/* stacked action buttons under a form / message */
.auth-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 22px;
}

/* --- form --- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field > label {
    font-size: 0.8rem;
    font-weight: 560;
    color: var(--auth-text);
}

.auth-input {
    width: 100%;
    height: 44px;
    padding: 0 13px;
    font: inherit;
    font-size: 0.92rem;
    color: var(--auth-text);
    background: var(--auth-surface);
    border: 1px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
}

.auth-input::placeholder {
    color: var(--auth-text-faint);
}

.auth-input:focus-visible {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px var(--auth-ring);
}

.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-text);
    -webkit-box-shadow: 0 0 0 40px var(--auth-surface) inset;
    caret-color: var(--auth-text);
}

/* password reveal button injected by password-toggle.js */
.auth-input + button[aria-label] {
    color: var(--auth-text-muted) !important;
    opacity: 1 !important;
    border-radius: 6px !important;
}
.auth-input + button[aria-label]:hover {
    color: var(--auth-text) !important;
}
.auth-input + button[aria-label]:focus-visible {
    outline: 2px solid var(--auth-accent) !important;
    outline-offset: 1px;
}

/* --- button --- */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--auth-accent-ink);
    background: var(--auth-accent);
    border: 1px solid transparent;
    border-radius: var(--auth-radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.auth-btn:hover {
    background: var(--auth-accent-hover);
}

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

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

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

.auth-btn--ghost:hover {
    background: var(--auth-surface-sunken);
}

.auth-form .auth-btn {
    margin-top: 2px;
}

/* --- helper row / links --- */
.auth-links {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 0.83rem;
}

.auth-link {
    color: var(--auth-accent);
    font-weight: 550;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-muted {
    color: var(--auth-text-muted);
}

/* --- alerts --- */
.auth-alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 0.85rem;
    line-height: 1.45;
    border: 1px solid var(--auth-danger-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-danger-bg);
    color: var(--auth-text);
}

.auth-alert strong {
    display: block;
    margin-bottom: 1px;
    color: var(--auth-danger);
}

.auth-alert--ok {
    border-color: var(--auth-ok-border);
    background: var(--auth-ok-bg);
}

.auth-alert--ok strong {
    color: var(--auth-ok);
}

.auth-alert--warn {
    border-color: var(--auth-warn-border);
    background: var(--auth-warn-bg);
}

.auth-alert--warn strong {
    color: var(--auth-warn);
}

.auth-alert--info {
    border-color: var(--auth-info-border);
    background: var(--auth-info-bg);
}

.auth-alert--info strong {
    color: var(--auth-info);
}

.auth-alert__mark {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    background: var(--auth-danger-solid);
}

.auth-alert--ok .auth-alert__mark {
    background: var(--auth-ok-solid);
}

.auth-alert--warn .auth-alert__mark {
    background: var(--auth-warn);
    color: #1c1300;
}

.auth-alert--info .auth-alert__mark {
    background: var(--auth-info);
    color: #04121f;
}

/* --- misc blocks reused across pages --- */
.auth-note {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--auth-border);
    font-size: 0.8rem;
    color: var(--auth-text-muted);
    line-height: 1.5;
}

.auth-disclosure {
    margin-top: 18px;
}

.auth-disclosure > summary {
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    list-style: none;
}

.auth-disclosure > summary::-webkit-details-marker {
    display: none;
}

.auth-disclosure > summary::after {
    content: " \25be";
}

.auth-disclosure[open] > summary::after {
    content: " \25b4";
}

.auth-kv {
    margin-top: 12px;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-surface-sunken);
    overflow: hidden;
}

.auth-kv > div {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: 10px;
    padding: 9px 13px;
    font-size: 0.8rem;
}

.auth-kv > div + div {
    border-top: 1px solid var(--auth-border);
}

.auth-kv span {
    color: var(--auth-text-faint);
}

.auth-kv strong {
    font-weight: 550;
    word-break: break-word;
}

.auth-code-grid {
    margin: 4px 0 6px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-family: var(--auth-font-mono);
    font-size: 0.9rem;
}

.auth-code-grid li {
    list-style: none;
    padding: 9px 12px;
    background: var(--auth-surface-sunken);
    border: 1px solid var(--auth-border);
    border-radius: 7px;
    text-align: center;
    letter-spacing: 0.06em;
}

.auth-btn.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.auth-qr {
    display: block;
    width: 190px;
    height: 190px;
    margin: 4px auto 14px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
}

/* --- numbered step list (MFA setup) --- */
.auth-steps {
    counter-reset: auth-step;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-steps > li {
    position: relative;
    padding-left: 34px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--auth-text);
}

.auth-steps > li::before {
    counter-increment: auth-step;
    content: counter(auth-step);
    position: absolute;
    left: 0;
    top: -1px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--auth-accent-ink);
    background: var(--auth-accent);
    border-radius: 50%;
}

.auth-steps .auth-step-title {
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
}

/* --- secret key + copy --- */
.auth-secret {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 8px 0 4px;
}

.auth-secret code {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font-family: var(--auth-font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    word-break: break-all;
    background: var(--auth-surface-sunken);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
}

.auth-secret button {
    flex: none;
    padding: 0 14px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--auth-text);
    background: var(--auth-surface);
    border: 1px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    cursor: pointer;
}

.auth-secret button:hover {
    background: var(--auth-surface-sunken);
}

/* --- one-time code input --- */
.auth-input--code {
    font-family: var(--auth-font-mono);
    font-size: 1.15rem;
    letter-spacing: 0.4em;
    text-align: center;
}

.auth-checkline {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin: 4px 0 4px;
    font-size: 0.85rem;
    color: var(--auth-text-muted);
    cursor: pointer;
}

.auth-checkline input {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--auth-accent);
}

.auth-footer {
    margin-top: 22px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--auth-text-faint);
}

@media (max-width: 460px) {
    body.auth-body {
        padding: 0;
        align-items: stretch;
    }

    .auth-card {
        max-width: none;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 28px 22px;
    }
}
