:root {
    --ink: #152033;
    --ink-soft: rgba(21, 32, 51, 0.62);
    --ink-mute: rgba(21, 32, 51, 0.45);
    --line: rgba(255, 255, 255, 0.55);
    --glass: rgba(255, 255, 255, 0.42);
    --glass-strong: rgba(255, 255, 255, 0.62);
    --accent: #2563eb;
    --accent-deep: #1e40af;
    --danger: #dc2626;
    --ok: #059669;
    --radius: 22px;
    --shadow: 0 18px 50px rgba(21, 32, 51, 0.12);
    --font: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--ink);
    background: #cfd7e2;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
    position: relative;
    isolation: isolate;
    overflow-x: hidden;
}

.login-scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.login-scene__wash {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(160deg, #d9e1ec 0%, #c8d2e0 42%, #b7c4d6 78%, #cad3e0 100%);
}

.login-scene__orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(8px);
    opacity: 0.9;
    animation: orb-drift 18s ease-in-out infinite alternate;
}

.login-scene__orb--a {
    width: 42vw;
    height: 42vw;
    max-width: 520px;
    max-height: 520px;
    top: -12%;
    left: -8%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.34) 0%, transparent 68%);
}

.login-scene__orb--b {
    width: 38vw;
    height: 38vw;
    max-width: 460px;
    max-height: 460px;
    right: -10%;
    top: 18%;
    background: radial-gradient(circle, rgba(14, 116, 144, 0.22) 0%, transparent 70%);
    animation-delay: -6s;
}

.login-scene__orb--c {
    width: 48vw;
    height: 48vw;
    max-width: 560px;
    max-height: 560px;
    left: 28%;
    bottom: -22%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.16) 0%, transparent 72%);
    animation-delay: -11s;
}

.login-scene__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.18) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black 20%, transparent 75%);
    opacity: 0.35;
}

@keyframes orb-drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(18px, -22px, 0) scale(1.05); }
}

.login-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1.05rem;
    animation: rise-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.brand {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    animation: rise-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

.logo-container {
    background: rgba(255, 255, 255, 0.48);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border-radius: 20px;
    padding: 0.9rem 1.55rem;
    border: 1px solid var(--line);
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.75);
    transition: transform 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
}

.logo-container:hover {
    background: rgba(255, 255, 255, 0.62);
    transform: translateY(-2px);
    box-shadow:
        0 22px 48px rgba(21, 32, 51, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.logo-img {
    width: 100%;
    max-width: 210px;
    height: auto;
    display: block;
    opacity: 0.92;
}

.brand-tagline {
    color: var(--ink-soft);
    font-size: 0.88rem;
    font-weight: 450;
    letter-spacing: 0.01em;
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(34px) saturate(170%);
    -webkit-backdrop-filter: blur(34px) saturate(170%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.55rem 1.5rem 1.45rem;
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);
    position: relative;
    overflow: hidden;
    animation: rise-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.75), transparent);
    pointer-events: none;
}

.glass-card__intro {
    margin-bottom: 1.2rem;
    position: relative;
    z-index: 1;
}

.glass-card__intro h2 {
    color: var(--ink);
    font-weight: 650;
    font-size: 1.42rem;
    letter-spacing: -0.03em;
    margin-bottom: 0.28rem;
}

.glass-card__intro p {
    color: var(--ink-soft);
    font-size: 0.92rem;
    line-height: 1.45;
    font-weight: 400;
}

.input-group {
    margin-bottom: 1.15rem;
    position: relative;
    z-index: 1;
}

.input-group label {
    display: block;
    color: var(--ink-soft);
    font-size: 0.82rem;
    margin-bottom: 0.45rem;
    letter-spacing: 0.02em;
    font-weight: 550;
}

.password-field {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    padding-right: 0.35rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 14px;
    box-shadow: inset 0 1px 2px rgba(21, 32, 51, 0.04);
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.password-field:focus-within {
    border-color: rgba(37, 99, 235, 0.45);
    background: rgba(255, 255, 255, 0.78);
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.12),
        inset 0 1px 2px rgba(21, 32, 51, 0.03);
}

.password-field.is-error {
    border-color: rgba(220, 38, 38, 0.55);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    background: rgba(254, 242, 242, 0.75);
}

.input-field {
    width: 100%;
    padding: 0.92rem 1.1rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 14px;
    color: var(--ink);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 1px 2px rgba(21, 32, 51, 0.04);
}

.password-field .input-field {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 12px;
    padding-right: 0.4rem;
}

.password-field .input-field:focus {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.input-field:focus {
    border-color: rgba(37, 99, 235, 0.45);
    background: rgba(255, 255, 255, 0.78);
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.12),
        inset 0 1px 2px rgba(21, 32, 51, 0.03);
}

.input-field::placeholder {
    color: rgba(21, 32, 51, 0.34);
    font-weight: 400;
}

.input-field.error {
    border-color: rgba(220, 38, 38, 0.55);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    background: rgba(254, 242, 242, 0.75);
}

.password-field .input-field.error {
    border: 0;
    box-shadow: none;
    background: transparent;
}

