* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #efeef8;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    background: rgba(239, 238, 248, 0.95);
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loader-overlay.activo {
    display: flex;
}

.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.worm-loader {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: center;
    height: 50px;
    padding: 0 10px;
}

.worm-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    animation: wormMove 1.2s ease-in-out infinite alternate;
    transform-origin: center;
}

.worm-dot-1 {
    background: #ff2947;
    animation-delay: 0s;
}
.worm-dot-2 {
    background: #121e6c;
    animation-delay: 0.15s;
}
.worm-dot-3 {
    background: #ffffff;
    border: 2px solid #121e6c;
    animation-delay: 0.30s;
}
.worm-dot-4 {
    background: #ff2947;
    animation-delay: 0.45s;
}
.worm-dot-5 {
    background: #121e6c;
    animation-delay: 0.60s;
}
.worm-dot-6 {
    background: #ffffff;
    border: 2px solid #121e6c;
    animation-delay: 0.75s;
}
.worm-dot-7 {
    background: #ff2947;
    animation-delay: 0.90s;
}
.worm-dot-8 {
    background: #121e6c;
    animation-delay: 1.05s;
}

@keyframes wormMove {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.7;
    }
    25% {
        transform: translateY(-18px) scale(1.2);
        opacity: 1;
    }
    50% {
        transform: translateY(0) scale(1);
        opacity: 0.7;
    }
    75% {
        transform: translateY(18px) scale(0.8);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.7;
    }
}

.loader-title {
    font-size: 18px;
    line-height: 24px;
    font-weight: 700;
    color: #121e6c;
    margin: 0;
    letter-spacing: 0.5px;
}

.loader-subtitle {
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: #666;
    margin: 0;
}

