/* ============ Tokens ============ */
:root {
  --bg: #f5f7fa; --surface: #fff; --surface-2: #f0f3f7; --text: #101828; --muted: #5a6474; --border: #e3e7ed;
  --primary: #2458d3; --primary-hover: #1c47b0; --primary-soft: #eaf0fd;
  --success: #137a3a; --success-soft: #e7f5ec; --warning: #9a5a06; --warning-soft: #fff4e2;
  --danger: #bf2531; --danger-soft: #fdeced; --accent: #6a3fcf; --accent-soft: #f2edfd;
  --radius: 14px; --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / .05);
  --shadow: 0 1px 2px rgb(16 24 40 / .04), 0 6px 20px -8px rgb(16 24 40 / .12);
  --shadow-lg: 0 24px 48px -12px rgb(16 24 40 / .25);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Mono", Consolas, "Lucida Console", ui-monospace, monospace;
  /* Pantalla BIOS: colores fijos en ambos temas, como un monitor real */
  --bios: #0000a8; --bios-texto: #e8e8e8; --bios-cian: #55ffff; --bios-gris: #aaa;
  --bios-sel: #00a8a8; --bios-amar: #ffff55; --bios-rojo: #ff5555; --bios-verde: #55ff55;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #161b23; --surface-2: #1d232d; --text: #e7ebf1; --muted: #9aa4b3; --border: #2a313d;
    --primary: #5b8cff; --primary-hover: #7aa2ff; --primary-soft: #1b2a4d;
    --success: #4cc27a; --success-soft: #16301f; --warning: #f0b35a; --warning-soft: #33260f;
    --danger: #ff7b83; --danger-soft: #3a1a1e; --accent: #b59cff; --accent-soft: #2a2144;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px -10px rgb(0 0 0 / .5);
  }
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 1.4rem; }
p { margin: 0 0 1rem; }
a { color: var(--primary); }
svg { width: 1em; height: 1em; flex: none; }
kbd { font: 600 .78em var(--mono); background: var(--surface); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .1em .4em; color: var(--text); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.contenedor { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 768px) { .contenedor { padding-inline: 32px; } }
.texto-suave { color: var(--muted); }
.sobretitulo { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); margin-bottom: .5rem; }
.tarjeta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.vista { padding-block: 32px 64px; }
.vista-cabecera { margin-bottom: 24px; max-width: 720px; }

