/* ============================================================
   CENSO VETERINARIO – EASUR – Premium UI / Flutter Material 3
   premium.css — carga DESPUÉS de styles.css
   ============================================================ */

/* ── Material 3 Token System ─────────────────────────────── */
:root {
  /* Primary – Forest Green */
  --m3-primary:           #1B5E20;
  --m3-primary-600:       #2E7D32;
  --m3-primary-400:       #43A047;
  --m3-primary-cnt:       #C8E6C9;
  --m3-primary-cnt-light: #E8F5E9;
  --m3-on-primary:        #FFFFFF;

  /* Secondary – Teal */
  --m3-secondary:         #00695C;
  --m3-secondary-cnt:     #B2DFDB;

  /* Tertiary – Amber accent */
  --m3-tertiary:          #E65100;
  --m3-tertiary-cnt:      #FFE0B2;

  /* Surface tokens */
  --m3-bg:           #F1F5F1;
  --m3-surface:      #FFFFFF;
  --m3-surface-1:    #F7FBF7;
  --m3-surface-2:    #EFF5EF;
  --m3-surface-var:  #DCE8DC;
  --m3-outline:      #D4DAD4;
  --m3-outline-var:  #E8EEE8;

  /* Text */
  --m3-on-bg:        #1A1C1A;
  --m3-on-surface:   #1A1C1A;
  --m3-on-surface-v: #42484A;
  --m3-dim:          #717970;

  /* Elevación / sombras M3 */
  --elev-1: 0 1px 3px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.06);
  --elev-2: 0 3px 8px rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.06);
  --elev-3: 0 6px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.07);
  --elev-4: 0 12px 28px rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.08);

  /* Radio M3 */
  --r-xs:  8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Bottom nav height */
  --bn-h: 68px;

  /* Transición M3 */
  --ease-std: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 200ms;
  --dur-med:  300ms;
  --dur-slow: 450ms;
}

/* ── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--m3-bg);
  color: var(--m3-on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, .header-titulo, .login-titulo,
.stat-numero, .formulario-card h2, .seccion-form h3,
.splash-titulo, .splash-brand-nombre {
  font-family: 'Poppins', system-ui, sans-serif;
}

/* ── APP SHELL — padding-bottom para bottom nav ─────────── */
#app {
  padding-bottom: var(--bn-h);
}

/* ── HEADER — Flutter AppBar ─────────────────────────────── */
.header {
  background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 60%, #1565C0 100%);
  padding: 0 16px;
  height: 60px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(27,94,32,0.35);
}

.header-logo {
  height: 38px;
  width: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  padding: 3px;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3), 0 2px 8px rgba(0,0,0,0.2);
  object-fit: contain;
  flex-shrink: 0;
}

.header-centro {
  grid-column: 2;
  text-align: center;
}
.header-titulo {
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: block;
  color: white;
  line-height: 1.2;
}
.header-subtitulo {
  font-size: 11px;
  opacity: 0.8;
  display: block;
  font-weight: 400;
  color: white;
}

.header-usuario {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  justify-self: end;
}
#nombre-usuario {
  font-size: 10.5px;
  color: rgba(255,255,255,0.85);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-rol {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--r-full);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.badge-rol-admin        { background: #FFD600; color: #1A1200; }
.badge-rol-censador     { background: rgba(255,255,255,0.18); color: white; border: 1px solid rgba(255,255,255,0.3); }
.badge-rol-investigador { background: #7C3AED; color: white; }

.btn-salir {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 5px 12px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-std);
  touch-action: manipulation;
}
.btn-salir:hover, .btn-salir:active {
  background: rgba(255,255,255,0.26);
}

/* ── BIENVENIDA BANNER ───────────────────────────────────── */
.bienvenida-banner {
  background: linear-gradient(90deg, var(--m3-primary-cnt-light), #E3F2FD);
  color: var(--m3-primary);
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--m3-primary-cnt);
  letter-spacing: 0.1px;
}

/* ── BOTTOM NAVIGATION BAR — Flutter style ───────────────── */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 300;
  background: var(--m3-surface);
  height: var(--bn-h);
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--m3-outline-var);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.10);
  padding: 0;
  overflow: visible;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px 8px;
  background: none;
  border: none;
  border-bottom: none;
  color: var(--m3-dim);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: color var(--dur-fast) var(--ease-std);
}

/* Pill indicator behind icon */
.tab::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 64px;
  height: 32px;
  background: var(--m3-primary-cnt);
  border-radius: var(--r-full);
  transition: transform var(--dur-med) var(--ease-std),
              opacity var(--dur-med) var(--ease-std);
  opacity: 0;
  z-index: 0;
}

.tab.activo {
  color: var(--m3-primary);
  border-bottom: none;
  background: none;
}
.tab.activo::before {
  transform: translateX(-50%) scaleX(1);
  opacity: 1;
}
.tab.activo .fas {
  font-size: 20px;
}

.tab .fas {
  font-size: 18px;
  position: relative;
  z-index: 1;
  transition: font-size var(--dur-fast) var(--ease-std);
}
.tab span.tab-label {
  position: relative;
  z-index: 1;
  font-size: 10px;
  line-height: 1;
  font-weight: 600;
}

/* Badge en tab */
.tab-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  background: #B3261E;
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--r-full);
  min-width: 16px;
  text-align: center;
  z-index: 2;
}

