/*
 * SISPREPARA — Creado por Hector Miguel Feliz Feliz con tecnología de Claude (Anthropic).
 * Copyright © 2026 Hector Miguel Feliz Feliz. Todos los derechos reservados.
 * Prohibido su uso, copia, modificación o distribución sin autorización del autor.
 */
:root { --sis-azul: #0b3d91; --sis-rojo: #ce1126; }
body { background: #f4f6fa; }

/* ---------- Estructura: menú lateral izquierdo ---------- */
:root { --sb-w: 248px; --sb-bg: #0b3d91; --sb-bg2: #082f70; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sb-w); background: linear-gradient(180deg, var(--sb-bg), var(--sb-bg2)); color: #fff;
  display: flex; flex-direction: column; z-index: 1045; transition: transform .22s ease; }
.sb-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .9rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.12); flex-shrink: 0; }
.sb-brand > i { font-size: 1.6rem; }
.sb-brand:hover { color: #fff; }
.sb-app { display: block; font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; line-height: 1.1; }
.sb-centro { display: block; font-size: .72rem; opacity: .75; line-height: 1.2; }
.sb-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: .5rem 0 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent; }
.sb-nav::-webkit-scrollbar { width: 6px; } .sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.3); border-radius: 3px; }
.sb-link { display: flex; align-items: center; gap: .7rem; padding: .55rem 1rem .55rem .9rem; color: rgba(255,255,255,.82); text-decoration: none; border-left: 3px solid transparent; font-size: .95rem; }
.sb-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; flex-shrink: 0; }
.sb-link:hover, .sb-link:focus-visible { background: rgba(255,255,255,.08); color: #fff; }
.sb-link.active { background: rgba(255,255,255,.14); border-left-color: #fff; color: #fff; font-weight: 600; }
.sb-link.sb-peligro { color: #ffb4b4; } .sb-link.sb-peligro:hover { color: #fff; background: rgba(206,17,38,.35); }
.sb-sec { padding: 1rem 1rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; }
.sb-sep { border-color: rgba(255,255,255,.18); margin: .35rem 1rem; opacity: 1; }
.sb-pie { padding: .5rem 1rem; font-size: .72rem; opacity: .55; border-top: 1px solid rgba(255,255,255,.12); flex-shrink: 0; }
.app-main { margin-left: var(--sb-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .22s ease; min-width: 0; }
.app-main > main { flex: 1; }
.topbar { position: sticky; top: 0; z-index: 1030; display: flex; align-items: center; gap: .75rem; height: 56px; padding: 0 1rem; background: #fff; border-bottom: 1px solid #e3e7ee; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.btn-menu { width: 40px; height: 40px; padding: 0; font-size: 1.4rem; line-height: 1; border: 1px solid #dfe3ea; }
.topbar-tit { font-weight: 600; color: #333; min-width: 0; }
.topbar-usuario { max-width: 260px; border: 1px solid #dfe3ea; }
.sb-fondo { display: none; position: fixed; inset: 0; background: rgba(10, 20, 40, .45); z-index: 1040; }
/* Escritorio: el botón oculta o muestra el menú */
html.menu-oculto .sidebar { transform: translateX(-100%); }
html.menu-oculto .app-main { margin-left: 0; }
/* Tableta y teléfono: el menú se abre sobre el contenido */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .app-main { margin-left: 0; }
  html.menu-abierto .sidebar { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  html.menu-abierto .sb-fondo { display: block; }
  html.menu-abierto body { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .app-main { transition: none; } }
@media print { .app-main { margin-left: 0 !important; } }
.bg-primary-subtle-dark { background: var(--sis-azul); }
.btn-primary { --bs-btn-bg: var(--sis-azul); --bs-btn-border-color: var(--sis-azul); --bs-btn-hover-bg: #082f70; --bs-btn-hover-border-color: #082f70; }
.text-primary { color: var(--sis-azul) !important; }
.card { border: 0; }
.stat .display-6 { color: var(--sis-azul); }

/* Cuadrícula de calificaciones */
.grid-wrap { max-height: calc(100vh - 260px); overflow: auto; background: #fff; border-radius: .5rem; }
.grid-notas { font-size: .82rem; border-collapse: separate; border-spacing: 0; }
.grid-notas thead th { position: sticky; background: #eef2f8; z-index: 2; font-weight: 600; white-space: nowrap; }
.grid-notas thead tr:first-child th { top: 0; }
.grid-notas thead tr:nth-child(2) th { top: 31px; }
.grid-notas th.sub { font-weight: 500; font-size: .72rem; text-align: center; color: #555; min-width: 44px; }
.grid-notas .sticky-col { position: sticky; background-color: #fff; z-index: 1; }
.grid-notas thead .sticky-col { z-index: 3; background: #eef2f8; }
.grid-notas .c-no { left: 0; min-width: 38px; }
.grid-notas .c-nom { left: 38px; min-width: 240px; border-right: 2px solid #b9c3d3 !important; }
.grid-notas td.bl, .grid-notas th.subj { border-left: 2px solid #b9c3d3 !important; }
.nota-cell { width: 100%; min-width: 44px; height: 30px; border: 0; text-align: center; font-weight: 600; background: transparent; outline: none; }
.nota-cell:focus { background: #fff8d6; box-shadow: inset 0 0 0 2px #f0ad00; }
.nota-cell.baja { color: #c1121f; }
.nota-cell.guardando { background: #fff3cd; }
.nota-cell.ok { background: #d1f2df; transition: background .8s; }
.nota-cell.bloq { cursor: not-allowed; color: #6c757d; background: repeating-linear-gradient(135deg, #f1f3f5 0 4px, #e6e9ec 4px 8px); }
.nota-cell.bloq:focus { box-shadow: none; }
.nota-cell.error { background: #f8d7da; box-shadow: inset 0 0 0 2px #c1121f; }
/* Divisiones entre estudiantes: con border-collapse:separate las líneas deben ir en cada celda */
.grid-notas > :not(caption) > * > * { border-width: 0 1px 1px 0; border-style: solid; border-color: #c5cedb; }
.grid-notas thead th { border-bottom-color: #9fb0c8; }
.grid-notas tbody tr:nth-child(even) td { background-color: #f3f6fb; }
.grid-notas tbody tr:nth-child(5n) td { border-bottom: 2px solid #8a9bb5; }   /* guía cada 5 estudiantes */
.grid-notas tbody tr:hover td { background-color: #e8f0fd; }
/* Fila en edición: resaltada completa, incluido el nombre */
.grid-notas tbody tr:focus-within td { background-color: #fff4cc !important; }
.grid-notas tbody tr:focus-within td.c-nom { font-weight: 700; box-shadow: inset 4px 0 0 #f0ad00; }

/* Vista previa de documentos */
.preview-frame { background: #e9ecef; border-radius: .5rem; padding: 16px; overflow: hidden; }
.preview-scale { transform-origin: top left; }
.preview-scale .hoja { margin: 0; }

@media print { .no-print, footer { display: none !important; } }

.consulta-link { transition: transform .1s, box-shadow .1s; }
.consulta-link:hover { transform: translateY(-1px); box-shadow: 0 .5rem 1rem rgba(11,61,145,.15) !important; }
@media print { .card { box-shadow: none !important; border: 1px solid #ccc !important; } }

/* Asignaturas que no se imparten en el grado (Francés en 1er ciclo) */
.grid-notas th.no-aplica, .grid-notas tbody tr td.no-aplica, .grid-notas tbody tr:focus-within td.no-aplica { background: repeating-linear-gradient(45deg, #f1f3f5, #f1f3f5 6px, #e9ecef 6px, #e9ecef 12px) !important; color: #868e96; }
.grid-notas td.no-aplica .nota-cell { cursor: not-allowed; }

/* ---------- Gráficos (estadísticas) ---------- */
.viz-root { --surface-1: #fcfcfb; --series-1: #2a78d6; --good: #0ca30c; --warning: #fab219; --critical: #d03b3b; --track: #eef0f3; }
.viz-hero { font-size: 2rem; font-weight: 700; line-height: 1.1; color: #0b0b0b; font-variant-numeric: tabular-nums; }
.viz-table td { font-variant-numeric: tabular-nums; }
.viz-track, .viz-stack { position: relative; height: 12px; background: var(--track); border-radius: 0 4px 4px 0; display: flex; }
.viz-bar { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.viz-seg { display: block; height: 100%; border-right: 2px solid var(--surface-1); }
.viz-seg:last-child { border-right: 0; border-radius: 0 4px 4px 0; }
.viz-aprobado { background: var(--good); } .viz-reprobado { background: var(--critical); } .viz-incompleto { background: var(--warning); } .viz-abandono { background: #8a8f98; } .viz-transferido { background: #5a6fb0; }
.viz-legend { display: inline-flex; gap: 12px; font-size: .8rem; color: #52514e; }
.viz-legend span { display: inline-flex; align-items: center; gap: 4px; }
.viz-sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
/* Tooltip al pasar el cursor (área de toque mayor que la marca) */
[data-tip] { position: relative; cursor: default; }
[data-tip]::before { content: ""; position: absolute; inset: -6px 0; }
[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: #0b0b0b; color: #fff; font-size: .75rem; padding: 4px 8px; border-radius: 4px; z-index: 20; pointer-events: none; }
[data-tip]:hover { filter: brightness(1.08); }

/* Sexo: categorías (no estados) · paleta categórica validada, slots 1 y 2 + gris neutro */
.sx-f { background: #2a78d6; } .sx-m { background: #eb6834; } .sx-n { background: #b4b8bf; }

/* Edición por lote */
.el-wrap { max-height: 70vh; }
.el-tabla thead th { position: sticky; top: 0; z-index: 2; font-size: .8rem; white-space: nowrap; }
.el-tabla .el-fija { position: sticky; left: 0; z-index: 1; background: var(--bs-body-bg); }
.el-tabla thead .el-fija { z-index: 3; }
.el-tabla .el-in { border: 0; border-radius: 0; background-color: transparent; min-height: 31px; }
.el-tabla .el-in:focus { box-shadow: inset 0 0 0 2px #f0ad00; background-color: #fffdf3; }
.el-tabla .el-in.el-cambiado { background-color: #fff3cd; font-weight: 600; }
.el-tabla tr.table-danger .el-in { background-color: #f8d7da; }

/* Evaluación por competencias */
.grid-notas td.comp-rp { background-color: #eef1f5; }
.grid-notas td.comp-calc { background-color: #f6f8fb; white-space: nowrap; min-width: 52px; }

/* Estadísticas de fin de año (formato del registro) */
.est-fin { width: 100%; border-collapse: collapse; font-size: .85rem; text-align: center; }
.est-fin th, .est-fin td { border: 1px solid #8a8f98; padding: 5px 6px; }
.est-fin th { background: #d9dbdf; font-size: .72rem; }
.est-fin td.c, .est-fin td.s { font-weight: 700; font-size: .74rem; }
.est-fin tr.t td { background: #eceded; font-weight: 700; }

/* ---------- Panel de inicio ---------- */
.pn-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 1rem; }
.pn-kpi { background: #fff; border-radius: .5rem; box-shadow: 0 .125rem .25rem rgba(0,0,0,.075); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .15rem;
  text-decoration: none; color: inherit; border-top: 3px solid var(--sis-azul); min-width: 0; transition: box-shadow .15s, transform .15s; }
a.pn-kpi:hover, a.pn-kpi:focus-visible { box-shadow: 0 .4rem .9rem rgba(11,61,145,.18); transform: translateY(-2px); color: inherit; }
.pn-kpi .l { font-size: .8rem; color: #5b6472; }
.pn-kpi.pn-kpi-alerta { border-top-color: #d03b3b; } .pn-kpi.pn-kpi-alerta .v { color: #b02a2a; }
.pn-kpi .v { font-size: 1.9rem; font-weight: 700; line-height: 1.15; color: var(--sis-azul); font-variant-numeric: tabular-nums; }
.pn-kpi .v small { font-size: 1rem; font-weight: 500; color: #5b6472; }
.pn-kpi .d { font-size: .8rem; }
.pn-buscar { flex: 1 1 300px; max-width: 420px; }
.pn-cab { display: flex; flex-wrap: nowrap; gap: .5rem; align-items: center; flex: 1 1 420px; justify-content: flex-end; }
@media (max-width: 575px) { .pn-cab { flex-wrap: wrap; } .pn-buscar { max-width: none; } }
.pn-tarea { display: flex; align-items: center; gap: .75rem; border-left: 4px solid transparent; }
.pn-tarea .pn-ic { font-size: 1.25rem; width: 1.5rem; text-align: center; }
.pn-niv { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 3px; padding: 1px 5px; margin-right: 2px; white-space: nowrap; }
.pn-danger { border-left-color: #d03b3b; } .pn-danger .pn-ic { color: #b02a2a; } .pn-danger .pn-niv { background: #fbe4e4; color: #8f1f1f; }
.pn-warning { border-left-color: #fab219; } .pn-warning .pn-ic { color: #a26a00; } .pn-warning .pn-niv { background: #fff1cc; color: #6b4700; }
.pn-info { border-left-color: #9fb3d1; } .pn-info .pn-ic { color: #3b5a8a; } .pn-info .pn-niv { background: #e8eef7; color: #2f4a75; }
.pn-accesos { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.pn-accesos a { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .6rem .3rem; border: 1px solid #dfe3ea; border-radius: .5rem; text-decoration: none;
  color: #1d2b45; font-size: .82rem; text-align: center; line-height: 1.15; transition: background .12s, border-color .12s; }
.pn-accesos a i { font-size: 1.35rem; color: var(--sis-azul); }
.pn-accesos a:hover, .pn-accesos a:focus-visible { background: #eef3fb; border-color: var(--sis-azul); }
/* Matrícula: una fila por grado; al pulsarla se abren sus secciones */
.pn-fila { display: grid; grid-template-columns: minmax(8.5rem, 13rem) 1fr 2.6rem 6.5rem; align-items: center; gap: .6rem; width: 100%; padding: .32rem .4rem; border: 0;
  background: none; text-align: left; color: inherit; text-decoration: none; border-radius: .35rem; font-variant-numeric: tabular-nums; }
.pn-fila[hidden] { display: none; }
.pn-grado { font-weight: 600; cursor: pointer; }
.pn-grado:hover:not(:disabled), .pn-seccion:hover { background: #f1f4f9; color: inherit; }
.pn-grado:disabled { cursor: default; }
.pn-grado small { font-weight: 400; }
.pn-seccion { font-size: .88rem; }
.pn-seccion .pn-et { padding-left: 1.6rem; }
.pn-seccion .viz-track { height: 8px; }
.pn-chev { display: inline-block; transition: transform .15s; font-size: .8rem; }
.pn-grado[aria-expanded="true"] .pn-chev { transform: rotate(90deg); }
.pn-grado:disabled .pn-chev { visibility: hidden; }
.pn-stack { display: flex; height: 100%; min-width: 4px; transition: width .5s ease-out; }
.pn-stack .viz-seg:last-child { border-radius: 0 4px 4px 0; }
.pn-n { text-align: right; font-weight: 700; }
.pn-fm { font-size: .78rem; color: #5b6472; white-space: nowrap; }
.pn-pct { min-width: 2.9rem; text-align: right; font-variant-numeric: tabular-nums; }
.viz-bar.pn-ok { background: var(--good); }
/* Períodos: completo (con marca), a medias (borde) o sin notas (gris). El estado no depende solo del color */
.pn-per { display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.4rem; margin-right: 2px; font-size: .7rem; font-weight: 700; border-radius: 4px;
  background: #eef0f3; color: #6b7280; border: 1px solid transparent; }
.pn-per-parte { background: #fff; color: #1d4f91; border-color: #2a78d6; }
.pn-per-ok { background: #0b7a0b; color: #fff; }
@media (max-width: 575px) {
  .pn-fila { grid-template-columns: 1fr 2.6rem; row-gap: .15rem; }
  .pn-fila .viz-track { grid-column: 1 / -1; grid-row: 2; }
  .pn-fila .pn-fm { display: none; }
  .pn-kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .pn-kpi .v { font-size: 1.5rem; }
}

/* ---------- Estudiantes en riesgo ---------- */
.rz-kpi { border-top: 3px solid #c9ced8; }
.rz-kpi .rz-v { font-size: 2rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rz-kpi.rz-alto { border-top-color: #d03b3b; } .rz-kpi.rz-alto .bi { color: #b02a2a; }
.rz-kpi.rz-medio { border-top-color: #fab219; } .rz-kpi.rz-medio .bi { color: #a26a00; }
.rz-b-alto { background: #b02a2a; color: #fff; } .rz-b-medio { background: #ffe08a; color: #4d3500; }
.rz-asig { display: inline-block; border: 1px solid #d5dae3; border-radius: .35rem; padding: 1px 7px; margin: 0 4px 4px 0; font-size: .82rem; background: #fff; font-variant-numeric: tabular-nums; }
.rz-asig.rz-rep { border-color: #d03b3b; background: #fdf1f1; }
details.card > summary { cursor: pointer; list-style-position: inside; }
