:root {
    --bg: #edf4ef;
    --card: #ffffff;
    --text: #1e2d23;
    --muted: #5b6a61;
    --line: #d7e3da;
    --primary: #217346;
    --primary-dark: #185b36;
    --soft-primary: #ebf6ef;
    --success: #1f7a45;
    --danger: #b42318;
    --warning: #a66b00;
    --shadow: 0 18px 40px rgba(23, 46, 31, .08);
    --radius: 22px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #f8fbf9 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f4f8f5; padding: 2px 6px; border-radius: 6px; }

.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0 60px;
}

.page-center {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.hero-card,
.result-card,
.feedback-card,
.intro-panel,
.table-card,
.question-card,
.submit-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-card,
.result-card {
    width: min(880px, 100%);
    padding: 34px;
}

.small-card { width: min(520px, 100%); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    background: var(--soft-primary);
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
}

h1, h2, h3 { margin-top: 0; line-height: 1.15; }
h1 { font-size: clamp(30px, 5vw, 46px); margin: 18px 0 14px; }
h2 { font-size: 21px; margin-bottom: 18px; }
h3 { font-size: 17px; margin-bottom: 6px; }

.lead { color: var(--muted); font-size: 18px; max-width: 760px; }

.rules-grid,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 26px 0;
}

.rules-grid div,
.summary-grid article {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fbf9;
}

.rules-grid strong,
.summary-grid strong {
    display: block;
    font-size: 20px;
    margin-bottom: 4px;
}

.rules-grid span,
.summary-grid span { color: var(--muted); }
.rules-grid small { color: #7a8797; }

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

label span {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 14px 15px;
    font-size: 16px;
    outline: none;
    background: #fff;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, .12);
}

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

.btn-primary,
.btn-secondary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 0;
    border-radius: 14px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 20px;
}

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

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

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

.btn-secondary:hover { background: #e7f0ea; text-decoration: none; }

.footer-links,
.actions-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 18px;
}

.actions-row.left { justify-content: flex-start; }