/* Admin tab — gold */
.tab-admin       { color: #92700A; }
.tab-admin::before { background: #FFF3C4; }
.tab-admin.activo { color: #6B5200; }

/* Alerta tab */
.tab-alerta       { color: #B3261E; }
.tab-alerta::before { background: #FCECEA; }
.tab-alerta.activo { color: #B3261E; }

/* ── CONTENT AREA ────────────────────────────────────────── */
.tab-contenido {
  padding: 16px 14px 20px;
  max-width: 640px;
  margin: 0 auto;
  animation: pm-slideUp var(--dur-med) var(--ease-std) both;
}

@keyframes pm-slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── FORMULARIO CARD — Material 3 ────────────────────────── */
.formulario-card {
  background: var(--m3-surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--elev-1);
  border: 1px solid var(--m3-outline-var);
  animation: pm-slideUp var(--dur-med) var(--ease-std) both;
}
.formulario-card h2 {
  font-family: 'Poppins', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--m3-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--m3-primary-cnt-light);
}

.seccion-form {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--m3-outline-var);
}
.seccion-form h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 11.5px;
  color: var(--m3-primary-600);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
  font-weight: 700;
}
.seccion-form h3 .fas {
  background: var(--m3-primary-cnt-light);
  color: var(--m3-primary);
  width: 24px; height: 24px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

/* Inputs M3 — filled style */
.campo input,
.campo select,
.campo textarea {
  padding: 11px 14px;
  border: 1.5px solid var(--m3-outline);
  border-radius: var(--r-sm);
  font-size: 14.5px;
  background: var(--m3-surface-1);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  color: var(--m3-on-surface);
}
.campo input:focus,
.campo select:focus,
.campo textarea:focus {
  outline: none;
  border-color: var(--m3-primary-400);
  box-shadow: 0 0 0 3px rgba(67,160,71,0.14);
  background: white;
}

/* ── BUTTONS — Material 3 ────────────────────────────────── */
.btn-primario {
  background: var(--m3-primary);
  color: white;
  border: none;
  border-radius: var(--r-full);
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.1px;
  box-shadow: 0 2px 8px rgba(27,94,32,0.3);
  transition: background var(--dur-fast), box-shadow var(--dur-fast),
              transform var(--dur-fast);
  touch-action: manipulation;
}
.btn-primario:hover {
  background: #1A5526;
  box-shadow: 0 4px 14px rgba(27,94,32,0.4);
  transform: translateY(-1px);
}
.btn-primario:active { transform: translateY(0); box-shadow: none; }

.btn-secundario {
  background: transparent;
  color: var(--m3-primary);
  border: 1.5px solid var(--m3-primary-400);
  border-radius: var(--r-full);
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 600;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.btn-secundario:hover {
  background: var(--m3-primary-cnt-light);
  border-color: var(--m3-primary);
}

.btn-azul {
  background: #1565C0 !important;
  color: white !important;
  border-color: transparent !important;
  border-radius: var(--r-full) !important;
}
.btn-azul:hover { background: #0D47A1 !important; }

.btn-rojo {
  background: #B3261E !important;
  color: white !important;
  border-color: transparent !important;
  border-radius: var(--r-full) !important;
}
.btn-rojo:hover { background: #8B0000 !important; }

/* ── ANIMAL CARDS — M3 Elevated ─────────────────────────── */
.animal-card {
  background: var(--m3-surface);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--elev-2);
  border: none;
  border-left: 4px solid var(--m3-primary-400);
  animation: pm-slideUp var(--dur-med) var(--ease-std) both;
  transition: box-shadow var(--dur-fast), transform var(--dur-fast);
}
.animal-card:hover {
  box-shadow: var(--elev-3);
  transform: translateY(-2px);
}
.animal-card.felino { border-left-color: #F97316; }

.card-titulo-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.card-titulo-row strong {
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--m3-on-surface);
  line-height: 1.3;
}

/* Card acciones — pill buttons */
.card-acciones {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn-ficha, .btn-editar, .btn-eliminar-card, .btn-eliminar {
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-width: 1.5px;
  touch-action: manipulation;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.btn-ficha {
  background: transparent;
  border: 1.5px solid #90CAF9;
  color: #1565C0;
}
.btn-ficha:hover, .btn-ficha:active {
  background: #E3F2FD;
}
.btn-editar {
  background: transparent;
  border: 1.5px solid var(--m3-primary-cnt);
  color: var(--m3-primary);
}
.btn-editar:hover, .btn-editar:active {
  background: var(--m3-primary-cnt-light);
}
.btn-eliminar-card, .btn-eliminar {
  background: transparent;
  border: 1.5px solid #FFCDD2;
  color: #B3261E;
}
.btn-eliminar-card:hover, .btn-eliminar:hover,
.btn-eliminar-card:active, .btn-eliminar:active {
  background: #FFEBEE;
}

/* ── STAT CARDS — Gradient Hero ──────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media(min-width: 480px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }

.stat-card {
  background: var(--m3-surface);
  border-radius: var(--r-md);
  padding: 18px 14px;
  text-align: center;
  box-shadow: var(--elev-2);
  border: none;
  border-top: none;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--elev-4); }

.stat-total::before         { background: var(--m3-primary); }
.stat-caninos::before       { background: #1565C0; }
.stat-felinos::before       { background: #E65100; }
.stat-vacunados::before     { background: #7C3AED; }
.stat-esterilizados::before { background: #0097A7; }
.stat-desparasitados::before{ background: var(--m3-secondary); }
.stat-pendientes::before    { background: #E65100; }
.stat-solicitudes::before   { background: #6A1B9A; }
.stat-reportes::before      { background: #B3261E; }

.stat-icono {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 2px;
}
.stat-total         .stat-icono { background: var(--m3-primary-cnt-light); color: var(--m3-primary); }
.stat-caninos       .stat-icono { background: #E3F2FD; color: #1565C0; }
.stat-felinos       .stat-icono { background: #FFF3E0; color: #E65100; }
.stat-vacunados     .stat-icono { background: #F3E5F5; color: #7C3AED; }
.stat-esterilizados .stat-icono { background: #E0F7FA; color: #0097A7; }
.stat-desparasitados .stat-icono { background: var(--m3-secondary-cnt); color: var(--m3-secondary); }
.stat-pendientes    .stat-icono { background: #FFF3E0; color: #E65100; }
.stat-solicitudes   .stat-icono { background: #F3E5F5; color: #6A1B9A; }
.stat-reportes      .stat-icono { background: #FFEBEE; color: #B3261E; }

.stat-numero {
  font-family: 'Poppins', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--m3-on-surface);
  line-height: 1;
  letter-spacing: -1.5px;
}
.stat-label {
  font-size: 11.5px;
  color: var(--m3-dim);
  font-weight: 500;
  line-height: 1.3;
}
.stat-sublabel {
  font-size: 11px;
  color: #9CA3AF;
  margin-top: 1px;
}

/* ── STATS HEADER ─────────────────────────────────────────── */
.stats-inst-header {
  background: linear-gradient(135deg, var(--m3-primary) 0%, var(--m3-primary-600) 60%, #1565C0 100%);
  border-radius: var(--r-lg);
  padding: 20px 16px;
  margin-bottom: 16px;
  color: white;
  box-shadow: var(--elev-3);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stats-inst-header > div { flex: 1; text-align: center; }
.stats-titulo {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}
.stats-subtitulo {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
  margin-top: 3px;
}

/* ── PRESENCE / ADMIN PANEL ──────────────────────────────── */
.presencia-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 6px;
  transition: background var(--dur-fast);
}
.presencia-activo  { background: rgba(27,94,32,0.06); }
.presencia-inactivo { background: var(--m3-surface-2); }
.presencia-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-verde { background: #4CAF50; box-shadow: 0 0 0 3px rgba(76,175,80,0.2); }
.dot-gris  { background: #9E9E9E; }

/* ── REGISTRO SWITCHER ────────────────────────────────────── */
.registro-switcher {
  display: flex;
  gap: 6px;
  background: var(--m3-surface-2);
  padding: 6px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  box-shadow: var(--elev-1);
}
.btn-reg-tipo {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--m3-dim);
  font-size: 12px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-reg-tipo.activo {
  background: var(--m3-surface);
  color: var(--m3-primary);
  box-shadow: var(--elev-2);
}
.btn-reg-tipo:not(.activo):hover {
  background: var(--m3-outline-var);
  color: var(--m3-on-surface);
}

/* ── MODALS — M3 Dialog ──────────────────────────────────── */
.modal-overlay {
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-contenido {
  border-radius: var(--r-xl);
  box-shadow: var(--elev-4);
  overflow: hidden;
}
.modal-header {
  border-radius: 0;
}

/* ── SEARCH BAR ───────────────────────────────────────────── */
.buscador-listado {
  border-radius: var(--r-full);
  border: 1.5px solid var(--m3-outline);
  background: var(--m3-surface);
  padding: 11px 16px 11px 38px;
  font-size: 14px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.buscador-listado:focus {
  outline: none;
  border-color: var(--m3-primary-400);
  box-shadow: 0 0 0 3px rgba(67,160,71,0.14);
}
.filtros-listado select {
  border-radius: var(--r-full);
  border: 1.5px solid var(--m3-outline);
  padding: 9px 14px;
  font-size: 13px;
  background: var(--m3-surface);
}

/* Toggle listado Todos / Mis registros */
.toggle-listado {
  padding: 8px 18px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--m3-outline);
  background: transparent;
  color: var(--m3-dim);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  cursor: pointer;
  touch-action: manipulation;
}
.toggle-listado.activo {
  background: var(--m3-primary);
  color: white;
  border-color: var(--m3-primary);
  box-shadow: 0 2px 8px rgba(27,94,32,0.3);
}
.toggle-listado:not(.activo):hover {
  background: var(--m3-primary-cnt-light);
  color: var(--m3-primary);
  border-color: var(--m3-primary-400);
}

/* ── MAP BUTTONS ──────────────────────────────────────────── */
.btn-mapa-ctrl {
  border-radius: var(--r-full);
  padding: 8px 14px;
  border: 1.5px solid var(--m3-outline);
  background: var(--m3-surface);
  font-size: 12px;
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.btn-mapa-ctrl.activo {
  background: var(--m3-primary);
  color: white;
  border-color: var(--m3-primary);
  box-shadow: 0 2px 8px rgba(27,94,32,0.25);
}
.btn-mapa-ctrl:hover:not(.activo) {
  background: var(--m3-primary-cnt-light);
  border-color: var(--m3-primary-400);
  color: var(--m3-primary);
}

/* ── PAGINATION ───────────────────────────────────────────── */
.btn-pag {
  border-radius: var(--r-full);
  padding: 8px 16px;
  border: 1.5px solid var(--m3-outline);
  background: var(--m3-surface);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.btn-pag:hover:not(:disabled) {
  background: var(--m3-primary-cnt-light);
  border-color: var(--m3-primary-400);
  color: var(--m3-primary);
}
.btn-pag.activo-pag {
  background: var(--m3-primary);
  color: white;
  border-color: var(--m3-primary);
  box-shadow: 0 2px 8px rgba(27,94,32,0.3);
}

/* ── GPS BUTTON ───────────────────────────────────────────── */
.btn-gps {
  background: #1565C0;
  color: white;
  border: none;
  border-radius: var(--r-full);
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: background var(--dur-fast);
  box-shadow: 0 2px 8px rgba(21,101,192,0.3);
}
.btn-gps:hover { background: #0D47A1; }

/* ── SKELETON ─────────────────────────────────────────────── */
.skeleton-card {
  background: var(--m3-surface);
  border-radius: var(--r-md);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--elev-1);
  border-left: 4px solid var(--m3-outline);
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge {
  border-radius: var(--r-full);
  font-size: 11px;
  padding: 3px 10px;
  font-weight: 600;
}
.badge-abandono {
  background: #FFEBEE;
  color: #B3261E;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
}
.badge-estado-pendiente {
  background: #FFF3E0;
  color: #E65100;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
}
.badge-estado-atendido {
  background: var(--m3-primary-cnt-light);
  color: var(--m3-primary);
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
}

/* ── PANEL DE ADMIN ───────────────────────────────────────── */
.panel-admin-seccion {
  background: var(--m3-surface);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--elev-1);
  border: 1px solid var(--m3-outline-var);
}
.panel-admin-seccion h3 {
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--m3-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── CHAT ─────────────────────────────────────────────────── */
.chat-input-row {
  border-radius: var(--r-full);
}
.chat-input-row input {
  border-radius: var(--r-full) 0 0 var(--r-full);
  border: 1.5px solid var(--m3-outline);
  background: var(--m3-surface-1);
  padding: 12px 18px;
}
.chat-send-btn {
  background: var(--m3-primary);
  border-radius: 0 var(--r-full) var(--r-full) 0;
  padding: 12px 20px;
  border: none;
  color: white;
  font-weight: 700;
  transition: background var(--dur-fast);
}
.chat-send-btn:hover { background: #1A5526; }

/* ── TOAST ───────────────────────────────────────────────── */
#toast-notif {
  border-radius: var(--r-md) !important;
  box-shadow: var(--elev-4) !important;
  font-family: 'Poppins', sans-serif !important;
  font-weight: 500 !important;
  bottom: calc(var(--bn-h) + 16px) !important;
}

/* ── PROGRESS BARS ────────────────────────────────────────── */
.cobertura-barra {
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--m3-outline-var);
}
.cobertura-fill {
  border-radius: var(--r-full);
}

/* ── MAP ──────────────────────────────────────────────────── */
#mapa {
  border-radius: var(--r-lg);
  box-shadow: var(--elev-2);
  border: none;
}

/* ── PWA BANNER ───────────────────────────────────────────── */
.pwa-banner {
  bottom: calc(var(--bn-h) + 12px) !important;
  border-radius: var(--r-md) !important;
  margin: 0 12px !important;
  box-shadow: var(--elev-4) !important;
}

/* ── INTERVENCION ITEMS ───────────────────────────────────── */
.intervencion-item {
  border-radius: var(--r-sm);
  border: 1.5px solid var(--m3-outline-var);
  background: var(--m3-surface-1);
  padding: 12px;
}

/* ── LOGIN PAGE — premium ─────────────────────────────────── */
.login-card {
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25), 0 6px 20px rgba(0,0,0,0.15);
  padding: 32px 24px;
}
.login-card-titulo {
  font-family: 'Poppins', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--m3-primary);
}
.login-header-logos {
  border-radius: var(--r-xl);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── RIPPLE EFFECT ────────────────────────────────────────── */
.tab, .btn-primario, .btn-secundario, .btn-pag, .btn-ficha,
.btn-editar, .btn-eliminar-card, .btn-reg-tipo, .toggle-listado {
  position: relative;
  overflow: hidden;
}

@keyframes ripple-anim {
  to { transform: scale(4); opacity: 0; }
}

/* ── SCROLL ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--m3-outline); border-radius: var(--r-full); }

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger animation for stat cards */
.stat-card:nth-child(1) { animation-delay: 0ms; }
.stat-card:nth-child(2) { animation-delay: 40ms; }
.stat-card:nth-child(3) { animation-delay: 80ms; }
.stat-card:nth-child(4) { animation-delay: 120ms; }
.stat-card:nth-child(5) { animation-delay: 160ms; }
.stat-card:nth-child(6) { animation-delay: 200ms; }

.stat-card {
  animation: fadeInUp var(--dur-med) var(--ease-std) both;
}

/* ── MOBILE FINE-TUNE ─────────────────────────────────────── */
@media(max-width: 380px) {
  .tab span.tab-label { font-size: 9px; }
  .stat-numero { font-size: 26px; }
  .btn-primario { font-size: 14px; padding: 13px 22px; }
}

/* Splash modal — premium */
.splash-card {
  border-radius: var(--r-xl) var(--r-xl) 0 0 !important;
}
/* Título en blanco — está sobre el header con gradiente verde */
.splash-titulo {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: #FFFFFF !important;
  letter-spacing: -0.3px;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0,0,0,0.22);
  margin-bottom: 6px;
}
.splash-lugar,
.splash-lema {
  color: #FFFFFF !important;
}

/* EASUR grande y bien visible */
.splash-brand-nombre {
  color: #FFFFFF !important;
  font-family: 'Poppins', sans-serif;
  font-weight: 900;
  letter-spacing: 3px;
}
.splash-brand-sub {
  color: rgba(255,255,255,0.88) !important;
}

.splash-cta {
  border-radius: var(--r-full) !important;
  font-family: 'Poppins', sans-serif !important;
  font-weight: 700 !important;
  padding: 14px 32px !important;
}

/* ============================================================
   📱 MOBILE-FIRST OPTIMIZATION
   Todo el siguiente bloque mejora visibilidad en celulares
   ============================================================ */

/* ── Variables mobile ─────────────────────────────────────── */
@media(max-width: 640px) {
  :root {
    --bn-h: 64px;
  }
  body {
    font-size: 15px;
    line-height: 1.55;
  }
}

/* ── HEADER móvil más compacto y legible ─────────────────── */
@media(max-width: 640px) {
  .header {
    height: 58px;
    padding: 0 12px;
    gap: 8px;
  }
  .header-logo {
    height: 36px;
    width: 36px;
  }
  .header-titulo {
    font-size: 13.5px;
    line-height: 1.15;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  .header-subtitulo {
    font-size: 10px;
    letter-spacing: 0.2px;
    white-space: nowrap;
  }
  #nombre-usuario {
    font-size: 10px;
    max-width: 88px;
  }
  .badge-rol {
    font-size: 9px;
    padding: 1px 7px;
  }
  .btn-salir {
    padding: 4px 10px;
    font-size: 10.5px;
  }
}

@media(max-width: 380px) {
  .header {
    height: 56px;
    padding: 0 8px;
  }
  .header-titulo  { font-size: 12px; }
  .header-subtitulo { font-size: 9.5px; }
  .header-usuario { gap: 2px; }
  #nombre-usuario { display: none; }  /* solo badge + salir en pantallas chicas */
  .header-logo { height: 32px; width: 32px; }
}

/* ── BIENVENIDA — banner más compacto ────────────────────── */
@media(max-width: 640px) {
  .bienvenida-banner {
    padding: 7px 12px;
    font-size: 12px;
    line-height: 1.4;
  }
}

/* ── BOTTOM NAV — scroll horizontal con snap ─────────────── */
@media(max-width: 640px) {
  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0 6px;
    justify-content: flex-start;
  }
  .tab {
    flex: 0 0 64px;
    min-width: 64px;
    max-width: 78px;
    scroll-snap-align: center;
    padding: 6px 2px 8px;
  }
  .tab::before {
    width: 52px;
    height: 30px;
    top: 5px;
  }
  .tab .fas {
    font-size: 17px;
  }
  .tab.activo .fas {
    font-size: 19px;
  }
  .tab span.tab-label {
    font-size: 9.5px;
    line-height: 1.1;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tab-badge {
    top: 3px;
    right: calc(50% - 20px);
    font-size: 8.5px;
    padding: 1px 4px;
    min-width: 14px;
  }
}

/* Indicador visual de scroll en bottom nav */
@media(max-width: 640px) {
  .tabs::before,
  .tabs::after {
    content: '';
    position: sticky;
    top: 0;
    width: 14px;
    height: var(--bn-h);
    flex-shrink: 0;
    pointer-events: none;
    z-index: 1;
  }
  .tabs::before {
    left: 0;
    background: linear-gradient(90deg, white 30%, transparent);
  }
  .tabs::after {
    right: 0;
    background: linear-gradient(-90deg, white 30%, transparent);
  }
}

/* ── CONTENT — padding y max-width móvil ─────────────────── */
@media(max-width: 640px) {
  .tab-contenido {
    padding: 14px 12px 24px;
    max-width: 100%;
  }
}

/* ── FORMULARIO — más respirable ─────────────────────────── */
@media(max-width: 640px) {
  .formulario-card {
    padding: 16px 14px;
    border-radius: var(--r-md);
  }
  .formulario-card h2 {
    font-size: 17px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }
  .seccion-form {
    margin-bottom: 16px;
    padding-bottom: 16px;
  }
  .seccion-form h3 {
    font-size: 11px;
    margin-bottom: 11px;
  }
  /* Inputs más grandes para tocar bien */
  .campo input,
  .campo select,
  .campo textarea {
    font-size: 15.5px;   /* >=16px previene zoom automático en iOS */
    padding: 12px 14px;
    min-height: 46px;
  }
  .campo label {
    font-size: 13px;
    margin-bottom: 2px;
    font-weight: 600;
  }
  .campo textarea {
    min-height: 90px;
  }
  /* Fila campos en móvil — apila siempre 1 columna */
  .fila-campos {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}

/* ── BOTONES MÁS GRANDES — touch target >=46px ──────────── */
@media(max-width: 640px) {
  .btn-primario {
    padding: 14px 24px;
    font-size: 15px;
    min-height: 48px;
    width: 100%;
  }
  .btn-secundario {
    padding: 13px 22px;
    font-size: 14.5px;
    min-height: 46px;
    width: 100%;
  }
  .botones-form {
    flex-direction: column-reverse;  /* primario abajo, cancelar arriba */
    gap: 10px;
  }
  .botones-form .btn-primario,
  .botones-form .btn-secundario {
    width: 100%;
  }
}

/* ── STATS GRID — siempre 2 columnas en mobile ───────────── */
@media(max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card {
    padding: 16px 10px;
  }
  .stat-icono {
    width: 40px;
    height: 40px;
    font-size: 17px;
  }
  .stat-numero {
    font-size: 26px;
    letter-spacing: -1px;
  }
  .stat-label {
    font-size: 11px;
    line-height: 1.3;
  }
  .stat-sublabel {
    font-size: 10px;
  }
  .stats-inst-header {
    padding: 16px 14px;
    gap: 10px;
  }
  .stats-titulo {
    font-size: 19px;
  }
  .stats-subtitulo {
    font-size: 12px;
  }
}

/* En pantallas muy pequeñas — 2 cols con números menores */
@media(max-width: 360px) {
  .stats-grid { gap: 8px; }
  .stat-card { padding: 14px 8px; }
  .stat-numero { font-size: 23px; }
  .stat-icono { width: 36px; height: 36px; font-size: 15px; }
}

/* ── ANIMAL CARDS — móvil ────────────────────────────────── */
@media(max-width: 640px) {
  .animal-card {
    padding: 14px;
    margin-bottom: 10px;
    border-radius: var(--r-md);
  }
  .card-titulo-row strong {
    font-size: 13.5px;
    line-height: 1.35;
  }
  .animal-foto {
    width: 80px;
    height: 80px;
  }
  .card-datos {
    font-size: 12.5px;
    line-height: 1.55;
  }
  .card-datos div {
    margin-bottom: 2px;
  }
  .animal-observaciones {
    font-size: 12.5px;
    padding: 8px 10px;
  }
  .animal-id {
    font-size: 10.5px;
    padding: 2px 7px;
  }
  /* Card acciones — botones más amplios en móvil */
  .card-acciones {
    gap: 6px;
    margin-top: 12px;
  }
  .btn-ficha, .btn-editar, .btn-eliminar-card, .btn-eliminar {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 12.5px;
    min-height: 38px;
    justify-content: center;
    text-align: center;
  }
  /* Badges — más legibles */
  .badge,
  .badge-abandono,
  .badge-estado-pendiente,
  .badge-estado-atendido {
    font-size: 10.5px;
    padding: 3px 9px;
  }
}

/* ── REGISTRO SWITCHER — móvil ───────────────────────────── */
@media(max-width: 640px) {
  .registro-switcher {
    padding: 5px;
    gap: 4px;
    border-radius: var(--r-md);
  }
  .btn-reg-tipo {
    padding: 10px 4px;
    font-size: 11.5px;
    gap: 4px;
    min-height: 42px;
    flex-direction: column;
    text-align: center;
    line-height: 1.2;
  }
  .btn-reg-tipo .fas {
    font-size: 15px;
  }
}

/* ── LISTADO — controles móvil ───────────────────────────── */
@media(max-width: 640px) {
  .listado-controles {
    gap: 8px;
    margin-bottom: 12px;
  }
  .listado-controles h2 {
    font-size: 18px;
  }
  .buscador-wrapper {
    width: 100%;
    flex: 1 1 100%;
  }
  .buscador-listado {
    font-size: 15px;
    padding: 11px 16px 11px 38px;
    min-height: 44px;
  }
  .filtros-listado {
    width: 100%;
    gap: 6px;
  }
  .filtros-listado select {
    flex: 1;
    min-height: 40px;
    font-size: 13px;
  }
  .toggle-listado {
    flex: 1;
    padding: 9px 12px;
    font-size: 12.5px;
    min-height: 40px;
  }
}

/* ── MAP — móvil ─────────────────────────────────────────── */
@media(max-width: 640px) {
  #mapa {
    height: 380px;
    border-radius: var(--r-md);
  }
  .btn-mapa-ctrl {
    padding: 7px 12px;
    font-size: 11.5px;
    min-height: 36px;
  }
  .mapa-seccion-label {
    font-size: 10.5px;
  }
}

/* ── PAGINACIÓN — móvil ──────────────────────────────────── */
@media(max-width: 640px) {
  .paginacion {
    gap: 6px;
    margin-top: 16px;
  }
  .btn-pag {
    padding: 9px 14px;
    font-size: 13px;
    min-height: 40px;
    min-width: 40px;
  }
  .paginacion-info {
    font-size: 12px;
    width: 100%;
  }
}

/* ── PANEL ADMIN — móvil ─────────────────────────────────── */
@media(max-width: 640px) {
  .panel-admin-seccion {
    padding: 14px;
    border-radius: var(--r-md);
  }
  .panel-admin-seccion h3 {
    font-size: 13px;
  }
  .presencia-item {
    padding: 9px 10px;
    gap: 8px;
  }
  .presencia-email {
    font-size: 12.5px;
  }
  .presencia-tiempo {
    font-size: 11px;
  }
}

/* ── MODALS — móvil pantalla completa ────────────────────── */
@media(max-width: 640px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;  /* slide desde abajo, estilo bottom sheet Flutter */
  }
  .modal-contenido {
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh;
    width: 100%;
    animation: pm-slideUpFull var(--dur-med) var(--ease-std);
  }
  .modal-header {
    padding: 14px 16px;
    border-radius: 0;
  }
  .modal-header h3 {
    font-size: 15px;
  }
  .modal-body {
    padding: 16px 14px;
  }
}

@keyframes pm-slideUpFull {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── CHAT — móvil ─────────────────────────────────────────── */
@media(max-width: 640px) {
  .chat-input-row input {
    font-size: 15px;
    padding: 11px 16px;
    min-height: 44px;
  }
  .chat-send-btn {
    padding: 11px 16px;
    min-height: 44px;
  }
}

/* ── TYPOGRAPHY MÓVIL: NO ZOOM AUTO ──────────────────────── */
@media(max-width: 640px) {
  input, select, textarea {
    font-size: 16px !important; /* iOS no hace zoom si es >=16 */
  }
  /* Pero el visible mantiene 15.5px via padding y line-height */
}

/* Reset el 16px forzado en selects pequeños donde no aplica iOS zoom */
.select-si-no {
  font-size: 14px !important;
}

/* ── DETALLE: SAFE AREA iOS notch ────────────────────────── */
@supports (padding: max(0px)) {
  .tabs {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    height: calc(var(--bn-h) + max(0px, env(safe-area-inset-bottom)));
  }
  #app {
    padding-bottom: calc(var(--bn-h) + max(0px, env(safe-area-inset-bottom)));
  }
  .header {
    padding-top: max(0px, env(safe-area-inset-top));
    height: calc(60px + max(0px, env(safe-area-inset-top)));
  }
}

/* ── TOAST y PWA banner sobre bottom nav ─────────────────── */
@media(max-width: 640px) {
  #toast-notif {
    bottom: calc(var(--bn-h) + 20px) !important;
    left: 12px !important;
    right: 12px !important;
    max-width: none !important;
    font-size: 13.5px !important;
  }
  .pwa-banner {
    bottom: calc(var(--bn-h) + 12px) !important;
    margin: 0 8px !important;
    padding: 12px !important;
    font-size: 12px !important;
  }
}

/* ── GPS row móvil — apila en 2 lineas ───────────────────── */
@media(max-width: 640px) {
  .gps-fila {
    gap: 6px;
  }
  .gps-fila input {
    flex: 1 1 calc(50% - 3px);
    font-size: 15.5px;
    min-height: 44px;
    padding: 11px 12px;
  }
  .btn-gps {
    flex: 1 1 100%;
    padding: 12px 16px;
    min-height: 44px;
    font-size: 13px;
  }
}

/* ── INTERVENCIONES grid móvil ────────────────────────────── */
@media(max-width: 640px) {
  .intervenciones-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .intervencion-item {
    padding: 10px;
  }
  .intervencion-item label {
    font-size: 11.5px;
  }
  .select-si-no {
    padding: 8px 10px;
    font-size: 14px;
  }
}

/* ── FOCUS visible (accesibilidad teclado/lector) ───────── */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2.5px solid var(--m3-primary-400);
  outline-offset: 2px;
}

/* ── reduce-motion para usuarios sensibles ───────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   ITASA — Logo del Instituto en splash y comunidad
   ============================================================ */

/* Logo ITASA en splash (modal de presentación) */
.splash-alianza-logo-img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(27,94,32,0.18), 0 0 0 3px var(--m3-primary-cnt);
  display: block;
  margin: 0 auto;
}

/* SVG inline del logo ITASA (fallback elegante si no hay PNG) */
.itasa-svg-wrap {
  width: 92px;
  height: 92px;
  margin: 0 auto;
  border-radius: 50%;
  background: white;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(27,94,32,0.18), 0 0 0 3px var(--m3-primary-cnt);
}
.itasa-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* En la card de comunidad — más pequeño */
.com-aliado-icono-img .itasa-svg-wrap {
  width: 100%;
  height: 100%;
  padding: 2px;
  box-shadow: none;
  margin: 0;
}

/* ============================================================
   💻 TABLET / DESKTOP OPTIMIZATION (≥ 768px)
   Mobile queda intacto. Todo el bloque aplica solo en pantallas
   grandes para aprovechar el espacio horizontal.
   ============================================================ */

/* ────────────── TABLET (768px – 1023px) ────────────── */
@media (min-width: 768px) {
  :root { --bn-h: 0px; } /* sin bottom nav en tablet+ */

  body {
    background: linear-gradient(180deg, var(--m3-bg) 0%, #E8EFE8 100%);
    background-attachment: fixed;
  }

  #app {
    padding-bottom: 0;
    max-width: 100%;
  }

  /* ── HEADER tablet — más espacioso ───────────────────── */
  .header {
    height: 68px;
    padding: 0 24px;
    gap: 16px;
    grid-template-columns: auto 1fr auto;
  }
  .header-logo {
    height: 44px;
    width: 44px;
  }
  .header-titulo {
    font-size: 18px;
    letter-spacing: -0.4px;
  }
  .header-subtitulo { font-size: 12px; }
  #nombre-usuario {
    font-size: 12px;
    max-width: 180px;
  }
  .badge-rol  { font-size: 10.5px; padding: 3px 11px; }
  .btn-salir  { padding: 6px 16px; font-size: 12.5px; }

  /* ── BIENVENIDA ───────────────────────────────────────── */
  .bienvenida-banner {
    padding: 10px 24px;
    font-size: 13.5px;
  }

  /* ── TABS arriba (no bottom nav) — Material Top App Bar  */
  .tabs {
    position: sticky;
    bottom: auto;
    top: 68px;
    left: auto;
    right: auto;
    height: 56px;
    border-top: none;
    border-bottom: 1px solid var(--m3-outline-var);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 0 16px;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: center;
    z-index: 199;
  }
  .tabs::before, .tabs::after { display: none; }

  .tab {
    flex: 0 0 auto;
    min-width: 100px;
    max-width: none;
    height: 56px;
    padding: 0 16px;
    flex-direction: row;
    gap: 8px;
    font-size: 13.5px;
    border-radius: 0;
    border-bottom: 3px solid transparent;
  }
  .tab::before { display: none; } /* sin pill indicator, usamos border-bottom */
  .tab .fas { font-size: 16px !important; }
  .tab.activo .fas { font-size: 16px !important; }
  .tab span.tab-label {
    font-size: 13.5px;
    max-width: none;
    white-space: nowrap;
  }
  .tab.activo {
    color: var(--m3-primary);
    border-bottom-color: var(--m3-primary);
    background: var(--m3-primary-cnt-light);
  }
  .tab:hover:not(.activo) {
    background: var(--m3-surface-2);
    color: var(--m3-primary-600);
  }
  .tab-admin.activo {
    border-bottom-color: #F59F00;
    background: #FFF8E1;
  }
  .tab-alerta.activo {
    border-bottom-color: #B3261E;
    background: #FCECEA;
  }
  .tab-badge {
    position: absolute;
    top: 10px;
    right: 6px;
    font-size: 10px;
    padding: 1px 6px;
  }

  /* ── CONTENT — más ancho y respirable ─────────────────── */
  .tab-contenido {
    padding: 28px 32px 48px;
    max-width: 1100px;
  }

  /* ── FORMULARIO — 2 columnas en tablet ───────────────── */
  .formulario-card {
    padding: 32px;
    border-radius: var(--r-xl);
  }
  .formulario-card h2 {
    font-size: 22px;
    margin-bottom: 24px;
    padding-bottom: 14px;
  }
  .seccion-form {
    margin-bottom: 24px;
    padding-bottom: 24px;
  }
  .seccion-form h3 {
    font-size: 13px;
    margin-bottom: 16px;
  }
  /* fila-campos 2 cols recuperado */
  .fila-campos {
    grid-template-columns: 1fr 1fr !important;
    gap: 18px;
  }
  .campo input,
  .campo select,
  .campo textarea {
    font-size: 14.5px !important;
    padding: 11px 14px;
    min-height: 44px;
  }
  /* Botones de formulario — recuperar layout horizontal */
  .botones-form {
    flex-direction: row;
    justify-content: flex-end;
    gap: 12px;
  }
  .botones-form .btn-primario,
  .botones-form .btn-secundario {
    width: auto;
    flex: 0 1 auto;
    min-width: 160px;
  }

  /* ── STATS HEADER hero ───────────────────────────────── */
  .stats-inst-header {
    padding: 28px 32px;
    border-radius: var(--r-xl);
  }
  .stats-titulo  { font-size: 26px; }
  .stats-subtitulo { font-size: 14px; }

  /* ── STATS GRID 3 cols ───────────────────────────────── */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  .stat-card {
    padding: 24px 18px;
  }
  .stat-icono {
    width: 52px; height: 52px;
    font-size: 22px;
  }
  .stat-numero {
    font-size: 38px;
  }
  .stat-label { font-size: 12.5px; }

  /* ── ANIMAL CARDS — grid 2 cols en tablet ───────────── */
  #tabla-animales {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .animal-card {
    margin-bottom: 0;
    padding: 18px;
  }

  /* ── LISTADO controls ────────────────────────────────── */
  .listado-controles {
    gap: 12px;
  }
  .listado-controles h2 { font-size: 22px; }
  .buscador-listado {
    font-size: 14px;
    padding: 11px 18px 11px 40px;
  }

  /* ── REGISTRO SWITCHER tablet ────────────────────────── */
  .btn-reg-tipo {
    flex-direction: row;
    padding: 12px 16px;
    font-size: 13.5px;
    min-height: 48px;
  }
  .btn-reg-tipo .fas {
    font-size: 14px;
  }

  /* ── MAPA grande ─────────────────────────────────────── */
  #mapa {
    height: 520px;
    border-radius: var(--r-xl);
  }
  .btn-mapa-ctrl {
    padding: 9px 16px;
    font-size: 13px;
    min-height: 40px;
  }

  /* ── MODALS centrados, no bottom-sheet ───────────────── */
  .modal-overlay {
    padding: 32px;
    align-items: center;
  }
  .modal-contenido {
    border-radius: var(--r-xl);
    max-width: 720px;
    max-height: 88vh;
    animation: pm-scaleIn var(--dur-med) var(--ease-std);
  }
  .modal-body {
    padding: 28px;
  }
  .modal-header {
    padding: 18px 24px;
  }
  .modal-header h3 {
    font-size: 17px;
  }

  @keyframes pm-scaleIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
  }

  /* ── PANEL ADMIN — grid 2 cols ───────────────────────── */
  .panel-admin-seccion {
    padding: 24px;
    border-radius: var(--r-xl);
  }
  .panel-admin-seccion h3 {
    font-size: 16px;
    margin-bottom: 18px;
  }

  /* ── PAGINACIÓN ──────────────────────────────────────── */
  .paginacion { gap: 8px; margin-top: 24px; }
  .btn-pag {
    padding: 9px 18px;
    font-size: 13.5px;
    min-height: 42px;
    min-width: 42px;
  }

  /* ── TOAST y PWA banner — esquina inferior derecha ───── */
  #toast-notif {
    bottom: 32px !important;
    left: auto !important;
    right: 32px !important;
    max-width: 380px !important;
    font-size: 14px !important;
  }
  .pwa-banner {
    bottom: 24px !important;
    right: 24px !important;
    left: auto !important;
    margin: 0 !important;
    max-width: 380px;
  }

  /* ── COMUNIDAD aliados grid ──────────────────────────── */
  .com-aliados-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  /* ── BUSCADOR + filtros en una fila ──────────────────── */
  .buscador-wrapper {
    flex: 1 1 360px;
    max-width: 480px;
  }
  .filtros-listado {
    flex: 0 0 auto;
  }
  .toggle-listado {
    flex: 0 0 auto;
    padding: 9px 22px;
  }
}

/* ────────────── DESKTOP (≥ 1024px) ────────────── */
@media (min-width: 1024px) {
  /* ── HEADER hero ─────────────────────────────────────── */
  .header {
    height: 72px;
    padding: 0 32px;
  }
  .header-logo {
    height: 48px;
    width: 48px;
  }
  .header-titulo {
    font-size: 20px;
    letter-spacing: -0.5px;
  }
  .header-subtitulo { font-size: 12.5px; }

  /* ── TABS más grandes ────────────────────────────────── */
  .tabs {
    top: 72px;
    height: 60px;
    padding: 0 24px;
  }
  .tab {
    height: 60px;
    padding: 0 22px;
    font-size: 14px;
  }
  .tab span.tab-label { font-size: 14px; }

  /* ── CONTENT max-width amplio ────────────────────────── */
  .tab-contenido {
    padding: 36px 48px 64px;
    max-width: 1280px;
  }

  /* ── STATS GRID 4–6 cols ─────────────────────────────── */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
  /* Cuando hay 6+ stats — usar 3x2 más uniforme */
  .stats-grid.stats-completo {
    grid-template-columns: repeat(6, 1fr);
  }
  .stat-card {
    padding: 28px 20px;
  }
  .stat-numero { font-size: 44px; letter-spacing: -2px; }
  .stat-icono  { width: 56px; height: 56px; font-size: 24px; }
  .stat-label  { font-size: 13px; }

  /* ── STATS HEADER hero más imponente ─────────────────── */
  .stats-inst-header {
    padding: 36px 40px;
  }
  .stats-titulo  { font-size: 30px; }
  .stats-subtitulo { font-size: 15px; }

  /* ── ANIMAL CARDS grid 3 cols ────────────────────────── */
  #tabla-animales {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
  .animal-card {
    padding: 22px;
    border-radius: var(--r-lg);
  }
  .animal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--elev-4);
  }
  .card-titulo-row strong {
    font-size: 15px;
  }
  .card-datos {
    font-size: 13px;
  }
  /* En grid, la foto va arriba, no flotante */
  .animal-foto {
    float: none;
    display: block;
    width: 100%;
    height: 160px;
    margin: 0 0 12px 0;
    border-radius: var(--r-md);
  }
  .card-acciones {
    margin-top: auto;
    padding-top: 12px;
  }
  .animal-card {
    display: flex;
    flex-direction: column;
  }

  /* ── FORMULARIO — más espacioso ──────────────────────── */
  .formulario-card {
    padding: 40px;
  }
  .formulario-card h2 {
    font-size: 24px;
    margin-bottom: 28px;
  }
  /* Layout 2-3 columnas en secciones */
  .intervenciones-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  /* ── MAPA enorme ─────────────────────────────────────── */
  #mapa {
    height: 600px;
  }

  /* ── REGISTRO SWITCHER pill style ────────────────────── */
  .registro-switcher {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
  .btn-reg-tipo {
    padding: 14px 24px;
    font-size: 14px;
    min-height: 52px;
  }

  /* ── PANEL ADMIN 2 columnas ──────────────────────────── */
  #tab-admin > .tab-contenido > div,
  #tab-admin .panel-admin-seccion {
    /* Manejado por contenedor externo si existe */
  }

  /* ── HOVER MÁS RICOS ─────────────────────────────────── */
  .stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  }
  .btn-primario:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(27,94,32,0.4);
  }
  .toggle-listado:hover:not(.activo) {
    transform: translateY(-1px);
  }

  /* ── BOTONES más grandes ─────────────────────────────── */
  .btn-primario {
    padding: 15px 32px;
    font-size: 15px;
  }

  /* ── MODAL ancho cómodo ──────────────────────────────── */
  .modal-contenido {
    max-width: 760px;
  }
  .modal-editar { max-width: 880px; }

  /* ── LISTADO grid de filtros en línea ────────────────── */
  .listado-controles {
    flex-wrap: nowrap;
    align-items: center;
  }
  .listado-controles h2 {
    font-size: 24px;
    flex: 0 0 auto;
  }

  /* ── COMUNIDAD aliados 3 cols ────────────────────────── */
  .com-aliados-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* ── PRESENCIA admin — 2 columnas ────────────────────── */
  .lista-presencia {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .presencia-item {
    margin-bottom: 0;
  }

  /* ── BIENVENIDA banner más alto y centrado ───────────── */
  .bienvenida-banner {
    padding: 12px 32px;
    font-size: 14px;
  }
}

