/* ColegioERP — hoja de estilos única. Tokens de color en :root, modo oscuro abajo. */
:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f0efec;
  --border: #e4e3dd;
  --border-strong: #cfcec6;
  --text: #121211;
  --text-2: #52514e;
  --muted: #6b6a63;
  --accent: #1f6fd1;
  --accent-hover: #1a5bab;
  --accent-fill: #1f6fd1;
  --accent-fill-hover: #1a5bab;
  --bad-fill: #b42323;
  --good-fill: #0f6e0f;
  --accent-soft: #e6f0fc;
  --accent-text: #ffffff;
  --good: #0f6e0f;
  --good-soft: #e3f3e3;
  --warn: #7f5300;
  --warn-soft: #fff1cc;
  --bad: #b42323;
  --bad-soft: #fbe7e7;
  --info: #1c5cab;
  --info-soft: #e6f0fc;
  --neutral-soft: #ecebe6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --shadow: 0 1px 2px rgba(16, 16, 15, .05), 0 1px 3px rgba(16, 16, 15, .04);
  --shadow-lg: 0 12px 32px rgba(16, 16, 15, .16), 0 2px 6px rgba(16, 16, 15, .06);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 248px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0e;
    --surface: #1a1a19;
    --surface-2: #202020;
    --surface-3: #2a2a28;
    --border: #2f2f2c;
    --border-strong: #45453f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #3987e5;
    --accent-hover: #6da7ec;
    --accent-soft: #16263a;
    --good: #4cc24c;
    --good-soft: #132a13;
    --warn: #f0b429;
    --warn-soft: #2d2410;
    --bad: #f28b8b;
    --bad-soft: #3a1818;
    --info: #86b6ef;
    --info-soft: #16263a;
    --neutral-soft: #2a2a28;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
    --axis: #45453f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0e;
  --surface: #1a1a19;
  --surface-2: #202020;
  --surface-3: #2a2a28;
  --border: #2f2f2c;
  --border-strong: #45453f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a998f;
  --accent: #5b9cec;
  --accent-hover: #8bb9f2;
  --accent-soft: #16263a;
  --accent-fill: #2b6fc4;
  --accent-fill-hover: #245fa8;
  --bad-fill: #c03232;
  --good-fill: #1f7a1f;
  --good: #4cc24c;
  --good-soft: #132a13;
  --warn: #f0b429;
  --warn-soft: #2d2410;
  --bad: #f28b8b;
  --bad-soft: #3a1818;
  --info: #86b6ef;
  --info-soft: #16263a;
  --neutral-soft: #2a2a28;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #2c2c2a;
  --axis: #45453f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* Colores por área del horario: paleta categórica validada (orden fijo; del 9.º en adelante, gris). */