.site-credit {
    margin-top: 26px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.site-credit strong {
    color: var(--primary);
}

.page-credit {
    margin-bottom: 8px;
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 22px;
}

.progress-card {
    min-width: 130px;
    text-align: center;
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.progress-card strong { font-size: 34px; }
.progress-card small { display: block; color: var(--muted); }

.question-card {
    padding: 26px;
    margin-bottom: 20px;
    transition: border-color .15s ease, transform .15s ease;
}

.question-card.answered { border-color: rgba(20, 122, 72, .35); }

.question-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.question-number {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary-dark);
}

.difficulty,
.pill {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    background: #edf7f0;
    color: #1f5d3a;
}

.difficulty.basico { background: #ecfdf3; color: #166534; }
.difficulty.intermedio { background: #fff8e6; color: #a16207; }
.difficulty.avanzado { background: #eef7ff; color: #1d4ed8; }

.question-image {
    margin: 12px 0 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #f8fbf9;
}

.question-image img {
    display: block;
    width: 100%;
    height: auto;
}

.options {
    display: grid;
    gap: 10px;
}

.option {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
    cursor: pointer;
}

.option:hover { border-color: #7caf90; background: #f4fbf6; }
.option input { margin-top: 4px; }
.option-key {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 8px;
    background: #e7f0ea;
    font-weight: 900;
}

.submit-panel {
    padding: 24px;
    text-align: center;
}

.score-circle {
    width: 210px;
    height: 210px;
    border-radius: 999px;
    margin: 26px auto;
    display: grid;
    place-items: center;
    text-align: center;
    background: #f4f8f5;
    border: 12px solid #cbd5e1;
}

.score-circle strong {
    display: block;
    font-size: 44px;
}

.score-circle span { color: var(--muted); }
.score-circle.basico { border-color: #fb7185; background: #fff1f2; }
.score-circle.intermedio { border-color: #f59e0b; background: #fffbeb; }
.score-circle.avanzado { border-color: #22c55e; background: #f0fdf4; }

.level-box {
    text-align: center;
    padding: 18px;
    border-radius: 16px;
    font-size: 22px;
    background: #f8fbf9;
    border: 1px solid var(--line);
}

.result-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 18px;
    margin-top: 24px;
}

.feedback-card { padding: 28px; margin-top: 22px; }
.feedback-item {
    padding: 18px;
    border: 1px solid var(--line);
    border-left-width: 6px;
    border-radius: 14px;
    margin-bottom: 12px;
    background: #fff;
}
.feedback-item.correct { border-left-color: var(--success); }
.feedback-item.wrong { border-left-color: var(--danger); }
.feedback-item small { color: var(--muted); }

.intro-panel { padding: 30px; margin-bottom: 20px; }
.summary-grid { margin-top: 0; }
.summary-grid article { text-align: center; background: #fff; box-shadow: var(--shadow); }
.summary-grid strong { font-size: 38px; }

.table-card { padding: 18px; }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fbf9; font-size: 14px; }

.check {
    padding: 14px;
    border-radius: 12px;
    background: #f8fbf9;
    border: 1px solid var(--line);
}
.check.ok { color: var(--success); }
.check.bad, .error-box { color: var(--danger); }
.error-box {
    padding: 12px;
    border: 1px solid #fecdd3;
    border-radius: 12px;
    background: #fff1f2;
}

@media (max-width: 760px) {
    .hero-card, .result-card, .feedback-card, .intro-panel, .question-card { padding: 20px; }
    .rules-grid, .form-grid, .summary-grid, .result-meta { grid-template-columns: 1fr; }
    .test-header { align-items: stretch; flex-direction: column; }
    .progress-card { text-align: left; }
    .option { grid-template-columns: auto 1fr; }
    .option input { grid-row: span 2; }
}


.info-box {
    padding: 14px 16px;
    border: 1px solid #b7d8c1;
    border-radius: 14px;
    background: #eff8f2;
    color: #205b38;
    margin: 18px 0;
}
.muted { color: var(--muted); margin-top: -6px; }
.level-description {
    text-align: center;
    color: var(--muted);
    max-width: 720px;
    margin: 18px auto;
}
.question-number small {
    color: var(--muted);
    font-weight: 700;
}

/* Marca GesCambio */
.brand-logo-block {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 14px;
}

.brand-logo-block.left {
    justify-content: flex-start;
}

.brand-logo-block.compact {
    margin-bottom: 10px;
}

.brand-logo {
    display: block;
    width: clamp(180px, 32vw, 320px);
    max-height: 100px;
    height: auto;
    object-fit: contain;
}

.brand-logo-block.compact .brand-logo,
.small-card .brand-logo {
    width: clamp(150px, 24vw, 240px);
    max-height: 78px;
}

.test-title-area {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.test-logo {
    width: clamp(140px, 18vw, 220px);
    max-height: 72px;
    height: auto;
    object-fit: contain;
    flex: 0 0 auto;
}

.test-title-area h1 {
    margin-top: 8px;
}

@media (max-width: 760px) {
    .brand-logo {
        width: min(78vw, 280px);
    }
    .brand-logo-block.compact .brand-logo,
    .small-card .brand-logo {
        width: min(70vw, 220px);
    }
    .test-title-area {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .test-logo {
        width: min(70vw, 220px);
        max-height: 72px;
    }
}


/* Controles de avance y obligatoriedad del test */
.question-card.unanswered {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .10), var(--shadow);
}

.required-status {
    margin: 14px 0 0;
    font-weight: 800;
    color: var(--danger);
}

.required-status.complete {
    color: var(--success);
}

.btn-primary:disabled {
    cursor: not-allowed;
    opacity: .55;
    background: #8aa393;
}

.btn-primary:disabled:hover {
    background: #8aa393;
}

.exam-error {
    margin-bottom: 20px;
    font-weight: 700;
}

.back-to-top {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    padding: 12px 17px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease, background .2s ease;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--primary-dark);
}

.result-level-label {
    margin: 8px auto 10px;
    text-align: center;
    color: var(--muted);
    font-size: 17px;
    font-weight: 700;
}

.level-box span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 4px;
}

.level-box strong {
    display: block;
    font-size: clamp(30px, 5vw, 44px);
    line-height: 1.1;
}

.level-box.basico {
    border-color: #fb7185;
    background: #fff1f2;
    color: #9f1239;
}

.level-box.intermedio {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

.level-box.avanzado {
    border-color: #22c55e;
    background: #f0fdf4;
    color: #166534;
}

@media (max-width: 760px) {
    .back-to-top {
        right: 14px;
        bottom: 14px;
        padding: 11px 14px;
    }
}


/* Tema visual profesional estilo Excel */
.hero-card,
.result-card,
.feedback-card,
.intro-panel,
.table-card,
.question-card,
.submit-panel,
.progress-card {
    backdrop-filter: saturate(110%);
}

.hero-card,
.result-card,
.feedback-card,
.intro-panel,
.table-card,
.question-card,
.submit-panel {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
}

.hero-card,
.result-card,
.intro-panel {
    border-top: 5px solid var(--primary);
}

.progress-card {
    border-top: 4px solid var(--primary);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbf9 100%);
}

.badge {
    box-shadow: inset 0 0 0 1px rgba(33, 115, 70, .10);
}

.btn-primary {
    background: linear-gradient(180deg, #2a8552 0%, var(--primary) 100%);
    box-shadow: 0 12px 24px rgba(33, 115, 70, .18);
}

.btn-primary:hover { background: linear-gradient(180deg, #237749 0%, var(--primary-dark) 100%); }

.btn-secondary {
    background: linear-gradient(180deg, #f6faf7 0%, #edf4ef 100%);
    border: 1px solid var(--line);
}

.question-card {
    position: relative;
}

.question-card::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    border-radius: 22px 0 0 22px;
    background: linear-gradient(180deg, #2a8552 0%, var(--primary) 100%);
}

.question-card.unanswered::before {
    background: linear-gradient(180deg, #dc2626 0%, #b42318 100%);
}

.question-card.answered::before {
    background: linear-gradient(180deg, #26a05b 0%, #1f7a45 100%);
}

.question-number,
.site-credit strong,
.progress-card strong {
    color: var(--primary-dark);
}

.option {
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.option:has(input:checked) {
    border-color: #7caf90;
    background: #f2faf4;
    box-shadow: 0 0 0 3px rgba(33, 115, 70, .08);
}

.option-key {
    color: var(--primary-dark);
}

.submit-panel {
    border-top: 5px solid var(--primary);
}

.level-box.basico {
    border-color: #f59e0b;
    background: #fff8e8;
    color: #9a6700;
}

.level-box.intermedio {
    border-color: #217346;
    background: #edf8f1;
    color: #166534;
}

.level-box.avanzado {
    border-color: #1d4ed8;
    background: #eef5ff;
    color: #1d4ed8;
}

.score-circle.basico { border-color: #f59e0b; background: #fff8e8; }
.score-circle.intermedio { border-color: #217346; background: #edf8f1; }
.score-circle.avanzado { border-color: #1d4ed8; background: #eef5ff; }

.info-box strong,
.required-status.complete {
    color: var(--primary-dark);
}

.back-to-top {
    background: linear-gradient(180deg, #2a8552 0%, var(--primary) 100%);
}

.back-to-top:hover {
    background: linear-gradient(180deg, #237749 0%, var(--primary-dark) 100%);
}

table th {
    background: #f2f7f3;
    color: var(--primary-dark);
}