/* ────────────── DESKTOP WIDE (≥ 1440px) ────────────── */
@media (min-width: 1440px) {
  .tab-contenido { max-width: 1400px; padding: 40px 56px 72px; }
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
  #tabla-animales { grid-template-columns: repeat(4, 1fr); }
  .stat-numero { font-size: 46px; }
  .stats-titulo { font-size: 32px; }
}

/* ────────────── DESKTOP — Logo ITASA splash más grande ── */
@media (min-width: 768px) {
  .splash-alianza-logo-img,
  .itasa-svg-wrap {
    width: 110px;
    height: 110px;
  }
  .splash-titulo { font-size: 26px !important; }
  .splash-brand-nombre { font-size: 30px !important; }
}

/* ────────────── DESKTOP — Stats header de admin ─────── */
@media (min-width: 1024px) {
  .panel-admin-seccion {
    padding: 28px;
  }
  .panel-admin-seccion h3 {
    font-size: 17px;
  }
}

/* ────────────── DESKTOP — Skeleton igual al grid ─────── */
@media (min-width: 1024px) {
  #tabla-animales .skeleton-card {
    margin-bottom: 0;
  }
  .skeleton-line.h-100 {
    height: 160px;
  }
}

/* ────────────── DESKTOP — Card buttons full-width fix ── */
@media (min-width: 768px) {
  /* Sobreescribe el flex:1 móvil que hacía botones full-width */
  .card-acciones {
    gap: 8px;
    flex-wrap: wrap;
  }
  .btn-ficha, .btn-editar, .btn-eliminar-card, .btn-eliminar {
    flex: 1 1 auto;
    min-height: 36px;
    padding: 7px 14px;
    font-size: 12.5px;
  }
}

