:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1d2433; --muted: #5d6676; --line: #e2e5ea; --line-2: #c9ced6;
  --brand: #1f5f8b; --brand-d: #173f5f; --brand-2: #e8f1f8; --ok: #1f7a4d; --ok-bg: #e6f4ec; --warn: #8a5300; --warn-bg: #fff4e0;
  --bad: #b3261e; --bad-bg: #fdecea; --radius: 10px; --focus: 0 0 0 3px rgba(42, 120, 214, .35);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card > h2:first-child { margin-top: 0; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

button, .btn {
  font: inherit; font-weight: 500; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
  transition: background .12s, box-shadow .12s, opacity .12s;
}
button:hover, .btn:hover { background: var(--brand-d); border-color: var(--brand-d); }
button.sec, .btn.sec { background: #fff; color: var(--brand); border-color: var(--line-2); }
button.sec:hover, .btn.sec:hover { background: var(--brand-2); border-color: var(--brand); }
button.peligro { background: #fff; color: var(--bad); border-color: #e7b7b3; }
button.peligro:hover { background: var(--bad-bg); }
button.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: 4px 8px; }
button.ghost:hover { background: var(--brand-2); }
button:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }
button.cargando::before { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: giro .7s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }

input, select, textarea {
  font: inherit; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; background: #fff; color: var(--ink);
  transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: #aab2be; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--s1); box-shadow: var(--focus); }
input[aria-invalid="true"] { border-color: var(--bad); }
textarea { resize: vertical; min-height: 70px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label .req { color: var(--bad); }
.ayuda { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.campo-clave { position: relative; }
.campo-clave input { padding-right: 70px; }
.campo-clave button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.caps { color: var(--warn); font-size: .82rem; margin-top: 4px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--brand-2); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.gris { background: #eef0f3; color: var(--muted); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: transparent; color: var(--muted); border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 10px 14px; }
.tabs button:hover { color: var(--ink); background: transparent; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; background: #fff; color: var(--muted); padding: 6px 12px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--brand); color: #fff; }

/* barra superior del panel */
.top { background: var(--brand-d); color: #fff; position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; min-height: 56px; flex-wrap: wrap; }
.top .marca { font-weight: 700; font-size: 1.05rem; margin-right: 18px; color: #fff; text-decoration: none; }
.top nav { display: flex; gap: 2px; flex-wrap: wrap; }
.top nav a { color: #c5d6e6; text-decoration: none; padding: 17px 12px; border-bottom: 3px solid transparent; font-weight: 500; }
.top nav a:hover { color: #fff; }
.top nav a.on { color: #fff; border-bottom-color: #6da7ec; }
.top .yo { color: #c5d6e6; font-size: .88rem; }
.top button.ghost { color: #fff; }
.top button.ghost:hover { background: rgba(255,255,255,.12); }

.doc { background: #fbfbfc; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.doc .meta { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.doc pre { white-space: pre-wrap; font-family: inherit; margin: 0; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.r, th.r { text-align: right; }
tr.clic { cursor: pointer; } tr.clic:hover td { background: #f3f6fa; }
tr.clic:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--s1); }
.tabla-scroll { overflow-x: auto; }
.hidden { display: none !important; }
.err { color: var(--bad); font-weight: 600; }
.aviso { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 14px; }
.info { background: var(--brand-2); color: var(--brand-d); border-radius: 8px; padding: 10px 14px; }
.vacio { text-align: center; padding: 36px 20px; color: var(--muted); }
.vacio b { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }

.modal { position: fixed; inset: 0; background: rgba(20,25,35,.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 20px 20px; z-index: 50; overflow-y: auto; animation: aparece .12s ease-out; }
.modal .card { width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal .card.ancho { max-width: 860px; }
.modal .cierre { float: right; margin: -6px -8px 0 0; }
@keyframes aparece { from { opacity: 0; } }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .92rem; animation: sube .18s ease-out; max-width: 380px; }
.toast.ok::before { content: '✓ '; color: #7fe0a8; font-weight: 700; } .toast.bad { background: var(--bad); } .toast.bad::before { content: '! '; font-weight: 700; }
@keyframes sube { from { transform: translateY(8px); opacity: 0; } }

/* candidato */
.barra { position: sticky; top: 0; z-index: 10; background: #fff; border-bottom: 1px solid var(--line); }
.barra .wrap { padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.reloj { font-variant-numeric: tabular-nums; font-size: 1.35rem; font-weight: 700; padding: 4px 12px; border-radius: 8px; background: var(--brand-2); color: var(--brand); }
.reloj.poco { background: var(--warn-bg); color: var(--warn); } .reloj.fuera { background: var(--bad-bg); color: var(--bad); }
.guardado { font-size: .82rem; color: var(--muted); }
.tipo { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
ul.reglas li { margin-bottom: 4px; }
.tab-ok::after { content: ' ✓'; color: var(--ok); }

/* evaluación */
.rub td.nivel { cursor: pointer; font-size: .84rem; border: 1px solid var(--line); width: 21%; }
.rub td.nivel:hover { background: #f3f6fa; }
.rub td.nivel:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--s1); }
.rub td.nivel.sel { background: var(--brand-2); box-shadow: inset 0 0 0 2px var(--brand); }
.rub td.nivel b { display: block; font-size: 1rem; }
.rub.solo-lectura td.nivel { cursor: default; }
.respuesta { white-space: pre-wrap; background: #fbfbfc; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.respuesta mark { background: #ffe9a8; color: inherit; padding: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .et { font-size: .8rem; color: var(--muted); display: block; }
.kpi b { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin: 4px 0 2px; }
.kpi .sub { font-size: .78rem; color: var(--muted); }
.card .kpis .kpi { background: #fbfbfc; }
.timeline { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; background: #fff; }
.timeline div { height: 100%; }
.leyenda { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .84rem; color: var(--muted); margin: 4px 0 10px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 4px 0; font-weight: normal; cursor: pointer; }
.check input { margin-top: 4px; }
details summary { cursor: pointer; color: var(--brand); }
.pega { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; font-size: .88rem; }
.flujo { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.flujo > div { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fbfbfc; }
.flujo h3 { font-size: .92rem; margin-bottom: 6px; }

/* gráficos */
.graf-h { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 12px; align-items: center; }
.graf-h .et { font-size: .86rem; color: var(--ink); }
.graf-h .pista { position: relative; height: 22px; display: flex; align-items: center; gap: 8px; }
.graf-h .barra-h { height: 14px; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.graf-h .val { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.graf-col { display: flex; align-items: flex-end; gap: 10px; height: 170px; border-bottom: 1px solid var(--line); padding: 0 4px; }
.graf-col .col { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; min-width: 14px; max-width: 56px; height: 100%; justify-content: flex-start; }
.graf-col .seg-c { width: 100%; min-height: 2px; }
.graf-col .col > .seg-c:last-child { border-radius: 4px 4px 0 0; }
.graf-col-et { display: flex; gap: 10px; padding: 4px 4px 0; }
.graf-col-et span { flex: 1; min-width: 14px; max-width: 56px; text-align: center; font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; }
#tip { position: fixed; pointer-events: none; background: #1d2433; color: #fff; font-size: .82rem; padding: 6px 10px; border-radius: 6px; z-index: 70; max-width: 280px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.heat td.v { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.filtros { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.filtros label { margin: 0 0 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.filtros select, .filtros input { width: auto; min-width: 150px; }

/* editor de casos */
.item-edit { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 10px 0; background: #fbfbfc; }
.item-edit .row h3 { margin: 0; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tres { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 12px; }
@media (max-width: 700px) { .dos, .tres { grid-template-columns: 1fr; } .graf-h { grid-template-columns: 1fr; } }

@media print {
  .noprint, .tabs, .barra, .top, #toasts { display: none !important; }
  body { background: #fff; } .card { border: none; padding: 0; }
  .seccion { display: block !important; page-break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.filtros input[type="checkbox"] { min-width: 0; }
.filtros label.check { font-size: .88rem; color: var(--ink); font-weight: 500; }

/* preguntas cerradas */
fieldset.preg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px 14px; margin: 0 0 14px; transition: border-color .15s; }
fieldset.preg.ok { border-color: #b7dcc6; background: #fbfefc; }
fieldset.preg legend { font-weight: 600; padding: 0 6px; line-height: 1.45; }
fieldset.preg .num { color: var(--brand); }
label.opc { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; margin: 6px 0; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
label.opc:hover { background: #f3f6fa; }
label.opc input { margin-top: 4px; }
label.opc:has(input:checked) { background: var(--brand-2); }
fieldset.mm table { max-width: 460px; }
fieldset.mm td, fieldset.mm th { padding: 6px 10px; }
fieldset.mm .c { text-align: center; width: 80px; }
fieldset.mm input[type=radio] { width: 18px; height: 18px; cursor: pointer; }
fieldset.mm tr:has(input:checked) td:first-child { font-weight: 600; }
.escala { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.escala label { display: inline-flex; gap: 4px; align-items: center; font-weight: normal; margin: 0; }
#progreso.listo { background: var(--ok-bg); color: var(--ok); }
.consigna { background: var(--brand-2); color: var(--brand-d); border-radius: 8px; padding: 10px 14px; }
.sel-prueba { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; align-items: center; }
.sel-prueba:has(input:checked) { border-color: var(--brand); background: var(--brand-2); }
.sel-prueba input { margin-top: 0; }
.facs { display: grid; gap: 14px; }
.fac-pista { position: relative; height: 14px; background: #f0f2f5; border-radius: 4px; margin: 6px 0 4px; }
.fac-barra { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.fac-cero { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #8a919c; }
.barra-editor { position: sticky; top: 56px; z-index: 15; background: var(--bg); padding: 10px 0; margin-bottom: 6px; }
details.item-preg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 6px 0; background: #fff; }
details.item-preg[open] { border-color: #9cc3e0; }
details.item-preg summary { color: var(--ink); }
details.item-preg summary .num { color: var(--brand); font-weight: 600; }
.tabla-op td, .tabla-op th { padding: 4px 6px; border: none; }
.tabla-op input, .tabla-op select { padding: 6px 8px; }
h4 { font-size: .92rem; }
