/* ==========================================================================
   UKCenter — hoja de estilos propia (sin Tailwind), con el look de ukc.mx
   Tokens: teal #009692 (primario), rojo #F43357 (acento), azul logo #0E79BF
   Mobile-first de facto: las reglas base valen para móvil y los @media afinan
   (ver «Diseño responsivo» en CLAUDE.md antes de tocar este archivo).
   ========================================================================== */
:root {
  --primary: #009692;
  --primary-dark: #007f7b;
  --primary-darker: #006d69;   /* :hover del botón primario; blanco encima da >= 6:1 (AA) */
  --primary-soft: #e0f5f4;
  --accent: #f43357;
  --brand-blue: #0e79bf;
  --hero-from: #006d69;   /* blanco sobre estos tonos cumple contraste AA (>= 5.9:1) */
  --hero-to: #0c68a6;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f5f7f8;
  --ok-bg: #dcfce7;      /* estados: verde / ámbar / rojo (texto sobre fondo claro, contraste AA) */
  --ok-fg: #166534;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --danger-bg: #fee2e2;
  --danger-fg: #991b1b;
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .08);
  --shadow: 0 10px 30px -10px rgb(15 23 42 / .18);
  --shadow-lg: 0 25px 50px -12px rgb(15 23 42 / .25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --container: 72rem;
  --gutter: 1.5rem;         /* margen lateral de la página */
  --tap: 2.75rem;           /* 44 px: tamaño mínimo de un objetivo táctil (WCAG 2.5.5, Apple HIG) */
  --safe-top: env(safe-area-inset-top, 0px);       /* notch / barra de estado (viewport-fit=cover) */
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px); /* barra de gestos */
  --safe-left: env(safe-area-inset-left, 0px);
  --overlay: rgb(15 23 42 / .55);   /* fondo tras un diálogo o el menú móvil */
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--slate-700);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;   /* un texto largo (p. ej. un correo) nunca provoca scroll horizontal */
  -webkit-tap-highlight-color: rgb(0 150 146 / .15);
}
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }   /* un display de autor (flex, grid) anularía el atributo hidden del navegador */
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--slate-900); line-height: 1.15; margin: 0 0 .75rem; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 900; }
h2 { font-size: clamp(1.75rem, 3.5vw, 2.5rem); font-weight: 800; }
.h3 { font-size: 1.5rem; font-weight: 800; }
p { margin: 0 0 1rem; }
ul { margin: 0; padding: 0; list-style: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

.container {
  width: 100%; max-width: var(--container); margin-inline: auto;
  padding-left: max(var(--gutter), var(--safe-left)); padding-right: max(var(--gutter), var(--safe-right));
}
.muted { color: var(--slate-500); }
.small { font-size: .875rem; }
.eyebrow {
  display: inline-block; font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--primary-dark); margin: 0 0 .5rem;
}
.eyebrow-light { color: #fff; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--slate-900); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; top: 1rem; }

/* Material Symbols */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined";
  font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap;
  word-wrap: normal; direction: ltr; vertical-align: middle;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}