/* ────────────── DESKTOP — Card datos legibilidad ────── */
@media (min-width: 768px) {
  .card-datos div {
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.55;
  }
  .animal-observaciones {
    font-size: 13px;
    padding: 10px 12px;
  }
}

/* ────────────── DESKTOP — Pagination centrada ────────── */
@media (min-width: 1024px) {
  .paginacion {
    margin-top: 32px;
    padding: 16px 0;
  }
  .paginacion-info {
    width: auto;
    font-size: 13.5px;
    margin-right: 12px;
  }
}

/* ────────────── DESKTOP — Bienvenida más sutil ───────── */
@media (min-width: 768px) {
  .bienvenida-banner {
    background: linear-gradient(90deg, var(--m3-primary-cnt-light), #E3F2FD, var(--m3-primary-cnt-light));
    letter-spacing: 0.2px;
    font-weight: 600;
  }
}

/* ────────────── DESKTOP — Custom scrollbar elegante ──── */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--m3-bg); }
  ::-webkit-scrollbar-thumb {
    background: var(--m3-outline);
    border-radius: var(--r-full);
    border: 2px solid var(--m3-bg);
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--m3-primary-400);
  }
}

/* ============================================================
   🔒 MODAL EDICIÓN — botones siempre visibles
   Los botones "Guardar Cambios" / "Cancelar" se vuelven
   sticky al fondo del modal para que NUNCA queden ocultos
   aunque el formulario sea largo.
   ============================================================ */

