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

.iems-auth-page {
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iems-auth-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(145deg, #FAF7F2 0%, #F3EDE3 40%, #EBE3D5 100%);
}

.iems-geo {
    position: absolute;
    pointer-events: none;
}

.iems-geo-1 {
    top: -12%;
    left: -8%;
    width: 58%;
    height: 75%;
    background: linear-gradient(155deg, rgba(105, 28, 50, 0.07) 0%, rgba(105, 28, 50, 0.02) 100%);
    clip-path: polygon(0 0, 80% 0, 40% 100%, 0 68%);
}

.iems-geo-2 {
    top: 8%;
    left: 12%;
    width: 38%;
    height: 55%;
    background: linear-gradient(135deg, rgba(188, 149, 92, 0.06) 0%, rgba(188, 149, 92, 0.01) 100%);
    clip-path: polygon(15% 0, 100% 12%, 65% 100%, 0 72%);
}

.iems-geo-3 {
    bottom: -15%;
    left: -5%;
    width: 45%;
    height: 50%;
    background: linear-gradient(120deg, rgba(105, 28, 50, 0.05) 0%, transparent 100%);
    clip-path: polygon(0 25%, 75% 0, 100% 75%, 20% 100%, 0 100%);
}

.iems-auth-layout {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 820px;
    padding: 2rem;
}

.iems-auth-brand {
    flex: 1;
    padding-right: 3rem;
    text-align: left;
}

.iems-brand-logo {
    width: 300px;
    height: auto;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.75rem;
    background: transparent;
}

.iems-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* o cover si quieres que llene todo */
}

.iems-brand-titulo {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--vino);
    line-height: 1.1;
    letter-spacing: -1px;
    margin-bottom: 0.75rem;
}

.iems-brand-titulo span {
    color: var(--dorado);
}

.iems-brand-subtitulo {
    font-size: 0.88rem;
    color: var(--gris-500);
    line-height: 1.5;
    font-weight: 400;
}

.iems-auth-divisor {
    width: 1px;
    height: 280px;
    background: linear-gradient(180deg, transparent 0%, var(--dorado) 30%, var(--dorado) 70%, transparent 100%);
    opacity: 0.35;
    flex-shrink: 0;
}

.iems-auth-form-area {
    flex: 1;
    max-width: 320px;
    padding-left: 3rem;
    text-align: center;
}

.iems-form-icono {
    color: var(--vino);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.iems-campo {
    margin-bottom: 1rem;
}

.iems-input-con-icono {
    position: relative;
    display: flex;
    align-items: center;
}

.iems-input-icono {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--vino);
    opacity: 0.45;
    pointer-events: none;
    border-right: 1px solid rgba(105, 28, 50, 0.1);
}

.iems-campo-input {
    width: 100%;
    padding: 0.7rem 0.85rem 0.7rem 52px;
    border: none;
    border-bottom: none;
    background-color: rgba(105, 28, 50, 0.04);
    font-family: inherit;
    font-size: 0.88rem;
    color: var(--gris-800);
    outline: none;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.iems-campo-input::placeholder {
    color: var(--gris-400);
    font-weight: 400;
}

.iems-campo-input:focus {
    background-color: rgba(105, 28, 50, 0.07);
    box-shadow: inset 0 -2px 0 var(--vino);
}

.iems-campo-input.error {
    background-color: rgba(220, 53, 69, 0.05);
    box-shadow: inset 0 -2px 0 var(--error);
}

.iems-campo-error {
    font-size: 0.72rem;
    color: var(--error);
    margin-top: 0.25rem;
    text-align: left;
    display: none;
    font-weight: 500;
    padding-left: 52px;
}

.iems-campo-error.visible {
    display: block;
}

.iems-campo-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.iems-toggle-pass {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gris-400);
    padding: 0.15rem;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.iems-toggle-pass:hover {
    color: var(--gris-700);
}

.iems-btn-auth {
    width: 100%;
    padding: 0.72rem;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--dorado);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.75rem;
    position: relative;
}

.iems-btn-auth::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background-color: var(--dorado);
    transition: width 0.3s ease;
}

.iems-btn-auth:hover {
    color: var(--vino);
}

.iems-btn-auth:hover::after {
    width: 100%;
    background-color: var(--vino);
}

.iems-btn-auth:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.iems-spinner-btn {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(188, 149, 92, 0.3);
    border-top-color: var(--dorado);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.4rem;
}

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

.iems-auth-link {
    margin-top: 1.5rem;
}

.iems-auth-link p {
    font-size: 0.8rem;
    color: var(--gris-500);
    margin: 0;
}

.iems-auth-link a {
    color: var(--vino);
    font-weight: 600;
    text-decoration: none;
    transition: all 0.25s ease;
}

.iems-auth-link a:hover {
    color: var(--dorado);
}

.iems-auth-pie {
    position: fixed;
    bottom: 1.25rem;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    color: var(--gris-400);
    z-index: 2;
    letter-spacing: 0.5px;
}