.material-symbols-outlined[data-size="20"] { font-size: 20px; }
.material-symbols-outlined[data-size="32"] { font-size: 32px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .8rem 1.5rem; border-radius: var(--radius-pill); font-weight: 700; font-size: .95rem;
  border: 2px solid transparent; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  text-decoration: none !important; text-align: center; font-family: inherit; line-height: 1.2; touch-action: manipulation;
}
@media (hover: hover) { .btn:hover { transform: translateY(-1px); } }   /* en táctil el :hover se queda «pegado» tras tocar */
.btn:focus-visible { outline: 3px solid rgb(14 121 191 / .4); outline-offset: 2px; }
.btn-primary { background: var(--primary-dark); color: #fff; box-shadow: 0 10px 20px -8px rgb(0 150 146 / .6); }
@media (hover: hover) { .btn-primary:hover { background: var(--primary-darker); } }   /* oscurece: con --primary el blanco daba 3.6:1 */
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 10px 20px -8px rgb(244 51 87 / .6); }
.btn-accent:hover { opacity: .92; }
.btn-light { background: #fff; color: var(--slate-900); box-shadow: var(--shadow); }
.btn-lg { padding: 1rem 2rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------- Barra superior y menú (solo con sesión iniciada) ----------
   Celular/tablet (< 800 px): botón hamburguesa que abre el menú como popover a pantalla completa
   (Popover API: cierre con Esc o al tocar fuera, sin JS). Escritorio: el mismo <nav> en línea, con
   submenús desplegables (<details>). */
.user-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem; min-height: calc(3.75rem + var(--safe-top));
  padding: calc(.5rem + var(--safe-top)) max(1rem, var(--safe-right)) .5rem max(1rem, var(--safe-left));
  background: rgb(255 255 255 / .95); box-shadow: var(--shadow-sm);
  font-size: .875rem; font-weight: 600;
}
.user-bar form { margin: 0; }
.user-bar a, .user-bar .link-button { color: var(--slate-700); white-space: nowrap; }
.user-bar a:hover, .user-bar .link-button:hover { color: var(--accent); text-decoration: none; }
.user-bar-brand { display: inline-flex; align-items: center; min-height: var(--tap); padding-inline: .25rem; font-size: 1.05rem; font-weight: 900; color: var(--primary-dark) !important; }
.user-bar-name { display: flex; align-items: center; gap: .3rem; min-width: 0; color: var(--brand-blue); }
.user-bar-name .material-symbols-outlined { flex: none; }
.user-bar-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Táctil o pantalla estrecha: enlaces de 44 px. */
@media (pointer: coarse), (max-width: 560px) {
  .user-bar a, .user-bar .link-button { display: inline-flex; align-items: center; min-height: var(--tap); padding-inline: .5rem; }
}
@media (max-width: 560px) {
  .user-bar { gap: .25rem; padding-inline: max(.5rem, var(--safe-left)) max(.5rem, var(--safe-right)); }
}
.app-menu-toggle, .app-nav-close {
  display: inline-grid; place-items: center; min-width: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: .75rem; background: transparent; color: var(--slate-900); cursor: pointer; touch-action: manipulation;
}
.app-menu-toggle:focus-visible, .app-nav-close:focus-visible, .app-nav-link:focus-visible { outline: 3px solid rgb(14 121 191 / .4); outline-offset: 2px; }
/* Base (celular): panel a pantalla completa. */
.app-nav {
  position: fixed; inset: 0; width: 100%; max-width: 100%; min-height: 100vh; min-height: 100dvh; margin: 0;
  padding: calc(.5rem + var(--safe-top)) max(1rem, var(--safe-right)) calc(1.5rem + var(--safe-bottom)) max(1rem, var(--safe-left));
  border: 0; background: var(--surface); color: var(--slate-700); overflow-y: auto; overscroll-behavior: contain;
  font-size: 1rem; font-weight: 600;
}
.app-nav::backdrop { background: var(--overlay); }
.app-nav-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; color: var(--slate-900); font-weight: 800; }
.app-nav-list, .app-subnav { display: grid; gap: .25rem; }
.app-nav .app-nav-link {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-height: var(--tap); padding: .6rem .9rem;
  border: 0; border-radius: .75rem; background: transparent; color: var(--slate-700) !important; font: inherit;
  text-align: left; cursor: pointer; touch-action: manipulation; list-style: none;
}
.app-nav-link::-webkit-details-marker { display: none; }
.app-nav-link[aria-current="page"], .app-nav-link.is-current { background: var(--primary-soft); color: var(--primary-dark) !important; }
.app-nav-chevron { margin-left: auto; transition: transform .15s ease; }
details[open] > .app-nav-link .app-nav-chevron { transform: rotate(180deg); }
.app-subnav { padding: .25rem 0 .25rem 1.25rem; }
.app-subnav form { margin: 0; }
.app-subnav .user-bar-name { padding: .25rem .9rem; font-size: .875rem; }
@media (hover: hover) { .app-nav-link:hover { background: var(--slate-100); text-decoration: none; } }
/* Escritorio: el menú vive en la barra y los submenús se despliegan bajo su título. */
@media (min-width: 800px) {
  .app-menu-toggle, .app-nav-head { display: none; }
  .app-nav {
    position: static; inset: auto; display: block; width: auto; min-height: 0; margin: 0 0 0 auto; padding: 0;
    background: transparent; overflow: visible; font-size: .9rem;
  }
  .app-nav-list { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .125rem; }
  .app-nav-list > li { position: relative; }
  .app-nav-list > li > .app-nav-link, .app-nav-list > li > details > .app-nav-link { width: auto; padding-inline: .7rem; }
  .app-nav-list > li > .app-nav-link .material-symbols-outlined:not(.app-nav-chevron),
  .app-nav-list > li > details > .app-nav-link .material-symbols-outlined:not(.app-nav-chevron) { display: none; }
  .app-subnav {
    position: absolute; top: calc(100% + .25rem); right: 0; z-index: 30; min-width: 14rem; max-width: min(20rem, calc(100vw - 2rem));
    padding: .5rem; background: var(--surface); border: 1px solid var(--slate-200); border-radius: var(--radius); box-shadow: var(--shadow);
  }
}
@media (prefers-reduced-motion: reduce) { .app-nav-chevron { transition: none; } }