:root {
  --area-0: #8a8983; --area-1: #2a78d6; --area-2: #eb6834; --area-3: #1baf7a; --area-4: #eda100;
  --area-5: #e87ba4; --area-6: #008300; --area-7: #6250d6; --area-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --area-0: #77766f; --area-1: #3987e5; --area-2: #d95926; --area-3: #199e70; --area-4: #c98500;
    --area-5: #d55181; --area-6: #008300; --area-7: #9085e9; --area-8: #e66767;
  }
}
:root[data-theme="dark"] {
  --area-0: #77766f; --area-1: #3987e5; --area-2: #d95926; --area-3: #199e70; --area-4: #c98500;
  --area-5: #d55181; --area-6: #008300; --area-7: #9085e9; --area-8: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Carga ---------- */
.cargando-app { display: grid; place-items: center; min-height: 100vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.cargando { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 32px; justify-content: center; }
.cargando .spinner { width: 20px; height: 20px; border-width: 2px; }

/* ---------- Ingreso ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg);
}
.login-caja { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; }
.login-caja .marca { margin-bottom: 20px; }
.login-caja h1 { font-size: 18px; margin-bottom: 4px; }
.login-caja .campo { margin-bottom: 14px; }
.login-caja .btn { width: 100%; justify-content: center; height: 40px; }
.login-pie { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface-2);
  border-right: 1px solid var(--border); padding: 14px 10px 24px; display: flex; flex-direction: column; gap: 4px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.marca img { width: 30px; height: 30px; }
.marca b { display: block; font-size: 14px; }
.marca span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.nav-grupo { margin-top: 10px; }
.nav-grupo > span { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 10px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2);
  font-weight: 500; text-decoration: none;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.activo { background: var(--accent-soft); color: var(--accent); }
.nav a .contador { margin-left: auto; font-size: 11px; background: #c62828; color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 700; min-width: 20px; text-align: center; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 56px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar .titulo { min-width: 0; }
.topbar .titulo h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .titulo small { display: block; font-size: 12px; }
.topbar .derecha { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar .menu-btn { display: none; }
.usuario-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.usuario-chip .nombre { font-weight: 600; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario-chip .rol { font-size: 11px; color: var(--muted); }
.aviso-servidor { display: flex; align-items: flex-start; gap: 10px; padding: 10px 24px; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); font-size: 13.5px; }
.aviso-servidor[hidden] { display: none; }
.aviso-servidor svg { margin-top: 1px; }
.contenido { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.contenido:focus { outline: none; }
.fondo-menu { display: none; }

/* ---------- Menú desplegable ---------- */
.desplegable { position: relative; }
.desplegable-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.desplegable-menu button, .desplegable-menu a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; color: var(--text);
  font: inherit; border-radius: var(--radius-sm); cursor: pointer; text-align: left; text-decoration: none;
}
.desplegable-menu button:hover, .desplegable-menu a:hover { background: var(--surface-3); }
.desplegable-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .nav a:focus-visible { outline: none; box-shadow: var(--focus); }
.btn.primario { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-text); }
.btn.primario:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
.btn.peligro { color: var(--bad); }
.btn.peligro:hover { background: var(--bad-soft); }
.btn.peligro-lleno { background: var(--bad-fill); border-color: var(--bad-fill); color: #fff; }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: var(--surface-3); }
.btn.chico { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icono { width: 34px; padding: 0; justify-content: center; }
.btn[disabled], .btn[disabled]:hover { cursor: not-allowed; background: var(--surface-3); border-color: var(--border); color: var(--muted); }
.grupo-btn { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  height: 34px; padding: 0 10px; width: 100%; min-width: 0;
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[readonly] { background: var(--surface-2); }
.campo label, .campo > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.campo .req { color: var(--bad); }
.campo .ayuda { font-size: 12px; color: var(--muted); margin-top: 3px; }
.campo.check label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); margin: 0; height: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .ancho { grid-column: 1 / -1; }
.error-form { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 12px; font-weight: 500; }

/* ---------- Tarjetas y paneles ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-cab { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-cab h2 { font-size: 15px; }
.card-cab .derecha { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-cuerpo { padding: 16px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > .card { margin-top: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.barra-acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.barra-acciones .derecha { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KPI ---------- */
.kpi { padding: 16px; }
.kpi .etq { font-size: 12.5px; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .valor { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .det { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.alerta .valor { color: var(--bad); }

/* ---------- Tablas ---------- */
.tabla-envoltura { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tabla th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.tabla th.num { text-align: right; }
.tabla th.centro { text-align: center; }
.tabla td.nowrap, .tabla th.nowrap { white-space: nowrap; }
.vacio-celda { color: var(--muted); }
.tabla td.acciones .btn.peligro { color: var(--muted); }
.tabla td.acciones .btn.peligro:hover { color: var(--bad); background: var(--bad-soft); }
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr.clic { cursor: pointer; }
.tabla tbody tr.clic:hover td, .tabla tbody tr:hover td { background: var(--surface-2); }
.tabla td.acciones { text-align: right; white-space: nowrap; width: 1%; }
.tabla tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.tabla .vacio { text-align: center; color: var(--muted); padding: 32px 12px; }
.tabla td.texto-largo { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paginacion { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.paginacion .derecha { margin-left: auto; display: flex; gap: 6px; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filtros .buscar { position: relative; flex: 1 1 220px; max-width: 340px; }
.filtros .buscar svg { position: absolute; left: 9px; top: 8px; color: var(--muted); width: 17px; height: 17px; }
.filtros .buscar input { padding-left: 32px; }
.filtros select, .filtros input[type="date"] { width: auto; max-width: 240px; }
.filtros .rango { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }

/* ---------- Insignias ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--neutral-soft); color: var(--text-2); }
.badge.bien { background: var(--good-soft); color: var(--good); }
.badge.aviso { background: var(--warn-soft); color: var(--warn); }
.badge.mal { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge .punto { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 550; color: var(--text-2); padding: 11px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.activo { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Modal ---------- */
.modal-fondo { position: fixed; inset: 0; background: rgba(10, 10, 9, .45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: aparecer .12s ease-out; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.chico { max-width: 440px; }
.modal.grande { max-width: 900px; }
.modal-cab { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-cab h2 { font-size: 16px; }
.modal-cab .btn { margin-left: auto; }
.modal-cuerpo { padding: 18px; overflow-y: auto; }
.modal-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes aparecer { from { opacity: 0; } }

/* ---------- Avisos ---------- */
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-weight: 500; max-width: 420px; animation: subir .16s ease-out; }
.toast.error { background: var(--bad-fill); color: #fff; }
.toast.bien { background: var(--good-fill); color: #fff; }
@keyframes subir { from { transform: translateY(8px); opacity: 0; } }
.aviso-caja { border-radius: var(--radius-sm); padding: 10px 12px; background: var(--info-soft); color: var(--info); font-weight: 500; margin-bottom: 12px; }
.aviso-caja.aviso { background: var(--warn-soft); color: var(--warn); }
.aviso-caja.mal { background: var(--bad-soft); color: var(--bad); }
.aviso-caja.bien { background: var(--good-soft); color: var(--good); }

/* ---------- Gráficos ---------- */
.grafico { position: relative; }
.grafico svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafico .grid-line { stroke: var(--grid); stroke-width: 1; }
.grafico .base-line { stroke: var(--axis); stroke-width: 1; }
.grafico text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.grafico .hit { fill: transparent; cursor: default; }
.grafico .hit:hover + .marca-hover, .grafico g.col:hover rect.barra { opacity: .85; }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
#tooltip { position: fixed; z-index: 300; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12.5px; min-width: 120px; }
#tooltip b { display: block; margin-bottom: 2px; }
#tooltip .fila { display: flex; align-items: center; gap: 6px; }
#tooltip .fila i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
#tooltip .fila span:last-child { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 600; }
.ver-tabla { margin-top: 8px; font-size: 12.5px; }
.ver-tabla summary { cursor: pointer; color: var(--accent); }

/* ---------- Listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.lista li:last-child { border-bottom: 0; }
.lista .fecha-chip { flex: none; width: 44px; text-align: center; border-radius: var(--radius-sm); background: var(--surface-3); padding: 4px 0; line-height: 1.1; }
.lista .fecha-chip b { display: block; font-size: 16px; }
.lista .fecha-chip small { font-size: 10.5px; text-transform: uppercase; }
.lista .txt { min-width: 0; flex: 1; }
.lista .txt b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.lista .txt small { display: block; }
.vacio-bloque { text-align: center; padding: 36px 16px; color: var(--muted); }
.vacio-bloque svg { width: 32px; height: 32px; margin-bottom: 8px; color: var(--border-strong); }

/* ---------- Ficha ---------- */
.ficha-cab { display: flex; align-items: center; gap: 16px; padding: 18px; flex-wrap: wrap; }
.ficha-cab .avatar { width: 52px; height: 52px; font-size: 18px; }
.ficha-cab h1 { font-size: 20px; }
.ficha-cab .meta { display: flex; gap: 8px 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; margin-top: 4px; }
.ficha-cab .derecha { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 20px; }
.datos div span { display: block; font-size: 12px; color: var(--muted); font-weight: 550; }
.datos div b { font-weight: 500; word-break: break-word; }

/* ---------- Asistencia ---------- */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.seg button:first-child { border-radius: calc(var(--radius-sm) - 1px) 0 0 calc(var(--radius-sm) - 1px); }
.seg button:last-child { border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0; }
.seg button:focus-visible { outline: none; box-shadow: var(--focus); position: relative; z-index: 1; }
.seg button { border: 0; border-right: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-weight: 650; width: 38px; height: 32px; cursor: pointer; color: var(--text-2); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-3); }
.seg button.on[data-v="P"] { background: var(--good-soft); color: var(--good); }
.seg button.on[data-v="T"] { background: var(--warn-soft); color: var(--warn); }
.seg button.on[data-v="F"] { background: var(--bad-soft); color: var(--bad); }
.seg button.on[data-v="J"] { background: var(--info-soft); color: var(--info); }
.conteo-asis { display: flex; gap: 8px; flex-wrap: wrap; }
.barra-fija { position: sticky; top: 57px; z-index: 6; background: var(--surface); padding: 10px 16px; margin: 0; border-bottom: 1px solid var(--border); }

/* ---------- Notas ---------- */
.celda-nota { width: 76px; text-align: center; font-weight: 650; padding: 0 4px; }
.celda-nota.AD { color: var(--good); }
.celda-nota.C, .celda-nota.baja { color: var(--bad); }
.nota-final { font-weight: 700; text-align: center; }
.nota-final.baja { color: var(--bad); }
.tabla td.centro, .tabla th.centro { text-align: center; }

/* ---------- Horario ---------- */
.horario { display: grid; grid-template-columns: 86px repeat(5, minmax(120px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 720px; }
.horario > div { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-height: 54px; padding: 4px; }
.horario .h-cab { background: var(--surface-2); font-weight: 600; font-size: 12.5px; text-align: center; min-height: 0; padding: 8px 4px; }
.horario .h-hora { background: var(--surface-2); font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; font-variant-numeric: tabular-nums; }
.horario .h-recreo { grid-column: 1 / -1; min-height: 0; text-align: center; font-size: 12px; color: var(--muted); background: var(--surface-3); padding: 4px; }
.bloque { border-radius: 7px; padding: 6px 8px; height: 100%; font-size: 12.5px; line-height: 1.3; background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); cursor: default; }
.bloque b { display: block; font-weight: 650; }
.bloque small { display: block; color: var(--text-2); }
.bloque.editable { cursor: pointer; }
.h-libre.editable { cursor: pointer; }
.h-libre.editable:hover { background: var(--surface-2); }
.h-libre.editable:hover::after { content: '+ Agregar'; display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 12px; }

/* ---------- Horario semanal ---------- */
.seg.seg-texto button { width: auto; padding: 0 14px; font-weight: 600; }
.seg.seg-texto button.on { background: var(--accent-soft); color: var(--accent); }
.confirmar-texto p { margin: 0 0 8px; }
.hz-imprimir { display: none; }
.hz-cab { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 16px 0; }
.hz-cab h2 { font-size: 17px; }
.hz-total { margin-left: auto; min-width: 230px; font-size: 13px; color: var(--text-2); }
.hz-panel .hz-total { margin: 4px 0 8px; }
.hz-total b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.hz-barra { height: 6px; border-radius: 999px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.hz-barra i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.hz-fuera, .hz-modo { margin: 12px 16px 0; }
.hz-fuera ul { margin: 6px 0 0; padding-left: 18px; font-weight: 500; }
.hz-fuera li { margin: 4px 0; }
.hz-modo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hz-modo .btn { margin-left: auto; }
.hz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 16px; padding: 16px; align-items: start; }
.hz-envoltura { min-width: 0; overflow-x: auto; }
.hz-grid { display: grid; gap: 4px; min-width: 560px; }
.hz-esquina, .hz-dia { font-size: 12.5px; font-weight: 650; color: var(--text-2); text-align: center; padding: 6px 4px; }
.hz-hora { display: flex; flex-direction: column; justify-content: center; align-items: flex-end; padding-right: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hz-hora b { font-weight: 600; color: var(--text-2); font-size: 12px; }
.hz-recreo { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); border-radius: 6px;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--surface-3) 6px 12px); }
.hz-celda { border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--border); min-height: 64px; transition: background .12s, border-color .12s, opacity .12s; }
.hz-celda.editable { cursor: pointer; }
.hz-celda.editable:hover { border-color: var(--border-strong); background: var(--surface-3); }
.hz-celda.editable:hover::after { content: '+'; display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 20px; }
.hz-grid.colocando .hz-celda { opacity: .5; }
.hz-celda.disponible { opacity: 1 !important; background: var(--good-soft); border-color: var(--good); }
.hz-celda.bloqueada { opacity: 1 !important; cursor: not-allowed; border-color: color-mix(in srgb, var(--bad) 45%, transparent);
  background: repeating-linear-gradient(135deg, var(--bad-soft) 0 6px, transparent 6px 12px); }
.hz-celda.bloqueada:hover::after { content: none; }
.hz-celda.soltar-si { background: var(--good-soft); border: 2px solid var(--good); }
.hz-celda.soltar-no { background: var(--bad-soft); border: 2px solid var(--bad); }
.hz-grid.arrastrando .hz-clase { pointer-events: none; }
.hz-clase { --c: var(--area-0); position: relative; z-index: 1; min-width: 0; border-radius: 8px; padding: 7px 9px 7px 10px; display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 32%, transparent); border-left: 4px solid var(--c);
  transition: box-shadow .12s, transform .12s; }
.hz-clase b { font-size: 13px; font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hz-clase small { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-clase .hz-meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.hz-clase.larga { justify-content: center; }
.hz-clase.clic { cursor: pointer; }
.hz-clase.clic:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.hz-clase[draggable="true"] { cursor: grab; }
.hz-clase.fantasma { opacity: .35; }
.hz-panel { position: sticky; top: 72px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.hz-panel h3 { margin-bottom: 4px; }
.hz-panel > p { font-size: 12.5px; }
.hz-areas { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.hz-area { --c: var(--area-0); display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; border: 1px solid transparent; }
.hz-area.clic { cursor: pointer; }
.hz-area.clic:hover { background: var(--surface-2); }
.hz-area.elegida { background: color-mix(in srgb, var(--c) 12%, var(--surface)); border-color: var(--c); }
.hz-area:focus-visible { outline: none; box-shadow: var(--focus); }
.hz-punto { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.hz-area-txt { min-width: 0; flex: 1; }
.hz-area-txt b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-area-txt small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hz-cuenta { display: inline-flex; align-items: center; gap: 3px; flex: none; font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.hz-cuenta svg { width: 13px; height: 13px; }
.hz-cuenta.ok { background: var(--good-soft); color: var(--good); }
.hz-cuenta.falta { background: var(--warn-soft); color: var(--warn); }
.hz-cuenta.mas { background: var(--bad-soft); color: var(--bad); }
.hz-nota { font-size: 12.5px; color: var(--warn); }
.hz-acciones { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.hz-acciones .btn { justify-content: center; }
.hz-estado { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 500; font-size: 13px; }
.hz-estado.bien { background: var(--good-soft); color: var(--good); }
.hz-estado.mal { background: var(--bad-soft); color: var(--bad); }
.hz-agenda { display: none; }
.hz-agenda section + section { margin-top: 16px; }
.hz-agenda h3 { margin-bottom: 6px; }
.hz-item { --c: var(--area-0); display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; cursor: pointer;
  border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); }
.hz-item-hora { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; min-width: 40px; }
.hz-item b { display: block; font-size: 13.5px; }
.hz-item small { display: block; color: var(--text-2); font-size: 12px; }
@media (max-width: 1280px) { .hz-layout { grid-template-columns: 1fr; } .hz-panel { position: static; } }
@media (max-width: 760px) { .hz-grid { display: none; } .hz-agenda { display: block; } .hz-total { margin-left: 0; width: 100%; } }
@page horario { size: A4 landscape; margin: 10mm; }
@media print {
  .hz { border: 0; page: horario; }
  .hz-imprimir { display: block; margin-bottom: 10px; color: #111; }
  .hz-imprimir h2 { font-size: 16px; margin: 2px 0; }
  .hz-layout { display: block; padding: 0; }
  .hz-envoltura { overflow: visible; }
  .hz-grid { display: grid !important; min-width: 0; }
  .hz-agenda { display: none !important; }
  .hz-celda { background: none; border: 1px solid #ddd; min-height: 44px; }
  .hz-celda::after { content: none !important; }
  .hz-clase, .hz-recreo { -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; box-shadow: none; }
}

/* ---------- Caja / recibo / libreta (impresión) ---------- */
.cuota-fila input[type="number"] { width: 110px; text-align: right; }
.total-caja { display: flex; align-items: baseline; justify-content: space-between; font-size: 15px; padding: 12px 0; border-top: 1px dashed var(--border-strong); margin-top: 8px; }
.total-caja b { font-size: 22px; }
.documento { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 36px 40px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13px; }
.documento h1 { font-size: 18px; }
.documento .doc-cab { display: flex; gap: 16px; align-items: flex-start; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 16px; }
.documento .doc-cab .derecha { margin-left: auto; text-align: right; }
.documento table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.documento th, .documento td { border: 1px solid #999; padding: 6px 8px; text-align: left; }
.documento th { background: #f0f0f0; font-size: 12px; }
.documento td.c, .documento th.c { text-align: center; }
.documento td.r, .documento th.r { text-align: right; }
.documento .firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; text-align: center; }
.documento .firmas div { border-top: 1px solid #111; padding-top: 6px; font-size: 12px; }
.documento .anulado-sello { color: #b42323; border: 3px solid #b42323; display: inline-block; padding: 4px 14px; font-weight: 800; font-size: 20px; transform: rotate(-6deg); margin: 8px 0; }
.documento .muted { color: #555; }
.salto { page-break-after: always; break-after: page; }
.libretas-lote .documento + .documento { margin-top: 24px; }

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-imprimir, #toasts, .fondo-menu { display: none !important; }
  .shell { display: block; }
  .contenido { padding: 0; max-width: none; }
  .documento { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .libretas-lote .documento + .documento { margin-top: 0; }
  .card { box-shadow: none; border-color: #bbb; }
  @page { margin: 14mm; }
}

/* ---------- Portal ---------- */
.hijo-cab { display: flex; gap: 12px; align-items: center; padding: 16px; flex-wrap: wrap; }
.hijo-cab .derecha { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.mini-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.mini-kpis div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.mini-kpis span { display: block; font-size: 12px; color: var(--muted); }
.mini-kpis b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Pantallas medianas y celular ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 60; transform: translateX(-100%); transition: transform .18s ease; box-shadow: none; visibility: hidden; }
  .shell.menu-abierto .sidebar { box-shadow: var(--shadow-lg); visibility: visible; }
  .shell.menu-abierto .sidebar { transform: none; }
  .shell.menu-abierto .fondo-menu { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .contenido { padding: 16px 16px 40px; }
  .usuario-chip .nombre, .usuario-chip .rol { display: none; }
  .usuario-chip { padding: 2px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .filtros .buscar { max-width: none; flex-basis: 100%; }
  .filtros select, .filtros input[type="date"] { flex: 1 1 140px; max-width: none; }
  .documento { padding: 20px 16px; }
  .ficha-cab .derecha { margin-left: 0; width: 100%; }
  .tabla.responsiva thead { display: none; }
  .tabla.responsiva tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 14px; border-bottom: 1px solid var(--border); padding: 10px 16px; }
  .tabla.responsiva td { display: block; border: 0; padding: 0; text-align: left; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
  .tabla.responsiva td::before { content: attr(data-etq); display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
  .tabla.responsiva td.col-principal { grid-column: 1 / -1; order: -1; font-size: 14px; font-weight: 600; }
  .tabla.responsiva td.col-principal::before { content: none; }
  .tabla.responsiva td.num { text-align: left; }
  .tabla.responsiva td.acciones { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; width: auto; }
  .tabla.responsiva td.acciones::before { content: none; }
  .tabla.responsiva td.texto-largo { max-width: none; white-space: normal; grid-column: 1 / -1; }
  .tabla.responsiva tbody tr:has(.vacio) { display: block; }
  .tabla.responsiva .vacio { display: block; text-align: center; }
  .tabla.responsiva .vacio::before { content: none; }
  .tabla-asis thead, .tabla-notas thead, .tabla-libreta thead { display: none; }
  .tabla-asis tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .tabla-asis td { border: 0; padding: 0; }
  .tabla-asis td:first-child { display: none; }
  .tabla-asis td:nth-child(4) { grid-column: 1 / -1; }
  .tabla-asis td:nth-child(4) input { height: 30px; font-size: 13px; }
  .tabla-asis .seg button { width: 36px; height: 34px; }
  .tabla-notas tbody tr, .tabla-libreta tbody tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .tabla-notas td, .tabla-libreta td { border: 0; padding: 0; text-align: center; }
  .tabla-notas td:first-child { display: none; }
  .tabla-notas td:nth-child(2), .tabla-libreta td:first-child { grid-column: 1 / -1; text-align: left; }
  .tabla-notas td::before, .tabla-libreta td::before { content: attr(data-etq); display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
  .tabla-notas td:nth-child(2)::before, .tabla-libreta td:first-child::before { content: none; }
  .tabla-notas .celda-nota { width: 100%; }
  .tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .valor { font-size: 20px; }
  .modal-fondo { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 14px 14px 0 0; }
  .barra-acciones .derecha { margin-left: 0; }
}

/* ---------- Piezas nuevas de la revisión ---------- */
.card-total { font-size: 13px; color: var(--muted); font-weight: 500; }
.texto-mal { color: var(--bad); }
.error-campo { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
[role="button"]:focus-visible, [role="link"]:focus-visible, tr.clic:focus-visible, .hz-celda:focus-visible, .hz-clase:focus-visible, .hz-item:focus-visible { outline: none; box-shadow: var(--focus); }
tr.clic:focus-visible td { background: var(--surface-2); }
.btn[aria-busy="true"] { cursor: progress; }

/* Buscador con resultados del servidor */
.buscador { position: relative; }
.buscador > input { width: 100%; }
.buscador-lista { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 264px; overflow-y: auto; }
.buscador-lista li { padding: 7px 10px; border-radius: 5px; cursor: pointer; font-size: 13.5px; line-height: 1.35; }
.buscador-lista li[aria-selected="true"], .buscador-lista li[data-i]:hover { background: var(--accent-soft); color: var(--text); }
.buscador-lista li.sin-resultados { color: var(--muted); cursor: default; }
.modal .buscador-lista { position: absolute; }

/* Etiquetas quitables (estudiantes que repiten) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 12.5px; font-weight: 500; }
.chip button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0; }
.chip button:hover { background: var(--surface); }
.chip button .ic { width: 13px; height: 13px; }

/* Notas y montos fuera de rango */
.celda-nota.invalida, input.invalida { border-color: var(--bad) !important; background: var(--bad-soft) !important; color: var(--bad); }

/* Inicio del docente */
.fecha-chip.hora b { font-size: 13px; }
.fecha-chip.hora small { text-transform: none; }
.lista li.actual { background: var(--accent-soft); }
.lista li.actual .fecha-chip { background: var(--surface); color: var(--accent); }
.chk-cuota { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-weight: inherit; margin: 0; }
.chk-cuota input { margin-top: 2px; flex: none; width: 16px; height: 16px; }
