:root {
    --azul: #2f6df6;
    --azul-d: #1f54c9;
    --bg: #f5f7fb;
    --card: #ffffff;
    --texto: #1b2330;
    --muted: #6b7480;
    --borde: #e3e8ef;
    --ok: #30a46c;
    --fail: #e5484d;
    --warn: #f5a524;
    --radio: 12px;
    --sombra: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--texto);
    line-height: 1.5;
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 920px; margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 620px; }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--borde); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--texto); }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); }
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { color: var(--azul); background: #eef3ff; }
.opos-badge { margin-left: auto; font-size: .85rem; color: var(--muted); background: var(--bg); padding: 5px 10px; border-radius: 20px; }

main.container { padding-top: 28px; padding-bottom: 60px; }
h1 { font-size: 1.6rem; margin: 0 0 18px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; margin-bottom: 18px; box-shadow: var(--sombra); }
.card.ok { border-color: #b7e4c7; background: #f0fbf4; }
.card.error { border-color: #f3c0c2; background: #fdf1f1; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px){ .grid-2,.grid-3 { grid-template-columns: 1fr; } }

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

/* Stats */
.stats-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px){ .stats-grid { grid-template-columns: 1fr 1fr; } }
.stat { text-align: center; }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--azul); }
.stat-lbl { font-size: .85rem; color: var(--muted); }
.stat.highlight { border-color: var(--warn); background: #fff8ec; }
.stat.highlight .stat-num { color: var(--warn); }

.cta-card { text-align: center; padding: 36px; }

/* Botones */
.btn { display: inline-block; background: var(--azul); color: #fff; border: none; border-radius: 8px; padding: 10px 18px; font-size: .95rem; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--azul-d); text-decoration: none; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-mini { padding: 6px 10px; font-size: .8rem; }
.btn-ghost { background: transparent; color: var(--azul); border: 1px solid var(--borde); }
.btn-ghost:hover { background: var(--bg); }
.link-danger { background: none; border: none; color: var(--fail); cursor: pointer; font-size: .85rem; padding: 6px; }
.link-danger:hover { text-decoration: underline; }

/* Test */
.test-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.pregunta-num { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.tema-tag { background: #eef3ff; color: var(--azul); padding: 2px 8px; border-radius: 12px; font-size: .72rem; text-transform: none; letter-spacing: 0; }
.enunciado { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }
.opciones { display: flex; flex-direction: column; gap: 8px; }
.opcion { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: 1px solid var(--borde); border-radius: 8px; cursor: pointer; }
.opcion:hover { border-color: var(--azul); }
.opcion input { margin: 0; }
.opcion .letra { font-weight: 700; color: var(--muted); width: 20px; }
.submit-bar { display: flex; align-items: center; gap: 16px; position: sticky; bottom: 0; }

/* Revisión de resultados */
.resultado-cabecera { display: flex; align-items: center; gap: 30px; }
.resultado-cabecera.aprobado { border-left: 5px solid var(--ok); }
.resultado-cabecera.suspenso { border-left: 5px solid var(--fail); }
.nota-grande { font-size: 3rem; font-weight: 800; line-height: 1; }
.aprobado .nota-grande { color: var(--ok); }
.suspenso .nota-grande { color: var(--fail); }

.pregunta.resultado.ok { border-left: 4px solid var(--ok); }
.pregunta.resultado.fail { border-left: 4px solid var(--fail); }
.opciones.revision .opcion { cursor: default; }
.r-correcta { border-color: var(--ok); background: #f0fbf4; }
.r-elegida-mal { border-color: var(--fail); background: #fdf1f1; }
.opcion .marca { margin-left: auto; font-size: .78rem; font-weight: 600; }
.r-correcta .marca { color: var(--ok); }
.r-elegida-mal .marca { color: var(--fail); }
.explicacion { margin-top: 14px; padding: 12px 14px; background: #f8fafc; border-radius: 8px; font-size: .92rem; }
.fuente { margin-top: 10px; font-size: .85rem; color: var(--muted); }
.fuente-tipo { background: var(--bg); padding: 1px 8px; border-radius: 10px; }

.badge { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 12px; }
.b-ok { background: #e7f6ee; color: var(--ok); }
.b-fail { background: #fdeaea; color: var(--fail); }
.estado-borrador { background: #fff8ec; color: var(--warn); }
.estado-verificada { background: #e7f6ee; color: var(--ok); }
.estado-revisar { background: #fdeaea; color: var(--fail); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(16,24,40,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: var(--radio); padding: 24px; max-width: 640px; width: 100%; }
.modal-box textarea { width: 100%; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; border: 1px solid var(--borde); border-radius: 8px; padding: 12px; }
.modal-acciones { display: flex; gap: 10px; margin-top: 14px; }

/* Tablas y formularios */
.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--borde); font-size: .92rem; }
.tabla th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }

label { display: block; margin-bottom: 14px; font-size: .9rem; font-weight: 600; }
input[type=text], input[type=number], textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 8px; font-size: .95rem; font-family: inherit; margin-top: 5px; font-weight: 400;
}
.respuestas-fs { border: 1px solid var(--borde); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.respuestas-fs legend { font-size: .85rem; color: var(--muted); padding: 0 6px; }
.resp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.resp-row input[type=text] { margin-top: 0; }
.inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form select { width: auto; margin-top: 0; }
.inline { display: inline; }

/* Lista de preguntas */
.pregunta-fila { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.pf-enunciado { margin-top: 8px; font-weight: 500; }
.pf-acciones { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* Barras de temas */
.lista-temas { list-style: none; padding: 0; margin: 0; }
.lista-temas li { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: .9rem; }
.lista-temas li > span:first-child { flex: 0 0 40%; }
.barra { flex: 1; height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.barra > span { display: block; height: 100%; }
.barra .bad { background: var(--fail); }
.barra .mid { background: var(--warn); }
.barra .good { background: var(--ok); }
.pct { flex: 0 0 42px; text-align: right; font-weight: 600; }

.footer { padding: 24px 0; border-top: 1px solid var(--borde); background: var(--card); }