/* ---------- Hero (tras iniciar sesión) ---------- */
.hero {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; text-align: center;
  padding: calc(5rem + var(--safe-top)) max(var(--gutter), var(--safe-right)) calc(3rem + var(--safe-bottom)) max(var(--gutter), var(--safe-left));
  color: #fff;
  background:
    radial-gradient(circle at 82% 12%, rgb(255 255 255 / .16), transparent 45%),
    linear-gradient(160deg, var(--hero-from), var(--hero-to));
}
.hero-inner { width: 100%; max-width: 46rem; display: flex; flex-direction: column; align-items: center; animation: hero-in .6s ease both; }
.hero-logo { width: min(17.5rem, 70vw); height: auto; margin-bottom: 2rem; }
.hero h1 { color: #fff; margin-bottom: 1rem; }
.hero-lead { max-width: 36rem; margin-bottom: 2rem; font-size: 1.15rem; color: #fff; }
.hero-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; width: 100%; margin: 0 0 2rem; }
.hero-summary li {
  display: grid; grid-template-columns: auto 1fr; column-gap: .9rem; align-items: center; text-align: left;
  padding: .9rem 1.1rem; border-radius: var(--radius);
  background: rgb(0 0 0 / .2); border: 1px solid rgb(255 255 255 / .22);
}
.hero-summary .material-symbols-outlined { grid-row: span 2; }
.hero-summary strong { color: #fff; line-height: 1.3; }
.hero-summary span:not(.material-symbols-outlined) { font-size: .9rem; line-height: 1.35; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; }
.hero-foot { margin: 2.5rem 0 0; font-size: .8rem; }
.hero .btn:focus-visible { outline-color: #fff; }
@keyframes hero-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 560px) {
  .hero-logo { margin-bottom: 1.5rem; }
  .hero-lead { font-size: 1.05rem; margin-bottom: 1.5rem; }
  .hero-summary { grid-template-columns: 1fr; margin-bottom: 1.5rem; }
  .hero .btn-lg { width: 100%; max-width: 22rem; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-foot { margin-top: 2rem; }
}
/* Móvil en horizontal: poca altura, así que se compacta el hero. */
@media (max-height: 500px) and (orientation: landscape) {
  .hero { padding-top: calc(4.5rem + var(--safe-top)); padding-bottom: calc(2rem + var(--safe-bottom)); }
  .hero-logo { width: 10rem; margin-bottom: 1rem; }
  .hero-foot { margin-top: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { .hero-inner { animation: none; } .btn { transition: none; } }

/* ---------- Mi cuenta ---------- */
.manage { min-height: 100vh; min-height: 100dvh; padding: calc(5rem + var(--safe-top)) 0 calc(3rem + var(--safe-bottom)); background: var(--surface-soft); }
.manage-title { font-size: 2rem; margin-bottom: 1.5rem; }
.card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--slate-100); }
.manage-content { padding: 2rem; min-width: 0; }
.manage-narrow { max-width: 48rem; }
@media (max-width: 560px) {
  .manage { padding-top: calc(4.75rem + var(--safe-top)); }
  .manage-title { font-size: 1.75rem; margin-bottom: 1rem; }
  .manage-content { padding: 1.25rem; }
}

/* ---------- Administración de usuarios (solo Admin) ---------- */
.admin-stack { display: grid; gap: 1.25rem; margin-top: 1.25rem; }
.user-list { display: grid; gap: .75rem; margin-top: 1rem; }
/* Sin punto de quiebre: la fila pasa a dos columnas cuando caben, y a una en celular. */
.user-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .75rem; align-items: center; padding: 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); }
.user-row-info { min-width: 0; }
.user-row-name { font-weight: 700; color: var(--slate-900); }
.user-row-email { font-size: .9rem; color: var(--slate-500); }
.role-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.role-form .input { flex: 1 1 11rem; width: auto; min-width: 0; }
.badge { display: inline-block; padding: .25rem .75rem; border-radius: var(--radius-pill); background: var(--primary-soft); color: var(--primary-dark); font-size: .85rem; font-weight: 700; }
.secret { display: block; padding: .6rem .8rem; border-radius: .5rem; background: #fff; border: 1px dashed var(--primary-dark); color: var(--slate-900); font-size: 1rem; overflow-wrap: anywhere; user-select: all; }

/* ---------- Alumnos, tutores y portal familiar ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.page-head .manage-title { margin-bottom: 0; min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 1rem; }
.toolbar .input { flex: 1 1 12rem; width: auto; min-width: 0; }
/* Campos en columnas cuando caben y a una columna en celular, sin punto de quiebre. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); }
.input[type="date"] { min-height: var(--tap); appearance: none; -webkit-appearance: none; }   /* iOS encoge los campos de fecha */
textarea.input { min-height: 6rem; resize: vertical; }
.data-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.data-table th, .data-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--slate-200); vertical-align: middle; }
.data-table td { overflow-wrap: anywhere; }   /* «break-word» no reduce el ancho mínimo: una cadena larga sacaba la tabla de su tarjeta */
.data-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; }
.row-closed td:not(.actions) { color: var(--slate-500); }
.data-table .input { min-width: 0; }
.data-list { display: grid; gap: .75rem; margin: 0 0 1rem; }
.data-list > div { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: .25rem 1rem; }
.data-list dt { font-weight: 600; color: var(--slate-800); }
.data-list dd { margin: 0; }
/* Cobranza: resumen en tarjetas (se apilan en celular) y movimientos anulados tachados con su motivo. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .75rem; margin: 0 0 1rem; }
.stat { display: grid; gap: .25rem; min-width: 0; padding: 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--slate-500); }
.stat-value { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--slate-900); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-danger .stat-value { color: var(--danger-fg); }
.stat-ok .stat-value { color: var(--ok-fg); }
.badge-muted { background: var(--slate-100); color: var(--slate-700); }
.row-void td:not(.actions) { color: var(--slate-500); }
.row-void .concept { text-decoration: line-through; }
.void-reason { display: block; font-size: .85rem; color: var(--danger-fg); }
.row-form .input { flex: 1 1 10rem; width: auto; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Tablet y celular: la tabla se apila en tarjetas (cada celda muestra su cabecera con data-label).
   Hasta 800 px porque las tablas con campos por fila (inscripciones, ledger con «anular») no caben en 700 px sin desbordar. */
