.auth-page {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 14% 8%, color-mix(in srgb, color-mix(in srgb, var(--color-primary) 28%, var(--color-paper)) 22%, transparent), transparent 34rem),
        linear-gradient(145deg, color-mix(in srgb, var(--color-primary) 16%, var(--color-paper)), color-mix(in srgb, var(--color-primary) 16%, var(--color-paper)));
    color: var(--color-text, var(--color-text));
}

.auth-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
}

.auth-card {
    width: min(100%, 460px);
    padding: clamp(24px, 5vw, 42px);
    border: 1px solid color-mix(in srgb, var(--color-line) 13%, transparent);
    border-radius: 24px;
    background: color-mix(in srgb, color-mix(in srgb, var(--color-warning) 16%, var(--color-paper)) 94%, transparent);
    box-shadow: 0 24px 70px color-mix(in srgb, var(--color-overlay) 13%, transparent);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 34px;
}

.auth-brand .brand-mark {
    flex: 0 0 auto;
}

.auth-brand strong,
.auth-brand span {
    display: block;
}

.auth-brand strong {
    font-size: 1rem;
    letter-spacing: .02em;
}

.auth-brand span {
    margin-top: 2px;
    color: var(--color-muted, var(--color-text));
    font-size: .8rem;
}

.auth-heading {
    margin-bottom: 24px;
}

.auth-heading h1 {
    margin: 4px 0 10px;
    font-size: clamp(2rem, 7vw, 2.7rem);
    font-weight: 500;
    letter-spacing: -.04em;
}

.auth-heading p:last-child {
    margin: 0;
    color: var(--color-muted, var(--color-text));
    line-height: 1.55;
}

.auth-form {
    display: grid;
    gap: 17px;
}

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

.auth-field > span {
    font-size: .82rem;
    font-weight: 650;
    letter-spacing: .015em;
}

.auth-field input {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid color-mix(in srgb, var(--color-line) 18%, transparent);
    border-radius: 11px;
    background: var(--color-paper);
    color: inherit;
    font: inherit;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.auth-field input:focus {
    border-color: color-mix(in srgb, var(--color-line) 75%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-overlay) 12%, transparent);
}

.auth-field small {
    color: var(--color-muted, var(--color-text));
    font-size: .75rem;
    line-height: 1.45;
}

.auth-submit {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

.auth-message {
    margin: 0 0 20px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: .86rem;
    line-height: 1.5;
}

.auth-message-error {
    border-color: color-mix(in srgb, var(--color-danger) 25%, transparent);
    background: color-mix(in srgb, var(--color-danger) 8%, transparent);
    color: var(--color-danger);
}

.auth-message-info {
    border-color: color-mix(in srgb, var(--color-line) 22%, transparent);
    background: color-mix(in srgb, var(--color-blue) 8%, transparent);
    color: var(--color-blue);
}

.auth-message-success {
    border-color: color-mix(in srgb, var(--color-line) 24%, transparent);
    background: color-mix(in srgb, var(--color-sage) 9%, transparent);
    color: var(--color-sage);
}

.auth-empty-state {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-radius: 14px;
    background: color-mix(in srgb, color-mix(in srgb, var(--color-primary) 28%, var(--color-paper)) 22%, transparent);
}

.auth-empty-state h2,
.auth-empty-state p {
    margin: 0;
}

.auth-empty-state p {
    color: var(--color-muted, var(--color-text));
    line-height: 1.55;
}

.account-layout {
    display: grid;
    grid-template-columns: minmax(240px, .72fr) minmax(420px, 1.28fr);
    gap: 22px;
    padding: 24px;
}

.account-card {
    align-self: start;
}

.account-role {
    padding: 6px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-muted) 12%, transparent);
    color: var(--color-text);
    font-size: .74rem;
    font-weight: 700;
}

.account-details {
    display: grid;
    gap: 13px;
    margin: 22px 0 0;
}

.account-details div {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--color-line) 10%, transparent);
}

