:root {
  --azul: #003b71;       /* mismo azul que ya usás en bg-azul */
  --azul-hover: #002c54;
  --celeste: #3d92d6;    /* mismo celeste que ya usás en bg-celeste */
  --celeste-soft: rgba(0, 114, 206, 0.10);

  --surface: #ffffff;
  --background: #f4f6f8;
  --border-color: rgba(0, 0, 0, 0.09);
  --muted: #5f6b7a;

  --header-h: 88px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; }

.app-body {
  background: var(--background);
  padding-top: calc(var(--header-h) + var(--safe-top));
  padding-bottom: calc(var(--safe-bottom) + 12px);
}

/* ===================== APP HEADER ===================== */

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1030;
  height: calc(var(--header-h) + var(--safe-top));
  padding-top: var(--safe-top);
  background: var(--azul);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.app-header__inner {
  height: var(--header-h);
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Ícono/botón cuadrado del header (marca en Inicio, "volver" en pantallas internas). */
.app-header__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.16) !important;
  color: #fff;
  font-size: 1.15rem;
  text-decoration: none;
  border: none;
  transition: background-color .15s ease;
}
.app-header__icon--link:hover,
.app-header__icon--link:focus-visible {
  background: rgba(255, 255, 255, 0.26);
}

.app-header__titles {
  min-width: 0;
  flex: 1 1 auto;
}
.app-header__eyebrow {
  margin: 0;
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .8;
  min-height: 1em; /* evita salto de layout cuando el bloque queda vacío */
}
.app-header__eyebrow:empty { margin: 0; min-height: 0; }
.app-header__title {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__subtitle {
  margin: 0;
  font-size: .78rem;
  opacity: .82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-header__escudo { height: 42px; width: auto; }

/* Badge de estado de conexión, para usar dentro de header_actions si hace falta */
.badge-offline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-offline i { font-size: .75rem; }

/* ===================== MAIN / CONTENIDO ===================== */

.app-main { padding-left: 0; padding-right: 0; }
.app-main .contenido { padding: 16px 12px 0; max-width: 720px; }

/* ===================== TARJETAS DE PANEL (dashboard) ===================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
@media (min-width: 576px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
}
.stat-card__valor {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--celeste);
  margin: 0;
}
.stat-card__etiqueta {
  margin: 2px 0 0;
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
}

.op-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 576px) {
  .op-grid { grid-template-columns: repeat(2, 1fr); }
}

.op-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 128px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: box-shadow .15s ease, transform .1s ease;
}
.op-card:active { transform: scale(0.99); }
.op-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); border-color: var(--celeste); }

.op-card__icono {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--celeste-soft);
  color: var(--celeste);
  margin-bottom: 12px;
}
.op-card__titulo {
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.02rem;
  color: #16202b;
}
.op-card__detalle {
  display: block;
  margin-top: 2px;
  font-size: .82rem;
  color: var(--muted);
}

.op-card--destacada {
  background: var(--celeste);
  border-color: var(--celeste);
  color: #fff;
  grid-column: 1 / -1;
}
.op-card--destacada .op-card__icono { background: rgba(255,255,255,.18); color: #fff; }
.op-card--destacada .op-card__titulo { color: #fff; }
.op-card--destacada .op-card__detalle { color: rgba(255,255,255,.82); }
.op-card--destacada:hover { border-color: var(--azul-hover); box-shadow: 0 6px 18px rgba(0,59,113,.28); }

/* ===================== FOOTER ===================== */

.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.footer-brand__escudo {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}
.footer-brand__texto {
  font-size: .82rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.85);
}
.footer-brand__texto strong {
  display: block;
  color: #fff;
  font-size: .88rem;
}

.footer-copyright-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
@media (min-width: 768px) {
  .footer-copyright-inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ===================== ACCESIBILIDAD ===================== */
@media (prefers-reduced-motion: reduce) {
  .op-card, .app-header__icon { transition: none; }
}

@media (min-width: 992px) {
  .app-header__inner,
  .app-main .contenido { max-width: 900px; }
}

/* ===================== WIZARD (pasos, escaneo, fichas) ===================== */
.paso-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 18px;
}
.paso-stepper__paso {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #e3eaf1;
  color: var(--azul, #003b71);
  font-weight: 700; font-size: .85rem;
}
.paso-stepper__paso--activo { background: var(--celeste, #005bac); color: #fff; }
.paso-stepper__paso--hecho { background: #2e7d32; color: #fff; }
.paso-stepper__linea { flex: 1 1 auto; height: 2px; background: #d7dee6; }
.paso-stepper__etiqueta { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

.paso-card { display: none; }
.paso-card--activo { display: block; animation: paso-entrada .18s ease-out; }
@keyframes paso-entrada { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.btn-escaneo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: 2px dashed var(--celeste, #005bac);
  border-radius: 12px;
  background: #f2f7fc;
  color: var(--azul, #003b71);
  font-weight: 600;
  cursor: pointer;
}
.btn-escaneo:hover { background: #e6eff8; }
.btn-escaneo i { font-size: 1.15rem; }

.escaneo-video { width: 100%; border-radius: 12px; background: #000; display: none; }
.escaneo-video--activo { display: block; }

.ficha-alumno {
  border: 1px solid #d7dee6;
  border-left: 4px solid var(--celeste, #005bac);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: #fbfdff;
}
.ficha-alumno__titulo {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: #5a6b7c; margin-bottom: 6px;
}
.ficha-alumno__campo { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; font-size: .92rem; }
.ficha-alumno__campo dt { color: #5a6b7c; }
.ficha-alumno__campo dd { font-weight: 600; margin: 0; }

.alert-flow { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: .93rem; }
.alert-flow ul { margin: 6px 0 0 18px; padding: 0; }
.alert-flow--warning { background: #fff7e0; border: 1px solid #e8c96a; color: #6b5510; }
.alert-flow--danger  { background: #fdecea; border: 1px solid #f2b8b5; color: #8c1d18; }
.alert-flow--info    { background: #e8f1fb; border: 1px solid #b9d4f2; color: #14497b; }

.toast-exito {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: #2e7d32; color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  z-index: 1080;
  animation: toast-entrada .25s ease-out;
}
@keyframes toast-entrada { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.contacto-fila { display: flex; gap: 8px; margin-bottom: 8px; }
.contacto-fila input { flex: 1 1 auto; }
.contacto-fila__quitar { border: none; background: transparent; color: #b02a37; cursor: pointer; }

/* ===================== CUPO INDICADOR ===================== */
.cupo-indicador {
  --cupo-color: #9aa7b4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  font-weight: 600;
}
.cupo-indicador::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--cupo-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cupo-color) 25%, transparent);
}
.cupo-indicador--blanco   { --cupo-color: #ffffff; box-shadow: inset 0 0 0 1px #cfd6dd; }
.cupo-indicador--blanco::before { box-shadow: inset 0 0 0 1px #cfd6dd; }
.cupo-indicador--azul     { --cupo-color: #1565c0; }
.cupo-indicador--amarillo { --cupo-color: #f9a825; }
.cupo-indicador--naranja  { --cupo-color: #ef6c00; }
.cupo-indicador--rojo     { --cupo-color: #c62828; }
.cupo-indicador--negro    { --cupo-color: #212121; }

.card-periodo { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.card-periodo:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.10); }