@media (max-width: 767.98px) {
    .iems-auth-layout {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
        max-width: 400px;
        padding: 2rem 1.5rem;
    }

    .iems-auth-brand {
        padding-right: 0;
        text-align: center;
    }

    .iems-brand-titulo {
        font-size: 1.8rem;
    }

    .iems-auth-divisor {
        width: 60px;
        height: 1px;
        background: linear-gradient(90deg, transparent, var(--dorado), transparent);
    }

    .iems-auth-form-area {
        padding-left: 0;
        max-width: 100%;
        width: 100%;
    }

    .iems-form-icono {
        margin-bottom: 1rem;
    }

    .iems-campo-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .iems-auth-layout--registro .iems-auth-form-area {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .iems-brand-titulo {
        font-size: 1.5rem;
    }

    .iems-brand-logo {
        width: 48px;
        height: 48px;
        font-size: 0.75rem;
    }
}

/* Select plantel */
.iems-select-wrapper {
    position: relative;
}

.iems-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 2.5rem;
}

.iems-select:invalid {
    color: var(--gris-400);
}

.iems-select option {
    color: var(--gris-800);
}

.iems-select option[value=""] {
    color: var(--gris-400);
}

.iems-select-chevron {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gris-400);
    pointer-events: none;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.iems-select:focus ~ .iems-select-chevron {
    color: var(--vino);
    transform: translateY(-50%) rotate(180deg);
}


/* Botón ayuda contraseña */
.iems-ayuda-pass-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.4rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    color: var(--gris-500);
    text-decoration: none;
    transition: all 0.25s ease;
    padding-left: 52px;
    font-weight: 500;
}

.iems-ayuda-pass-btn:hover {
    color: var(--vino);
}

/* Overlay modal */
.iems-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(33, 37, 41, 0.45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.iems-modal-overlay.activo {
    opacity: 1;
    visibility: visible;
}

.iems-modal-box {
    background: #FFFDF9;
    border-radius: 10px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 12px 40px rgba(105, 28, 50, 0.15);
    transform: translateY(12px) scale(0.97);
    transition: all 0.25s ease;
    overflow: hidden;
}

.iems-modal-overlay.activo .iems-modal-box {
    transform: translateY(0) scale(1);
}

/* Header modal */
.iems-modal-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.15rem 0.85rem;
    border-bottom: 1px solid rgba(105, 28, 50, 0.08);
}

.iems-modal-icono {
    color: var(--vino);
    opacity: 0.7;
    display: flex;
    flex-shrink: 0;
}

.iems-modal-titulo {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--vino);
    flex: 1;
    margin: 0;
    line-height: 1.3;
}

.iems-modal-cerrar {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gris-400);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.iems-modal-cerrar:hover {
    color: var(--vino);
    background: rgba(105, 28, 50, 0.06);
}

/* Body modal */
.iems-modal-body {
    padding: 1.1rem 1.15rem 1.25rem;
}

.iems-modal-desc {
    font-size: 0.8rem;
    color: var(--gris-500);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.iems-modal-desc strong {
    color: var(--gris-800);
}

/* Fórmula visual */
.iems-modal-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.iems-formula-bloque {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
}

.iems-formula-label {
    font-size: 0.62rem;
    color: var(--gris-500);
    text-align: center;
    line-height: 1.3;
}

.iems-formula-valor {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.35rem 0.6rem;
    border-radius: 5px;
    min-width: 50px;
    text-align: center;
}

.iems-formula-matricula .iems-formula-valor {
    background: rgba(105, 28, 50, 0.08);
    color: var(--vino);
}

.iems-formula-apellido .iems-formula-valor {
    background: rgba(188, 149, 92, 0.12);
    color: var(--dorado-oscuro);
}

.iems-formula-nombre .iems-formula-valor {
    background: rgba(188, 149, 92, 0.12);
    color: var(--dorado-oscuro);
}

.iems-formula-mas {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gris-400);
    flex-shrink: 0;
}

/* Ejemplo */
.iems-modal-ejemplo {
    background: rgba(105, 28, 50, 0.04);
    border-left: 3px solid var(--vino);
    border-radius: 0 5px 5px 0;
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.iems-ejemplo-datos {
    font-size: 0.75rem;
    color: var(--gris-500);
    line-height: 1.4;
}

.iems-ejemplo-datos strong {
    color: var(--vino);
}

.iems-ejemplo-resultado {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.iems-ejemplo-etiqueta {
    font-size: 0.72rem;
    color: var(--gris-500);
    font-weight: 500;
}

.iems-ejemplo-clave {
    font-size: 1rem;
    font-weight: 700;
    color: var(--vino);
    letter-spacing: 2px;
    background: rgba(105, 28, 50, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

@media (max-width: 767.98px) {
    .iems-brand-logo {
        width: 100%;
        max-width: 280px;
        margin: 0 auto 1.25rem auto;
    }

    .iems-brand-logo img {
        width: auto;
        max-height: 52px;
        object-fit: contain;
    }
}

@media (max-width: 480px) {
    .iems-brand-logo {
        max-width: 240px;
    }

    .iems-brand-logo img {
        max-height: 44px;
    }
}