/* Layout: header arriba, body scrolleable, botones sticky abajo */
.modal-editar {
  display: flex;
  flex-direction: column;
  overflow: hidden;        /* el scroll vive en modal-body */
}
.modal-editar .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Botones sticky en la parte inferior del modal de edición */
.modal-editar .botones-form {
  position: sticky;
  bottom: 0;
  background: white;
  margin: 0 -20px -20px;   /* sangría negativa para alinear con modal-body */
  padding: 14px 20px;
  border-top: 1px solid var(--m3-outline-var);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  z-index: 5;
  margin-top: 16px;
}
.modal-editar #ed-mensaje {
  position: sticky;
  bottom: 70px;
  background: white;
  margin: 0 -20px;
  padding: 8px 20px 0;
  z-index: 4;
}

/* En móvil — botones primario primero (debajo), cancelar arriba */
@media (max-width: 640px) {
  .modal-editar .botones-form {
    margin: 0 -14px -14px;
    padding: 12px 14px;
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-editar .botones-form .btn-primario,
  .modal-editar .botones-form .btn-secundario {
    width: 100%;
  }
}

/* En desktop — botones lado a lado, alineados a la derecha */
@media (min-width: 768px) {
  .modal-editar .botones-form {
    margin: 0 -28px -28px;
    padding: 16px 28px;
    flex-direction: row;
    justify-content: flex-end;
    gap: 12px;
  }
  .modal-editar .botones-form .btn-primario {
    flex: 0 0 auto;
    min-width: 180px;
  }
  .modal-editar .botones-form .btn-secundario {
    flex: 0 0 auto;
    min-width: 130px;
  }
}

/* Ajuste estructural: el modal-contenido NO debe scrollear
   (eso lo hace ahora el modal-body). Mantenemos el scroll
   de #modal-ficha y otros modales sin este patrón. */
#modal-edicion .modal-contenido {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   🧩 BOTONES UNIFICADOS — Mapa + Listado con estilo "pill"
   Solo móvil/tablet — en desktop se mantiene el look compacto.
   ============================================================ */

@media (max-width: 1023px) {

  /* ── Botones del listado (Todos / Mis registros) ─────── */
  .toggle-listado {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 14px;
    border-radius: 24px;
    border: 2px solid var(--m3-outline-var);
    background: white;
    color: var(--m3-on-surface-v);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transicion);
    white-space: nowrap;
    min-height: 44px;
    min-width: 0;
  }
  .toggle-listado:hover:not(.activo) {
    border-color: var(--m3-primary-300);
    background: var(--m3-primary-cnt);
    color: var(--m3-primary);
  }
  .toggle-listado.activo {
    background: var(--m3-primary);
    color: white;
    border-color: var(--m3-primary);
    box-shadow: 0 2px 8px rgba(46,125,50,0.25);
  }

  /* ── Botones del mapa (vistas + capas de datos) ──────── */
  .btn-mapa-ctrl {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 24px;
    border: 2px solid var(--m3-outline-var);
    background: white;
    color: var(--m3-on-surface-v);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transicion);
    white-space: nowrap;
    min-height: 42px;
    cursor: pointer;
  }
  .btn-mapa-ctrl:hover:not(.activo) {
    border-color: var(--m3-primary-300);
    background: var(--m3-primary-cnt);
    color: var(--m3-primary);
  }
  .btn-mapa-ctrl.activo {
    background: var(--m3-primary);
    color: white;
    border-color: var(--m3-primary);
    box-shadow: 0 2px 8px rgba(46,125,50,0.25);
  }

  /* Botones de capa de datos: diferenciación visual por color al activar */
  .btn-mapa-ctrl.btn-datos.activo {
    background: var(--m3-primary);
    border-color: var(--m3-primary);
  }

  /* Filtros del mapa con el mismo radio pill */
  .filtro-mapa,
  .filtros-listado select {
    padding: 10px 16px;
    border-radius: 24px;
    border: 2px solid var(--m3-outline-var);
    background: white;
    font-size: 13.5px;
    font-weight: 500;
    min-height: 44px;
    color: var(--m3-on-surface);
  }
}

