.login-page {
    position: relative;
    isolation: isolate;
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    overflow: hidden;
    background:
        radial-gradient(circle at 16% 12%, rgba(98, 168, 255, 0.18), transparent 29rem),
        radial-gradient(circle at 84% 16%, rgba(84, 214, 138, 0.12), transparent 31rem),
        radial-gradient(circle at 50% 112%, rgba(100, 111, 255, 0.11), transparent 36rem),
        linear-gradient(145deg, #04070b 0%, #070c13 44%, #05080d 100%);
}

.login-page::before,
.login-page::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.login-page::before {
    z-index: -2;
    opacity: 0.62;
    background-image:
        linear-gradient(rgba(116, 164, 224, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(116, 164, 224, 0.05) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 86%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 86%);
    transform: perspective(900px) rotateX(58deg) scale(1.55) translateY(16%);
    transform-origin: center bottom;
}

.login-page::after {
    z-index: -1;
    background:
        radial-gradient(circle at 20% 30%, rgba(101, 165, 255, 0.12) 0 1px, transparent 2px),
        radial-gradient(circle at 72% 26%, rgba(83, 230, 167, 0.10) 0 1px, transparent 2px),
        radial-gradient(circle at 64% 72%, rgba(101, 165, 255, 0.08) 0 1px, transparent 2px);
    background-size: 150px 150px, 210px 210px, 260px 260px;
    filter: drop-shadow(0 0 12px rgba(91, 155, 255, 0.18));
    animation: login-drift 24s linear infinite;
}

.login-shell {
    position: relative;
    width: min(100%, 470px);
}

.login-shell::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 50%;
    left: 50%;
    width: min(76vw, 760px);
    aspect-ratio: 1;
    border: 1px solid rgba(102, 170, 255, 0.07);
    border-radius: 50%;
    box-shadow:
        0 0 0 72px rgba(102, 170, 255, 0.016),
        0 0 0 144px rgba(63, 218, 153, 0.010);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-card {
    position: relative;
    overflow: hidden;
    padding: 42px;
    background: linear-gradient(150deg, rgba(18, 25, 35, 0.90), rgba(8, 12, 18, 0.95));
    border: 1px solid rgba(132, 169, 216, 0.21);
    border-radius: 22px;
    box-shadow:
        0 30px 90px rgba(0, 0, 0, 0.52),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(22px) saturate(125%);
    -webkit-backdrop-filter: blur(22px) saturate(125%);
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(115deg, rgba(103, 172, 255, 0.10), transparent 24%, transparent 72%, rgba(72, 219, 156, 0.07)),
        radial-gradient(circle at 100% 0%, rgba(75, 216, 153, 0.09), transparent 22rem);
}

.login-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(128, 188, 255, 0.72), rgba(76, 226, 160, 0.58), transparent);
    box-shadow: 0 0 18px rgba(98, 168, 255, 0.28);
}

.login-card > * {
    position: relative;
    z-index: 1;
}

.brand-mark {
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    margin-bottom: 18px;
    font-size: 29px;
    background: linear-gradient(145deg, rgba(87, 151, 255, 0.14), rgba(77, 226, 158, 0.07));
    border: 1px solid rgba(118, 177, 255, 0.20);
    border-radius: 16px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.login-brandline {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 8px;
}

.login-card h1 {
    margin: 0;
    font-size: 54px;
}

.login-version {
    display: inline-flex;
    align-items: center;
    min-height: 21px;
    padding: 3px 7px;
    color: #83efb6;
    background: rgba(72, 210, 145, 0.075);
    border: 1px solid rgba(72, 210, 145, 0.24);
    border-radius: 999px;
    box-shadow: 0 0 18px rgba(72, 210, 145, 0.06);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1;
    white-space: nowrap;
    transform: translateY(-4px);
}

.login-subtitle {
    color: var(--muted);
    margin-top: 0;
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 30px;
}

.login-form label {
    color: #cbd6e2;
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 50px;
    padding: 14px 15px;
    color: var(--text);
    background: rgba(5, 9, 14, 0.72);
    border: 1px solid rgba(129, 167, 214, 0.23);
    border-radius: 10px;
    outline: none;
    font: inherit;
}

.login-form input:focus {
    border-color: rgba(98, 168, 255, 0.62);
    box-shadow: 0 0 0 3px rgba(98, 168, 255, 0.12), 0 0 28px rgba(98, 168, 255, 0.07);
}

.password-field { position: relative; }
.password-field input { padding-right: 58px; }

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transform: translateY(-50%);
    -webkit-tap-highlight-color: transparent;
}

