:root {
    --primary: #0156ba;
    --primary-dark: #0156ba;
    --text: #263640;
    --muted: #6c7880;
    --danger: #c62828;
    --border: #d8e0e5;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }

.login-background {
    min-height: 100dvh;
    width: 100%;
    padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    display: grid;
    place-items: start center;
    background-image: linear-gradient(rgba(255,255,255,.03), rgba(255,255,255,.03)), url("assets/images/Imagen_fondo_acceso_sistema.png");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

.login-card {
    width: min(920px, 100%);
    min-height: 460px;
    margin-top: clamp(8px, 2.5vh, 32px);
    padding: clamp(20px, 3vw, 30px);
    border-radius: 12px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 4px 18px rgba(0,0,0,.22);
    backdrop-filter: blur(3px);
}

.login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 2px 0 28px;
}
.login-header h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.3rem); font-weight: 650; }
.login-header img { max-height: 96px; width: auto; max-width: min(68%, 470px); object-fit: contain; }

.login-form { width: min(620px, 100%); margin: 20px auto 0; display: grid; gap: 18px; }
.login-field {
    min-height: 60px;
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    transition: border-color .16s ease, box-shadow .16s ease;
}
.login-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(1,86,186,.12); }
.login-field-icon { display: grid; place-items: center; border-right: 1px solid var(--border); color: #4e5f69; font-size: 1.4rem; background: #f7f9fa; }
.login-field input { min-width: 0; width: 100%; border: 0; outline: 0; padding: 0 16px; font-size: 1rem; background: transparent; color: var(--text); }
.login-field input::placeholder { color: #8a969d; }
.password-toggle { width: 52px; border: 0; background: transparent; color: #6b7880; }
.password-toggle:hover { color: var(--primary); background: #f4f8fa; }

.login-button {
    min-height: 58px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: clamp(1.1rem, 2.4vw, 1.55rem);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background .18s ease, border-color .18s ease;
}
.login-button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.login-button:disabled { opacity: .7; cursor: wait; }
.login-spinner { width: 19px; height: 19px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.recover-link { justify-self: center; border: 0; background: transparent; color: var(--primary); font-size: clamp(1rem, 2vw, 1.18rem); padding: 8px 12px; text-decoration: underline; text-underline-offset: 3px; }
.recover-link:hover { color: var(--primary-dark); }
.login-error { margin: -4px 0 0; padding: 11px 13px; border-radius: 8px; background: #fff0f0; color: var(--danger); font-weight: 650; }

.demo-access {
    width: min(620px, 100%);
    margin: 24px auto 0;
    padding: 12px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    border-radius: 8px;
    background: rgba(1,86,186,.07);
    color: #53636d;
    font-size: .82rem;
}
.demo-access strong { width: 100%; color: #0156ba; }
.demo-access code { background: rgba(255,255,255,.8); padding: 1px 4px; border-radius: 4px; }
.login-toast { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 10; max-width: min(90vw, 380px); padding: 13px 16px; border-radius: 9px; background: #26343c; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.2); }

[hidden] { display: none !important; }

@media (max-width: 640px) {
    .login-background { padding-left: 12px; padding-right: 12px; place-items: center; }
    .login-card { min-height: auto; margin-top: 0; padding: 18px 14px 22px; }
    .login-header { padding-bottom: 18px; gap: 12px; }
    .login-header img { max-height: 72px; max-width: 68%; }
    .login-form { margin-top: 10px; gap: 14px; }
    .login-field { min-height: 56px; grid-template-columns: 52px minmax(0,1fr) auto; }
    .login-button { min-height: 54px; }
}

.login-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    padding: 18px;
    display: grid;
    place-items: center;
    background: rgba(14, 31, 40, .58);
    backdrop-filter: blur(2px);
}
.login-modal-card {
    position: relative;
    width: min(540px, 100%);
    padding: 28px;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 18px 55px rgba(0, 0, 0, .28);
}
.login-modal-card h2 { margin: 8px 42px 10px 0; color: var(--text); font-size: 1.55rem; }
.login-modal-copy { margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.login-modal-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: rgba(1,86,186,.1); color: var(--primary); font-size: 1.35rem; }
.login-modal-close { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: #66757e; }
.login-modal-close:hover { background: #f0f4f6; color: var(--primary); }
.recover-form { display: grid; gap: 10px; }
.recover-label { font-weight: 700; font-size: .93rem; color: #43545e; }
.recover-field { min-height: 56px; grid-template-columns: 52px minmax(0, 1fr); }
.recover-message { margin: 4px 0 0; padding: 11px 13px; border-radius: 8px; background: #edf8f1; color: #28653b; line-height: 1.45; }
.recover-message.is-error { background: #fff0f0; color: var(--danger); }
.login-modal-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.modal-button { min-height: 44px; padding: 0 18px; border-radius: 7px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.modal-button--secondary { border: 1px solid #cbd5da; background: #fff; color: #4b5b64; }
.modal-button--secondary:hover { background: #f5f7f8; }
.modal-button--primary { border: 1px solid var(--primary); background: var(--primary); color: #fff; }
.modal-button--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.modal-button:disabled { opacity: .65; cursor: wait; }

@media (max-width: 640px) {
    .login-modal { padding: 10px; align-items: end; }
    .login-modal-card { width: 100%; padding: 24px 18px max(20px, env(safe-area-inset-bottom)); border-radius: 16px 16px 8px 8px; }
    .login-modal-actions { display: grid; grid-template-columns: 1fr; }
    .modal-button { width: 100%; }
}

.reset-card { min-height: 430px; }
.reset-subtitle { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }
.reset-state { width: min(620px, 100%); margin: 35px auto 0; padding: 18px; display: flex; align-items: flex-start; gap: 14px; border-radius: 9px; background: rgba(1,86,186,.07); color: #0156ba; }
.reset-state > i { margin-top: 2px; font-size: 1.3rem; color: var(--primary); }
.reset-state p { margin: 6px 0 12px; color: #6a777e; }
.reset-state--error { background: #fff1f1; color: #8f2929; }
.reset-state--error > i { color: #b52d2d; }
.reset-back-link { color: var(--primary); font-weight: 700; }
.reset-hint { margin: -4px 2px 0; color: var(--muted); font-size: .88rem; }
.reset-success { width: min(620px, 100%); margin: 28px auto 0; text-align: center; padding: 28px 18px; }
.reset-success > i { font-size: 3rem; color: #2f8a4b; }
.reset-success h2 { margin: 12px 0 6px; }
.reset-success p { margin: 0 0 22px; color: var(--muted); }
.reset-login-link { min-height: 50px; padding: 0 24px; text-decoration: none; font-size: 1rem; display: inline-flex; }
