:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #657089;
    --primary: #1d4ed8;
    --primary-dark: #173ea8;
    --premium: #7c3aed;
    --success: #0f9f6e;
    --danger: #d14343;
    --border: #dfe5ef;
    --shadow: 0 12px 35px rgba(31, 41, 55, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: min(1120px, calc(100% - 32px));
    margin-inline: auto;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    font-weight: 900;
    color: var(--text);
    font-size: 1.15rem;
}

nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.welcome { color: var(--muted); }

.main { padding-block: 38px 70px; }

.hero,
.result-hero,
.exam-heading {
    background: linear-gradient(135deg, #eaf1ff, #f4edff);
    border: 1px solid #dbe5ff;
    border-radius: 26px;
    padding: clamp(28px, 5vw, 58px);
    margin-bottom: 30px;
}

.hero h1,
.result-hero h1,
.exam-heading h1 {
    margin: 8px 0 12px;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1.05;
}

.hero p,
.result-hero p,
.exam-heading p {
    max-width: 760px;
    color: var(--muted);
    font-size: 1.08rem;
}

.eyebrow {
    display: inline-block;
    color: var(--primary);
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: .8rem;
}

.grid,
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
}

.card,
.question-card,
.analysis-card,
.review-card,
.form-card,
.auth-card,
.checkout-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.card { padding: 24px; }

.card h2 { margin: 16px 0 8px; }

.card p { color: var(--muted); }

.card-top,
.meta,
.analysis-title,
.review-status,
.admin-heading,
.exam-heading,
.result-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .06em;
}