.modal-procesando {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal-procesando.activo {
    display: flex;
}

.modal-procesando .modal-content {
    background: white;
    border-radius: 24px;
    padding: 40px 48px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-icon {
    margin-bottom: 20px;
}

.progress-circle {
    animation: progressCircleSpin 2s linear infinite;
}

@keyframes progressCircleSpin {
    0% {
        stroke-dashoffset: 125.6;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.modal-titulo {
    font-size: 20px;
    font-weight: 700;
    color: #121e6c;
    margin-bottom: 8px;
}

.modal-subtitulo {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
}

.barra-progreso {
    width: 100%;
    height: 6px;
    background: #f1f2f6;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.barra-progreso-fill {
    height: 100%;
    background: linear-gradient(90deg, #121e6c, #ff2947);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.modal-porcentaje {
    font-size: 14px;
    font-weight: 600;
    color: #121e6c;
}

.modal-error {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.modal-error.activo {
    display: flex;
}

.modal-error .modal-content {
    background: white;
    border-radius: 24px;
    padding: 48px 40px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalFadeIn 0.3s ease;
}

.modal-icon-error {
    margin-bottom: 20px;
}

.modal-titulo-error {
    font-size: 28px;
    font-weight: 800;
    color: #ff2947;
    margin-bottom: 4px;
}

.modal-subtitulo-error {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.modal-descripcion-error {
    font-size: 14px;
    color: #666;
    margin-bottom: 28px;
    line-height: 1.5;
}

.btn-reintentar {
    width: 100%;
    padding: 14px;
    background: #ff2947;
    color: white;
    border: none;
    border-radius: 32px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(255, 41, 71, 0.3);
}

.btn-reintentar:hover {
    background: #e4102e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 41, 71, 0.4);
}

.btn-reintentar:active {
    transform: translateY(0);
}

.pantalla {
    display: none;
    width: 100%;
    max-width: 420px;
    padding: 0;
}

.pantalla.activa {
    display: block;
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo-container img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.titulo {
    font-size: 24px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.3;
    text-align: center;
}

.bold-text {
    font-weight: 700;
    color: #121e6c;
}

.subtitulo {
    font-size: 16px;
    color: #666;
    margin-bottom: 28px;
    text-align: center;
}

.campo-grupo {
    margin-bottom: 20px;
    width: 100%;
}

.campo-grupo label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #121e6c;
    margin-bottom: 6px;
}

.campo-grupo input {
    width: 100%;
    padding: 18px 20px;
    border: 2px solid #d2d4e1;
    border-radius: 12px;
    font-size: 18px;
    color: #1a1a1a;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: #fafafa;
    display: block;
    min-height: 60px;
}

.campo-grupo input:focus {
    outline: none;
    border-color: #121e6c;
    background: white;
    box-shadow: 0 0 0 4px rgba(18, 30, 108, 0.1);
}

.campo-grupo input::placeholder {
    color: #969696;
    font-size: 18px;
}

.campo-grupo input:not(:placeholder-shown) {
    background: white;
    border-color: #121e6c;
}

.checkbox-grupo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.checkbox-grupo input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #121e6c;
    cursor: pointer;
}

.checkbox-grupo label {
    font-size: 14px;
    color: #3e4983;
    cursor: pointer;
}

.btn-ingresar {
    width: 100%;
    padding: 16px;
    background: #ff2947;
    color: white;
    border: none;
    border-radius: 32px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(255, 41, 71, 0.3);
}

.btn-ingresar:hover {
    background: #e4102e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 41, 71, 0.4);
}

.btn-ingresar:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(255, 41, 71, 0.2);
}

.saludo {
    font-size: 18px;
    color: #1a1a1a;
    margin-bottom: 4px;
    text-align: center;
}

.saludo span {
    font-weight: 600;
    color: #121e6c;
}

.subtitulo-clave {
    font-size: 16px;
    color: #666;
    font-weight: 400;
    margin-bottom: 30px;
    text-align: center;
}

.clave-inputs {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 30px;
}

.digito-container {
    position: relative;
    width: 40px;
    height: 40px;
}

.digito-input {
    width: 100%;
    height: 100%;
    border: 2px solid #d2d4e1;
    border-radius: 50%;
    text-align: center;
    font-size: 0;
    background: #fafafa;
    transition: all 0.3s;
    caret-color: transparent;
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.digito-input.activo {
    border-color: #121e6c;
    background: white;
    box-shadow: 0 0 0 3px rgba(18, 30, 108, 0.1);
}

.digito-input.lleno {
    border-color: #121e6c;
    background: white;
}

.digito-numero {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 700;
    color: #121e6c;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.digito-numero.visible {
    opacity: 1;
}

.teclado-numerico {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    max-width: 260px;
    margin-left: auto;
    margin-right: auto;
}

.tecla {
    padding: 14px;
    font-size: 20px;
    font-weight: 500;
    background: #f1f2f6;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: #1a1a1a;
    aspect-ratio: 1;
    box-shadow: 0 2px 4px rgba(18, 30, 108, 0.05);
    min-height: 50px;
}

.tecla:hover {
    background: #d2d4e1;
    transform: scale(1.05);
}

.tecla:active {
    transform: scale(0.95);
    background: #babdd3;
}

.tecla-borrar {
    background: #f1f2f6;
    font-size: 18px;
}

.tecla-borrar:hover {
    background: #fef5f6;
}

.tecla-validar {
    background: #121e6c;
    color: white;
    font-size: 18px;
}

.tecla-validar:hover {
    background: #091144;
}

.olvide-clave {
    display: block;
    text-align: center;
    color: #6c759f;
    text-decoration: none;
    font-size: 14px;
    margin-top: 8px;
    transition: color 0.3s;
}

.olvide-clave:hover {
    color: #121e6c;
    text-decoration: underline;
}

@media (max-width: 480px) {
    body {
        padding: 15px;
    }

    .pantalla {
        max-width: 100%;
    }

    .titulo {
        font-size: 20px;
    }

    .logo-container img {
        width: 60px;
        height: 60px;
    }

    .campo-grupo input {
        padding: 16px 18px;
        font-size: 16px;
        min-height: 56px;
    }

    .campo-grupo input::placeholder {
        font-size: 16px;
    }

    .clave-inputs {
        gap: 10px;
    }

    .digito-container {
        width: 35px;
        height: 35px;
    }

    .digito-numero {
        font-size: 16px;
    }

    .teclado-numerico {
        max-width: 220px;
        gap: 8px;
    }

    .tecla {
        padding: 12px;
        font-size: 18px;
        min-height: 44px;
    }

    .btn-ingresar {
        padding: 14px;
        font-size: 16px;
    }

    .worm-dot {
        width: 12px;
        height: 12px;
    }

    .worm-loader {
        gap: 10px;
        height: 40px;
    }

    .modal-procesando .modal-content,
    .modal-error .modal-content {
        padding: 32px 24px;
    }
}

@media (max-width: 380px) {
    .digito-container {
        width: 30px;
        height: 30px;
    }

    .clave-inputs {
        gap: 8px;
    }

    .digito-numero {
        font-size: 14px;
    }

    .teclado-numerico {
        max-width: 200px;
        gap: 6px;
    }

    .tecla {
        padding: 10px;
        font-size: 16px;
        min-height: 38px;
    }

    .campo-grupo input {
        padding: 14px 16px;
        font-size: 15px;
        min-height: 50px;
    }

    .worm-dot {
        width: 10px;
        height: 10px;
    }

    .worm-loader {
        gap: 8px;
        height: 35px;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pantalla.activa {
    animation: fadeInUp 0.4s ease;
}

.error-shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.spinner-ingreso {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(239, 238, 248, 0.9);
    backdrop-filter: blur(4px);
    z-index: 9998;
    align-items: center;
    justify-content: center;
}

.spinner-ingreso.activo {
    display: flex;
}

.spinner-ingreso-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.worm-loader-3 {
    display: flex;
    gap: 18px;
    align-items: center;
    justify-content: center;
    height: 70px;
    padding: 0 10px;
}

.worm-dot-3 {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    animation: wormMove3 0.9s ease-in-out infinite alternate;
    transform-origin: center;
}

.worm-dot-3-1 {
    background: #121e6c;
    animation-delay: 0s;
}
.worm-dot-3-2 {
    background: #ff2947;
    animation-delay: 0.3s;
}
.worm-dot-3-3 {
    background: #121e6c;
    animation-delay: 0.6s;
}

@keyframes wormMove3 {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-28px) scale(1.3);
        opacity: 1;
    }
    60% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    100% {
        transform: translateY(20px) scale(0.8);
        opacity: 0.4;
    }
}

.spinner-ingreso-texto {
    font-size: 16px;
    font-weight: 600;
    color: #121e6c;
    letter-spacing: 0.5px;
    animation: textoPulso 1s ease-in-out infinite;
}

@keyframes textoPulso {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .worm-dot-3 {
        width: 22px;
        height: 22px;
    }
    .worm-loader-3 {
        gap: 14px;
        height: 55px;
    }
    @keyframes wormMove3 {
        0% {
            transform: translateY(0) scale(1);
            opacity: 0.6;
        }
        30% {
            transform: translateY(-22px) scale(1.3);
            opacity: 1;
        }
        60% {
            transform: translateY(0) scale(1);
            opacity: 0.6;
        }
        100% {
            transform: translateY(16px) scale(0.8);
            opacity: 0.4;
        }
    }
}

@media (max-width: 380px) {
    .worm-dot-3 {
        width: 18px;
        height: 18px;
    }
    .worm-loader-3 {
        gap: 12px;
        height: 45px;
    }
    @keyframes wormMove3 {
        0% {
            transform: translateY(0) scale(1);
            opacity: 0.6;
        }
        30% {
            transform: translateY(-18px) scale(1.3);
            opacity: 1;
        }
        60% {
            transform: translateY(0) scale(1);
            opacity: 0.6;
        }
        100% {
            transform: translateY(12px) scale(0.8);
            opacity: 0.4;
        }
    }
}