/* ── MÓVIL pequeño (≤640px) — más compacto pero misma forma ── */
@media (max-width: 640px) {
  .toggle-listado {
    padding: 10px 12px;
    font-size: 13px;
    min-height: 42px;
  }
  .btn-mapa-ctrl {
    padding: 9px 12px;
    font-size: 12.5px;
    min-height: 40px;
  }
  .filtro-mapa,
  .filtros-listado select {
    padding: 9px 14px;
    font-size: 13px;
    min-height: 42px;
  }
}

/* ============================================================
   📱 MODAL FICHA — móvil con bottom sheet + botón sticky
   ============================================================ */

/* Estructura columna: header + body scroll + footer sticky */
@media (max-width: 767px) {
  #modal-ficha .modal-contenido {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 92vh;
  }
  #modal-ficha .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;  /* espacio para el botón cerrar sticky */
  }
}

/* Inyecto un botón "Cerrar" sticky en la ficha móvil — vía CSS */
@media (max-width: 767px) {
  #modal-ficha .modal-header .modal-close {
    /* Hacer el botón cerrar del header más grande y visible */
    width: 38px;
    height: 38px;
    font-size: 20px;
    background: rgba(255,255,255,0.25);
  }
  #modal-ficha .modal-header .modal-close:active {
    background: rgba(255,255,255,0.4);
    transform: scale(0.92);
  }
}