@media (max-width: 800px) {
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table tr { display: grid; gap: .25rem; padding: .75rem 0; border-bottom: 1px solid var(--slate-200); }
  .data-table td { display: grid; grid-template-columns: minmax(0, 7rem) minmax(0, 1fr); gap: .5rem; padding: 0; border: 0; }
  .data-table td::before { content: attr(data-label); font-weight: 600; color: var(--slate-500); font-size: .85rem; }
  .data-table td.actions { grid-template-columns: minmax(0, 1fr); }
  .data-table .num { text-align: left; }
  /* Alumno con miniatura: el avatar y el nombre ocupan toda la fila (la etiqueta «Alumno» sobra y comía 7 rem al nombre). */
  .data-table td:has(> .person) { grid-template-columns: minmax(0, 1fr); }
  .data-table td:has(> .person)::before { display: none; }
}
@media (max-width: 560px) {
  .data-list > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .row-actions, .row-form { width: 100%; }
  .row-actions .btn, .row-form .btn, .form-actions .btn, .toolbar .btn { width: 100%; }
}

/* ---------- Foto del alumno (miniatura en listados, tarjeta de la ficha, captura con el celular) ---------- */
.person { display: inline-flex; align-items: center; gap: .625rem; min-width: 0; }
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; overflow: hidden;
  object-fit: cover; background: var(--primary-soft); color: var(--primary-dark); font-size: .85rem; font-weight: 800; line-height: 1;
}
.avatar-lg { width: 6rem; height: 6rem; font-size: 1.75rem; }
.photo-card { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.photo-card-body { flex: 1 1 14rem; min-width: 0; }
.photo-card-body p { margin-bottom: .5rem; }
.qr { width: min(100%, 16rem); margin: 0 auto 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.qr svg { width: 100%; height: auto; }
.capture-preview { width: min(100%, 22.5rem); height: auto; aspect-ratio: 1; margin: 0 auto 1rem; border-radius: var(--radius); background: var(--slate-100); object-fit: cover; }
.capture { display: grid; gap: 1rem; }

/* ---------- Diálogos de edición y alta (EditDialog) ----------
   Base (celular): a pantalla completa, cabecera y botones pegados arriba y abajo. Desde 560 px: tarjeta centrada. */
html:has(dialog.modal[open]) { overflow: hidden; }
.modal {
  /* Alto fijo = la pantalla (el <dialog> crece con su contenido por defecto): el cuerpo hace scroll y los botones quedan a la vista. */
  width: 100%; max-width: 100%; min-height: 100vh; min-height: 100dvh; max-height: 100vh; max-height: 100dvh; margin: 0; padding: 0;
  border: 0; background: var(--surface); color: var(--slate-700); overflow-y: auto; overscroll-behavior: contain;
}
.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s ease both; }
.modal::backdrop { background: var(--overlay); }
.modal:focus-visible { outline: none; }   /* showModal() enfoca el propio <dialog> al abrirlo por #id; sus controles dibujan su propio anillo */
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: calc(.5rem + var(--safe-top)) max(1.25rem, var(--safe-right)) .5rem max(1.25rem, var(--safe-left));
  background: var(--surface); border-bottom: 1px solid var(--slate-200);
}
.modal-title { margin: 0; min-width: 0; font-size: 1.25rem; font-weight: 800; }
.modal-close {
  flex: none; display: inline-grid; place-items: center; min-width: var(--tap); min-height: var(--tap); padding: 0;
  border: 0; border-radius: .75rem; background: transparent; color: var(--slate-700); cursor: pointer; touch-action: manipulation;
}
.modal-close:focus-visible { outline: 3px solid rgb(14 121 191 / .4); outline-offset: 2px; }
.modal-body { flex: 1 0 auto; display: flex; flex-direction: column; padding: 1.25rem max(1.25rem, var(--safe-right)) 0 max(1.25rem, var(--safe-left)); }
.modal-body > form { flex: 1 0 auto; display: flex; flex-direction: column; gap: 1rem; margin: 0; }
.modal-actions {
  position: sticky; bottom: 0; display: flex; flex-direction: column-reverse; gap: .5rem; margin-top: auto;
  padding: .75rem 0 calc(.75rem + var(--safe-bottom)); background: var(--surface); border-top: 1px solid var(--slate-200);
}
.modal-actions .btn { width: 100%; }
.btn-ghost { background: transparent; color: var(--slate-700); border-color: var(--slate-200); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (min-width: 560px) {
  .modal { width: min(40rem, calc(100vw - 2rem)); min-height: 0; max-height: calc(100dvh - 2rem); margin: auto; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
  .modal-wide { width: min(56rem, calc(100vw - 2rem)); }
  .modal-head { padding-top: .75rem; }
  .modal-actions { flex-direction: row; justify-content: flex-end; padding-bottom: 1.25rem; }
  .modal-actions .btn { width: auto; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .modal { max-height: 100dvh; margin-block: 0; }
  .modal-head { padding-block: calc(.25rem + var(--safe-top)) .25rem; }
  .modal-title { font-size: 1.1rem; }
  .modal-actions { padding-block: .5rem calc(.5rem + var(--safe-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 1rem; }
.form-narrow { max-width: 28rem; }
.field { display: grid; align-content: start; gap: .35rem; }   /* sin esto el vecino de un campo con error se estira al alto de la fila */
.field label { font-weight: 600; font-size: .9rem; color: var(--slate-800); }
/* font-size >= 16 px: iOS Safari hace zoom al enfocar un campo con letra menor. */
.input { width: 100%; min-height: var(--tap); padding: .75rem 1rem; border-radius: .75rem; border: 1px solid var(--slate-200); font: inherit; font-size: max(1rem, 16px); color: var(--slate-900); background: #fff; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(0 150 146 / .2); }
.input:disabled { background: var(--slate-50); color: var(--slate-500); }
.check { display: flex; align-items: center; gap: .6rem; min-height: var(--tap); font-size: .9rem; }
.check input { flex: none; width: 1.25rem; height: 1.25rem; accent-color: var(--primary-dark); }
.field-error, .form-errors { color: #b91c1c; font-size: .85rem; }
.form-errors ul { list-style: disc; padding-left: 1.2rem; }
.form-errors:empty, .validation-message:empty { display: none; }
.valid.modified:not([type=checkbox]) { border-color: #16a34a; }
.invalid { border-color: #dc2626; }
.alert { padding: .8rem 1rem; border-radius: .75rem; font-size: .9rem; margin-bottom: 1rem; }
.alert-danger { background: var(--danger-bg); color: var(--danger-fg); }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); }
@media (max-width: 560px) { .form .btn { width: 100%; } }   /* botón de envío a todo el ancho: fácil de tocar con el pulgar */

/* ---------- Páginas de acceso y errores ---------- */
.auth-page {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(2rem + var(--safe-top)) max(1rem, var(--safe-right)) calc(2rem + var(--safe-bottom)) max(1rem, var(--safe-left));
  background: linear-gradient(160deg, var(--hero-from), var(--hero-to));
}
.auth-card { width: 100%; max-width: 26rem; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 2.5rem 2rem; }
.auth-logo { display: block; min-height: var(--tap); margin-bottom: 1.5rem; }
.auth-title { font-size: 1.75rem; margin-bottom: .25rem; }
.auth-subtitle { color: var(--slate-500); margin-bottom: 1.5rem; }
.auth-help { margin: 1.5rem 0 0; font-size: .85rem; color: var(--slate-500); }
.auth-help a { padding-block: .85rem; }   /* enlace dentro de un párrafo: el relleno vertical agranda el área táctil sin mover el texto */
p.muted a { padding-block: .85rem; }   /* mismo criterio para los párrafos de ayuda del portal familiar */
.auth-footer { margin-top: 1.5rem; }
.auth-footer a { display: inline-flex; align-items: center; min-height: var(--tap); color: #fff; }
@media (max-width: 380px) {
  .auth-page { padding-top: calc(1rem + var(--safe-top)); }
  .auth-card { padding: 1.75rem 1.25rem; border-radius: var(--radius); }
  .auth-title { font-size: 1.5rem; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .auth-page { justify-content: flex-start; padding-block: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-bottom)); }
  .auth-card { padding-block: 1.5rem; }
  .auth-logo, .auth-subtitle { margin-bottom: 1rem; }
}

/* ---------- Recibo de pago (pantalla e impresión) ---------- */
.receipt { position: relative; padding: 1.5rem; }
.receipt-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: center; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 2px solid var(--primary); }
.receipt-logo { width: 10rem; height: auto; }
.receipt-school { display: grid; gap: .1rem; font-size: .9rem; color: var(--slate-500); }
.receipt-school strong { color: var(--slate-900); }
.receipt-folio { display: grid; gap: .1rem; }
.receipt-folio strong { font-size: 1.5rem; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.receipt-data { margin-bottom: 1.25rem; }
.receipt-totals { margin-top: 1rem; }
.receipt-stamp {
  display: grid; justify-items: start; gap: .25rem; margin: 0 0 1rem; padding: .75rem 1rem; border: 3px solid var(--danger-fg); border-radius: var(--radius);
  color: var(--danger-fg); font-size: 1.5rem; font-weight: 900; letter-spacing: .15em;
}
.receipt-stamp .small { letter-spacing: normal; font-weight: 600; }
.receipt-void .receipt-data, .receipt-void .receipt-lines, .receipt-void .receipt-totals { opacity: .6; }
.receipt-foot { margin-top: 2rem; display: grid; gap: 1rem; }
.receipt-sign { display: grid; gap: .25rem; max-width: 18rem; }
.receipt-sign-line { display: block; border-top: 1px solid var(--slate-700); padding-top: .25rem; }
.receipt-link { gap: .25rem; margin-left: .25rem; font-size: .875rem; }
@media (min-width: 560px) {
  .receipt { padding: 2rem; }
  .receipt-head { grid-template-columns: auto minmax(0, 1fr) auto; }
  .receipt-folio { text-align: right; }
}
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; }
  .user-bar, .no-print, .page-actions, .skip-link, #blazor-error-ui { display: none !important; }
  .manage { min-height: 0; padding: 0; background: #fff; }
  .manage-title { font-size: 1.25rem; }
  .card, .receipt { box-shadow: none; border: 0; border-radius: 0; padding: 0; }
  .data-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .data-table tr { display: table-row; }
  .data-table td { display: table-cell; padding: .4rem .5rem; border-bottom: 1px solid #ccc; }
  .data-table td::before { content: none; }
  .data-table .num { text-align: right; }
  .stat { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Importación CSV ---------- */
.import-steps { display: grid; gap: .5rem; padding-left: 1.25rem; margin: 0 0 1rem; list-style: decimal; }
.input[type="file"] { padding: .6rem 1rem; }
.import-summary { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.import-row-error td:not(.actions) { color: var(--danger-fg); }
.import-row-skip td:not(.actions) { color: var(--slate-500); }

/* ---------- Grupos: horario semanal ---------- */
.schedule-fieldset { margin: 0; padding: 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); }
.schedule-fieldset legend { font-weight: 600; font-size: .9rem; color: var(--slate-800); padding-inline: .25rem; }
.weekday-picks { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-bottom: .75rem; }
.weekday-pick { min-width: 7.5rem; }
.input[type="time"] { min-height: var(--tap); appearance: none; -webkit-appearance: none; }

/* ---------- Académico: pase de lista y avance ---------- */
.attendance-picks { display: flex; flex-wrap: wrap; gap: 0 .75rem; }
.attendance-pick { min-width: 7rem; }
.progress-block { padding: 1rem 0; border-top: 1px solid var(--slate-200); }
.progress-block:first-child { border-top: 0; padding-top: 0; }
.progress-bar { width: 100%; height: .75rem; border-radius: var(--radius-pill); background: var(--slate-100); overflow: hidden; margin: 0 0 .5rem; }
.progress-fill { display: block; height: 100%; background: var(--primary); border-radius: var(--radius-pill); }

/* ---------- Avisos ---------- */
.notices-section { min-height: 0; padding-top: 1.5rem; }
.notice-list { display: grid; gap: .75rem; }
.notice { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; padding: 1rem; border: 1px solid var(--primary); border-left-width: 4px; border-radius: var(--radius); background: var(--primary-soft); }
.notice-read { border-color: var(--slate-200); background: var(--surface); }
.notice-title { font-weight: 700; color: var(--slate-900); }
.notice-text { margin: .25rem 0 0; white-space: pre-line; }
@media (min-width: 560px) { .notice { grid-template-columns: minmax(0, 1fr) auto; align-items: start; } }

/* ---------- Constancias ---------- */
.certificate-title { text-align: center; letter-spacing: .15em; font-size: 1.25rem; margin: 1.5rem 0; }
.certificate-text { font-size: 1.05rem; line-height: 1.8; }

/* ---------- Blazor ---------- */
#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); box-sizing: border-box; display: none; left: 0; padding: .6rem 3.5rem calc(.7rem + var(--safe-bottom)) max(1.25rem, var(--safe-left)); position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .reload { display: inline-block; padding-block: .6rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: max(.25rem, var(--safe-right)); top: .25rem; display: grid; place-items: center; width: var(--tap); height: var(--tap); }
