/* Login: visual formal, tecnologico y minimalista. */

:root {
    --brand-1: #233469;
    --brand-2: #81212F;
    --font-family: 'Montserrat', sans-serif;
    --ink-strong: #142034;
    --ink-muted: #637083;
    --line-soft: rgba(36, 52, 84, 0.14);
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --accent: #1f9d8a;
    --shadow-card: 0 24px 70px rgba(20, 32, 52, 0.14);
    --shadow-control: 0 14px 34px rgba(20, 32, 52, 0.12);
    --radius-card: 8px;
    --radius-control: 8px;
}

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

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

body {
    min-height: 100vh;
    color: var(--ink-strong);
    background: #f6f8fb;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.login-wrapper {
    position: relative;
    isolation: isolate;
    display: grid;
    min-height: 100vh;
    place-items: center;
    overflow: hidden;
    padding: 32px 20px;
    background:
        linear-gradient(120deg, rgba(35, 52, 105, 0.1), transparent 34%, rgba(31, 157, 138, 0.1) 68%, transparent),
        linear-gradient(24deg, transparent 0 18%, rgba(129, 33, 47, 0.08) 28%, transparent 42% 100%),
        linear-gradient(135deg, #f8fafc 0%, #eef5f4 50%, #fbf8f2 100%);
    background-size: 160% 160%, 180% 180%, 100% 100%;
    animation: backdropShift 18s ease-in-out infinite;
}

.login-wrapper::before {
    content: "";
    position: absolute;
    inset: -60px;
    z-index: -3;
    background-image:
        linear-gradient(rgba(35, 52, 105, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(35, 52, 105, 0.07) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.54;
    transform: translate3d(0, 0, 0);
    animation: gridDrift 16s linear infinite;
}

.login-wrapper::after {
    content: "";
    position: absolute;
    top: -22%;
    bottom: -22%;
    left: -46%;
    width: 58%;
    z-index: -2;
    background: linear-gradient(
        103deg,
        transparent 0 18%,
        rgba(255, 255, 255, 0.18) 34%,
        color-mix(in srgb, var(--accent) 16%, transparent) 46%,
        rgba(255, 255, 255, 0.38) 55%,
        transparent 74% 100%
    );
    filter: blur(1px);
    opacity: 0.86;
    transform: translateX(0) skewX(-12deg);
    animation: lightSweep 9s ease-in-out infinite;
}

.login-ambient {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.login-ambient::before {
    content: "";
    position: absolute;
    inset: -80px;
    background-image:
        linear-gradient(90deg, transparent 0 18px, rgba(35, 52, 105, 0.1) 19px, transparent 20px),
        linear-gradient(0deg, transparent 0 28px, rgba(31, 157, 138, 0.09) 29px, transparent 30px),
        linear-gradient(135deg, transparent 0 46%, rgba(35, 52, 105, 0.11) 47%, transparent 48% 100%);
    background-size: 148px 112px, 168px 132px, 220px 220px;
    opacity: 0.26;
    transform: rotate(-7deg) scale(1.08);
    animation: circuitDrift 14s linear infinite;
}

.ambient-scan {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent 0 36%,
        color-mix(in srgb, var(--brand-1) 8%, transparent) 43%,
        color-mix(in srgb, var(--accent) 12%, transparent) 50%,
        transparent 60% 100%
    );
    opacity: 0.54;
    transform: translateY(-42%);
    animation: verticalScan 7.5s ease-in-out infinite;
}

.ambient-track {
    position: absolute;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--brand-1) 44%, transparent),
        color-mix(in srgb, var(--accent) 38%, transparent),
        transparent
    );
    opacity: 0.34;
    overflow: hidden;
    transform-origin: center;
}

.ambient-track::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0 18%, rgba(255, 255, 255, 0.92) 48%, transparent 72% 100%);
    transform: translateX(-100%);
    animation: trackPulse 4.8s linear infinite;
}

.ambient-track-a {
    top: 18%;
    left: -10%;
    width: min(760px, 82vw);
    transform: rotate(-17deg);
}

.ambient-track-b {
    right: -18%;
    bottom: 28%;
    width: min(820px, 88vw);
    transform: rotate(13deg);
}

.ambient-track-b::before {
    animation-delay: -1.7s;
}

.ambient-track-c {
    bottom: 13%;
    left: 6%;
    width: min(520px, 64vw);
    opacity: 0.22;
    transform: rotate(-5deg);
}

.ambient-track-c::before {
    animation-delay: -3.1s;
}

.ambient-line {
    position: absolute;
    width: min(560px, 72vw);
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        color-mix(in srgb, var(--brand-1) 50%, transparent),
        color-mix(in srgb, var(--accent) 44%, transparent),
        transparent
    );
    opacity: 0.56;
    --rotation: 0deg;
    --move: 34px;
    transform-origin: center;
    transform: rotate(var(--rotation)) translate3d(0, 0, 0);
}

.ambient-line::after {
    content: "";
    position: absolute;
    top: -4px;
    left: -10px;
    width: 9px;
    height: 9px;
    border-radius: 3px;
    background: var(--surface-strong);
    border: 1px solid color-mix(in srgb, var(--accent) 48%, transparent);
    box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
    animation: packetMove 3.8s linear infinite;
}