/* ============================================================
   🛠️ EDICIÓN — refuerzos extra en móvil para foto y botones
   ============================================================ */

@media (max-width: 640px) {
  /* Sección de foto en edición — más compacta */
  #modal-edicion .foto-preview-img {
    max-width: 100%;
    height: 180px;
  }
  #modal-edicion .btn-foto {
    padding: 11px 12px;
    font-size: 13px;
  }

  /* Selects en edición (especie, sexo, etc.) — tamaño de input nativo */
  #modal-edicion select {
    font-size: 16px !important;
    padding: 12px 14px;
    min-height: 46px;
  }

  /* Asegurar que los botones del footer sticky sean accesibles */
  #modal-edicion .botones-form .btn-primario,
  #modal-edicion .botones-form .btn-secundario {
    min-height: 48px;
    font-size: 15px;
  }
}

/* ============================================================
   🎨 MAPA-CONTROLES — wrap mejor en móvil
   ============================================================ */

@media (max-width: 640px) {
  .mapa-controles {
    gap: 8px;
    margin-bottom: 12px;
  }
  /* Cuando hay múltiples botones en fila — que envuelvan limpiamente */
  .mapa-controles-datos {
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .mapa-seccion-label {
    width: 100%;
    margin-bottom: 4px;
  }
  /* Quitamos el fade-out derecho — no hace falta cuando ya envuelve */
  .mapa-datos-wrapper::after {
    display: none;
  }
}

/* ── Listado: filtros se apilan limpios ──────────────────── */
@media (max-width: 640px) {
  .filtros-listado {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .filtros-listado select,
  .filtros-listado .toggle-listado {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}

/* (Los estilos de .btn-sublista están unificados en styles.css —
    son idénticos al .btn-reg-tipo del registro switcher) */

/* ============================================================
   📱 MODAL "VER FICHA" — más compacto en móvil
   Reduce padding, tipografía, imagen y altura para que entre
   completo en pantallas pequeñas sin scroll excesivo.
   ============================================================ */

@media (max-width: 640px) {
  /* Header del modal — más pequeño */
  #modal-ficha .modal-header {
    padding: 12px 14px;
  }
  #modal-ficha .modal-header h3 {
    font-size: 14.5px;
    line-height: 1.25;
    word-break: break-word;
  }

  /* Body — padding reducido */
  #modal-ficha .modal-body {
    padding: 14px 14px 80px;
  }

  /* Foto del animal — más chica para no dominar la pantalla */
  #modal-ficha .ficha-foto-grande {
    max-height: 180px;
    margin-bottom: 10px;
    border-width: 1.5px;
  }

  /* Secciones — espaciado compacto */
  #modal-ficha .ficha-seccion {
    margin-bottom: 14px;
  }
  #modal-ficha .ficha-seccion h4 {
    font-size: 11px;
    margin-bottom: 7px;
    padding-bottom: 4px;
    letter-spacing: 0.5px;
  }

  /* Grid de datos — 2 columnas pero más densas */
  #modal-ficha .ficha-grid {
    gap: 6px 10px;
  }
  #modal-ficha .ficha-dato {
    font-size: 13px;
    line-height: 1.35;
    word-break: break-word;
  }
  #modal-ficha .ficha-dato span {
    font-size: 10px;
    margin-bottom: 1px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
  }

  /* Observaciones — caja compacta */
  #modal-ficha .ficha-seccion p {
    font-size: 12.5px !important;
    line-height: 1.5 !important;
    padding: 8px 10px;
    background: var(--m3-surface-2);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--m3-primary);
    margin: 0;
  }

  /* Badges intervenciones — más chicos */
  #modal-ficha .animal-badges {
    gap: 5px !important;
  }
  #modal-ficha .animal-badges .badge {
    font-size: 10.5px;
    padding: 3px 8px;
  }
}

/* ============================================================
   ✏️ MODAL "EDITAR REGISTRO" — móvil más denso
   Observaciones y campos con menos altura para reducir scroll.
   ============================================================ */

@media (max-width: 640px) {
  /* Header */
  #modal-edicion .modal-header {
    padding: 12px 14px;
  }
  #modal-edicion .modal-header h3 {
    font-size: 14.5px;
  }

  /* Body padding más justo */
  #modal-edicion .modal-body {
    padding: 14px;
  }

  /* Secciones — menos espaciado */
  #modal-edicion .seccion-form {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }
  #modal-edicion .seccion-form h3 {
    font-size: 11px;
    margin-bottom: 10px;
  }
  #modal-edicion .seccion-form h3 .fas {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }

  /* Inputs y selects — apenas más compactos para que quepan */
  #modal-edicion .campo {
    margin-bottom: 8px;
    gap: 3px;
  }
  #modal-edicion .campo label {
    font-size: 12.5px;
    font-weight: 600;
  }
  #modal-edicion .campo input,
  #modal-edicion .campo select {
    padding: 11px 12px;
    min-height: 44px;
  }

  /* TEXTAREA de observaciones — reducir altura, mantener scroll interno */
  #modal-edicion .campo textarea,
  #modal-edicion #ed-observaciones {
    min-height: 70px !important;
    max-height: 120px;
    font-size: 16px !important;
    padding: 10px 12px;
    line-height: 1.5;
  }

  /* Sección Foto en edición — todo más compacto */
  #modal-edicion .seccion-form h3 .fas[class*="camera"] + * {
    /* selector de hermano */
  }
  #modal-edicion .foto-preview-img {
    height: 150px !important;
    max-width: 100%;
  }
  #modal-edicion .btn-foto {
    padding: 10px 12px;
    font-size: 12.5px;
    min-height: 42px;
  }

  /* GPS row más compacta */
  #modal-edicion .gps-fila input {
    padding: 10px 12px;
    min-height: 42px;
    font-size: 16px !important;
  }
  #modal-edicion .btn-gps {
    padding: 10px 14px;
    min-height: 42px;
    font-size: 12.5px;
  }

  /* Intervenciones — más compacto */
  #modal-edicion .intervencion-item {
    padding: 8px 10px;
  }
  #modal-edicion .intervencion-item label {
    font-size: 11px;
  }
  #modal-edicion .select-si-no {
    padding: 7px 10px;
    font-size: 13.5px !important;
    min-height: 36px;
  }
}

/* ============================================================
   🗺️ MAPA — popups compactos en móvil (PC intacto)
   Los mensajes al hacer clic en marcadores son grandes —
   los acotamos al ancho de la pantalla menos márgenes.
   ============================================================ */

