html,
body {
    min-height: 100%;
}

body.login-redesign,
body.app.login-redesign {
    margin: 0;
    color: var(--ledger-text, #172033);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    background: var(--ledger-sidebar-2, #0c1220);
}

.login-redesign * {
    box-sizing: border-box;
}

/* ===============================================================
   STAGE — full-screen animated aurora + grid backdrop
================================================================*/
.login-stage {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow: hidden;
    background:
        radial-gradient(1200px 700px at 80% -10%, var(--ledger-primary-strong, #0b6f8d), transparent 60%),
        radial-gradient(1000px 600px at 0% 110%, var(--ledger-sidebar, #182033), transparent 55%),
        linear-gradient(160deg, var(--ledger-sidebar-2, #0c1220) 0%, var(--ledger-sidebar, #182033) 60%, var(--ledger-primary-strong, #0b6f8d) 140%);
}

/* faint moving grid for depth */
.login-grid {
    position: absolute;
    inset: -2px;
    background-image:
        linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(circle at 50% 45%, #000 30%, transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 30%, transparent 78%);
    animation: lr-grid 26s linear infinite;
    pointer-events: none;
}

/* coloured aurora blobs that breathe and drift */
.login-aurora {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .6;
    pointer-events: none;
    will-change: transform;
}

.login-aurora--1 {
    width: 520px; height: 520px;
    top: -120px; left: -80px;
    background: var(--ledger-primary, #149dcc);
    animation: lr-blob1 16s ease-in-out infinite;
}

.login-aurora--2 {
    width: 460px; height: 460px;
    bottom: -140px; right: -60px;
    background: var(--ledger-accent, #16a085);
    animation: lr-blob2 19s ease-in-out infinite;
}

.login-aurora--3 {
    width: 360px; height: 360px;
    top: 40%; left: 55%;
    background: var(--ledger-primary-strong, #0b6f8d);
    opacity: .4;
    animation: lr-blob3 22s ease-in-out infinite;
}

/* ===============================================================
   GLASS CARD
================================================================*/
.login-glass {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 430px;
    padding: 42px 38px 38px;
    border-radius: 22px;
    color: #eef3fb;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, .45),
        inset 0 1px 0 rgba(255, 255, 255, .25);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    overflow: hidden;
    animation: lr-card-in .9s cubic-bezier(.21, 1, .27, 1) both;
}

/* diagonal sheen sweeping once on load */
.login-glass__sheen {
    position: absolute;
    top: -60%;
    left: -120%;
    width: 70%;
    height: 220%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .22), transparent);
    transform: skewX(-18deg);
    animation: lr-sheen 4.5s ease-in-out 1s infinite;
    pointer-events: none;
}

/* ---- header ---- */
.login-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 26px;
    animation: lr-rise .6s ease both .2s;
}

.login-logo-ring {
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
    position: relative;
}

.login-logo-ring::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 18px;
    padding: 2px;
    background: linear-gradient(140deg, var(--ledger-primary, #149dcc), var(--ledger-accent, #16a085));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.login-logo-ring img {
    max-width: 40px;
    height: auto;
}

.login-head__name {
    display: block;
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
}

.login-head__kicker {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .65);
}

.login-title {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 700;
    color: #ffffff;
    animation: lr-rise .6s ease both .28s;
}

.login-subtitle {
    margin: 0 0 22px;
    font-size: 14px;
    color: rgba(238, 243, 251, .7);
    animation: lr-rise .6s ease both .34s;
}

/* ===============================================================
   FLOATING-LABEL FIELDS
================================================================*/
.lf-field {
    position: relative;
    margin-bottom: 20px;
    animation: lr-rise .55s ease both;
}

.lf-field:nth-of-type(1) { animation-delay: .42s; }
.lf-field:nth-of-type(2) { animation-delay: .5s; }

.lf-field input {
    width: 100%;
    height: 54px;
    padding: 18px 44px 6px 14px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 12px;
    background: rgba(255, 255, 255, .06);
    color: #ffffff;
    font-size: 15px;
    box-shadow: none;
    transition: border-color .2s ease, box-shadow .25s ease, background .2s ease;
}

.lf-field input:focus {
    outline: none;
    border-color: var(--ledger-primary, #149dcc);
    background: rgba(255, 255, 255, .1);
    box-shadow: 0 0 0 4px var(--ledger-primary-soft, rgba(20, 157, 204, .3));
}

.lf-field label {
    position: absolute;
    left: 14px;
    top: 17px;
    font-size: 15px;
    color: rgba(238, 243, 251, .62);
    pointer-events: none;
    transition: transform .18s ease, color .18s ease, font-size .18s ease;
    transform-origin: left top;
}

/* float the label up when focused or filled */
.lf-field input:focus + label,
.lf-field input:not(:placeholder-shown) + label {
    transform: translateY(-11px) scale(.78);
    color: var(--ledger-primary, #6fd1ec);
    font-weight: 600;
}

.lf-icon {
    position: absolute;
    right: 14px;
    top: 18px;
    color: rgba(238, 243, 251, .5);
    transition: color .2s ease;
}

.lf-field input:focus ~ .lf-icon {
    color: var(--ledger-primary, #6fd1ec);
}

/* ===============================================================
   ROW — custom checkbox + link
================================================================*/
.login-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 6px 0 24px;
    animation: lr-rise .55s ease both .58s;
}

.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: rgba(238, 243, 251, .82);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.login-remember input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.login-remember__box {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .06);
    position: relative;
    transition: background .2s ease, border-color .2s ease;
}

.login-remember__box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
}

.login-remember input:checked + .login-remember__box {
    background: var(--ledger-primary, #149dcc);
    border-color: var(--ledger-primary, #149dcc);
}

.login-remember input:checked + .login-remember__box::after {
    transform: rotate(45deg) scale(1);
}

.login-remember input:focus-visible + .login-remember__box {
    box-shadow: 0 0 0 3px var(--ledger-primary-soft, rgba(20, 157, 204, .35));
}

.login-link {
    color: #9fe0f3;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    position: relative;
    transition: color .2s ease;
}

.login-link::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease;
}

.login-link:hover,
.login-link:focus {
    color: #ffffff;
}

.login-link:hover::after,
.login-link:focus::after {
    transform: scaleX(1);
}

/* ===============================================================
   SUBMIT BUTTON
================================================================*/
.login-button {
    position: relative;
    width: 100%;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(120deg, var(--ledger-primary, #149dcc), var(--ledger-accent, #16a085));
    background-size: 200% 100%;
    background-position: 0% 0%;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .3px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 16px 34px var(--ledger-primary-soft, rgba(20, 157, 204, .4));
    transition: transform .2s ease, box-shadow .25s ease, background-position .5s ease;
    animation: lr-rise .55s ease both .66s;
}

.login-button svg {
    transition: transform .25s ease;
}

.login-button:hover {
    transform: translateY(-2px);
    background-position: 100% 0%;
    box-shadow: 0 22px 44px var(--ledger-primary-soft, rgba(20, 157, 204, .55));
}

.login-button:hover svg {
    transform: translateX(4px);
}

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

/* ===============================================================
   THEME PICKER (kept functional, restyled for glass)
================================================================*/
.login-theme-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px;
    animation: lr-rise .55s ease both .38s;
}

.login-theme-picker .ledger-theme-picker__label {
    font-size: 12px;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: rgba(238, 243, 251, .55);
}

.login-theme-picker .ledger-theme-picker__select {
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .08);
    color: #eef3fb;
    font-size: 13px;
    cursor: pointer;
}

.login-theme-picker .ledger-theme-picker__select option {
    color: #172033;
}

/* ===============================================================
   MESSAGES
================================================================*/
.login-redesign .help-block,
.login-redesign .error {
    display: block;
    margin-top: 7px;
    color: #ff9d9d;
    font-size: 12px;
    line-height: 1.5;
}

.login-redesign .alert,
.login-redesign #errorMsg {
    border-radius: 10px;
    animation: lr-rise .4s ease both;
}

.public-login-wrap {
    min-height: calc(100vh - 118px);
}

/* ===============================================================
   KEYFRAMES
================================================================*/
@keyframes lr-card-in {
    from { opacity: 0; transform: translateY(34px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes lr-rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes lr-sheen {
    0%   { left: -120%; }
    55%  { left: 130%; }
    100% { left: 130%; }
}

@keyframes lr-grid {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 46px 46px, 46px 46px; }
}

@keyframes lr-blob1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(60px, 40px) scale(1.12); }
}

@keyframes lr-blob2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50%      { transform: translate(-50px, -40px) scale(1.15); }
}

@keyframes lr-blob3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-58%, -42%) scale(1.2); }
}

@media (prefers-reduced-motion: reduce) {
    .login-aurora,
    .login-grid,
    .login-glass,
    .login-glass__sheen,
    .login-head,
    .login-title,
    .login-subtitle,
    .login-theme-picker,
    .lf-field,
    .login-row,
    .login-button {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ===============================================================
   RESPONSIVE
================================================================*/
@media (max-width: 480px) {
    .login-stage {
        padding: 24px 14px;
    }

    .login-glass {
        padding: 32px 24px 30px;
        border-radius: 18px;
    }

    .login-title {
        font-size: 26px;
    }

    .login-aurora {
        filter: blur(54px);
    }
}