.ambient-line-a {
    top: 23%;
    left: -8%;
    --rotation: -12deg;
    --move: 54px;
    animation: signalFlow 8s ease-in-out infinite;
}

.ambient-line-b {
    top: 64%;
    right: -12%;
    --rotation: 10deg;
    --move: -58px;
    animation: signalFlow 9s ease-in-out infinite reverse;
}

.ambient-line-c {
    top: 78%;
    left: 12%;
    width: min(420px, 56vw);
    --rotation: -4deg;
    --move: 42px;
    opacity: 0.4;
    animation: signalFlow 11s ease-in-out infinite;
}

.ambient-node {
    position: absolute;
    width: 240px;
    height: 120px;
    border: 0;
    border-radius: 0;
    opacity: 0.34;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--brand-1) 18%, transparent) 0 34%, transparent 34% 100%) 0 20px / 100% 1px no-repeat,
        linear-gradient(90deg, transparent 0 52%, color-mix(in srgb, var(--accent) 20%, transparent) 52% 100%) 0 72px / 100% 1px no-repeat,
        linear-gradient(180deg, color-mix(in srgb, var(--brand-1) 16%, transparent) 0 56%, transparent 56% 100%) 42px 0 / 1px 100% no-repeat,
        linear-gradient(180deg, transparent 0 32%, color-mix(in srgb, var(--accent) 18%, transparent) 32% 100%) 168px 0 / 1px 100% no-repeat;
}

.ambient-node::before,
.ambient-node::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: color-mix(in srgb, var(--accent) 58%, #ffffff);
    box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 46%, transparent);
    animation: nodePacket 5s ease-in-out infinite;
}

.ambient-node::before {
    top: 20px;
    left: 40px;
}

.ambient-node::after {
    right: 66px;
    bottom: 44px;
    animation-delay: -2.2s;
}

.ambient-node-a {
    top: 13%;
    right: 9%;
    animation: circuitFloat 12s ease-in-out infinite;
}

.ambient-node-b {
    bottom: 12%;
    left: 9%;
    width: 190px;
    height: 104px;
    animation: circuitFloat 14s ease-in-out infinite reverse;
}

.login-card {
    position: relative;
    z-index: 1;
    width: min(100%, 430px);
    padding: 38px 36px 34px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.76);
    border-radius: var(--radius-card);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.86)),
        linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 8%, transparent), color-mix(in srgb, var(--accent) 6%, transparent));
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(18px);
    animation: cardReveal 520ms ease-out both;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-1), var(--accent), var(--brand-2));
    opacity: 0.86;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.login-logo img {
    display: block;
    max-width: 196px;
    height: auto;
    filter: drop-shadow(0 10px 18px rgba(20, 32, 52, 0.08));
}

.login-kicker,
.login-title,
.login-subtitle {
    text-align: center;
    letter-spacing: 0;
}

.login-kicker {
    margin-bottom: 8px;
    color: color-mix(in srgb, var(--brand-2) 86%, var(--ink-strong));
    font-size: 0.82rem;
    font-weight: 700;
}

.login-title {
    color: var(--ink-strong);
    font-size: 1.32rem;
    font-weight: 700;
    line-height: 1.25;
}

.login-subtitle {
    margin: 8px 0 28px;
    color: var(--ink-muted);
    font-size: 0.92rem;
    font-weight: 500;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-muted);
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0;
}

.input-icon-wrapper {
    position: relative;
}

.form-group input {
    width: 100%;
    min-height: 48px;
    padding: 13px 48px;
    color: var(--ink-strong);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-control);
    outline: none;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.form-group input::placeholder {
    color: color-mix(in srgb, var(--ink-muted) 62%, #ffffff);
}

.form-group input:hover {
    border-color: color-mix(in srgb, var(--brand-1) 28%, var(--line-soft));
}

.form-group input:focus {
    border-color: color-mix(in srgb, var(--brand-1) 58%, var(--accent));
    background: var(--surface-strong);
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.input-icon-wrapper .icon {
    position: absolute;
    top: 50%;
    left: 15px;
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    color: color-mix(in srgb, var(--brand-1) 52%, var(--ink-muted));
    pointer-events: none;
    transform: translateY(-50%);
    transition: color 180ms ease;
}

.input-icon-wrapper .icon svg,
.toggle-password svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.input-icon-wrapper input:focus + .icon {
    color: var(--accent);
}

.toggle-password {
    position: absolute;
    top: 50%;
    right: 7px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: color-mix(in srgb, var(--brand-1) 56%, var(--ink-muted));
    cursor: pointer;
    transform: translateY(-50%);
    transition: background 180ms ease, color 180ms ease;
}

.toggle-password:hover,
.toggle-password:focus-visible {
    background: color-mix(in srgb, var(--brand-1) 7%, transparent);
    color: var(--brand-1);
    outline: none;
}

.toggle-password .icon-eye-off,
.toggle-password.is-visible .icon-eye {
    display: none;
}

.toggle-password.is-visible .icon-eye-off {
    display: block;
}

.btn-login {
    position: relative;
    display: inline-flex;
    width: 100%;
    min-height: 48px;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    padding: 13px 18px;
    overflow: hidden;
    color: #ffffff;
    border: 0;
    border-radius: var(--radius-control);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--brand-1) 92%, #111827), var(--brand-2)),
        var(--brand-1);
    box-shadow: 0 15px 34px color-mix(in srgb, var(--brand-1) 22%, transparent);
    cursor: pointer;
    font-size: 0.96rem;
    font-weight: 700;
    letter-spacing: 0;
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.btn-login::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 0 34%, rgba(255, 255, 255, 0.22) 48%, transparent 62% 100%);
    opacity: 0;
    transform: translateX(-60%);
    transition: opacity 180ms ease;
}