.password-toggle:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.password-toggle:focus-visible { color: var(--text); outline: 2px solid var(--blue); outline-offset: 1px; }
.eye-icon { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eye-closed { display: none; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

.button {
    border: 0;
    border-radius: 10px;
    padding: 14px 18px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.button-primary {
    margin-top: 8px;
    color: var(--bg);
    background: linear-gradient(135deg, #f5f8fc 0%, #dfe9f5 100%);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.button-primary:hover { opacity: 0.92; }

.alert { margin-top: 20px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert-error { color: #ffd6db; background: rgba(255, 102, 120, 0.1); border: 1px solid rgba(255, 102, 120, 0.3); }
.login-note { margin: 22px 0 0; color: var(--muted); font-size: 12px; }

@keyframes login-drift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-70px, 45px, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .login-page::after { animation: none; }
}

@media (max-width: 600px) {
    .login-page { padding: 16px; }
    .login-card { padding: 28px 22px; border-radius: 18px; }
    .login-card h1 { font-size: clamp(42px, 14vw, 54px); }
    .login-version { font-size: 8px; transform: translateY(-3px); }
    .password-toggle { width: 46px; height: 46px; right: 4px; }
    .password-field input { min-height: 54px; padding-right: 58px; }
    .button { min-height: 52px; }
    .login-shell::before { width: 115vw; opacity: 0.6; }
}

/* =========================================================
   LOGIN V2 — PREMIUM + STABILITÉ MOBILE
   ========================================================= */

:root {
    --login-stable-height: 100svh;
}

.login-page {
    min-height: var(--login-stable-height);
    align-content: center;
    justify-items: center;
    overscroll-behavior: none;
}

/* Evite les micro-sauts liés au focus/clavier et aux calculs de viewport. */
.login-shell {
    width: min(100%, 480px);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.login-card {
    padding: 44px;
    border-color: rgba(132, 184, 235, 0.24);
    background:
        radial-gradient(circle at 8% 0%, rgba(98, 168, 255, 0.075), transparent 18rem),
        radial-gradient(circle at 100% 100%, rgba(84, 214, 138, 0.055), transparent 18rem),
        linear-gradient(150deg, rgba(18, 26, 37, 0.94), rgba(7, 11, 17, 0.97));
    box-shadow:
        0 34px 100px rgba(0, 0, 0, 0.56),
        0 0 0 1px rgba(255, 255, 255, 0.018) inset,
        inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.login-card::before {
    background:
        linear-gradient(115deg, rgba(103, 172, 255, 0.11), transparent 24%, transparent 72%, rgba(72, 219, 156, 0.075)),
        radial-gradient(circle at 100% 0%, rgba(75, 216, 153, 0.10), transparent 22rem);
}

.brand-mark {
    position: relative;
    overflow: hidden;
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
    border-color: rgba(118, 177, 255, 0.26);
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.08), transparent 45%),
        linear-gradient(145deg, rgba(87, 151, 255, 0.17), rgba(77, 226, 158, 0.08));
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.28),
        0 0 34px rgba(98,168,255,.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-mark::after {
    content: "";
    position: absolute;
    width: 34px;
    height: 1px;
    right: -10px;
    bottom: 9px;
    background: linear-gradient(90deg, transparent, rgba(84,214,138,.75));
    transform: rotate(-34deg);
}

.login-brandline {
    margin-bottom: 7px;
}

.login-card h1 {
    font-size: clamp(48px, 7vw, 58px);
    letter-spacing: -0.055em;
    line-height: .98;
}

.login-subtitle {
    max-width: 340px;
    margin-bottom: 0;
    color: #91a0af;
    font-size: 14px;
}

.login-trust {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 17px;
}

.login-trust span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 8px;
    color: #8595a6;
    border: 1px solid rgba(255,255,255,.065);
    border-radius: 999px;
    background: rgba(255,255,255,.018);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .025em;
}

.login-form {
    gap: 11px;
    margin-top: 28px;
}

.login-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.login-label-row label {
    color: #d8e2ec;
}

.login-label-row span {
    color: #657587;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

/* Le conteneur porte le focus premium, pas l'input seul. */
.password-field {
    position: relative;
    border: 1px solid rgba(129, 167, 214, 0.24);
    border-radius: 13px;
    background:
        linear-gradient(180deg, rgba(7, 12, 18, 0.88), rgba(4, 8, 13, 0.92));
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.025),
        0 8px 24px rgba(0,0,0,.12);
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        background .18s ease;
}

/*
   IMPORTANT :
   la bordure reste toujours à 1px.
   On ne modifie donc jamais les dimensions du champ au focus.
*/
.password-field:focus-within {
    border-color: rgba(98, 168, 255, 0.62);
    background:
        linear-gradient(180deg, rgba(8, 14, 21, 0.94), rgba(5, 10, 16, 0.96));
    box-shadow:
        0 0 0 3px rgba(98, 168, 255, 0.105),
        0 0 34px rgba(98, 168, 255, 0.07),
        inset 0 1px 0 rgba(255,255,255,.03);
}

.login-form input {
    min-height: 54px;
    padding: 14px 62px 14px 16px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
    outline: 0;
    caret-color: #79b7ff;
}

.login-form input:focus {
    border: 0;
    box-shadow: none;
    outline: 0;
}

.password-toggle {
    right: 6px;
    width: 42px;
    height: 42px;
    color: #7f91a3;
    border: 1px solid transparent;
    transition:
        color .16s ease,
        background .16s ease,
        border-color .16s ease,
        transform .12s ease;
}

.password-toggle:hover {
    color: #e3edf6;
    border-color: rgba(255,255,255,.07);
    background: rgba(255, 255, 255, 0.045);
}

.password-toggle:active {
    transform: translateY(-50%) scale(.96);
}

.password-toggle:focus-visible {
    color: #e3edf6;
    border-color: rgba(98,168,255,.34);
    outline: 0;
    box-shadow: 0 0 0 2px rgba(98,168,255,.10);
}

.eye-icon {
    width: 21px;
    height: 21px;
}

.button-primary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    margin-top: 7px;
    padding: 0 17px 0 18px;
    color: #06101a;
    background:
        linear-gradient(135deg, #f8fbff 0%, #dfeaf6 55%, #d5e4f4 100%);
    border: 1px solid rgba(255,255,255,.72);
    box-shadow:
        0 15px 34px rgba(0,0,0,.30),
        0 1px 0 rgba(255,255,255,.86) inset;
    transition:
        transform .18s ease,
        box-shadow .18s ease,
        filter .18s ease;
}

.button-primary:hover {
    opacity: 1;
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow:
        0 18px 40px rgba(0,0,0,.34),
        0 1px 0 rgba(255,255,255,.9) inset;
}

.button-primary:active {
    transform: translateY(0);
}

.button-arrow {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 8px;
    background: rgba(5, 15, 25, 0.07);
    font-size: 17px;
}

.alert-error {
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}

.login-note {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 20px;
    color: #6f7f90;
}

.login-note span {
    color: #55d88d;
    font-size: 8px;
    text-shadow: 0 0 10px rgba(84,214,138,.45);
}

/* Mobile : carte stable, pas de recentrage brutal à l'ouverture du clavier. */
@media (max-width: 700px) {
    .login-page {
        place-items: start center;
        align-content: start;
        min-height: var(--login-stable-height);
        padding: max(28px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
    }

    .login-shell {
        width: min(100%, 470px);
        margin-top: clamp(18px, 8svh, 72px);
    }

    .login-card {
        padding: 30px 23px;
        border-radius: 20px;
    }

    .login-card h1 {
        font-size: clamp(44px, 13vw, 54px);
    }

    .login-trust {
        gap: 6px;
    }

    .login-trust span {
        font-size: 8px;
    }

    .password-field input {
        min-height: 56px;
        font-size: 16px; /* évite le zoom automatique iOS */
    }

    .password-toggle {
        right: 5px;
        width: 44px;
        height: 44px;
    }

    .button-primary {
        min-height: 56px;
    }
}

@media (max-width: 380px) {
    .login-page {
        padding-inline: 12px;
    }

    .login-shell {
        margin-top: 18px;
    }

    .login-card {
        padding: 26px 18px;
    }

    .login-label-row span {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .password-field,
    .password-toggle,
    .button-primary {
        transition: none !important;
    }
}

/* =========================================================
   LOGIN V3 — FOND MYSTÉRIEUX PREMIUM
   ========================================================= */

.login-page {
    --mx: 50%;
    --my: 42%;
    background:
        radial-gradient(circle at var(--mx) var(--my), rgba(89, 154, 255, 0.085), transparent 24rem),
        radial-gradient(circle at 16% 12%, rgba(98, 168, 255, 0.16), transparent 31rem),
        radial-gradient(circle at 84% 16%, rgba(84, 214, 138, 0.10), transparent 33rem),
        radial-gradient(circle at 50% 112%, rgba(100, 111, 255, 0.10), transparent 38rem),
        linear-gradient(145deg, #03060a 0%, #07101a 44%, #04070c 100%);
}

/* Grille qui dérive très lentement. */
.login-page::before {
    opacity: .54;
    background-image:
        linear-gradient(rgba(116, 164, 224, 0.043) 1px, transparent 1px),
        linear-gradient(90deg, rgba(116, 164, 224, 0.043) 1px, transparent 1px);
    background-size: 58px 58px;
    animation: mystery-grid 18s ease-in-out infinite alternate;
}

/* Points / étoiles lointaines qui bougent doucement. */
.login-page::after {
    opacity: .95;
    background:
        radial-gradient(circle at 20% 30%, rgba(101, 165, 255, 0.16) 0 1px, transparent 2px),
        radial-gradient(circle at 72% 26%, rgba(83, 230, 167, 0.13) 0 1px, transparent 2px),
        radial-gradient(circle at 64% 72%, rgba(101, 165, 255, 0.11) 0 1px, transparent 2px),
        radial-gradient(circle at 30% 78%, rgba(137, 113, 255, 0.10) 0 1px, transparent 2px),
        radial-gradient(circle at 88% 62%, rgba(84, 214, 138, 0.09) 0 1px, transparent 2px);
    background-size:
        150px 150px,
        210px 210px,
        260px 260px,
        330px 330px,
        390px 390px;
    filter: drop-shadow(0 0 10px rgba(91, 155, 255, 0.16));
    animation: mystery-stars 34s linear infinite;
}

/* Halo orbital derrière la carte. */
.login-shell::before {
    animation: mystery-orbit 12s ease-in-out infinite alternate;
}

/* Ajoute un second halo sans toucher au HTML. */
.login-shell::after {
    content: "";
    position: absolute;
    z-index: -2;
    inset: -90px;
    pointer-events: none;
    border-radius: 50%;
    background:
        conic-gradient(
            from 180deg,
            transparent 0deg,
            rgba(98, 168, 255, 0.08) 54deg,
            transparent 112deg,
            rgba(84, 214, 138, 0.055) 188deg,
            transparent 260deg,
            rgba(116, 98, 255, 0.05) 320deg,
            transparent 360deg
        );
    filter: blur(28px);
    opacity: .55;
    animation: mystery-spin 26s linear infinite;
}

/* Reflet très discret qui traverse parfois la carte. */
.login-card::before {
    background:
        linear-gradient(115deg, rgba(103, 172, 255, 0.11), transparent 24%, transparent 72%, rgba(72, 219, 156, 0.075)),
        radial-gradient(circle at 100% 0%, rgba(75, 216, 153, 0.10), transparent 22rem),
        linear-gradient(
            102deg,
            transparent 0%,
            transparent 38%,
            rgba(255, 255, 255, 0.028) 47%,
            rgba(110, 179, 255, 0.045) 50%,
            transparent 56%,
            transparent 100%
        );
    background-size: auto, auto, 240% 100%;
    animation: mystery-card-sheen 8.5s ease-in-out infinite;
}

.login-card {
    transition:
        transform .28s ease,
        border-color .25s ease,
        box-shadow .25s ease;
}

@media (hover:hover) and (pointer:fine) {
    .login-card:hover {
        border-color: rgba(132, 184, 235, 0.32);
        box-shadow:
            0 38px 110px rgba(0, 0, 0, 0.60),
            0 0 58px rgba(76, 144, 255, 0.055),
            0 0 0 1px rgba(255, 255, 255, 0.02) inset,
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

/* Petit "signal" lumineux autour du robot. */
.brand-mark {
    animation: mystery-brand-breathe 4.8s ease-in-out infinite;
}

.brand-mark::before {
    content: "";
    position: absolute;
    inset: -14px;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(98,168,255,.13), transparent 68%);
    filter: blur(8px);
    opacity: .7;
    animation: mystery-brand-ring 3.8s ease-in-out infinite;
}

/* Bouton légèrement vivant, sans être flashy. */
.button-primary {
    position: relative;
    overflow: hidden;
}

.button-primary::before {
    content: "";
    position: absolute;
    top: 0;
    left: -35%;
    width: 30%;
    height: 100%;
    transform: skewX(-22deg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.48), transparent);
    opacity: 0;
}

.button-primary:hover::before {
    opacity: .75;
    animation: mystery-button-sheen .85s ease forwards;
}

@keyframes mystery-grid {
    0% {
        transform: perspective(900px) rotateX(58deg) scale(1.55) translateY(16%) translateX(0);
        opacity: .46;
    }
    100% {
        transform: perspective(900px) rotateX(58deg) scale(1.58) translateY(13%) translateX(-22px);
        opacity: .60;
    }
}

@keyframes mystery-stars {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(-36px, 22px, 0) scale(1.015); }
    100% { transform: translate3d(-72px, 44px, 0) scale(1); }
}

@keyframes mystery-orbit {
    0% {
        transform: translate(-50%, -50%) scale(.985);
        opacity: .72;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.025);
        opacity: 1;
    }
}

@keyframes mystery-spin {
    from { transform: rotate(0deg) scale(1); }
    50%  { transform: rotate(180deg) scale(1.025); }
    to   { transform: rotate(360deg) scale(1); }
}

@keyframes mystery-card-sheen {
    0%, 70%   { background-position: 0 0, 0 0, 180% 0; }
    100%      { background-position: 0 0, 0 0, -80% 0; }
}

@keyframes mystery-brand-breathe {
    0%, 100% {
        box-shadow:
            0 14px 40px rgba(0, 0, 0, 0.28),
            0 0 24px rgba(98,168,255,.05),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
    50% {
        box-shadow:
            0 14px 40px rgba(0, 0, 0, 0.28),
            0 0 42px rgba(98,168,255,.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.06);
    }
}

@keyframes mystery-brand-ring {
    0%, 100% { transform: scale(.86); opacity: .28; }
    50%      { transform: scale(1.12); opacity: .72; }
}

@keyframes mystery-button-sheen {
    from { left: -35%; }
    to   { left: 115%; }
}

/* Mobile : on garde l'ambiance mais on allège les animations. */
@media (max-width:700px) {
    .login-shell::after {
        inset: -55px;
        opacity: .38;
        filter: blur(24px);
    }

    .login-page::after {
        opacity: .70;
    }
}

/* Accessibilité / économie de batterie. */
@media (prefers-reduced-motion: reduce) {
    .login-page::before,
    .login-page::after,
    .login-shell::before,
    .login-shell::after,
    .login-card::before,
    .brand-mark,
    .brand-mark::before,
    .button-primary::before {
        animation: none !important;
    }

    .login-card {
        transform: none !important;
    }
}