@media (max-width: 640px) {

  /* ── Popups de Leaflet: ancho controlado ──────────────── */
  .leaflet-popup {
    /* Forzar que NUNCA exceda el ancho de la pantalla */
    max-width: calc(100vw - 32px) !important;
  }
  .leaflet-popup-content-wrapper {
    border-radius: var(--r-md) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18) !important;
    padding: 2px !important;
  }
  .leaflet-popup-content {
    margin: 12px 14px !important;
    min-width: 0 !important;
    max-width: calc(100vw - 64px) !important;
    width: 240px !important;       /* base — Leaflet recalcula con maxWidth del bindPopup */
    font-size: 12.5px !important;
    line-height: 1.45 !important;
    word-wrap: break-word;
  }

  /* Título del popup más compacto */
  .popup-titulo,
  .popup-titulo-rojo {
    font-size: 13.5px !important;
    margin-bottom: 5px !important;
    line-height: 1.25 !important;
    word-break: break-word;
  }
  .popup-fila {
    font-size: 12px !important;
    margin-bottom: 2px !important;
    line-height: 1.4 !important;
    word-break: break-word;
  }
  .popup-fila strong {
    font-size: 11.5px;
  }

  /* Foto dentro del popup — más pequeña */
  .popup-foto,
  .leaflet-popup-content img {
    max-width: 100% !important;
    max-height: 110px !important;
    object-fit: cover;
    border-radius: var(--r-sm);
    margin: 6px 0 !important;
  }

  /* Lista de animales en popup de focos — scroll interno */
  .popup-animales-titulo {
    font-size: 10px !important;
    margin: 6px 0 4px !important;
  }
  .popup-animales-lista {
    max-height: 140px !important;
    padding-right: 2px;
  }
  .popup-animal-item {
    font-size: 11.5px !important;
    padding: 3px 0 !important;
  }
  .popup-animal-id {
    font-size: 9.5px !important;
  }
  .popup-btn-mini {
    font-size: 10.5px !important;
    padding: 3px 7px !important;
    min-height: 26px;
  }

  /* Botón "Ver ficha" debajo del popup — touch target ok */
  .leaflet-popup-content button.popup-btn-mini {
    padding: 5px 10px !important;
    font-size: 11.5px !important;
    margin-top: 4px;
  }

  /* Tip (flecha del popup) más pequeño y centrado */
  .leaflet-popup-tip-container {
    width: 30px !important;
    height: 14px !important;
  }

  /* Botón cerrar (X) del popup — más grande para tocar */
  .leaflet-popup-close-button {
    width: 32px !important;
    height: 32px !important;
    font-size: 22px !important;
    padding: 4px 0 0 0 !important;
    color: var(--m3-on-surface-v) !important;
    background: rgba(255,255,255,0.9) !important;
    border-radius: 50%;
    margin: 4px 4px 0 0 !important;
  }

  /* ── Panel lateral de foco (cuando se clickea un dueño) ── */
  .panel-foco-mapa {
    width: 100% !important;
    /* Bottom sheet: ocupa parte inferior, no toda la altura */
    top: auto !important;
    bottom: 0 !important;
    height: auto !important;
    max-height: 65vh;
    border-left: none !important;
    border-top: 3px solid #e53935;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
  }
  .panel-foco-mapa.oculto {
    transform: translateY(105%) !important;
  }
  .panel-foco-header {
    padding: 10px 14px;
    font-size: 13.5px;
    /* Indicador visual de bottom sheet (drag handle) */
    position: relative;
  }
  .panel-foco-header::before {
    content: '';
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--m3-outline-var);
    border-radius: var(--r-full);
  }
  .panel-foco-body {
    padding: 12px 14px 24px;
    font-size: 12.5px;
  }
  .panel-foco-fila {
    padding: 5px 0;
    line-height: 1.4;
  }
  .panel-foco-fila strong {
    min-width: 64px;
    font-size: 11.5px;
  }
  .panel-foco-animal {
    padding: 6px 8px;
    font-size: 11.5px;
  }
  .panel-foco-cerrar {
    width: 32px;
    height: 32px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Marcador foco de abandono — más visible en móvil ── */
  .foco-abandono-ring {
    transform: scale(0.92);
  }

  /* ── Toast info del mapa: que no choque con bottom nav ── */
  /* Ya está manejado por #toast-notif global, mantenemos consistencia */

  /* ── Tooltip "Foco de abandono" hover desactivado en touch ── */
  .leaflet-tooltip {
    max-width: calc(100vw - 32px) !important;
    font-size: 11.5px !important;
    padding: 4px 8px !important;
    word-wrap: break-word;
  }
}

/* ── Móvil chico (≤380px) — popups aún más estrictos ────── */
@media (max-width: 380px) {
  .leaflet-popup-content {
    width: 200px !important;
    max-width: calc(100vw - 48px) !important;
    margin: 10px 12px !important;
    font-size: 12px !important;
  }
  .popup-titulo, .popup-titulo-rojo {
    font-size: 13px !important;
  }
  .popup-foto {
    max-height: 90px !important;
  }
  .panel-foco-mapa {
    max-height: 70vh;
  }
}

/* ============================================================
   🍞 TOAST — base + responsive (PC: floating; móvil: full-width)
   ============================================================ */

.toast-base {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  color: white;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  text-align: center;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast-base.toast-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Móvil — ancho controlado y siempre encima del bottom nav */
@media (max-width: 640px) {
  .toast-base {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(var(--bn-h, 64px) + 16px) !important;
    transform: translateY(12px) !important;
    max-width: none !important;
    width: auto !important;
    padding: 11px 16px !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    border-radius: var(--r-md) !important;
    word-break: break-word;
  }
  .toast-base.toast-visible {
    transform: translateY(0) !important;
  }
}

/* PC — esquina inferior derecha, no centrado */
@media (min-width: 768px) {
  .toast-base {
    left: auto !important;
    right: 24px !important;
    bottom: 24px !important;
    transform: translateY(12px) !important;
    max-width: 380px;
    text-align: left;
    padding: 14px 18px;
  }
  .toast-base.toast-visible {
    transform: translateY(0) !important;
  }
}

/* ============================================================
   ❓ MODALES DE CONFIRMACIÓN — responsive premium
   Reemplaza los modales inline-style por estructura limpia.
   ============================================================ */

.modal-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: pm-fadeIn var(--dur-fast) var(--ease-std);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-confirm-overlay[style*="flex"] {
  display: flex !important;
}

.modal-confirm-card {
  background: white;
  border-radius: var(--r-xl);
  padding: 28px 24px 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 56px rgba(0,0,0,0.28);
  animation: pm-scaleIn 0.22s var(--ease-std);
}

@keyframes pm-fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-confirm-icono {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.modal-confirm-rojo .modal-confirm-icono {
  background: var(--rojo-claro);
  color: var(--rojo);
}
.modal-confirm-azul .modal-confirm-icono {
  background: var(--azul-claro);
  color: var(--azul);
}

.modal-confirm-titulo {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--m3-on-surface);
  margin: 0 0 8px;
  line-height: 1.3;
  letter-spacing: -0.2px;
}
.modal-confirm-desc {
  color: var(--m3-on-surface-v);
  font-size: 13.5px;
  margin: 0 0 22px;
  line-height: 1.5;
  word-break: break-word;
}

.modal-confirm-botones {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-confirm-btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--fuente);
  transition: var(--transicion);
  min-height: 46px;
  touch-action: manipulation;
  border: none;
}
.modal-confirm-cancelar {
  background: var(--m3-surface-2);
  color: var(--m3-on-surface);
  border: 1.5px solid var(--m3-outline-var);
}
.modal-confirm-cancelar:hover {
  background: var(--m3-surface-3);
}
.modal-confirm-eliminar {
  background: var(--rojo);
  color: white;
  box-shadow: 0 4px 12px rgba(198,40,40,0.3);
}
.modal-confirm-eliminar:hover {
  background: #8b0000;
}
.modal-confirm-aceptar {
  background: var(--azul);
  color: white;
  box-shadow: 0 4px 12px rgba(21,101,192,0.3);
}
.modal-confirm-aceptar:hover {
  background: #0d47a1;
}

/* ── Móvil — modal de confirmación ajustado a pantalla ──── */
@media (max-width: 640px) {
  .modal-confirm-overlay {
    padding: 16px;
  }
  .modal-confirm-card {
    max-width: calc(100vw - 32px);
    padding: 24px 20px 20px;
    border-radius: var(--r-lg);
  }
  .modal-confirm-icono {
    width: 52px;
    height: 52px;
    font-size: 20px;
    margin-bottom: 12px;
  }
  .modal-confirm-titulo {
    font-size: 15.5px;
  }
  .modal-confirm-desc {
    font-size: 13px;
    margin-bottom: 18px;
  }
  .modal-confirm-botones {
    gap: 8px;
  }
  .modal-confirm-btn {
    padding: 11px 12px;
    font-size: 13.5px;
    min-height: 44px;
  }
}

/* Móvil chico — apila botones verticalmente para mayor touch target */
@media (max-width: 360px) {
  .modal-confirm-botones {
    flex-direction: column-reverse;
  }
  .modal-confirm-btn {
    width: 100%;
  }
}

/* Descripción del proyecto socio comunitario en splash */
.splash-alianza-proyecto {
  margin-top: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--m3-primary-cnt-light), #E3F2FD);
  border-radius: var(--r-md);
  border-left: 4px solid var(--m3-primary);
  text-align: left;
}
.splash-alianza-proyecto strong {
  display: block;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--m3-primary);
  margin-bottom: 4px;
  letter-spacing: -0.1px;
}
.splash-alianza-proyecto span {
  display: block;
  font-size: 12px;
  color: var(--m3-on-surface-v);
  line-height: 1.5;
}

/* Logo ITASA en comunidad (card de aliado) */
.com-aliado-icono-img {
  background: white !important;
  padding: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 2px solid var(--m3-primary-cnt) !important;
  overflow: hidden !important;
}
.com-aliado-icono-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

/* Datos del aliado con tercera línea para carrera/proyecto */
.com-aliado-datos small {
  display: block;
  font-size: 11px;
  color: var(--m3-primary-600);
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.2px;
}

/* Descripción del proyecto en comunidad */
.com-proyecto-desc {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--m3-primary-cnt-light);
  border-radius: var(--r-md);
  border-left: 4px solid var(--m3-primary);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--m3-on-surface);
}
.com-proyecto-desc .fas {
  color: var(--m3-primary);
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}
.com-proyecto-desc strong {
  color: var(--m3-primary);
  font-weight: 700;
}

/* Mobile fine-tune */
@media(max-width: 480px) {
  .splash-alianza-logo-img,
  .itasa-svg-wrap {
    width: 78px;
    height: 78px;
  }
  .splash-alianza-proyecto {
    padding: 10px 12px;
  }
  .splash-alianza-proyecto strong { font-size: 12.5px; }
  .splash-alianza-proyecto span { font-size: 11.5px; }
  .com-proyecto-desc { font-size: 12px; padding: 11px 12px; }
}