.account-details dt {
    color: var(--color-muted, var(--color-text));
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.account-details dd {
    margin: 0;
    font-weight: 600;
}

.account-password-form {
    max-width: 620px;
    margin-top: 22px;
}

@media (max-width: 850px) {
    .account-layout {
        grid-template-columns: 1fr;
        padding: 16px;
    }
}


/* V011 — contrôle d’affichage du mot de passe */
.password-control {
    position: relative;
    display: block;
    width: 100%;
}

.password-control > input {
    width: 100%;
    padding-right: 7.25rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: .55rem;
    transform: translateY(-50%);
    min-width: 5.8rem;
    padding: .48rem .7rem;
    border: 1px solid color-mix(in srgb, var(--color-line) 18%, transparent);
    border-radius: .65rem;
    background: color-mix(in srgb, var(--color-paper) 90%, transparent);
    color: var(--color-text, var(--color-text));
    font: inherit;
    font-size: .78rem;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 .1rem .35rem color-mix(in srgb, var(--color-overlay) 8%, transparent);
}

.password-toggle:hover,
.password-toggle:focus-visible {
    border-color: color-mix(in srgb, var(--color-line) 36%, transparent);
    background: var(--color-paper);
    outline: none;
}

.password-toggle[aria-pressed="true"] {
    background: color-mix(in srgb, color-mix(in srgb, var(--color-sage) 16%, var(--color-paper)) 78%, transparent);
}

.auth-diagnostic {
    margin-top: 1rem;
    padding: .85rem 1rem;
    border: 1px dashed color-mix(in srgb, var(--color-line) 22%, transparent);
    border-radius: .85rem;
    background: color-mix(in srgb, var(--color-paper) 52%, transparent);
    font-size: .82rem;
}

.auth-diagnostic summary {
    cursor: pointer;
    font-weight: 700;
}

.auth-diagnostic dl {
    display: grid;
    grid-template-columns: minmax(8rem, auto) 1fr;
    gap: .35rem .8rem;
    margin: .75rem 0 0;
}

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

.auth-diagnostic dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* V021 — thème individuel dans Mon compte */
.account-theme-card { grid-column: 1 / -1; }
.account-theme-copy { margin: 12px 0 16px; color: var(--color-muted); font-size: .78rem; line-height: 1.6; }

/* V082 — connexion WebAuthn / biométrie locale. */
.auth-biometric-login { display: grid; gap: 12px; margin-top: 18px; }
.auth-or { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; color: var(--color-muted); }
.auth-or i { height: 1px; background: var(--color-line); }
.auth-or em { font-size: .74rem; font-style: normal; text-transform: uppercase; letter-spacing: .12em; }
.auth-biometric-button { width: 100%; min-height: 48px; justify-content: center; gap: 9px; }
.auth-biometric-icon { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; font-size: 18px; }
.auth-biometric-button.is-loading::after,
#webauthnRegisterButton.is-loading::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: webauthn-spin .75s linear infinite; }
@keyframes webauthn-spin { to { transform: rotate(360deg); } }
.account-biometric-card { grid-column: 1 / -1; }
.account-biometric-copy { max-width: 820px; margin: 12px 0 18px; color: var(--color-muted); font-size: .82rem; line-height: 1.65; }
.webauthn-register-row { display: grid; grid-template-columns: minmax(240px, 1fr) auto; align-items: end; gap: 12px; max-width: 760px; }
.webauthn-register-row .button { min-height: 48px; }
.webauthn-device-list { display: grid; gap: 8px; margin-top: 18px; }
.webauthn-device { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--color-line); border-radius: 12px; background: var(--color-layer-light); }
.webauthn-device div { min-width: 0; display: grid; gap: 4px; }
.webauthn-device strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.webauthn-device small { color: var(--color-muted); font-size: .72rem; line-height: 1.45; }
.webauthn-empty { margin: 0; padding: 15px; border-radius: 11px; background: var(--color-layer-light); color: var(--color-muted); font-size: .8rem; }
@media (max-width: 620px) {
    .webauthn-register-row { grid-template-columns: 1fr; }
    .webauthn-device { align-items: stretch; flex-direction: column; }
    .webauthn-device .button { align-self: flex-end; }
}


