:root {
    --navy-deep: #0b1a3a;
    --navy: #0f2657;
    --blue: #1447e6;
    --teal: #14b8a6;
    --teal-light: #e6faf7;
    --ink: #0b1a3a;
    --muted: #5b6b8c;
    --error: #d64545;
    --white: #ffffff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--navy);
    color: var(--white);
}

header.topbar {
    background: var(--navy-deep);
    padding: 18px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.brand {
    display: flex;
    align-items: center;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.logo {
    margin: 0;
    max-width: 140px;
    width: auto;
    height: auto;
}

.topnav a {
    color: #cfe0ff;
    text-decoration: none;
    font-size: 14px;
    margin-left: 28px;
}

.topnav a:hover { color: var(--white); }

main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 60px;
    padding: 60px 40px 80px;
    max-width: 1200px;
    margin: 0 auto;
}

.intro { max-width: 420px; }

.intro h1 {
    font-size: 34px;
    line-height: 1.25;
    margin: 0 0 12px;
}
.intro h1 span { color: var(--teal); }

.intro p.sub {
    color: #b9c7ea;
    font-size: 16px;
    margin: 0 0 28px;
}

.intro ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.intro li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 14px;
    color: #dbe4fb;
    font-size: 15px;
}

.intro li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
}

.card {
    background: var(--white);
    color: var(--ink);
    width: 380px;
    max-width: 100%;
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.card h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.card p.card-sub {
    margin: 0 0 24px;
    font-size: 13.5px;
    color: var(--muted);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}

.field { margin-bottom: 18px; }

.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #d7deee;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease;
}

.field input:focus { border-color: var(--blue); }
.field input.invalid { border-color: var(--error); }

.field .hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}

.field .hint.error { color: var(--error); }

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    padding: 8px 4px;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 24px;
    background: var(--teal);
    color: var(--navy-deep);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    margin-top: 6px;
    transition: filter 0.15s ease, transform 0.05s ease;
}

.submit-btn:hover { filter: brightness(0.95); }
.submit-btn:active { transform: scale(0.99); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-link {
    text-align: center;
    margin-top: 18px;
    font-size: 13.5px;
    color: var(--muted);
}

.login-link a { color: var(--blue); text-decoration: none; font-weight: 600; }
.login-link a:hover { text-decoration: underline; }

.terms {
    font-size: 12px;
    color: var(--muted);
    margin-top: 16px;
    line-height: 1.5;
}

.terms a { color: var(--blue); text-decoration: none; }

.server-msg {
    display: none;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.server-msg.error { display: block; background: #fdecec; color: var(--error); }
.server-msg.success { display: block; background: var(--teal-light); color: #0d7d6e; }

/* INFORMATION */

.information {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--white);
}

.information img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

@media screen and (min-width: 800px) {
    .information img {
        width: 100%;
        height: auto;
        max-height: 90px;
        object-fit: contain;
    }
}

@media screen and (max-width: 600px) {
    .information img {
        width: 100%;
        height: auto;
        max-height: 150px;
        object-fit: contain;
    }
}

/* FOOTER */

footer, h3 {
    position: relative;
    text-align: left;
    margin: 0px;
    padding: 20px;
    font-size: 0.6rem;
    background-color: #f3f3f3;
    color: #000;
}

.footer {
    text-align: center;
    padding: 30px;
    color: var(--navy);
    color: #fff;
}

@media screen and (min-width: 600px) {
    .footer {
        text-align: center;
    }
}

/* ============================================
   MODAL — TARJETA DE ID (SOLO LECTURA)
   ============================================ */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 26, 58, 0.65);
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
    z-index: 1000;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--white);
    color: var(--ink);
    width: 100%;
    max-width: 440px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.4);
    animation: modalIn 0.2s ease;

    /* el scroll interno vive aquí, no solo en el overlay */
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
}

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

.modal-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--white);
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--ink);
    line-height: 1;
    padding: 8px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--muted);
}

/* Este contenedor es el que scrollea: incluye la tarjeta + las secciones */
.modal-scroll-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1;
}

.id-card {
    background: var(--navy-deep);
    color: var(--white);
    padding: 22px 24px 26px;
}

.id-card-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 18px;
}
.id-card-brand svg { flex-shrink: 0; }

.id-card-label {
    font-size: 11px;
    color: #9fb0d6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.id-card-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 18px;
    word-break: break-word;
}

.id-card-grid {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.id-card-grid .col div + div { margin-top: 14px; }

.id-card-value {
    font-size: 14.5px;
    font-weight: 600;
    word-break: break-word;
}

.id-card-strip {
    height: 46px;
    background: repeating-linear-gradient(
        100deg,
        var(--teal) 0px,
        var(--teal) 2px,
        #0f9d8d 2px,
        #0f9d8d 4px
    );
}

.modal-body {
    padding: 22px 24px 26px;
}

.modal-section {
    margin-bottom: 24px;
}
.modal-section:last-child { margin-bottom: 0; }

.modal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal-section-header h3 {
    font-size: 15px;
    margin: 0;
    color: var(--ink);
}

.info-card {
    border: 1px solid #e3e8f3;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}

.info-item .info-label {
    font-size: 11.5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}

.info-item .info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    word-break: break-word;
}

.info-item.full { grid-column: 1 / -1; }

.empty-note {
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
}

/* ============================================
   RESPONSIVE — TABLETS Y MÓVILES GRANDES
   ============================================ */
@media (max-width: 900px) {
    main {
        padding: 40px 24px 60px;
        gap: 40px;
    }
    .intro h1 {
        font-size: 30px;
    }
}

/* ============================================
   RESPONSIVE — MÓVILES
   ============================================ */
@media (max-width: 720px) {
    header.topbar {
        padding: 14px 20px;
        justify-content: center;
        text-align: center;
    }
    .topnav {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    .topnav a {
        margin: 0 14px;
    }

    main {
        flex-direction: column;
        padding: 32px 20px 48px;
        gap: 32px;
    }

    .intro {
        text-align: center;
        max-width: 100%;
    }
    .intro li {
        text-align: left;
    }
    .intro h1 {
        font-size: 26px;
    }
    .intro p.sub {
        font-size: 15px;
    }

    .card {
        width: 100%;
        padding: 24px;
    }
}

/* ============================================
   RESPONSIVE — MÓVILES PEQUEÑOS
   ============================================ */
@media (max-width: 480px) {
    .intro h1 {
        font-size: 22px;
    }

    .card {
        padding: 20px;
        border-radius: 8px;
    }

    .modal-overlay {
        padding: 0;
        align-items: stretch;
        overflow: hidden; /* el overlay ya no scrollea, scrollea .modal-scroll-content */
    }
    .modal-box {
        max-width: 100%;
        max-height: 100dvh; /* alto real de pantalla en móvil, evita cortes por la barra del navegador */
        border-radius: 0;
    }

    .id-card {
        padding: 18px 20px 22px;
    }
    .id-card-name {
        font-size: 19px;
    }
    .id-card-grid {
        flex-direction: column;
        gap: 12px;
    }

    .modal-body {
        padding: 18px 20px 24px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}