:root {
  --verde: #2e6e4e;
  --verde-osc: #1f4d36;
  --tinta: #1f2933;
  --gris: #6b7280;
  --gris-cl: #e5e7eb;
  --fondo: #f4f6f5;
  --rojo: #b23b3b;
  --amarillo: #b8860b;
  --radio: 10px;
  --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
  line-height: 1.5;
}

/* ---- Barra superior ---- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--verde); color: #fff;
  padding: .7rem 1.2rem;
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; color: inherit; text-decoration: none; }
.brand:hover { opacity: .9; }
.brand-logo { height: 1.9rem; width: auto; max-width: 140px; display: block; }
.logo-preview { height: 3rem; width: auto; max-width: 200px; vertical-align: middle; border: 1px solid var(--gris-cl); border-radius: 6px; padding: 2px; background: #fff; }
.logo-actual { display: flex; align-items: center; gap: .6rem; }
.topbar-right { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.userbox { font-size: .9rem; opacity: .9; }
.hamburger {
  cursor: pointer; font-size: 1.4rem; line-height: 1; user-select: none;
  padding: .1rem .5rem; border-radius: 6px;
}
.hamburger:hover { background: rgba(255,255,255,.15); }

/* ---- Menu lateral (drawer) ---- */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 40;
  background: #fff; box-shadow: 2px 0 12px rgba(0,0,0,.18);
  transform: translateX(-100%); transition: transform .22s ease;
  padding-top: 3.4rem;  /* deja hueco para la barra superior fija */
}
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
  display: block; padding: .8rem 1.3rem; color: var(--tinta); text-decoration: none;
  border-left: 3px solid transparent; font-weight: 600;
}
.sidebar nav a:hover { background: #eef2ef; border-left-color: var(--verde); color: var(--verde-osc); }
.backdrop {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.35);
  opacity: 0; visibility: hidden; transition: opacity .22s ease; cursor: pointer;
}
/* Abierto: cuando el checkbox esta marcado (con el boton). Al navegar, se cierra solo. */
.nav-toggle:checked ~ .sidebar { transform: translateX(0); }
.nav-toggle:checked ~ .backdrop { opacity: 1; visibility: visible; }

/* ---- Contenedor ---- */
.container { max-width: 1080px; margin: 1.5rem auto; padding: 0 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.actions { display: flex; gap: .5rem; }

/* ---- Tarjetas ---- */
.card { background: #fff; border: 1px solid var(--gris-cl); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1.2rem; }
.help { margin-top: 1.2rem; }
.help h3 { margin-top: 0; }
.empty { text-align: center; padding: 2.5rem 1rem; }

/* ---- Tabla ---- */
.tabla-wrap { overflow-x: auto; border-radius: var(--radio); box-shadow: var(--sombra); }
.tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radio); overflow: hidden; }
.tabla td:nth-child(2) { min-width: 8rem; }
.tabla th, .tabla td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--gris-cl); overflow-wrap: break-word; }
.tabla thead th { background: #eef2ef; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--gris); }
.tabla tbody tr:hover { background: #f9fbfa; }
.fila-click { cursor: pointer; }
.col-acciones { vertical-align: middle; }
/* Acciones agrupadas de 2 en 2 (rejilla de 2 columnas) */
.acciones { display: grid; grid-template-columns: repeat(2, minmax(4.5rem, 1fr)); gap: .35rem; align-items: stretch; }
.acciones form { margin: 0; }
.acciones > .btn, .acciones form, .acciones form .btn { width: 100%; box-sizing: border-box; }
.acciones .muted { display: flex; align-items: center; justify-content: center; }

/* ---- Formularios ---- */
.form label, .login-card label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .92rem; }
.form input, .login-card input, .form textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem;
  border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; font-weight: 400;
  font-family: inherit; box-sizing: border-box; resize: vertical;
}
.form input:focus, .login-card input:focus, .form textarea:focus { outline: 2px solid var(--verde); border-color: var(--verde); }
.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }
small.muted { font-weight: 400; }