/* V084 — empreinte digitale clairement visible. */
.auth-biometric-button,
.webauthn-register-button {
    display: inline-flex;
    align-items: center;
}
.auth-biometric-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 0;
}
.auth-fingerprint-svg {
    width: 30px;
    height: 30px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.auth-biometric-button:not(:disabled) .auth-fingerprint-svg,
.webauthn-register-button:not(:disabled) .auth-fingerprint-svg {
    animation: fingerprint-breathe 2.2s ease-in-out infinite;
}
@keyframes fingerprint-breathe {
    0%, 100% { transform: scale(1); opacity: .82; }
    50% { transform: scale(1.06); opacity: 1; }
}
.webauthn-register-button { gap: 10px; justify-content: center; }
@media (prefers-reduced-motion: reduce) {
    .auth-fingerprint-svg { animation: none !important; }
}


/* V085 — surface biométrique tactile, sans apparence de bouton. */
.auth-biometric-login {
    justify-items: center;
    margin: 1.25rem 0 1.1rem;
}
.auth-biometric-title {
    margin: 0;
    color: var(--color-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.auth-fingerprint-reader {
    appearance: none;
    -webkit-appearance: none;
    width: 112px;
    min-width: 112px;
    height: 132px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-accent, #3f8c8e);
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 9px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.auth-fingerprint-reader-ring {
    width: 92px;
    height: 92px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, currentColor 56%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 8%, var(--color-paper));
    box-shadow: 0 10px 28px color-mix(in srgb, currentColor 12%, transparent), inset 0 0 0 8px color-mix(in srgb, currentColor 4%, transparent);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.auth-fingerprint-reader .auth-fingerprint-svg {
    width: 62px;
    height: 62px;
    stroke-width: 1.25;
}
.auth-fingerprint-reader-label {
    color: var(--color-muted);
    font-size: .72rem;
    font-weight: 700;
}
.auth-fingerprint-reader:hover .auth-fingerprint-reader-ring,
.auth-fingerprint-reader:focus-visible .auth-fingerprint-reader-ring {
    transform: scale(1.035);
    background: color-mix(in srgb, currentColor 13%, var(--color-paper));
    box-shadow: 0 12px 34px color-mix(in srgb, currentColor 18%, transparent), inset 0 0 0 8px color-mix(in srgb, currentColor 6%, transparent);
}
.auth-fingerprint-reader:focus-visible { outline: none; }
.auth-fingerprint-reader:active .auth-fingerprint-reader-ring,
.auth-fingerprint-reader.is-scanning .auth-fingerprint-reader-ring {
    transform: scale(.96);
    background: color-mix(in srgb, currentColor 18%, var(--color-paper));
}
.auth-fingerprint-reader.is-scanning .auth-fingerprint-svg {
    animation: fingerprint-scan 1.05s ease-in-out infinite;
}
.auth-fingerprint-reader:disabled { opacity: .52; cursor: wait; }
.auth-fingerprint-reader + .auth-message { width: 100%; }
@keyframes fingerprint-scan {
    0%, 100% { opacity: .52; transform: scale(.94); }
    50% { opacity: 1; transform: scale(1.04); }
}
@media (max-width: 620px) {
    .auth-fingerprint-reader { width: 122px; min-width: 122px; height: 142px; }
    .auth-fingerprint-reader-ring { width: 102px; height: 102px; }
    .auth-fingerprint-reader .auth-fingerprint-svg { width: 68px; height: 68px; }
}
@media (prefers-reduced-motion: reduce) {
    .auth-fingerprint-reader-ring,
    .auth-fingerprint-reader .auth-fingerprint-svg { animation: none !important; transition: none !important; }
}


/* V089 — identité All in One et biométrie réservée au smartphone */
.auth-brand {
    justify-content: center;
    margin-bottom: 28px;
}
.auth-brand-logo {
    width: min(100%, 330px);
    height: auto;
    display: block;
    object-fit: contain;
}
.auth-biometric-login,
.auth-or {
    display: none;
}
html.is-phone-device .auth-biometric-login {
    display: grid;
}
html.is-phone-device .auth-or {
    display: grid;
}

/* V106 — page de connexion indépendante des thèmes métier, dans les tons du logo. */
.auth-page {
    --auth-ink: #354147;
    --auth-muted: #718086;
    --auth-line: #c9d0ce;
    --auth-paper: #fbfaf7;
    --auth-sage: #aeb8aa;
    --auth-blue-gray: #9cabb5;
    --auth-taupe: #c7b29a;
    background:
        radial-gradient(circle at 16% 10%, rgba(174, 184, 170, .34), transparent 34rem),
        radial-gradient(circle at 88% 88%, rgba(156, 171, 181, .24), transparent 30rem),
        linear-gradient(145deg, #f4f2ed, #e9ece9);
    color: var(--auth-ink);
}
.auth-card {
    border-color: rgba(156, 171, 181, .48);
    background: rgba(251, 250, 247, .96);
    box-shadow: 0 24px 70px rgba(53, 65, 71, .14);
}
.auth-heading p:last-child,
.auth-brand span,
.auth-field small {
    color: var(--auth-muted);
}
.auth-field input {
    border-color: var(--auth-line);
    background: #fff;
    color: var(--auth-ink);
}
.auth-field input:focus {
    border-color: var(--auth-blue-gray);
    box-shadow: 0 0 0 4px rgba(156, 171, 181, .18);
}
.auth-page .button-primary,
.auth-page .auth-submit {
    border-color: #788b89;
    background: #788b89;
    color: #fff;
}
.auth-page .button-primary:hover,
.auth-page .auth-submit:hover {
    background: #687b79;
}
.auth-fingerprint-reader-ring {
    border-color: rgba(156, 171, 181, .75);
    background: linear-gradient(145deg, rgba(174, 184, 170, .22), rgba(199, 178, 154, .18));
}

/* V408 — Connexion Dométis */
.auth-page {
    --auth-ink: #172B46;
    --auth-muted: #6B7B8F;
    --auth-line: #D5E1EE;
    --auth-paper: rgba(255,255,255,.97);
    --auth-sage: #DCEBFF;
    --auth-blue-gray: #A9C6EA;
    --auth-taupe: #F3C64F;
    background:
        radial-gradient(circle at 14% 12%, rgba(30, 103, 194, .16), transparent 32rem),
        radial-gradient(circle at 92% 86%, rgba(243, 198, 79, .14), transparent 28rem),
        linear-gradient(145deg, #F4F8FD, #EEF4FB);
}
.auth-card {
    border-color: #D8E3F0;
    background: rgba(255,255,255,.97);
    box-shadow: 0 24px 60px rgba(17,44,86,.12);
}
.auth-brand-logo {
    width: min(100%, 360px);
}

/* V476 — connexion smartphone Dométis : splash minimal + login après interaction. */
.auth-mobile-splash,
.auth-brand-logo-mobile {
    display: none;
}

html.is-phone-device,
html.is-phone-device body.auth-page {
    width: 100%;
    min-height: 100%;
    background: #122C54;
    overscroll-behavior: none;
}

html.is-phone-device body.auth-page {
    min-height: 100dvh;
    overflow: hidden;
    color: #122C54;
}

html.is-phone-device .auth-mobile-splash {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100dvh;
    padding: max(20px, env(safe-area-inset-top)) 8vw max(20px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    background: #122C54;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: opacity .16s ease, visibility .16s ease;
}

html.is-phone-device .auth-mobile-splash img {
    display: block;
    width: min(72vw, 430px);
    height: auto;
    object-fit: contain;
    image-rendering: auto;
}

html.is-phone-device body.auth-mobile-login-revealed .auth-mobile-splash {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

html.is-phone-device .auth-layout {
    min-height: 100dvh;
    padding: 0;
    display: block;
    background: #122C54;
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s ease;
}

html.is-phone-device body.auth-mobile-login-revealed .auth-layout {
    opacity: 1;
    pointer-events: auto;
}

html.is-phone-device .auth-card {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding:
        max(24px, env(safe-area-inset-top))
        clamp(28px, 8vw, 58px)
        max(34px, calc(env(safe-area-inset-bottom) + 24px));
    border: 0;
    border-radius: 0;
    background: #122C54;
    box-shadow: none;
}

html.is-phone-device .auth-brand {
    grid-row: 1;
    align-self: center;
    justify-self: center;
    justify-content: center;
    width: 100%;
    margin: 0;
    transform: translateY(-6vh);
}

html.is-phone-device .auth-brand-logo-desktop {
    display: none;
}

html.is-phone-device .auth-brand-logo-mobile {
    display: block;
    width: min(72vw, 430px);
    max-height: 22vh;
    object-fit: contain;
}

html.is-phone-device .auth-heading,
html.is-phone-device .auth-biometric-login,
html.is-phone-device .auth-or {
    display: none !important;
}

html.is-phone-device .auth-form {
    grid-row: 2;
    align-self: end;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding-bottom: clamp(12px, 4.5vh, 52px);
    gap: 18px;
}

html.is-phone-device .auth-field {
    display: block;
}

html.is-phone-device .auth-field > span {
    display: none;
}

html.is-phone-device .auth-field input {
    width: 100%;
    min-height: 66px;
    padding: 0 20px;
    border: 1px solid rgba(255,255,255,.82);
    border-radius: 16px;
    background: #fff;
    color: #122C54;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0,0,0,.05);
}

html.is-phone-device .auth-field input::placeholder {
    color: #122C54;
    opacity: .96;
}

html.is-phone-device .auth-field input:focus {
    border-color: #b9d1ee;
    box-shadow: 0 0 0 4px rgba(169,198,234,.19);
}

html.is-phone-device .password-control > input {
    padding-right: 8rem;
}

html.is-phone-device .password-toggle {
    right: 12px;
    min-width: 7rem;
    padding: .7rem .9rem;
    border: 1px solid #d5e1ee;
    border-radius: 13px;
    background: #fff;
    color: #111;
    font-size: .82rem;
    font-weight: 750;
    box-shadow: 0 2px 9px rgba(18,44,84,.16);
}

html.is-phone-device .password-toggle:hover,
html.is-phone-device .password-toggle:focus-visible {
    border-color: #a9c6ea;
    background: #f8fbff;
}

html.is-phone-device .auth-page .auth-submit {
    min-height: 62px;
    margin-top: 4px;
    border: 0;
    border-radius: 15px;
    background: #4C82C3;
    color: #fff;
    font-size: 1rem;
    font-weight: 750;
    box-shadow: none;
}

html.is-phone-device .auth-page .auth-submit:hover,
html.is-phone-device .auth-page .auth-submit:focus-visible {
    background: #3E72B2;
}

html.is-phone-device .auth-card > .auth-message,
html.is-phone-device .auth-empty-state {
    position: fixed;
    left: 8vw;
    right: 8vw;
    bottom: calc(max(34px, env(safe-area-inset-bottom)) + 245px);
    z-index: 2;
    margin: 0;
}

@media (max-height: 700px) {
    html.is-phone-device .auth-brand {
        transform: translateY(-9vh);
    }
    html.is-phone-device .auth-brand-logo-mobile {
        width: min(64vw, 360px);
    }
    html.is-phone-device .auth-form {
        padding-bottom: 8px;
        gap: 12px;
    }
    html.is-phone-device .auth-field input {
        min-height: 58px;
    }
    html.is-phone-device .auth-page .auth-submit {
        min-height: 56px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html.is-phone-device .auth-mobile-splash,
    html.is-phone-device .auth-layout {
        transition: none;
    }
}


/* V478 — même position verticale du logo sur le splash et après révélation du login. */
html.is-phone-device body.auth-page {
    --auth-mobile-logo-center-y: 40dvh;
}
html.is-phone-device .auth-mobile-splash img {
    position: absolute;
    left: 50%;
    top: var(--auth-mobile-logo-center-y);
    transform: translate(-50%, -50%);
}
html.is-phone-device .auth-brand {
    position: absolute;
    z-index: 1;
    left: 50%;
    top: var(--auth-mobile-logo-center-y);
    width: calc(100% - clamp(56px, 16vw, 116px));
    transform: translate(-50%, -50%);
}