.password-toggle {
    flex: 0 0 auto;
    width: 2.2rem;
    height: 2.2rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-mute);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.password-toggle svg {
    display: block;
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.password-toggle:hover {
    color: var(--accent-deep);
    background: rgba(37, 99, 235, 0.08);
}

.error-message {
    color: var(--danger);
    font-size: 0.78rem;
    margin-top: 0.4rem;
    display: none;
    font-weight: 500;
}

.btn-login {
    width: 100%;
    min-height: 3.05rem;
    padding: 0.95rem 1.1rem;
    border: none;
    border-radius: 14px;
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.96rem;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.22s ease, box-shadow 0.22s ease, filter 0.22s ease, background 0.22s ease;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
    margin-top: 0.35rem;
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    overflow: hidden;
}

.btn-login::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.22) 48%, transparent 66%);
    transform: translateX(-120%);
    pointer-events: none;
}

.btn-login:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.34);
}

.btn-login:hover::after {
    animation: btn-sheen 0.85s ease;
}

.btn-login:active {
    transform: translateY(0) scale(0.985);
}

.btn-login:disabled {
    cursor: wait;
    transform: none;
    filter: none;
}

.btn-login.is-loading {
    background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
    pointer-events: none;
    animation: btn-pulse 1.1s ease-in-out infinite;
}

.btn-login.is-loading::after {
    animation: btn-sheen 1.1s ease-in-out infinite;
    opacity: 1;
}

.btn-login .btn-text {
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn-login .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.28);
    border-top-color: #fff;
    border-radius: 50%;
    flex-shrink: 0;
    animation: spin 0.65s linear infinite;
}

.btn-login.is-loading .spinner {
    display: inline-block;
}

.glass-card.is-authenticating {
    transition: opacity 0.25s ease, filter 0.25s ease, transform 0.25s ease;
    opacity: 0.88;
    filter: saturate(0.9);
    transform: scale(0.992);
}

.glass-card.is-authenticating .input-field,
.glass-card.is-authenticating .password-field,
.glass-card.is-authenticating .password-toggle {
    pointer-events: none;
}

.glass-card.is-shake {
    animation: card-shake 0.42s ease;
}

@keyframes card-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(3px); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes btn-sheen {
    from { transform: translateX(-120%); }
    to { transform: translateX(120%); }
}

@keyframes btn-pulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22); }
    50% { box-shadow: 0 10px 28px rgba(37, 99, 235, 0.4); }
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.84rem;
    display: none;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.18);
    color: var(--danger);
}

.alert-success {
    background: rgba(5, 150, 105, 0.1);
    border: 1px solid rgba(5, 150, 105, 0.18);
    color: var(--ok);
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    text-align: center;
    color: var(--ink-mute);
    font-size: 0.8rem;
    font-weight: 500;
    animation: rise-in 1s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.login-footer a {
    color: var(--accent-deep);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-footer a:hover {
    color: var(--accent);
}

@media (max-width: 480px) {
    .glass-card {
        padding: 1.55rem 1.2rem 1.4rem;
        border-radius: 18px;
    }

    .logo-img {
        max-width: 190px;
    }

    .logo-container {
        padding: 0.9rem 1.25rem;
    }

    .glass-card__intro h2 {
        font-size: 1.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-wrapper,
    .brand,
    .glass-card,
    .login-footer,
    .login-scene__orb,
    .glass-card.is-shake,
    .btn-login:hover::after {
        animation: none !important;
    }

    .btn-login,
    .btn-login .spinner {
        transition: none !important;
    }
}

/* SweetAlert2 */
.swal2-container.swal2-center > .swal2-popup {
    background: rgba(255, 255, 255, 0.58) !important;
    backdrop-filter: blur(40px) saturate(170%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(170%) !important;
    border: 1px solid rgba(255, 255, 255, 0.58) !important;
    border-radius: 22px !important;
    box-shadow: 0 18px 50px rgba(21, 32, 51, 0.16) !important;
    padding: 2.1rem 1.7rem !important;
    font-family: var(--font) !important;
    width: 90% !important;
    max-width: 400px !important;
}

.swal2-container.swal2-center > .swal2-popup .swal2-title {
    color: var(--ink) !important;
    font-weight: 650 !important;
    font-size: 1.3rem !important;
    letter-spacing: -0.02em !important;
}

.swal2-container.swal2-center > .swal2-popup .swal2-html-container {
    color: var(--ink-soft) !important;
    font-size: 0.92rem !important;
}

.swal2-container.swal2-center > .swal2-popup .swal2-actions .swal2-confirm {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%) !important;
    border: none !important;
    border-radius: 12px !important;
    color: white !important;
    font-weight: 600 !important;
    padding: 0.7rem 1.8rem !important;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28) !important;
}

.swal2-container.swal2-center > .swal2-popup .swal2-timer-progress-bar {
    background: linear-gradient(90deg, #2563eb, #60a5fa) !important;
    height: 3px !important;
}

.swal2-container.swal2-center {
    background: rgba(15, 23, 42, 0.35) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
}