/* ============ Botones ============ */
button { font: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primario { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primario:hover:not(:disabled) { background: var(--primary-hover); }
.btn-sec { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-sec:hover:not(:disabled) { background: var(--surface-2); border-color: color-mix(in srgb, var(--border) 60%, var(--muted)); }
.btn-fantasma { background: transparent; color: var(--muted); }
.btn-fantasma:hover { background: var(--surface-2); color: var(--text); }
.btn-peligro { background: var(--danger); color: #fff; }
.btn-peligro:hover { filter: brightness(.92); }
.btn-bloque { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .85rem; }
.btn-lg { min-height: 48px; font-size: 1rem; }
.enlace { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px 0; color: var(--primary); font-weight: 600; cursor: pointer; }
.enlace:hover { text-decoration: underline; }
.enlace svg, .migas svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.botones { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* ============ Insignias y avisos ============ */
.insignia { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 99px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.insignia-exito { background: var(--success-soft); color: var(--success); }
.insignia-aviso { background: var(--warning-soft); color: var(--warning); }
.insignia-acento { background: var(--accent-soft); color: var(--accent); }
.aviso { border-radius: var(--radius-sm); padding: 12px 16px; margin: 20px 0 0; font-weight: 550; border: 1px solid transparent; }
.aviso:empty { display: none; }
.aviso-info { background: var(--primary-soft); color: var(--primary); }
.aviso-exito { background: var(--success-soft); color: var(--success); }
.aviso-alerta { background: var(--warning-soft); color: var(--warning); }

/* ============ Cabecera ============ */
.cabecera { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.cabecera-in { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.marca { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.marca-icono { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary); }
.marca-icono svg { width: 22px; height: 22px; fill: #fff; }
.marca-texto { display: flex; flex-direction: column; line-height: 1.2; }
.marca-texto small { color: var(--muted); font-size: .78rem; }
.usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem; }
.usuario-datos { display: flex; flex-direction: column; line-height: 1.2; max-width: 220px; }
.usuario-datos strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-datos small { color: var(--muted); font-size: .78rem; }
@media (max-width: 600px) { .marca-texto small, .usuario-datos { display: none; } }

/* ============ Ingreso ============ */
.login { display: grid; gap: 40px; align-items: center; min-height: calc(100vh - 64px); }
@media (min-width: 960px) { .login { grid-template-columns: 1.15fr 1fr; gap: 72px; } }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 560px; }
.beneficios { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 18px; }
.beneficios li { display: flex; gap: 14px; align-items: flex-start; }
.beneficios strong { display: block; }
.beneficios li > span:last-child { color: var(--muted); }
.beneficios li > span:last-child strong { color: var(--text); }
.beneficio-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.beneficio-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-tarjeta { padding: 32px; max-width: 460px; width: 100%; justify-self: center; }
.campo { margin-top: 18px; }
.campo label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.campo input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
.campo input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.campo input:hover { border-color: color-mix(in srgb, var(--border) 50%, var(--muted)); }
.campo input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.campo input:user-invalid { border-color: var(--danger); }
.campo-error { display: none; color: var(--danger); font-size: .85rem; margin: 6px 0 0; }
.campo input:user-invalid + .campo-error { display: block; }
#f-login > .btn { margin-top: 24px; }

/* ============ Ejercicios ============ */
.rejilla-ejercicios { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.ejercicio { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; }
.ejercicio:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .ejercicio:hover { transform: translateY(-2px); } }
.ejercicio-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.ejercicio-num { font-size: .8rem; color: var(--muted); font-weight: 550; }
.ejercicio h2 { font-size: 1.08rem; }
.ejercicio p { color: var(--muted); font-size: .93rem; flex: 1; }
.meta { list-style: none; display: flex; gap: 18px; padding: 14px 0 0; margin: 0 0 18px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); }
.meta li { display: flex; align-items: center; gap: 6px; }
.meta svg { fill: currentColor; opacity: .75; }

/* ============ Simulador ============ */
.migas { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: .9rem; color: var(--muted); }
.migas #t-miga { color: var(--text); font-weight: 550; }
.sim { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 1080px) { .sim { grid-template-columns: 1fr; } }
.consola { background: #1b1f27; border-radius: var(--radius); padding: 0 12px 12px; box-shadow: var(--shadow-lg); }
.consola-barra { display: flex; align-items: center; gap: 10px; min-height: 40px; color: #aab3c2; font-size: .8rem; }
.consola-tip { margin-left: auto; opacity: .75; }
@media (max-width: 600px) { .consola-tip { display: none; } }
.led { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 8px #3ddc84; }
.tarea { position: sticky; top: 88px; }
@media (max-width: 1080px) { .tarea { position: static; } }
.tarea-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.reloj { display: inline-flex; align-items: center; gap: 6px; font: 600 .9rem var(--mono); color: var(--muted); background: var(--surface-2); padding: 4px 10px; border-radius: 99px; }
.reloj svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tarea h2 { font-size: 1.15rem; }
.tarea #t-desc { font-size: .93rem; }
.objetivos { list-style: none; counter-reset: obj; padding: 0; margin: 0; display: grid; gap: 10px; }
.objetivos li { counter-increment: obj; display: flex; gap: 10px; font-size: .93rem; }
.objetivos li::before { content: counter(obj); flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: .75rem; font-weight: 700; margin-top: 1px; }
.tarea-acciones { display: grid; gap: 10px; margin-top: 24px; }
.atajos { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; font-size: .88rem; }
.atajos summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.atajos dl { display: grid; gap: 8px; margin: 12px 0 0; }
.atajos dl div { display: flex; justify-content: space-between; gap: 12px; }
.atajos dd { margin: 0; color: var(--muted); text-align: right; }

/* ---- Monitor BIOS (estética de pantalla de texto intencional) ---- */
.monitor { position: relative; background: #000; color: var(--bios-texto); border-radius: 6px; font: 14px/1.35 var(--mono); min-height: 560px; overflow: auto; user-select: none; outline: none; }
.monitor:focus-visible { box-shadow: 0 0 0 3px var(--primary); }
.post { padding: 16px; white-space: pre-wrap; min-height: 560px; }
.post .amar { color: var(--bios-amar); } .post .rojo { color: var(--bios-rojo); } .post .verde { color: var(--bios-verde); }
.post button, .bios button { font: inherit; background: none; border: 0; color: inherit; padding: 0; text-decoration: underline; cursor: pointer; border-radius: 0; }
.parpadeo { animation: parpadeo 1s steps(1) infinite; }
@keyframes parpadeo { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .parpadeo { animation: none; } }
.bios { background: var(--bios); min-height: 560px; display: flex; flex-direction: column; }
.bios .titulo { background: var(--bios-gris); color: #000; padding: 2px 8px; display: flex; justify-content: space-between; }
.bios .tabs { display: flex; gap: 2px; padding: 6px 8px 0; flex-wrap: wrap; }
.bios .tabs button { text-decoration: none; padding: 2px 10px; color: var(--bios-cian); border: 1px solid var(--bios-cian); border-bottom: 0; }
.bios .tabs button[aria-selected="true"] { background: var(--bios-cian); color: #000; }
.bios .cuerpo { flex: 1; display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); border: 1px solid var(--bios-cian); margin: 0 8px; min-height: 400px; }
@media (max-width: 700px) { .bios .cuerpo { grid-template-columns: 1fr; } }
.bios .izq { padding: 6px; border-right: 1px solid var(--bios-cian); overflow: auto; }
.bios .der { padding: 6px 10px; overflow: auto; }
.bios .fila { white-space: pre; cursor: pointer; padding: 0 4px; }
.bios .fila.nosel { cursor: default; color: var(--bios-gris); }
.bios .fila[aria-selected="true"] { background: var(--bios-sel); color: #000; }
.bios .rojo { color: var(--bios-rojo); } .bios .amar { color: var(--bios-amar); } .bios .verde { color: var(--bios-verde); }
.bios .fila[aria-selected="true"] span { color: #000; }
.bios h4 { margin: 0 0 6px; color: var(--bios-amar); font-weight: normal; font-size: inherit; }
.bios dl { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; margin: 0; }
.bios dt { color: var(--bios-cian); }
.bios dd { margin: 0; }
.bios p { margin: 8px 0 0; }
.bios .ayuda { background: var(--bios-gris); color: #000; padding: 2px 8px; margin-top: 8px; }
.bios .ayuda button { color: #000; }
.barra-prog { border: 1px solid var(--bios-texto); height: 14px; margin-top: 4px; }
.barra-prog > div { background: var(--bios-verde); height: 100%; }
.bios select, .bios input[type=text] { background: #000; color: var(--bios-texto); border: 1px solid var(--bios-cian); font: inherit; padding: 1px 4px; }
.capa { position: absolute; inset: 0; background: rgb(0 0 0 / .35); display: grid; place-items: center; padding: 12px; }
.ventana { background: var(--bios-gris); color: #000; border: 2px solid #fff; box-shadow: 6px 6px 0 #000; min-width: 280px; max-width: 640px; width: 100%; }
.ventana .cab { background: var(--bios); color: #fff; padding: 2px 8px; }
.ventana .cont { padding: 10px; }
.ventana p { margin: 0 0 8px; }
.ventana button { font: inherit; color: #000; background: #ddd; border: 1px solid #000; padding: 2px 12px; text-decoration: none; border-radius: 0; cursor: pointer; }
.ventana button:focus-visible, .ventana .opcion:focus-visible { outline: 2px solid var(--bios); outline-offset: 0; background: var(--bios); color: #fff; }
.ventana button:disabled { color: #777; border-color: #777; cursor: not-allowed; }
.ventana .opcion { display: block; width: 100%; text-align: left; margin: 2px 0; background: transparent; border: 0; }
.ventana .opcion:hover:not(:disabled) { background: var(--bios); color: #fff; }
.ventana select, .ventana input[type=text] { font: inherit; background: #fff; color: #000; border: 1px solid #000; }
.ventana .rejilla-form { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.ventana fieldset label { display: block; white-space: pre; }
.ventana fieldset { border: 1px solid #000; margin: 8px 0; padding: 4px 8px; max-height: 180px; overflow: auto; }
.ventana .error { color: #a00000; min-height: 1.3em; }
.ventana .acciones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ============ Resultado ============ */
.resultado { max-width: 820px; margin-inline: auto; padding: 32px; }
.resultado-cab { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.resultado-cab h1 { margin-bottom: 4px; }
.resultado-cab p:last-child { margin: 0; }
.anillo { --p: 0; --c: var(--muted); width: 128px; height: 128px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(closest-side, var(--surface) 80%, transparent 81%), conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); }
.anillo span { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.anillo strong { font-size: 2.3rem; font-weight: 750; color: var(--c); letter-spacing: -.02em; }
.anillo small { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.anillo-exito { --c: var(--success); } .anillo-peligro { --c: var(--danger); }
.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; margin: 24px 0 0; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.resumen div { background: var(--surface); padding: 12px 16px; }
.resumen div:last-child { grid-column: 1 / -1; }
.resumen dt { font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.resumen dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.resultado h2 { margin-top: 28px; }
.criterios { list-style: none; padding: 0; margin: 12px 0 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.criterios li { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.criterios li + li { border-top: 1px solid var(--border); }
.criterio-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; }
.criterio-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.criterios .ok .criterio-ico { background: var(--success-soft); color: var(--success); }
.criterios .mal .criterio-ico { background: var(--danger-soft); color: var(--danger); }
.criterio-txt { flex: 1; }
.criterio-txt small { display: block; font-size: .8rem; color: var(--muted); }
.criterio-pts { font: 600 .9rem var(--mono); color: var(--muted); }

/* ============ Diálogo ============ */
.dialogo { border: 0; border-radius: var(--radius); padding: 28px; max-width: 440px; width: calc(100% - 32px); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialogo::backdrop { background: rgb(15 20 30 / .5); backdrop-filter: blur(2px); }
.dialogo h2 { font-size: 1.2rem; }
.dialogo-acciones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ============ Tablas (panel docente y manual) ============ */
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th { text-align: left; font-size: .75rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }

/* ============ Impresión ============ */
@media print {
  .cabecera, .no-imprimir, .migas { display: none !important; }
  body { background: #fff; color: #000; }
  .tarjeta, .resultado { border: 0; box-shadow: none; padding: 0; }
  .anillo { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
