:root {
  --azul: #2457D6;
  --azul-osc: #1A3FA3;
  --azul-claro: #E8EFFF;
  --lima: #D4F03C;
  --lima-osc: #9DB81C;
  --lima-claro: #F1F9CC;
  --tinta: #0E1B3D;
  --gris: #55627F;
  --borde: #D5DDEC;
  --fondo: #F3F6FB;
  --campo: #F8FAFE;
  --naranja: #FF8A3D;
  --naranja-claro: #FFE0CC;
  --naranja-texto: #7A3300;
  --verde-claro: #DDF5E4;
  --verde-texto: #1F6B3A;
  --ambar-claro: #FFEBC7;
  --ambar-texto: #8A4B00;
  --rojo: #B42318;
  --rojo-claro: #FFE9E4;
  --titulo: 'Bricolage Grotesque', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: #DCE3EF;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--tinta);
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--fondo);
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (min-width: 520px) {
  .app { box-shadow: 0 0 40px rgba(14, 27, 61, 0.12); }
}
button, input, select { font-family: inherit; font-size: 16px; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 3px solid var(--lima); outline-offset: 2px; }
h1, h2 { font-family: var(--titulo); font-weight: 800; margin: 0; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Login ---------- */
.login-hero {
  position: relative; height: 270px; flex-shrink: 0; background: var(--azul); overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 32px 28px; color: #fff;
}
.login-hero .pista { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-hero .bola {
  position: absolute; right: 34px; top: 34px; width: 84px; height: 84px; border-radius: 50%;
  background: var(--lima); box-shadow: 0 14px 30px rgba(14, 27, 61, 0.35);
}
.chip-hero {
  position: relative; align-self: flex-start; background: var(--lima); color: var(--tinta);
  font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 999px; margin-bottom: 14px;
}
.login-hero h1 { position: relative; font-size: 46px; line-height: 0.98; letter-spacing: -0.5px; }
.login-hero p { position: relative; margin: 12px 0 0; color: #DCE6FF; line-height: 1.4; }
.login-form {
  flex: 1; margin: -24px 16px 0; position: relative; background: #fff; border-radius: 28px 28px 0 0;
  padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 -6px 24px rgba(14, 27, 61, 0.08);
}
.login-form h2 { font-size: 26px; }
.nota { margin: 0; text-align: center; font-size: 14px; color: var(--gris); }

/* ---------- Formularios ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo > label, .leyenda { font-weight: 600; font-size: 14px; }
.campo input, .campo select {
  height: 52px; border-radius: 14px; border: 2px solid var(--borde); padding: 0 16px;
  background: var(--campo); width: 100%;
}
.campo input:focus, .campo select:focus { border-color: var(--azul); outline: none; }
.campo .ayuda { font-size: 13px; color: var(--gris); }
.select-envoltura { position: relative; }
.select-envoltura select { appearance: none; -webkit-appearance: none; padding-right: 44px; background: #fff; }
.select-envoltura svg { position: absolute; right: 16px; top: 16px; pointer-events: none; }
.check {
  display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; font-weight: 500;
}
.check input { width: 22px; height: 22px; accent-color: var(--azul); margin: 0; }
.check.caja { background: var(--fondo); border-radius: 14px; padding: 0 14px; min-height: 52px; font-size: 16px; font-weight: 600; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
legend { padding: 0; margin-bottom: 10px; }

.btn {
  height: 54px; border-radius: 16px; border: 0; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 18px;
}
.btn-oscuro { background: var(--tinta); color: #fff; }
.btn-borde { background: #fff; border: 2px solid var(--borde); color: var(--tinta); }
.btn-rojo { background: var(--rojo); color: #fff; }
.btn-grande { height: 56px; font-size: 17px; }
.fila-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.error {
  background: var(--naranja-claro); color: #5C2600; border-radius: 14px; padding: 12px 14px;
  font-size: 14px; line-height: 1.4; display: flex; gap: 10px; align-items: flex-start;
}
.error svg { flex-shrink: 0; margin-top: 1px; }

/* ---------- Cabeceras ---------- */
.cab {
  color: #fff; padding: 22px 20px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.cab-azul { background: var(--azul); padding-bottom: 72px; }
.cab-oscura { background: var(--tinta); }
.cab-persona { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cab-textos { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cab-textos small { font-size: 13px; color: #DCE6FF; }
.cab-textos strong { font-family: var(--titulo); font-weight: 800; font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-oscura .cab-textos strong { font-size: 26px; }
.avatar {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; background: var(--lima); color: var(--tinta);
  font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.cab-acciones { display: flex; gap: 8px; }
.icono-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(255, 255, 255, 0.14);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icono-btn.naranja { background: var(--naranja); }
.etiqueta-rol {
  align-self: flex-start; font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: var(--lima); color: var(--tinta);
}
.etiqueta-rol.admin { background: var(--naranja); }

/* ---------- Avisos ---------- */
.aviso {
  background: var(--naranja); color: var(--tinta); padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.aviso .aviso-icono {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; background: var(--tinta);
  display: flex; align-items: center; justify-content: center;
}
.aviso-textos { display: flex; flex-direction: column; gap: 2px; font-size: 14px; line-height: 1.35; }
.aviso-textos strong { font-size: 16px; }
.aviso.info { background: var(--lima); }

/* ---------- Alumno ---------- */
.contador {
  margin: -52px 16px 0; background: #fff; border-radius: 22px; padding: 18px;
  box-shadow: 0 8px 24px rgba(14, 27, 61, 0.10); display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.contador-textos { display: flex; flex-direction: column; gap: 4px; }
.contador-textos small { font-size: 13px; font-weight: 600; color: var(--gris); }
.contador-textos strong { font-family: var(--titulo); font-weight: 800; font-size: 28px; white-space: nowrap; }
@media (max-width: 380px) {
  .contador-textos strong { font-size: 24px; }
  .bolas { gap: 4px; }
  .bolita { width: 18px; height: 18px; }
}
.contador-textos .extra { font-size: 13px; color: var(--gris); }
.bolas { display: flex; gap: 6px; align-items: center; }
.bolita { width: 22px; height: 22px; border-radius: 50%; background: var(--fondo); border: 2px dashed #B7C2D8; }
.bolita.llena { background: var(--lima); border: 2px solid var(--lima-osc); }
.bolas .mas { font-weight: 800; color: var(--naranja-texto); font-size: 15px; margin-left: 2px; }

.botones-grandes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px 16px 0; }
.btn-tarjeta {
  height: 128px; border: 0; border-radius: 24px; display: flex; flex-direction: column; align-items: flex-start;
  justify-content: space-between; padding: 18px; text-align: left;
  font-family: var(--titulo); font-weight: 800; font-size: 22px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn-tarjeta:active:not(:disabled) { transform: translateY(6px); }
.btn-tarjeta .icono {
  width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
}
.btn-tarjeta small { font-family: Inter, system-ui, sans-serif; font-size: 13px; font-weight: 600; opacity: 0.85; }
.btn-tarjeta.azul { background: var(--azul); color: #fff; box-shadow: 0 8px 0 var(--azul-osc); }
.btn-tarjeta.azul .icono { background: rgba(255, 255, 255, 0.18); }
.btn-tarjeta.lima { background: var(--lima); color: var(--tinta); box-shadow: 0 8px 0 var(--lima-osc); }
.btn-tarjeta.lima .icono { background: rgba(14, 27, 61, 0.08); }
.btn-tarjeta.resaltar { outline: 3px solid var(--naranja); outline-offset: 3px; }
.btn-tarjeta.bajo { height: 92px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; font-size: 19px; line-height: 1.05; padding: 0 16px; }
.btn-tarjeta.bajo.azul { box-shadow: 0 6px 0 var(--azul-osc); }
.btn-tarjeta.bajo.lima { box-shadow: 0 6px 0 var(--lima-osc); }

/* ---------- Pestañas y listas ---------- */
.pestanas {
  margin: 22px 16px 0; background: #E3E9F4; border-radius: 16px; padding: 5px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
}
.pestana {
  height: 44px; border: 0; border-radius: 12px; font-weight: 700; font-size: 15px; background: transparent; color: var(--gris);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.pestana[aria-selected="true"] { background: #fff; color: var(--tinta); box-shadow: 0 2px 6px rgba(14, 27, 61, 0.12); }
.contador-pill {
  min-width: 22px; height: 22px; border-radius: 11px; background: var(--naranja); color: var(--tinta);
  font-size: 12px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.lista { padding: 14px 16px 32px; display: flex; flex-direction: column; gap: 10px; }
.fila { background: #fff; border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.fila-icono {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.fila-icono.azul { background: var(--azul-claro); color: var(--azul); }
.fila-icono.lima { background: var(--lima-claro); color: #4A5A08; }
.fila-icono.redondo { border-radius: 50%; }
.fila-textos { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fila-textos strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila-textos span { font-size: 13px; color: var(--gris); }
.pill { font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.pill.azul { color: var(--azul); background: var(--azul-claro); }
.pill.verde { color: var(--verde-texto); background: var(--verde-claro); }
.pill.ambar { color: var(--ambar-texto); background: var(--ambar-claro); }
.pill.naranja { color: var(--naranja-texto); background: var(--naranja-claro); }
.pill.lima { color: #4A5A08; background: var(--lima-claro); }
.btn-mini {
  height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--tinta); color: #fff;
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.btn-mini.borde { background: #fff; border: 2px solid var(--borde); color: var(--tinta); font-weight: 600; }
.btn-borrar {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; border: 0; background: var(--rojo-claro);
  display: flex; align-items: center; justify-content: center;
}
.vacio { text-align: center; color: var(--gris); font-size: 15px; margin: 28px 0; }

/* ---------- Profesor ---------- */
.filtro { margin: 22px 16px 0; }
.filtro + .pestanas { margin-top: 18px; }

/* ---------- Usuarios ---------- */
.tarjeta-usuario { background: #fff; border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.tarjeta-usuario .arriba { display: flex; align-items: center; gap: 12px; }
.tarjeta-usuario .abajo { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tarjeta-usuario .abajo .pill { font-size: 12px; padding: 4px 10px; }
.separador { flex: 1; }
.seccion-titulo { margin: 22px 16px 0; font-size: 13px; font-weight: 700; color: var(--gris); text-transform: uppercase; letter-spacing: 0.6px; }
.btn-ancho {
  width: 100%; height: 64px; border: 0; border-radius: 20px; background: var(--lima); color: var(--tinta);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--titulo); font-weight: 800; font-size: 20px; box-shadow: 0 6px 0 var(--lima-osc);
}

/* ---------- Hojas y diálogos ---------- */
.fondo-modal {
  position: fixed; inset: 0; background: rgba(14, 27, 61, 0.5); display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center; z-index: 10; animation: aparecer 0.15s ease-out;
}
.fondo-modal.centro { justify-content: center; padding: 24px; }
.hoja {
  width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; background: #fff; border-radius: 28px 28px 0 0;
  padding: 12px 20px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
  animation: subir 0.2s ease-out;
}
.hoja .asa { width: 44px; height: 5px; border-radius: 3px; background: var(--borde); align-self: center; }
.hoja .cabecera-hoja { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hoja h2 { font-size: 26px; }
.hoja p { margin: 0; color: var(--gris); font-size: 15px; line-height: 1.4; }
.dialogo {
  width: 100%; max-width: 400px; background: #fff; border-radius: 24px; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.dialogo h2 { font-size: 24px; }
.dialogo p { margin: 0; color: var(--gris); font-size: 15px; line-height: 1.4; }
.segmentado { background: #E3E9F4; border-radius: 16px; padding: 5px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.segmentado button { height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--gris); font-weight: 700; font-size: 15px; }
.segmentado button[aria-pressed="true"] { background: var(--lima); color: var(--tinta); box-shadow: 0 2px 6px rgba(14, 27, 61, 0.12); }
.icono-cerrar { width: 44px; height: 44px; border-radius: 14px; border: 0; background: var(--fondo); display: flex; align-items: center; justify-content: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 448px; background: var(--tinta); color: #fff; border-radius: 16px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 15px;
  box-shadow: 0 10px 30px rgba(14, 27, 61, 0.3); z-index: 20; animation: subir 0.2s ease-out;
}
.toast[hidden] { display: none; }
.toast .ok { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--lima); display: flex; align-items: center; justify-content: center; }
.toast.mal .ok { background: var(--naranja); }

.cargando { flex: 1; display: flex; align-items: center; justify-content: center; }
.cargando .bolita-salta { width: 36px; height: 36px; border-radius: 50%; background: var(--lima); border: 3px solid var(--lima-osc); animation: botar 0.6s infinite alternate ease-in; }

@keyframes subir { from { transform: translateY(24px); opacity: 0; } }
.toast { animation-name: subir-toast; }
@keyframes subir-toast { from { transform: translate(-50%, 24px); opacity: 0; } }
@keyframes aparecer { from { opacity: 0; } }
@keyframes botar { to { transform: translateY(-28px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
