/* Colores tomados del escudo de la E.E.T. N° 3117 */
:root {
  --azul: #1b3a94;
  --azul-osc: #11265f;
  --azul-claro: #e8edfa;
  --rojo: #e2232a;
  --rojo-claro: #fde8e8;
  --amarillo: #f5e01c;
  --amarillo-osc: #b89f00;
  --tinta: #141821;
  --muted: #5d6576;
  --fondo: #f3f5fa;
  --panel: #ffffff;
  --borde: #dde2ec;
  --verde: #1f8a4c;
  --verde-claro: #e3f4ea;
  --naranja: #c77700;
  --naranja-claro: #fdf1dc;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(17, 38, 95, .06), 0 6px 20px rgba(17, 38, 95, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--fondo); }
[hidden] { display: none !important; }
a { color: var(--azul); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 17px; margin-bottom: 14px; }

.ic { width: 18px; height: 18px; flex: none; }

/* ---------- Botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--borde); background: var(--panel); color: var(--tinta);
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--rojo); border-color: #f3c3c5; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }

input, select, textarea {
  font: inherit; color: var(--tinta); width: 100%;
  padding: 9px 12px; border: 1px solid var(--borde); border-radius: 10px; background: #fff;
}
textarea { resize: vertical; min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: var(--azul); }
.campo { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--tinta); cursor: pointer; }
.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .ancho { grid-column: 1 / -1; }
.form-error { color: var(--rojo); font-size: 14px; margin: 0; min-height: 1em; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 16px;
  background:
    radial-gradient(circle at 15% 20%, rgba(245, 224, 28, .18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(226, 35, 42, .22), transparent 45%),
    linear-gradient(160deg, var(--azul-osc), var(--azul));
}
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border-radius: 22px;
  padding: 34px 30px 28px; text-align: center;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .3);
  border-top: 6px solid var(--rojo);
}
.login-logo { width: 116px; height: 116px; object-fit: contain; margin-top: -4px; }
.login-card h1 { font-size: 24px; margin-top: 10px; color: var(--azul-osc); }
.login-sub { margin: 6px 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.login-card form { display: grid; gap: 14px; text-align: left; }
.login-card .nota { font-size: 13px; color: var(--muted); margin: -8px 0 4px; text-align: left; }
.franja { display: flex; height: 6px; width: 100%; max-width: 400px; margin-top: 18px; border-radius: 99px; overflow: hidden; }
.franja span { flex: 1; }
.franja span:nth-child(1) { background: var(--rojo); }
.franja span:nth-child(2) { background: var(--amarillo); }
.franja span:nth-child(3) { background: #fff; }

/* ---------- Estructura ---------- */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--azul-osc) 0%, var(--azul) 100%);
  color: #fff; border-top: 5px solid var(--rojo); z-index: 50;
}
.marca { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; color: #fff; text-decoration: none; }
.marca img { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3)); }
.marca strong { display: block; font-size: 16px; }
.marca small { display: block; font-size: 12px; opacity: .75; margin-top: 2px; }
.sidebar nav { display: grid; gap: 2px; padding: 8px 10px; flex: 1; overflow-y: auto; align-content: start; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: rgba(255, 255, 255, .82); text-decoration: none; font-weight: 500; position: relative;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar nav a.activo { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; }
.sidebar nav a.activo::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--amarillo);
}
.usuario { display: flex; align-items: center; gap: 10px; padding: 14px 14px; margin: 0 10px; border-top: 1px solid rgba(255, 255, 255, .15); }
.usuario > div:nth-child(2) { flex: 1; min-width: 0; }
.usuario strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario small { font-size: 12px; opacity: .7; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--amarillo); color: var(--azul-osc); font-weight: 800; font-size: 13px;
}
.avatar.grande { width: 72px; height: 72px; font-size: 24px; background: var(--azul); color: #fff; }

.contenido { min-width: 0; }
.topbar-movil { display: none; }
main#vista { padding: 28px 32px 48px; max-width: 1240px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.volver { display: inline-block; margin-bottom: 14px; text-decoration: none; font-weight: 600; }

.card { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio); padding: 20px; box-shadow: var(--sombra); }
.card + .card, .grid-2 + .card, .card + .grid-2 { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.cargando, .vacio { color: var(--muted); padding: 24px 4px; text-align: center; }
.aviso { padding: 14px 16px; border-radius: 12px; background: var(--azul-claro); color: var(--azul-osc); }
.aviso.error { background: var(--rojo-claro); color: #8c1116; }

/* ---------- Inicio ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px 20px; box-shadow: var(--sombra); border-top: 4px solid var(--azul);
}
.kpi:hover { border-color: #c4cde3; }
.kpi.rojo { border-top-color: var(--rojo); }
.kpi.amarillo { border-top-color: var(--amarillo); }
.kpi.verde { border-top-color: var(--verde); }
.kpi span { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi strong { display: block; font-size: 34px; margin-top: 6px; color: var(--azul-osc); }
.kpi small { color: var(--muted); }
.pasos { margin: 0; padding-left: 20px; line-height: 1.9; }

/* ---------- Tablas ---------- */
.tabla-wrap { padding: 0; overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; }
.tabla th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 16px; background: #f7f9fd; border-bottom: 1px solid var(--borde);
}
.tabla td { padding: 12px 16px; border-bottom: 1px solid #eef1f6; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover { background: #fafbfe; }
.tabla td.num, .tabla th.num { text-align: center; width: 1%; white-space: nowrap; }
.tabla a { font-weight: 600; text-decoration: none; }
.tabla .inactivo { opacity: .55; }
.card .tabla th { background: transparent; }
.card:not(.tabla-wrap) .tabla td, .card:not(.tabla-wrap) .tabla th { padding-left: 0; }

.filtros { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; padding: 14px 16px; }
.filtros > * { flex: 1 1 180px; }
.filtros .check { flex: 0 0 auto; padding-bottom: 10px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: var(--azul-claro); color: var(--azul);
}
.badge.rojo { background: var(--rojo-claro); color: #b3141a; }
.badge.verde { background: var(--verde-claro); color: var(--verde); }
.badge.naranja { background: var(--naranja-claro); color: var(--naranja); }
.badge.gris { background: #eceff4; color: var(--muted); }
.badge.amarillo { background: #fdf8cf; color: #7a6900; }

/* ---------- Cursos ---------- */
.cursos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.curso-card {
  display: flex; gap: 16px; align-items: center; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 18px; box-shadow: var(--sombra); transition: transform .12s, border-color .12s;
}
.curso-card:hover { transform: translateY(-2px); border-color: var(--azul); }
.curso-num {
  width: 64px; height: 64px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: var(--azul); color: #fff; font-size: 24px; font-weight: 800; line-height: 1;
  box-shadow: inset 0 -5px 0 var(--rojo);
}
.curso-num span { font-size: 14px; font-weight: 700; color: var(--amarillo); }
.curso-card strong { display: block; font-size: 16px; }
.curso-card small { display: block; color: var(--muted); margin-top: 3px; }

/* ---------- Ficha del alumno ---------- */
.ficha-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; border-top: 4px solid var(--azul); }
.ficha-datos { flex: 1; min-width: 240px; }
.ficha-datos > p { margin: 6px 0 14px; color: var(--muted); }
.datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 20px; margin: 0; }
.datos dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.datos dd { margin: 2px 0 0; }
.asis-pct { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.asis-pct strong { font-size: 40px; color: var(--azul-osc); }
.barra { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #eceff4; margin-bottom: 12px; }
.barra span { height: 100%; }
.leyenda-asis { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.leyenda-asis i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.c-P { background: var(--verde); }
.c-A { background: var(--rojo); }
.c-T { background: var(--naranja); }
.c-J { background: var(--azul); }
.nota-baja { color: var(--rojo); font-weight: 700; }
.nota-ok { font-weight: 700; }

/* ---------- Observaciones ---------- */
.obs-lista { display: grid; gap: 12px; }
.obs { border: 1px solid var(--borde); border-left: 4px solid var(--azul); border-radius: 12px; padding: 12px 14px; background: #fff; }
.obs.t-conducta { border-left-color: var(--rojo); }
.obs.t-reconocimiento { border-left-color: var(--verde); }
.obs.t-comunicacion-con-la-familia { border-left-color: var(--amarillo); }
.obs.t-salud { border-left-color: var(--naranja); }
.obs-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.obs-head a { font-weight: 700; text-decoration: none; }
.obs-head time { margin-left: auto; color: var(--muted); font-size: 13px; }
.obs p { margin: 8px 0 6px; white-space: pre-wrap; line-height: 1.5; }
.obs footer { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }

/* ---------- Asistencia ---------- */
.barra-acciones { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.barra-acciones .spacer { flex: 1; }
.resumen-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.asis-lista { list-style: none; margin: 0; padding: 0; }
.asis-lista li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #eef1f6; }
.asis-lista li:last-child { border-bottom: 0; }
.asis-lista .n { width: 26px; color: var(--muted); font-size: 13px; text-align: right; }
.asis-lista .nom { flex: 1; font-weight: 600; min-width: 0; }
.asis-lista .nom small { display: block; font-weight: 400; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg button {
  width: 40px; height: 36px; border-radius: 9px; border: 1px solid var(--borde); background: #fff;
  font: inherit; font-weight: 800; color: var(--muted); cursor: pointer;
}
.seg button:hover { border-color: #b9c3da; }
.seg button.on { color: #fff; border-color: transparent; }
.seg button.on.e-P { background: var(--verde); }
.seg button.on.e-A { background: var(--rojo); }
.seg button.on.e-T { background: var(--naranja); }
.seg button.on.e-J { background: var(--azul); }
.leyenda { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.sin-guardar { color: var(--naranja); font-weight: 700; font-size: 13px; }

/* ---------- Calificaciones ---------- */
.nota-input { width: 90px; text-align: center; font-weight: 700; }
.nota-input.baja { color: var(--rojo); border-color: #f3b6b8; background: #fff7f7; }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgba(17, 24, 39, .5); animation: aparecer .12s ease-out;
}
.modal {
  width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border-radius: 18px; box-shadow: 0 30px 70px rgba(0, 0, 0, .3);
}
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal > header h2 { margin: 0; font-size: 19px; }
.modal .x { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px 22px 6px; }
.modal-body p { line-height: 1.5; }
.modal .form-error { padding: 0 22px; }
.modal > footer { display: flex; gap: 10px; padding: 14px 22px 20px; flex-wrap: wrap; }
.modal > footer .spacer { flex: 1; }
.clave-temporal {
  font-family: ui-monospace, Consolas, monospace; font-size: 24px; font-weight: 700; letter-spacing: .08em;
  text-align: center; padding: 14px; border-radius: 12px; background: #fdf8cf; border: 1px dashed var(--amarillo-osc); user-select: all;
}
@keyframes aparecer { from { opacity: 0; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 2000; max-width: 360px;
  padding: 12px 18px; border-radius: 12px; color: #fff; font-weight: 600;
  background: var(--verde); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); animation: aparecer .15s;
}
.toast.error { background: var(--rojo); }

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 270px; height: auto;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.menu-abierto .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .topbar-movil {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40;
    padding: 10px 14px; background: var(--azul-osc); color: #fff; border-top: 4px solid var(--rojo);
  }
  .topbar-movil img { width: 32px; height: 32px; object-fit: contain; }
  main#vista { padding: 20px 16px 40px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  .seg button { width: 36px; }
}
