:root { 
    --primary: #E40078; 
    --primary-hover: #c20065;
    --primary-glow: rgba(228, 0, 120, 0.35);
    --bg: #070D18; 
    --card-bg: #111A2E; 
    --card-border: rgba(255, 255, 255, 0.08);
    --input-bg: #090F1C;
    --text: #F8FAFC; 
    --text-muted: #94A3B8;
    --error: #EF4444;
    --success: #10B981;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Poppins', sans-serif; 
    user-select: none; 
    -webkit-tap-highlight-color: transparent;
}

body { 
    background: var(--bg); 
    min-height: 100vh;
    min-height: 100dvh; /* Altura dinámica real en navegadores móviles */
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 16px;
    background-image: radial-gradient(circle at 50% 10%, #17233d 0%, #070D18 100%);
    overflow-x: hidden;
}

.login-wrapper {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
}

/* MARCA LATERAL (SOLO TABLETS GRANDES / PC) */
.brand-side {
    display: none;
    text-align: center;
    flex: 1;
}
.brand-side img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    padding: 8px;
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 35px var(--primary-glow);
    object-fit: contain;
}
.brand-side h1 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    color: var(--text);
    font-size: 2rem;
    margin-top: 15px;
    letter-spacing: 1px;
}
.brand-side p {
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

@media (min-width: 860px) {
    .brand-side { display: block; }
}

/* TARJETA PRINCIPAL */
.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 360px;
    padding: 24px 20px;
    border-radius: 28px;
    box-shadow: 0 20px 45px -10px rgba(0,0,0,0.6);
    border: 1px solid var(--card-border);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* CABECERA DE TARJETA */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}
.card-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
}
.mode-toggle {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.2s;
}
.mode-toggle:active { transform: scale(0.92); }

/* VISOR DE PIN DINÁMICO */
.pin-display-box {
    background: var(--input-bg);
    border: 1.5px solid var(--card-border);
    border-radius: 16px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    padding: 0 16px;
    transition: border-color 0.2s;
}
.pin-display-box.error { border-color: var(--error); animation: shake 0.35s; }
.pin-mask-text {
    font-size: 1.6rem;
    letter-spacing: 8px;
    font-weight: 900;
    color: var(--primary);
    min-height: 30px;
    display: flex;
    align-items: center;
}
.pin-placeholder {
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: #475569;
    font-weight: 600;
}

/* TECLADO NUMÉRICO RESPONSIVO */
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.pad-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    height: 54px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.1s;
}
.pad-btn:active {
    background: rgba(228, 0, 120, 0.25);
    border-color: var(--primary);
    transform: scale(0.95);
}
.pad-btn.btn-backspace {
    color: var(--error);
    font-size: 1.15rem;
}

/* BOTÓN DE ENTRAR DEDICADO */
.btn-submit-action {
    width: 100%;
    margin-top: 14px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s;
}
.btn-submit-action:active { transform: scale(0.97); }

/* MODO FORMULARIO (USUARIO / CONTRASEÑA) */
.form-mode-container {
    display: none;
    flex-direction: column;
    gap: 12px;
}
.input-field-wrap {
    position: relative;
}
.input-field-wrap i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
}
.form-ctrl {
    width: 100%;
    height: 50px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 0 16px 0 46px;
    color: white;
    font-size: 0.95rem;
    outline: none;
}
.form-ctrl:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* MENSAJE DE ESTADO */
.status-alert {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--error);
    min-height: 20px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px); }
    75% { transform: translateX(7px); }
}

/* OPTIMIZACIÓN EXTREMA EN MÓVILES PEQUEÑOS (iPhone SE, etc.) */
@media screen and (max-width: 380px) {
    body { padding: 10px; }
    .login-card { padding: 18px 14px; border-radius: 22px; }
    .pad-btn { height: 48px; font-size: 1.2rem; }
    .pin-display-box { height: 46px; }
    .btn-submit-action { height: 46px; font-size: 0.9rem; }
}