.btn-login:hover {
    box-shadow: var(--shadow-control);
    filter: saturate(1.06);
    transform: translateY(-1px);
}

.btn-login:hover::after {
    opacity: 1;
    animation: buttonSweep 900ms ease-out;
}

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

.btn-login:disabled {
    cursor: not-allowed;
    filter: grayscale(0.1);
    opacity: 0.72;
    transform: none;
}

.btn-login span {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-login .spinner {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.34);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.login-error {
    display: none;
    margin-bottom: 18px;
    padding: 12px 14px;
    color: color-mix(in srgb, var(--brand-2) 86%, #111827);
    border: 1px solid color-mix(in srgb, var(--brand-2) 22%, #ffffff);
    border-left: 3px solid var(--brand-2);
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--brand-2) 8%, #ffffff);
    font-size: 0.86rem;
    font-weight: 600;
}

.login-error.visible {
    display: block;
    animation: errorIn 220ms ease-out both;
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gridDrift {
    to {
        transform: translate3d(48px, 48px, 0);
    }
}

@keyframes backdropShift {
    0%, 100% {
        background-position: 0% 46%, 100% 42%, 0 0;
    }
    50% {
        background-position: 100% 54%, 0% 58%, 0 0;
    }
}

@keyframes lightSweep {
    0% {
        transform: translateX(0) skewX(-12deg);
        opacity: 0;
    }
    18%, 68% {
        opacity: 0.88;
    }
    100% {
        transform: translateX(250%) skewX(-12deg);
        opacity: 0;
    }
}

@keyframes circuitDrift {
    to {
        background-position: 148px 112px, -168px 132px, 220px -220px;
    }
}

@keyframes verticalScan {
    0% {
        transform: translateY(-48%);
        opacity: 0;
    }
    18%, 70% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(48%);
        opacity: 0;
    }
}

@keyframes trackPulse {
    to {
        transform: translateX(100%);
    }
}

@keyframes packetMove {
    from {
        left: -10px;
        opacity: 0;
    }
    16%, 82% {
        opacity: 1;
    }
    to {
        left: calc(100% - 4px);
        opacity: 0;
    }
}

@keyframes signalFlow {
    0%, 100% {
        opacity: 0.28;
        transform: rotate(var(--rotation)) translate3d(0, 0, 0);
    }
    50% {
        opacity: 0.66;
        transform: rotate(var(--rotation)) translate3d(var(--move), 8px, 0);
    }
}

@keyframes circuitFloat {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(22px, 12px, 0);
    }
}

@keyframes nodePacket {
    0%, 100% {
        opacity: 0.35;
        transform: translate3d(0, 0, 0);
    }
    50% {
        opacity: 1;
        transform: translate3d(42px, 0, 0);
    }
}

@keyframes buttonSweep {
    from {
        transform: translateX(-70%);
    }
    to {
        transform: translateX(70%);
    }
}

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

@keyframes errorIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 520px) {
    .login-wrapper {
        padding: 24px 16px;
    }

    .login-card {
        padding: 34px 22px 28px;
    }

    .login-logo {
        margin-bottom: 20px;
    }

    .login-logo img {
        max-width: 168px;
    }

    .login-title {
        font-size: 1.14rem;
    }

    .login-subtitle {
        margin-bottom: 24px;
    }

    .ambient-line,
    .ambient-track,
    .ambient-node {
        opacity: 0.2;
    }
}

@media (max-height: 680px) and (min-width: 640px) {
    .login-wrapper {
        padding-top: 22px;
        padding-bottom: 22px;
    }

    .login-card {
        padding-top: 30px;
        padding-bottom: 28px;
    }

    .login-logo {
        margin-bottom: 18px;
    }

    .login-subtitle {
        margin-bottom: 22px;
    }
}

.login-sso-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: #65738b;
    font-size: .85rem;
}
.login-sso-separator::before,
.login-sso-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #dbe2ee;
}
.btn-login.btn-login-sso {
    background: #fff;
    color: var(--brand-1, #233469);
    border: 1px solid currentColor;
    box-shadow: none;
}
.btn-login.btn-login-sso:hover {
    background: #f0f4fa;
}
.btn-login.btn-login-sso:focus-visible {
    outline: 3px solid #6485cc;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }
}