/* ---- Botones ---- */
.btn {
  display: inline-block; cursor: pointer; text-decoration: none;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--gris-cl);
  background: #fff; color: var(--tinta); font-size: .92rem; font-family: inherit;
}
.btn:hover { background: #f1f5f3; }
.btn-primary { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-primary:hover { background: var(--verde-osc); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--rojo); border-color: #e7c9c9; }
.btn-danger:hover { background: #fbeaea; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }

/* ---- Avisos ---- */
.alert { padding: .7rem 1rem; border-radius: 8px; margin: .5rem 0 1rem; }
.alert-ok { background: #e7f4ec; color: var(--verde-osc); border: 1px solid #bfe0cc; }
.alert-error { background: #fbeaea; color: var(--rojo); border: 1px solid #eecccc; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; margin-top: 3rem; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-top: 0; font-size: 1.3rem; }
.login-card .btn { width: 100%; margin-top: .3rem; }

/* ---- Campamentos ---- */
.sec-title { margin: 1.8rem 0 .8rem; font-size: 1.2rem; }
.resumen-pagos { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.kpi {
  flex: 1 1 120px; background: #fff; border: 1px solid var(--gris-cl); border-radius: 10px;
  padding: .9rem 1rem; text-align: center; display: flex; flex-direction: column; gap: .2rem;
}
.kpi-num { font-size: 1.4rem; font-weight: 700; }
.kpi-lbl { font-size: .78rem; color: var(--gris); text-transform: uppercase; letter-spacing: .05em; }
.kpi-ok { border-color: #bfe3cc; background: #f2fbf5; }
.kpi-warn { border-color: #f5d9a8; background: #fff9ee; }
.inscribir-form { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.inscribir-form label { margin: 0; flex: 1 1 320px; }
.inscribir-form select { width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; }
.tabla-camp td { vertical-align: top; }
.fila-insc { background: #f8fafc; border: 1px solid var(--gris-cl); border-radius: 8px; padding: .7rem .8rem; margin-bottom: .4rem; }

/* ---- Inscritos como desplegables (click en el niño -> ver/editar) ---- */
.insc-lista { display: flex; flex-direction: column; gap: .5rem; }
.insc-item { background: #fff; border: 1px solid var(--gris-cl); border-radius: 10px; box-shadow: var(--sombra); }
.insc-item > summary {
  list-style: none; cursor: pointer; padding: .7rem 1rem; display: flex;
  align-items: center; gap: .7rem; flex-wrap: wrap;
}
.insc-item > summary::-webkit-details-marker { display: none; }
.insc-item > summary::before {
  content: '\25B8'; color: var(--gris); font-size: 1rem; display: inline-block;
  transition: transform .15s; flex: 0 0 auto;
}
.insc-item[open] > summary::before { transform: rotate(90deg); }
.insc-item > summary:hover { background: #f7faf8; border-radius: 10px; }
.insc-sum-nombre { font-weight: 700; }
.insc-sum-pago { margin-left: auto; }
.insc-detalle { padding: .2rem 1rem 1rem; border-top: 1px solid #f0f0f0; margin-top: .2rem; }
.insc-detalle .fila-insc { background: transparent; border: none; padding: .4rem 0 0; margin-bottom: .3rem; }
.insc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
.fila-insc label { font-size: .8rem; font-weight: 600; margin: .3rem 0 0; display: block; }
.fila-insc input, .fila-insc select, .fila-insc textarea {
  width: 100%; margin-top: .2rem; padding: .4rem .5rem; border: 1px solid #cbd5e1;
  border-radius: 6px; font-size: .9rem; font-family: inherit;
}
.insc-acciones { margin-top: .5rem; }
.check-inline { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.check-inline input { width: auto; }
.form-fila { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-fila label { flex: 1 1 160px; }

/* ---- Pie: entidades colaboradoras (en todas las paginas) ---- */
.colaboradores {
  margin-top: 2.5rem; padding: 1.6rem 1rem 2rem; background: #ececec;
  border-top: 1px solid #dcdcdc; text-align: center;
}
.colab-titulo {
  margin: 0 0 1.2rem; font-size: .8rem; letter-spacing: .12em;
  color: #8a8a8a; font-weight: 700; text-transform: uppercase;
}
.colab-logos {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2.5rem;
}
.colab-logo { height: 48px; width: auto; max-width: 220px; object-fit: contain; }
@media (max-width: 560px) { .colab-logos { gap: 1.5rem; } .colab-logo { height: 38px; } }

/* ---- Campo de contraseña con boton ver/ocultar ---- */
.input-pass { position: relative; display: block; }
.input-pass input { width: 100%; padding-right: 2.6rem; }
.ver-pass {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; font-size: 1.1rem;
  line-height: 1; padding: .2rem; opacity: .5; border-radius: 6px;
}
.ver-pass:hover { opacity: .8; }
.ver-pass.activo { opacity: 1; }

/* ---- Solicitud de ingreso (alta publica) ---- */
.solicitud-wrap { max-width: 820px; margin: 2rem auto; }
.solicitud-titulo { font-size: 2rem; margin: 0 0 .8rem; }
.solicitud-form { display: flex; flex-wrap: wrap; gap: 2rem; margin-top: 1.2rem; }
.solicitud-col { flex: 1 1 280px; }
.solicitud-intro { text-align: center; }
.solicitud-intro h2 { font-size: 1.4rem; margin: 0 0 1rem; }
.solicitud-logo { max-width: 180px; width: 60%; height: auto; }
.solicitud-logo-emoji { font-size: 5rem; }
.solicitud-nota { margin-top: 1rem; color: var(--gris); }

/* ---- Barra de filtros ---- */
.filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.2rem; }
.filtros label { display: block; font-weight: 600; font-size: .85rem; margin: 0; }
.filtros input, .filtros select { margin-top: .3rem; padding: .45rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px; font-size: .95rem; }
.filtros input[type=number] { width: 7rem; }
.filtro-acciones { display: flex; gap: .5rem; margin-left: auto; }

/* ---- Tarjeta de origen en inscripcion ---- */
.info-espera { margin-bottom: 1rem; background: #eef2ef; border-color: #cfe0d5; }
.form select { display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; background: #fff; }

/* ---- Fieldset de contacto ---- */
.fs-contacto { border: 1px solid var(--gris-cl); border-radius: 8px; padding: 1rem 1rem .3rem; margin: .3rem 0 1rem; }
.fs-contacto legend { font-weight: 700; font-size: .9rem; color: var(--verde-osc); padding: 0 .4rem; }
.req { color: var(--rojo); font-weight: 700; }
.col-contacto div { line-height: 1.35; }
.small { font-size: .82rem; }

/* ---- Etiqueta de seccion por edad ---- */
.badge-seccion {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .82rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge-castores { background: #fde9d6; color: #8a5b1a; border-color: #f0d3a8; }
.badge-manada   { background: #fde2e0; color: #9a342c; border-color: #f3c1bd; }
.badge-tropa    { background: #dcefe1; color: #1f6a3c; border-color: #b7ddc4; }
.badge-escultas { background: #dde7f7; color: #2a4d86; border-color: #bcd0ee; }
.badge-rovers   { background: #e7e0f3; color: #543b86; border-color: #cdbde9; }
.badge-espera   { background: #eef1f4; color: #5b6672; border-color: #d7dde3; font-style: italic; }

/* ---- Ficha del nino ---- */
.card + .card { margin-top: 1rem; }
.card h3 { margin-top: 0; }
.ficha-datos { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: center; }
.ficha-acciones { margin-left: auto; }
.ficha-acciones form { margin: 0; }
.form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.form-inline select { padding: .5rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px; }
.grid-tutor { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; align-items: end; }
.grid-tutor label { display: block; font-weight: 600; font-size: .85rem; margin: 0; }
.grid-tutor input, .grid-tutor select { width: 100%; margin-top: .3rem; padding: .5rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px; font-weight: 400; }
.tutor-card { border: 1px solid var(--gris-cl); border-radius: 8px; padding: .8rem 1rem; margin-bottom: .8rem; }
.tutor-cab { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.tutor-cab .tutor-quitar { margin-left: auto; }
.tutor-guardar { display: flex; align-items: end; }
.badge-hist { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-hist-alta { background: #e7f4ec; color: var(--verde-osc); }
.badge-hist-baja { background: #fbeaea; color: var(--rojo); }
.badge-hist-cambio_seccion { background: #dde7f7; color: #2a4d86; }
.badge-hist-cambio_contacto { background: #fdf0d6; color: #8a5b1a; }

/* ---- Calendario de actividades ---- */
.ronda-nav { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: .7rem 1rem; margin-bottom: 1rem; }
.ronda-nav .btn { margin-left: 0; }
.ronda-nav a:last-child { margin-left: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.cal-mes { padding: .6rem .7rem; }
.cal-mes-cab { font-weight: 700; margin-bottom: .4rem; }
.cal-tabla { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-tabla th { font-size: .7rem; color: var(--gris); font-weight: 600; padding: .2rem 0; text-align: center; }
.cal-tabla td { height: 2.6rem; vertical-align: top; border: 1px solid #eef2ef; padding: 1px 2px; }
.cal-click { cursor: pointer; }
.cal-click:hover { outline: 2px solid var(--verde); outline-offset: -2px; }
.cal-fuera { background: #fafbfa; }
.cal-dnum { display: inline-block; font-size: .78rem; color: var(--tinta); text-decoration: none; padding: 0 .15rem; border-radius: 4px; }
.cal-dnum:hover { background: var(--verde); color: #fff; }
.cal-fuera .cal-dnum { color: #b9c2bd; }
.cal-hoy .cal-dnum { background: #cdebd8; outline: 2px solid var(--verde); }
.cal-con-act { background: #f0f7f2; }
.cal-chip { display: block; font-size: .66rem; line-height: 1.25; margin-top: 1px; padding: 0 3px; border-radius: 3px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
/* Color por seccion (actividad de una sola seccion) */
.cal-chip.cal-sec-castores { background: #b9791f; }
.cal-chip.cal-sec-manada   { background: #b23b3b; }
.cal-chip.cal-sec-tropa    { background: #2e7d4f; }
.cal-chip.cal-sec-escultas { background: #3a5f9e; }
.cal-chip.cal-sec-rovers   { background: #6b4fa0; }
/* Actividad de grupo: azul oscuro; acampada: marron */
.cal-chip.cal-actividad { background: #16305c; }
.cal-chip.cal-acampada  { background: #6b4423; }
.cal-mas { font-size: .62rem; color: var(--gris); padding-left: 3px; }

/* ---- Imagenes de tarjeta sanitaria ---- */
.tarjeta-actual { margin: .4rem 0; }
.tarjeta-img { display: block; max-width: 100%; max-height: 160px; width: auto; border: 1px solid var(--gris-cl); border-radius: 8px; background: #fff; }
.chk-quitar { display: inline-flex; align-items: center; gap: .3rem; font-weight: 400; font-size: .85rem; margin-top: .3rem; }
.chk-quitar input { width: auto; display: inline; margin: 0; }

/* ---- Datos de salud: bloques Si/No + indicar ---- */
.salud-item { margin: 0 0 .9rem; }
.salud-tri { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-weight: 600; margin-bottom: .3rem; }
.salud-tri select { width: auto; min-width: 8rem; margin: 0; }
.lista-docs { list-style: none; padding: 0; margin: .3rem 0; }
.lista-docs li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .35rem 0; border-bottom: 1px solid var(--gris-cl); }
.lista-docs li:last-child { border-bottom: 0; }

/* ---- DECLARAMOS: puntos numerados con Si/No ---- */
.declara-punto { display: flex; gap: .8rem; padding: .8rem 0; border-bottom: 1px solid var(--gris-cl); }
.declara-punto:last-of-type { border-bottom: 0; }
.declara-num { flex: 0 0 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--verde-osc); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.declara-cuerpo { flex: 1; }
.declara-cuerpo p { margin: 0 0 .5rem; }
.declara-opts { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.radio-inline { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; }
.radio-inline input { width: auto; display: inline; margin: 0; }
.textos-legales article { margin: 0 0 1.4rem; }
.textos-legales h3 { margin: 0 0 .3rem; color: var(--verde-osc); }
.textos-legales p { white-space: pre-wrap; margin: 0; }

/* ---- Tarjetas de hijos (todas iguales) ---- */
.hijos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); grid-auto-rows: 1fr; gap: 1rem; align-items: stretch; }
/* Son celdas de grid: el gap ya las separa; se anula el margen de .card + .card
   que desalineaba la segunda tarjeta. */
.hijos-grid .hijo-card { margin: 0; }
.hijo-card { display: flex; flex-direction: column; }
.hijo-card h3 { margin: 0 0 .4rem; }
.hijo-acciones { margin-top: auto; padding-top: .6rem; flex-wrap: wrap; }

/* ---- Boton WhatsApp ---- */
.wa-btn { background: #25d366; border-color: #25d366; color: #fff; }
.wa-btn:hover { background: #1da851; border-color: #1da851; }

/* ---- Varios ---- */
.muted { color: var(--gris); }
code { background: #eef2ef; padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }

/* ---- Consentimientos ---- */
.consent-texto { border: 1px solid var(--gris-cl); border-radius: 8px; padding: .5rem .8rem; margin-bottom: .5rem; }
.consent-texto summary { cursor: pointer; }
.consent-parrafo { margin: .6rem 0 .2rem; line-height: 1.5; text-align: justify; }

.badge-consent-sin { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: #eee; color: #777; }
.tabla-consent td, .tabla-consent th { vertical-align: middle; }
.leyenda span { margin-right: .5rem; }
.badge-consent-old { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: #fdecc8; color: #9a6a00; font-weight: 600; }

/* ---- Navegación entre niños (ficha) ---- */
.nav-ninos { display: inline-flex; gap: .3rem; margin-right: .4rem; }
.btn.disabled { opacity: .4; pointer-events: none; cursor: default; }

/* ---- Pestañas de datos del niño ---- */
.tabs-nino { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 1.2rem; border-bottom: 2px solid var(--gris-cl); }
.tabs-nino a { padding: .5rem .9rem; border-radius: 8px 8px 0 0; color: var(--gris); text-decoration: none; font-weight: 600; font-size: .95rem; border: 1px solid transparent; border-bottom: none; margin-bottom: -2px; }
.tabs-nino a:hover { background: #eef2ef; color: var(--verde, #2f6b3f); }
.tabs-nino a.activa { background: #fff; color: var(--verde, #2f6b3f); border-color: var(--gris-cl); border-bottom: 2px solid #fff; }

/* ---- Cabeceras de tabla ordenables ---- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--verde); }
th.sortable::after { content: '\2195'; opacity: .35; margin-left: .3rem; font-size: .85em; }
th.sortable.asc::after { content: '\2191'; opacity: 1; }
th.sortable.desc::after { content: '\2193'; opacity: 1; }

/* Las tarjetas de mes son celdas de grid: el row-gap ya las separa, así que
   se anula el margen de .card + .card que las desalineaba. Con align-items:stretch
   todas las tarjetas de una misma fila tienen la misma altura. */
.cal-grid { align-items: stretch; }
.cal-grid .cal-mes { margin: 0; display: flex; flex-direction: column; justify-content: center; }

/* ---- Lista de padres/tutores: hijos apilados con ajuste de texto ---- */
.col-hijos { min-width: 200px; }
.hijos-lista { display: flex; flex-direction: column; gap: .25rem; align-items: flex-start; }
.hijo-chip { display: inline-block; padding: .15rem .55rem; border-radius: 10px; font-size: .82rem;
  font-weight: 600; border: 1px solid transparent; text-decoration: none; white-space: normal;
  line-height: 1.2; max-width: 100%; }

/* =====================================================================
   RESPONSIVE (móvil): cabecera y filtros apilados; la tabla de niños se
   convierte en tarjetas (una por niño) con etiqueta a la izquierda.
   ===================================================================== */
@media (max-width: 640px) {
  .container { padding-left: .8rem; padding-right: .8rem; }

  /* Calendario: los controles (título, navegación de ronda y filtro) quedan
     fijos bajo la barra superior; solo scrollea la rejilla de meses. */
  .cal-sticky {
    position: sticky; top: var(--topbar-h, 56px); z-index: 40;
    background: var(--fondo); margin: 0 -.8rem; padding: .4rem .8rem .3rem;
    box-shadow: 0 8px 8px -8px rgba(0, 0, 0, .3);
  }
  /* Compactar los controles para dejar mas sitio al calendario */
  .cal-sticky .page-head { margin-bottom: .4rem; gap: .4rem; }
  .cal-sticky .page-head h1 { font-size: 1.15rem; }
  .cal-sticky .actions { gap: .35rem; }
  .cal-sticky .actions .btn { flex: 1 1 auto; padding: .35rem .5rem; font-size: .82rem; }
  /* Navegacion de ronda en una fila compacta; se ocultan el rango y el recuento */
  .cal-sticky .ronda-nav { padding: .4rem .6rem; gap: .5rem; margin-bottom: .4rem; }
  .cal-sticky .ronda-nav .muted { display: none; }
  .cal-sticky .ronda-nav b { font-size: .92rem; }
  .cal-sticky .ronda-nav .btn { padding: .3rem .5rem; font-size: .8rem; }
  /* Filtro compacto: etiqueta y desplegable + boton en una fila */
  .cal-sticky .filtros { padding: .45rem .6rem; gap: .5rem; margin-bottom: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .cal-sticky .filtros .filtro-campo { flex: 1 1 60%; }
  .cal-sticky .filtros label { font-size: .8rem; }
  .cal-sticky .filtros .filtro-acciones { flex: 0 0 auto; margin-left: auto; }
  .cal-sticky .filtros .filtro-acciones .btn { padding: .4rem .7rem; }

  /* Barra superior: dar sitio a la marca (el nombre del grupo no se parte) */
  .brand { font-size: .98rem; }
  .brand-logo { height: 1.6rem; }
  .userbox-email { display: none; }        /* en móvil basta con el rol */

  /* Cabecera de página y botones */
  .page-head { flex-direction: column; align-items: stretch; gap: .6rem; }
  .page-head .actions { flex-wrap: wrap; }
  .page-head .actions .btn { flex: 1 1 auto; text-align: center; }

  /* Filtros a ancho completo */
  .filtros { flex-direction: column; align-items: stretch; gap: .7rem; }
  .filtros .filtro-campo { width: 100%; }
  .filtros input, .filtros select { width: 100%; box-sizing: border-box; }
  .filtro-acciones { margin-left: 0; }
  .filtro-acciones .btn { flex: 1 1 auto; text-align: center; }

  /* Tablas de listado -> tarjetas apiladas. La clase la llevan las tablas
     "una fila = una ficha"; las celdas se etiquetan solas (JS en base.html). */
  .tabla-cards, .tabla-cards tbody, .tabla-cards tr, .tabla-cards td { display: block; width: 100%; }
  .tabla-cards thead, .tabla-cards tfoot { display: none; }  /* el total ya se muestra en el encabezado */
  .tabla-cards tr {
    background: #fff; border: 1px solid var(--gris-cl); border-radius: var(--radio);
    box-shadow: var(--sombra); margin-bottom: .8rem; padding: .3rem .1rem; overflow: hidden;
  }
  .tabla-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    text-align: right; padding: .55rem .9rem; border: none;
    border-bottom: 1px solid #f0f0f0; min-width: 0; word-break: break-word;
  }
  .tabla-cards td::before {
    content: attr(data-label); font-weight: 600; color: var(--gris); text-align: left;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; flex: 0 0 auto;
  }
  .tabla-cards td:empty { display: none; }           /* celdas vacías no ocupan */
  .tabla-cards td.col-num { display: none; }          /* el número de fila no aporta en móvil */
  .tabla-cards td.col-nombre { font-weight: 700; font-size: 1.02rem; }
  /* Columna de acciones: a lo ancho, sin etiqueta */
  .tabla-cards td.col-acciones,
  .tabla-cards td:has(.acciones),
  .tabla-cards td:has(.btn),
  .tabla-cards td:has(form) {
    display: block; text-align: left; border-bottom: none;
  }
  .tabla-cards td.col-acciones::before,
  .tabla-cards td:has(.acciones)::before,
  .tabla-cards td:has(.btn)::before,
  .tabla-cards td:has(form)::before { display: none; }
  .tabla-cards td .acciones { grid-template-columns: repeat(2, 1fr); }

  /* Las demás tablas (matrices, hojas de asistencia) siguen con scroll horizontal */
  .tabla-wrap { overflow-x: auto; }
}

/* ===================================================================== */
/*  CMS: editor enriquecido y panel                                       */
/* ===================================================================== */
.ed-toolbar { display: flex; flex-wrap: wrap; gap: .25rem; padding: .5rem; background: #eef2ef;
  border: 1px solid var(--gris-cl); border-bottom: none; border-radius: 8px 8px 0 0; align-items: center; }
.ed-btn { border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; padding: .3rem .55rem;
  cursor: pointer; font-size: .9rem; line-height: 1; min-width: 2rem; }
.ed-btn:hover { background: #f1f5f3; }
.ed-toolbar select { width: auto; display: inline-block; margin: 0; padding: .25rem .5rem; border: 1px solid #cbd5e1; border-radius: 6px; height: 2rem; background: #fff; }
.ed-toolbar input[type=color] { width: 2.4rem; display: inline-block; margin: 0; padding: 2px; border: 1px solid #cbd5e1; border-radius: 6px; height: 2rem; }
.ed-sep { width: 1px; height: 1.4rem; background: #cbd5e1; margin: 0 .2rem; }
#editor { min-height: 320px; border: 1px solid var(--gris-cl); border-radius: 0 0 8px 8px;
  padding: 1rem 1.1rem; background: #fff; line-height: 1.6; overflow-wrap: break-word; }
#editor:focus { outline: 2px solid var(--verde); }
/* El editor refleja el MISMO aspecto que la web publica (WYSIWYG). */
#editor { font-size: 1.02rem; line-height: 1.7; color: #1a1a1a; }
#editor h1 { font-size: 2rem; color: var(--verde-osc, #1c6b34); margin: 1rem 0 .6rem; }
#editor h2 { font-size: 1.5rem; margin: 1.2rem 0 .5rem; }
#editor h3 { font-size: 1.2rem; margin: 1rem 0 .4rem; }
#editor p { margin: .7rem 0; }
#editor ul, #editor ol { margin: .6rem 0 .6rem 1.6rem; }
#editor img { max-width: 100%; height: auto; border-radius: 8px; }
#editor blockquote { border-left: 4px solid var(--verde); margin: .8rem 0; padding: .4rem 1rem; color: #555; background: #f6f8f7; }
#editor a { color: var(--verde-osc, #1c6b34); }
#editor .web-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin: 1rem 0; }
#editor .web-figure { margin: 0 0 1rem; text-align: center; }
#editor .web-figure img { width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,.16); }
#editor .web-figure figcaption { font-size: .9rem; color: #555; font-style: italic; margin-top: .35rem; }
#editor .web-boton { display: inline-block; background: #4a9d5b; color: #fff; padding: .6rem 1.2rem; border-radius: 8px; text-decoration: none; font-weight: 700; }
#editor .doc-list { list-style: none; margin: 1rem 0; padding: 0; }
#editor .doc-list a { display: inline-block; padding: .5rem .8rem; background: #f2f6f3; border: 1px solid #d8e4dc; border-radius: 8px; text-decoration: none; font-weight: 600; }
.ed-btn.activo { background: var(--verde); color: #fff; }
.ed-html { width: 100%; min-height: 340px; border: 1px solid var(--gris-cl); border-radius: 0 0 8px 8px;
  padding: 1rem; font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: .85rem;
  line-height: 1.5; resize: vertical; box-sizing: border-box; }
/* Columnas: mismo grid que la web, con un contorno tenue para verlas y
   una minima altura para poder pinchar dentro y colocar el cursor. */
#editor .web-cols { display: grid; gap: 1.4rem; margin: 1.2rem 0; align-items: start; }
#editor .web-cols.cols-2 { grid-template-columns: 1fr 1fr; }
#editor .web-cols.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
#editor .web-col { min-width: 0; min-height: 2.4rem; outline: 1px dashed #cdddd3;
  outline-offset: 3px; border-radius: 4px; }
@media (max-width: 720px) {
  #editor .web-cols.cols-2, #editor .web-cols.cols-3 { grid-template-columns: 1fr; }
}
.ed-media-panel { display: none; border: 1px solid var(--gris-cl); border-radius: 8px; padding: .7rem;
  margin-top: .5rem; background: #fafbfa; max-height: 320px; overflow-y: auto; }
.ed-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .5rem; }
.ed-media-grid a { display: block; text-align: center; text-decoration: none; color: var(--tinta); font-size: .75rem; }
.ed-media-grid img { width: 100%; height: 70px; object-fit: cover; border-radius: 6px; border: 1px solid var(--gris-cl); }
.ed-media-doc { display: inline-block; padding: .4rem .6rem; border: 1px solid var(--gris-cl); border-radius: 6px; background: #fff; }
.cms-kpis { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.cms-kpis .kpi { cursor: default; }
.medio-card { display: flex; gap: .8rem; align-items: center; }
.medio-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--gris-cl); background: #fff; }
.medio-url { font-family: monospace; font-size: .8rem; background: #f2f4f3; padding: .15rem .4rem; border-radius: 5px; word-break: break-all; }
.fondo-field { border: 1px solid var(--gris-cl); border-radius: 10px; padding: .8rem 1rem; margin: .3rem 0; }
.fondo-field legend { font-weight: 700; padding: 0 .4rem; }
.fondo-field .check-inline { display: block; margin: .25rem 0; }
.fondo-propia { margin: .5rem 0 .2rem; padding-left: 1.4rem; }
.fondo-picker { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .4rem; }
.fondo-picker select { max-width: 320px; }
.fondo-prev { margin-top: .5rem; }
.fondo-prev img { max-width: 260px; max-height: 150px; border-radius: 8px; border: 1px solid var(--gris-cl); object-fit: cover; }
.apar-colores { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: .6rem 0; }
.apar-colores label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; }
.apar-colores input[type=color] { width: 56px; height: 38px; padding: 0; border: 1px solid var(--gris-cl); border-radius: 8px; cursor: pointer; }
.apar-hex { font-family: monospace; font-size: .8rem; color: #666; }
.apar-colabs { display: flex; flex-direction: column; gap: .7rem; }
.apar-colab { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; border: 1px solid var(--gris-cl); border-radius: 10px; padding: .5rem .7rem; }
.apar-colab img { height: 44px; width: auto; object-fit: contain; background: #fff; border-radius: 6px; }
.apar-colab-form { display: flex; gap: .4rem; flex: 1 1 260px; align-items: center; }
.apar-colab-form input { flex: 1; }

/* ===================================================================== */
/*  Web publica (generada por el CMS)                                     */
/* ===================================================================== */
.web-body { background: #fff; display: flex; flex-direction: column; min-height: 100vh; }
.web-body--foto { background-color: #2b3b2e; background-position: center top; background-size: cover;
  background-attachment: fixed; background-repeat: no-repeat; }
.web-header { background: var(--verde); color: #fff; padding: .6rem 1rem; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.web-header-in { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.web-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; }
.web-brand img { height: 2.2rem; width: auto; }
.web-hamburger { display: none; margin-left: auto; font-size: 1.7rem; line-height: 1; color: #fff; cursor: pointer; padding: .1rem .5rem; user-select: none; }
.web-sub-plus { display: none; }
.web-nav { margin-left: auto; display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.web-nav > .web-nav-item { position: relative; }
.web-nav a { color: #fff; text-decoration: none; padding: .5rem .8rem; border-radius: 8px; display: inline-block; font-weight: 600; }
.web-nav a:hover { background: rgba(255,255,255,.15); }
.web-submenu { display: none; position: absolute; top: 100%; left: 0; background: #fff; min-width: 190px;
  border-radius: 0 0 10px 10px; box-shadow: 0 8px 20px rgba(0,0,0,.18); padding: .3rem 0; z-index: 60; }
.web-nav-item:hover .web-submenu { display: block; }
.web-submenu a { color: var(--tinta); display: block; padding: .55rem 1rem; border-radius: 0; font-weight: 500; }
.web-submenu a:hover { background: #eef2ef; }
.web-main { max-width: 960px; margin: 2.4rem auto; padding: 0 1.1rem; width: 100%; flex: 1 0 auto; }
.web-content { line-height: 1.7; font-size: 1.02rem; color: #1a1a1a;
  background: rgba(255,255,255,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: 1.6rem 1.8rem; border-radius: 14px; box-shadow: 0 6px 26px rgba(0,0,0,.28); }
.web-content h1 { font-size: 2rem; color: var(--verde-osc, #1c6b34); margin: 1rem 0 .6rem; }
.web-content h2 { font-size: 1.5rem; margin: 1.2rem 0 .5rem; }
.web-content h3 { font-size: 1.2rem; margin: 1rem 0 .4rem; }
.web-content p { margin: .7rem 0; }
.web-content ul, .web-content ol { margin: .6rem 0 .6rem 1.6rem; }
.web-content img { max-width: 100%; height: auto; border-radius: 8px; }
.web-content a { color: var(--verde-osc, #1c6b34); }
.web-content blockquote { border-left: 4px solid var(--verde); margin: .8rem 0; padding: .4rem 1rem; background: #f6f8f7; color: #555; }
.web-content .doc-list { list-style: none; margin: 1rem 0; padding: 0; }
.web-content .doc-list li { margin: .35rem 0; }
.web-content .doc-list a { display: inline-block; padding: .55rem .8rem; background: #f2f6f3; border: 1px solid #d8e4dc; border-radius: 8px; text-decoration: none; font-weight: 600; }
.web-content .doc-list a:hover { background: #e6efe9; }
.web-content .web-boton { display: inline-block; background: #4a9d5b; color: #fff; padding: .7rem 1.4rem; border-radius: 8px; text-decoration: none; font-weight: 700; }
.web-content .web-boton:hover { background: #3d8a4d; }
/* Catalogo de la tienda */
.web-content .tienda-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.4rem; margin: 1.4rem 0; }
.web-content .tienda-item { border: 1px solid #e2e2e2; border-radius: 12px; padding: 1rem; background: #fff; display: flex; flex-direction: column; box-shadow: 0 1px 5px rgba(0,0,0,.08); }
.web-content .tienda-item img { width: 100%; height: 230px; object-fit: contain; border-radius: 8px; background: #f6f7f6; }
.web-content .tienda-item h3 { margin: .7rem 0 .1rem; font-size: 1.05rem; }
.web-content .tienda-precio { font-size: 1.35rem; font-weight: 800; color: #2e7d32; margin: .2rem 0 .4rem; }
.web-content .tienda-desc { font-size: .9rem; color: #444; margin: .2rem 0; }
.web-content .tienda-tallas { font-size: .82rem; color: #666; margin: .3rem 0; }
.web-content .tienda-estado { font-size: .82rem; font-weight: 700; color: #2e7d32; margin: .2rem 0 .6rem; }
.web-content .tienda-estado.agotado { color: #c62828; }
.web-content .tienda-item .web-boton { margin-top: auto; text-align: center; padding: .55rem 1rem; }
.web-content .tienda-item .web-boton.deshab { background: #bbb; pointer-events: none; }
.web-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 1rem 0; }
.web-gallery img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* Maquetacion a columnas (estilo revista) + fotos con pie */
.web-cols { display: grid; gap: 1.4rem; margin: 1.2rem 0; align-items: start; }
.web-cols.cols-2 { grid-template-columns: 1fr 1fr; }
.web-cols.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.web-cols .web-col { min-width: 0; }
.web-figure { margin: 0 0 1rem; text-align: center; }
.web-figure img { width: 100%; height: auto; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.web-figure figcaption { font-size: .9rem; color: #555; margin-top: .35rem; font-style: italic; }
@media (max-width: 720px) {
  .web-cols.cols-2, .web-cols.cols-3 { grid-template-columns: 1fr; }
}
.web-aviso { max-width: 960px; margin: 0 auto 1rem; padding: .8rem 1.1rem; border-radius: 10px; font-weight: 600; }
.web-aviso--ok { background: #e6f4ea; color: #1c6b34; border: 1px solid #b7e0c2; }
.web-aviso--error { background: #fdecea; color: #b3261e; border: 1px solid #f5c6c2; }
/* Formulario de contacto */
.web-content .web-form label { display: block; font-weight: 600; margin: .7rem 0 .2rem; }
.web-content .web-form input, .web-content .web-form textarea { width: 100%; padding: .6rem .7rem; border: 1px solid #ccc; border-radius: 8px; font: inherit; box-sizing: border-box; background: #fff; }
.web-content .web-form textarea { min-height: 160px; resize: vertical; }
.web-content .web-form .req { color: #c62828; }
.web-content .web-form button { margin-top: .9rem; cursor: pointer; border: 0; }
.web-footer { background: #ececec; color: #666; text-align: center; padding: .8rem 1rem; margin-top: 1.6rem; border-top: 1px solid #dcdcdc; flex-shrink: 0; }
/* Rejilla de equipo (retratos) responsive: 3 por fila en escritorio */
.web-content .web-equipo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1.2rem 0; }
.web-content .web-equipo .web-figure { margin: 0; }

@media (max-width: 720px) {
  .web-header-in { flex-wrap: wrap; }
  .web-brand { flex: 1 1 auto; }
  .web-hamburger { display: block; flex: 0 0 auto; }
  .web-nav { display: none; flex-basis: 100%; width: 100%; flex-direction: column; gap: .1rem; margin: .4rem 0 0; }
  .web-nav-toggle:checked ~ .web-nav { display: flex; }
  .web-nav { align-items: stretch; text-align: left; }
  .web-nav > .web-nav-item { position: static; display: flex; flex-wrap: wrap; align-items: center; border-top: 1px solid rgba(255,255,255,.12); }
  .web-nav a { flex: 1 1 auto; width: auto; text-align: left; }
  /* Boton + para desplegar cada submenu (acordeon) */
  .web-sub-plus { display: inline-flex; align-items: center; justify-content: center;
    width: 2.2rem; height: 2.2rem; margin-right: .3rem; flex: 0 0 auto; cursor: pointer;
    color: #fff; background: rgba(255,255,255,.15); border-radius: 6px; font-size: 1.3rem;
    line-height: 1; user-select: none; transition: transform .15s ease; }
  .web-submenu { position: static; box-shadow: none; display: none; flex-basis: 100%; width: 100%;
    padding-left: 1rem; background: rgba(0,0,0,.12); min-width: 0; border-radius: 0; }
  .web-sub-toggle:checked ~ .web-submenu { display: block; }
  .web-sub-toggle:checked ~ .web-sub-plus { transform: rotate(45deg); }
  .web-submenu a { color: rgba(255,255,255,.92); }
  .web-body { background-attachment: scroll; }
  .web-main { margin: 1rem auto; }
  .web-content { padding: 1.1rem 1.1rem; }
  .web-content .web-equipo { grid-template-columns: 1fr 1fr; }
}