.badge.free { background: #dcfce7; color: #087a50; }
.badge.premium { background: #ede9fe; color: #6d28d9; }

.meta {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 18px;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 46px;
    padding: 11px 18px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    margin-top: 18px;
}

.btn:hover { text-decoration: none; }

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover { background: var(--primary-dark); }

.btn.secondary {
    background: #eef2f8;
    color: var(--text);
}

.premium-btn {
    background: var(--premium);
    color: white;
}

.btn.large {
    width: 100%;
    min-height: 58px;
    font-size: 1.05rem;
}

.alert {
    padding: 14px 16px;
    border-radius: 12px;
    background: #eef2ff;
    border: 1px solid #cdd8ff;
    margin-bottom: 18px;
}

.alert.success { background: #ecfdf5; border-color: #a7f3d0; color: #087a50; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #b42323; }

.auth-card,
.form-card,
.checkout-card {
    max-width: 760px;
    margin: 0 auto;
    padding: clamp(24px, 5vw, 42px);
}

form label {
    display: block;
    font-weight: 800;
    margin-bottom: 18px;
}

input,
textarea,
select {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font: inherit;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #dbe7ff;
    border-color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.question-card {
    padding: clamp(22px, 4vw, 34px);
    margin-bottom: 22px;
}

.question-number,
.review-status {
    color: var(--muted);
    font-weight: 800;
    font-size: .9rem;
}

.question-number span,
.review-status span {
    float: right;
    color: var(--primary);
}

.options { display: grid; gap: 12px; margin-top: 22px; }

.option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: 1px solid var(--border);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    margin: 0;
}

.option:hover { border-color: var(--primary); background: #f8faff; }

.option input {
    width: auto;
    margin: 4px 0 0;
}

.timer {
    font-size: 1.7rem;
    font-weight: 900;
    background: white;
    border-radius: 14px;
    padding: 12px 18px;
    min-width: 110px;
    text-align: center;
}

.score-circle {
    width: 170px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: white;
    display: grid;
    place-content: center;
    text-align: center;
    box-shadow: var(--shadow);
    flex: 0 0 auto;
}

.score-circle strong { font-size: 2.8rem; line-height: 1; }
.score-circle span { color: var(--muted); margin-top: 8px; }

.result-level { font-weight: 900; color: var(--primary) !important; }

.analysis-card { padding: 22px; }

.progress {
    height: 11px;
    background: #e8edf5;
    border-radius: 999px;
    overflow: hidden;
}

.progress span {
    height: 100%;
    display: block;
    background: var(--primary);
}

.review-section { margin-top: 40px; }

.review-card {
    padding: 24px;
    margin: 16px 0;
    border-left: 6px solid var(--border);
}

.review-card.correct { border-left-color: var(--success); }
.review-card.incorrect { border-left-color: var(--danger); }

.explanation {
    background: #f7f9fc;
    border-radius: 12px;
    padding: 15px;
    margin-top: 14px;
}

.admin-heading { margin-bottom: 22px; }

.table-wrap {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #f8fafc; }

fieldset {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 18px;
}

.option-admin {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.option-admin input[type="radio"] { width: auto; margin: 0; }
.option-admin input[type="text"] { margin: 0; }

.help { color: var(--muted); }

.price {
    font-size: 2.4rem;
    font-weight: 900;
    margin: 22px 0;
}

.footer {
    background: #111827;
    color: #d1d5db;
    padding: 28px 0;
    margin-top: 50px;
}

@media (max-width: 760px) {
    .nav,
    .admin-heading,
    .exam-heading,
    .result-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    nav { gap: 12px; }
    .form-grid { grid-template-columns: 1fr; }
    .score-circle { width: 140px; }
    .timer { align-self: stretch; }
}

/* Portada y buscador por nivel educativo */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.search-hero {
    background:
        radial-gradient(circle at 85% 20%, rgba(124, 58, 237, .18), transparent 28%),
        radial-gradient(circle at 10% 90%, rgba(29, 78, 216, .16), transparent 30%),
        linear-gradient(135deg, #edf4ff, #f8f5ff);
}

.search-hero > div {
    max-width: 940px;
}

.exam-search {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, .34fr) auto;
    gap: 12px;
    align-items: stretch;
    margin-top: 26px;
    padding: 10px;
    background: rgba(255, 255, 255, .88);
    border: 1px solid rgba(207, 218, 239, .95);
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(31, 41, 55, .10);
}

.exam-search input,
.exam-search select {
    margin: 0;
    min-height: 52px;
    border-radius: 12px;
}

.exam-search .search-button {
    margin: 0;
    min-height: 52px;
    white-space: nowrap;
}

.exam-search.compact {
    max-width: 760px;
    grid-template-columns: 1fr auto;
}

.level-section {
    margin-top: 36px;
}

.section-heading,
.results-heading {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 20px;
}

.section-heading h2,
.results-heading h2 {
    margin: 7px 0 0;
    font-size: clamp(1.65rem, 4vw, 2.45rem);
}

.results-heading span {
    color: var(--muted);
    font-weight: 800;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.level-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 17px;
    min-height: 190px;
    padding: 25px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.level-card:hover {
    transform: translateY(-4px);
    border-color: #9fb8ff;
    box-shadow: 0 18px 42px rgba(31, 41, 55, .13);
    text-decoration: none;
}

.level-card h3 {
    margin: 0 0 7px;
    font-size: 1.42rem;
}

.level-card p {
    margin: 0 0 12px;
    color: var(--muted);
}

.level-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 17px;
    background: #eef3ff;
    font-size: 1.75rem;
}

.level-count {
    color: var(--primary);
    font-size: .86rem;
    font-weight: 900;
}

.level-arrow {
    font-size: 1.7rem;
    color: var(--primary);
}

.home-benefits {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 25px;
}

.home-benefits article {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 15px;
}

.home-benefits article span {
    color: var(--muted);
}

.level-hero {
    margin-bottom: 28px;
    padding: clamp(28px, 5vw, 48px);
    background: linear-gradient(135deg, #edf4ff, #faf7ff);
    border: 1px solid #dbe5ff;
    border-radius: 25px;
}

.level-hero h1 {
    max-width: 850px;
    margin: 8px 0 12px;
    font-size: clamp(2rem, 5vw, 3.35rem);
    line-height: 1.08;
}

.level-hero p {
    color: var(--muted);
    max-width: 760px;
    font-size: 1.05rem;
}

.breadcrumbs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    color: var(--muted);
    font-size: .9rem;
}

.breadcrumbs a {
    color: var(--muted);
}

.exam-card {
    display: flex;
    flex-direction: column;
}

.exam-card .btn {
    align-self: flex-start;
}

.exam-card > p {
    flex-grow: 1;
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.level-badge {
    background: #e8f0ff;
    color: #234ca7;
}

.empty-state {
    text-align: center;
    padding: clamp(35px, 7vw, 70px) 25px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.empty-state h2 {
    margin: 10px 0 7px;
}

.empty-state p {
    color: var(--muted);
}

.empty-icon {
    font-size: 3rem;
}

.empty-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}

@media (max-width: 940px) {
    .level-grid,
    .home-benefits {
        grid-template-columns: 1fr;
    }

    .level-card {
        min-height: auto;
    }
}

@media (max-width: 760px) {
    .exam-search,
    .exam-search.compact {
        grid-template-columns: 1fr;
    }

    .level-card {
        grid-template-columns: auto 1fr;
    }

    .level-arrow {
        display: none;
    }

    .section-heading,
    .results-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* ===== DIRECTORIO DE UNIVERSIDADES V3 ===== */

.university-directory {
    margin: 34px 0 42px;
}

.directory-count {
    color: var(--muted);
    font-weight: 900;
}

.university-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.university-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    min-height: 132px;
    padding: 19px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, .06);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.university-card:hover {
    text-decoration: none;
    transform: translateY(-3px);
    border-color: #9fb8ff;
    box-shadow: 0 15px 32px rgba(31, 41, 55, .11);
}

.university-symbol,
.university-detail-symbol {
    display: grid;
    place-items: center;
    min-width: 62px;
    height: 62px;
    padding: 7px;
    border-radius: 17px;
    color: #173ea8;
    background: linear-gradient(135deg, #e8f0ff, #f1ebff);
    border: 1px solid #d5e1ff;
    font-size: .82rem;
    font-weight: 950;
    text-align: center;
    overflow-wrap: anywhere;
}

.university-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.university-content strong {
    line-height: 1.28;
}

.university-content small {
    margin-top: 4px;
    color: var(--muted);
    font-weight: 800;
}

.university-exam-count {
    margin-top: 9px;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 900;
}

.university-arrow {
    color: var(--primary);
    font-size: 1.35rem;
    font-weight: 900;
}

.institution-badge {
    background: #fff4d8;
    color: #8a5a00;
}

.institution-badge:hover {
    text-decoration: none;
    background: #ffe9aa;
}

.exam-results-heading {
    margin-top: 38px;
}

.notice-panel {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 22px;
    color: var(--text);
    background: #eef4ff;
    border: 1px solid #cfddff;
    border-radius: 15px;
}

.notice-panel span {
    color: var(--muted);
}

.compact-empty {
    padding-block: 35px;
}

.search-universities {
    margin-top: 0;
}

.university-detail-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 25px;
}

.university-detail-symbol {
    width: 108px;
    height: 108px;
    border-radius: 25px;
    font-size: 1rem;
}

.university-detail-hero .breadcrumbs {
    margin-top: 3px;
}

.university-acronym {
    font-weight: 800;
}

.field-help {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 500;
}

[hidden] {
    display: none !important;
}

@media (max-width: 980px) {
    .university-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .university-grid {
        grid-template-columns: 1fr;
    }

    .university-card {
        min-height: 112px;
    }

    .university-detail-layout {
        grid-template-columns: 1fr;
    }

    .university-detail-symbol {
        width: 82px;
        height: 82px;
    }
}


/* ===== DIRECTORIOS DE INSTITUCIONES V4 ===== */

.institution-directory {
    margin: 34px 0 42px;
}

.institution-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.institution-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    min-height: 132px;
    padding: 19px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(31, 41, 55, .06);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.institution-card:hover {
    text-decoration: none;
    transform: translateY(-3px);
    border-color: #9fb8ff;
    box-shadow: 0 15px 32px rgba(31, 41, 55, .11);
}

.institution-symbol,
.institution-detail-symbol {
    display: grid;
    place-items: center;
    min-width: 62px;
    height: 62px;
    padding: 7px;
    border-radius: 17px;
    color: #173ea8;
    background: linear-gradient(135deg, #e8f0ff, #f1ebff);
    border: 1px solid #d5e1ff;
    font-size: .82rem;
    font-weight: 950;
    text-align: center;
    overflow-wrap: anywhere;
}

.preparatory-symbol {
    color: #8a3b00;
    background: linear-gradient(135deg, #fff1dd, #fff8e8);
    border-color: #f6d6a7;
}

.institution-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.institution-content strong {
    line-height: 1.28;
}

.institution-content small {
    margin-top: 4px;
    color: var(--muted);
    font-weight: 800;
}

.institution-exam-count {
    margin-top: 9px;
    color: var(--primary);
    font-size: .82rem;
    font-weight: 900;
}

.institution-arrow {
    color: var(--primary);
    font-size: 1.35rem;
    font-weight: 900;
}

.institution-detail-layout {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 25px;
}

.institution-detail-symbol {
    width: 108px;
    height: 108px;
    border-radius: 25px;
    font-size: 1rem;
}

.institution-detail-hero .breadcrumbs {
    margin-top: 3px;
}

.institution-acronym {
    font-weight: 800;
}

.search-institutions {
    margin-top: 0;
}

.prep-badge {
    background: #fff0da;
    color: #8a3b00;
}

.prep-badge:hover {
    background: #ffe1b5;
}

@media (max-width: 980px) {
    .institution-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .institution-grid {
        grid-template-columns: 1fr;
    }

    .institution-card {
        min-height: 112px;
    }

    .institution-detail-layout {
        grid-template-columns: 1fr;
    }

    .institution-detail-symbol {
        width: 82px;
        height: 82px;
    }
}

.admin-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-actions .btn {
    margin-top: 0;
}

.admin-form-wide {
    max-width: none;
    margin-bottom: 32px;
}
