:root {
  --bg: #F4F6FA; --card: #FFFFFF; --texto: #1B2430; --suave: #6B7686; --linea: #E3E8F0;
  --azul: #0247AF; --azul-suave: #E8EFFB; --rojo: #C62828; --verde: #2E7D32; --ambar: #B26A00;
  --sombra: 0 1px 2px rgba(20, 40, 80, .06); --hero: #0247AF; --aviso-bg: #FFF4DD; --aviso-tx: #7A4B00;
}
/* modo oscuro: el que elige el botón de la barra; si no se eligió ninguno, el del celular */
:root[data-theme="dark"] {
  --bg: #0F141B; --card: #19212B; --texto: #E9EEF5; --suave: #93A0B2; --linea: #26313F;
  --azul: #6EA2FF; --azul-suave: #1C2B45; --rojo: #FF8A80; --verde: #7FD18B; --ambar: #FFC266; --sombra: none;
  --hero: #1E3A6E; --aviso-bg: #3A2E12; --aviso-tx: #FFD38A;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F141B; --card: #19212B; --texto: #E9EEF5; --suave: #93A0B2; --linea: #26313F;
    --azul: #6EA2FF; --azul-suave: #1C2B45; --rojo: #FF8A80; --verde: #7FD18B; --ambar: #FFC266; --sombra: none;
    --hero: #1E3A6E; --aviso-bg: #3A2E12; --aviso-tx: #FFD38A;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--texto);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { min-height: 100vh; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- ingreso ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; }
.login img { width: 92px; height: auto; margin-bottom: 18px; }
.login h1 { font-size: 24px; margin: 0 0 4px; }
.login p { color: var(--suave); margin: 0 0 22px; }
.login label { display: block; font-size: 13px; color: var(--suave); margin: 12px 0 4px; }
.login input { width: 100%; padding: 13px 14px; font-size: 17px; border-radius: 12px; border: 1px solid var(--linea); background: var(--card); color: var(--texto); }
.login input:focus { outline: 2px solid var(--azul); border-color: transparent; }
.boton { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; font-size: 17px; background: var(--azul); color: #fff; margin-top: 20px; }
.boton:disabled { opacity: .6; }
.boton.sec { background: var(--azul-suave); color: var(--azul); margin-top: 12px; }
.error { color: var(--rojo); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* ---------- estructura ---------- */
header { position: sticky; top: 0; z-index: 5; background: var(--hero); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; gap: 12px; }
header .t { flex: 1; min-width: 0; }
header .t b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header .t span { font-size: 12.5px; opacity: .9; display: flex; align-items: center; gap: 6px; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: #7CE08A; flex: none; }
.punto.viejo { background: #FFC266; }
header button { background: rgba(255,255,255,.16); border: 0; border-radius: 10px; width: 38px; height: 38px; color: #fff; font-size: 19px; }
main { padding: 14px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom); }
nav button { flex: 1; background: none; border: 0; padding: 11px 2px 9px; color: var(--suave); font-size: 11px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; gap: 3px; }
nav button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
nav button.on { color: var(--azul); font-weight: 600; }

.aviso { background: var(--aviso-bg); color: var(--aviso-tx); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }

/* ---------- navegación de fecha / mes ---------- */
.selector { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.selector button.f { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--linea); background: var(--card); font-size: 20px; color: var(--azul); }
.selector button:disabled { opacity: .35; }
.selector .centro { flex: 1; position: relative; text-align: center; background: var(--card); border: 1px solid var(--linea); border-radius: 12px; height: 44px; display: flex; flex-direction: column; justify-content: center; }
.selector .centro b { font-size: 16px; line-height: 1.15; display: block; }
.selector .centro b::first-letter { text-transform: uppercase; }
.selector .centro small { color: var(--suave); font-size: 12px; line-height: 1.1; }
.selector input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }

/* ---------- tarjetas ---------- */
.hero { background: var(--hero); color: #fff; border-radius: 18px; padding: 18px 18px 16px; margin-bottom: 12px; }
.hero small { opacity: .85; font-size: 13.5px; }
.hero .grande { font-size: 34px; font-weight: 700; letter-spacing: -.5px; margin: 2px 0 0; }
.hero .par { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.25); font-size: 14.5px; }
.hero .par b { font-size: 17px; white-space: nowrap; }
.hero .par span { padding-right: 8px; }
.grilla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.grilla.tres { grid-template-columns: 1fr 1fr 1fr; }
.dato { background: var(--card); border-radius: 14px; padding: 11px 12px; box-shadow: var(--sombra); border: 1px solid var(--linea); min-width: 0; }
.dato small { display: block; color: var(--suave); font-size: 12.5px; }
.dato b { font-size: 17px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dato b.neg { color: var(--rojo); }
.seccion { background: var(--card); border-radius: 16px; border: 1px solid var(--linea); box-shadow: var(--sombra); margin-bottom: 12px; overflow: hidden; }
.seccion h2 { margin: 0; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--suave); padding: 13px 14px 6px; }
.fila { display: flex; align-items: baseline; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--linea); }
.fila:first-of-type { border-top: 0; }
.fila .n { flex: 1; min-width: 0; }
.fila .n small { display: block; color: var(--suave); font-size: 12.5px; }
.fila .v { text-align: right; white-space: nowrap; font-weight: 600; }
.fila .v small { display: block; font-weight: 400; color: var(--suave); font-size: 12px; }
.fila.total { background: var(--azul-suave); font-weight: 700; }
.fila .v.rojo { color: var(--rojo); }
.vacio { text-align: center; color: var(--suave); padding: 40px 20px; }
.vacio b { display: block; color: var(--texto); font-size: 17px; margin-bottom: 4px; }

/* ---------- tabla del mes ---------- */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-top: 1px solid var(--linea); }
th { color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-top: 0; background: var(--card); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
tr.cero td { color: var(--suave); }
tr.tot td { background: var(--azul-suave); font-weight: 700; }
tr.tot td:first-child { background: var(--azul-suave); }
.nota { color: var(--suave); font-size: 12.5px; padding: 4px 14px 12px; }
.cargando { text-align: center; color: var(--suave); padding: 50px 0; }

/* ---------- botón "volver a hoy", comparación y gráfico ---------- */
.chip { display: block; margin: -4px auto 14px; background: var(--azul-suave); color: var(--azul); border: 0; border-radius: 999px; padding: 8px 18px; font-size: 14px; font-weight: 600; }
.dato em { display: block; font-style: normal; color: var(--suave); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dato b.pos { color: var(--verde); }

/* ---------- pantalla de bienvenida ---------- */
#splash { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease, visibility .45s; }
#splash.fuera { opacity: 0; visibility: hidden; }
#splash img { width: min(38vw, 170px); height: auto; animation: sp-entra .6s ease both; }
#splash i { position: absolute; left: 50%; bottom: calc(14vh + env(safe-area-inset-bottom)); width: 56px; height: 3px; margin-left: -28px;
  border-radius: 3px; background: var(--linea); overflow: hidden; }
#splash i::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: 3px; background: var(--azul); animation: sp-corre 1.1s ease-in-out infinite; }
@keyframes sp-entra { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes sp-corre { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@media (prefers-reduced-motion: reduce) { #splash img, #splash i::after { animation: none; } #splash { transition: none; } }

/* ---------- modo claro/oscuro y ver contraseña ---------- */
header button { display: flex; align-items: center; justify-content: center; flex: none; }
header button + button { margin-left: -4px; }
.ico-tema { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.login .btn-tema { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--linea); background: var(--card); color: var(--suave); display: flex; align-items: center; justify-content: center; }
.pw { position: relative; }
.pw input { padding-right: 92px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--azul);
  font-size: 15px; font-weight: 600; padding: 8px 10px; border-radius: 8px; }

/* ---------- gestos ---------- */
@keyframes entra-izq { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }
@keyframes entra-der { from { opacity: 0; transform: translateX(-26px); } to { opacity: 1; transform: none; } }
main.entra-izq { animation: entra-izq .22s ease-out; }
main.entra-der { animation: entra-der .22s ease-out; }
#ptr { position: fixed; left: 50%; top: 70px; width: 38px; height: 38px; margin-left: -19px; border-radius: 50%; background: var(--card);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2); display: flex; align-items: center; justify-content: center; z-index: 4; opacity: 0;
  transform: translateY(-44px); pointer-events: none; color: var(--azul); }
#ptr svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#ptr.gira svg { animation: ptr-gira .8s linear infinite; }
@keyframes ptr-gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { main.entra-izq, main.entra-der { animation: none; } }
html, body { overscroll-behavior-y: none; }

/* ---------- cierre del día: columnas como en el cuaderno ---------- */
.hero .par.sub { margin-top: 6px; padding-top: 0; border-top: 0; font-size: 14px; opacity: .92; }
.hero .par.sub b { font-size: 15px; }
.dos { display: grid; grid-template-columns: 1fr 1fr; }
.dos .col { padding: 0 14px 10px; min-width: 0; }
.dos .col + .col { border-left: 1px solid var(--linea); }
.dos h3 { margin: 4px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--suave); }
.dos .lin { display: flex; flex-direction: column; align-items: flex-end; padding: 5px 0; border-top: 1px solid var(--linea); font-size: 15px; }
.dos .lin:first-of-type { border-top: 0; }
.dos .lin small { color: var(--suave); font-size: 11.5px; }
.dos .lin.tot { margin-top: 4px; padding-top: 8px; border-top: 2px solid var(--linea); font-weight: 700; font-size: 16px; }
.dos .vacio-col { color: var(--suave); }
.leyenda { padding-top: 8px; }

/* tarjetas resumidas del cierre del día (se tocan para ver el detalle) */
.rc { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--linea); box-shadow: var(--sombra); border-radius: 16px; padding: 13px 14px 12px; margin-bottom: 12px; color: var(--texto); font: inherit; }
.rc:active { background: var(--azul-suave); }
.rc-t { display: flex; justify-content: space-between; align-items: center; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; color: var(--suave); margin-bottom: 6px; }
.rc-t i { display: inline-flex; }
.rc-t svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rc-c { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }
.rc-c small { display: block; color: var(--suave); font-size: 12.5px; }
.rc-c b { font-size: 19px; }
.volver { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.volver button { display: inline-flex; align-items: center; gap: 2px; background: var(--azul-suave); color: var(--azul); border: 0; border-radius: 12px; padding: 9px 14px 9px 8px; font: inherit; font-weight: 600; }
.volver button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(180deg); }
.volver span { color: var(--suave); font-size: 14px; }

/* Con la app abierta el fondo de la página (html) es del azul del encabezado: así el borde difuminado que iOS dibuja bajo la barra de estado
   (hora, batería) no se aclara hacia el gris de las tarjetas. El contenido sigue sobre el fondo claro. */
html.app { background: var(--hero); }
html.app body { background: linear-gradient(var(--hero), var(--hero)) top / 100% env(safe-area-inset-top, 0px) no-repeat, var(--bg); }

/* ---------- textos escolares y trajes de danza ---------- */
.selector .centro.gsel { font: inherit; color: inherit; cursor: pointer; padding: 0 6px; }
.selector .centro.gsel small { color: var(--azul); font-weight: 600; }
.anios { display: flex; justify-content: center; gap: 8px; margin: 0 0 10px; }
.anios .ya { border: 1px solid var(--linea); background: var(--card); color: var(--suave); border-radius: 999px; padding: 6px 16px; font-weight: 600; font-size: 14px; }
.anios .ya.on { background: var(--azul); border-color: var(--azul); color: #fff; }
.filtros { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 2px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.fl { flex: none; border: 1px solid var(--linea); background: var(--card); color: var(--suave); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; }
.fl.on { background: var(--azul-suave); border-color: transparent; color: var(--azul); }
.al { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--linea); padding: 11px 12px 11px 14px; color: var(--texto); font: inherit; }
.seccion > .al:first-of-type, .seccion h2 + .al { border-top: 0; }
.al:active { background: var(--azul-suave); }
.al .n { flex: 1; min-width: 0; }
.al .n b { display: block; font-weight: 600; font-size: 15.5px; }
.al .n small { display: block; color: var(--suave); font-size: 12.5px; }
.al .n small.obs { font-style: italic; }
.al .v { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; font-weight: 600; }
.al .v small { font-weight: 400; color: var(--suave); font-size: 12px; }
.al .v small.rojo { color: var(--rojo); }
.al > svg { width: 18px; height: 18px; flex: none; stroke: var(--suave); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.est { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; background: var(--linea); color: var(--suave); }
.est.ok { background: color-mix(in srgb, var(--verde) 16%, transparent); color: var(--verde); }
.est.parcial { background: color-mix(in srgb, var(--ambar) 18%, transparent); color: var(--ambar); }
.est.mal { background: color-mix(in srgb, var(--rojo) 14%, transparent); color: var(--rojo); }
.est.tiene { background: var(--azul-suave); color: var(--azul); }
.ficha { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.ficha b { font-size: 18px; }
.hoja { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 24, .5); display: flex; align-items: flex-end; animation: hoja-fondo .18s ease-out; }
.hoja .panel { width: 100%; max-width: 640px; margin: 0 auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 82vh; overflow-y: auto; overscroll-behavior: contain; animation: hoja-sube .22s ease-out; }
.hoja .asa { width: 40px; height: 4px; border-radius: 4px; background: var(--linea); margin: 4px auto 10px; }
.hoja h2 { margin: 0 0 10px; font-size: 18px; }
.hgs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hg { text-align: left; border: 1px solid var(--linea); background: var(--bg); border-radius: 14px; padding: 11px 12px; color: var(--texto); font: inherit; }
.hg:first-child { grid-column: 1 / -1; }
.hg b { display: block; font-size: 15.5px; }
.hg small { color: var(--suave); font-size: 12.5px; }
.hg.on { border-color: var(--azul); background: var(--azul-suave); }
.hg.on b { color: var(--azul); }
@keyframes hoja-sube { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes hoja-fondo { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hoja, .hoja .panel { animation: none; } }

/* ---------- cierre del día: lo que no se toca ---------- */
h3.grupo { margin: 18px 2px 8px; font-size: 14px; font-weight: 700; }
h3.grupo small { display: block; font-weight: 400; color: var(--suave); font-size: 12.5px; margin-top: 1px; }
