/* ==========================================================================
   Guía de Mariposas Ibéricas y Lepidópteros - Fijate Tools
   Estilos canónicos adaptativos, accesibles y optimizados para móvil
   ========================================================================== */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta cromática temática (Modo Claro) */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --brand-primary: #059669; /* Verde esmeralda bosque */
  --brand-primary-hover: #047857;
  --brand-primary-light: #ecfdf5;
  --brand-accent: #d97706;  /* Ámbar oruga/alas */
  --brand-accent-light: #fffbeb;
  --brand-blue: #0284c7;    /* Azul licénido */
  --brand-blue-light: #f0f9ff;
  --brand-purple: #7c3aed;  /* Violáceo tornasolado */

  --tag-strict-bg: #fee2e2;
  --tag-strict-text: #991b1b;
  --tag-vuln-bg: #fef3c7;
  --tag-vuln-text: #92400e;
  --tag-safe-bg: #dcfce7;
  --tag-safe-text: #166534;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Modo Oscuro Canónico */
body.theme-dark,
html[data-theme="dark"] body {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-subtle: #1a2433;
  --bg-hover: #223044;
  --border-color: #273549;
  --border-subtle: #1e293b;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --brand-primary: #10b981;
  --brand-primary-hover: #34d399;
  --brand-primary-light: #064e3b;
  --brand-accent: #f59e0b;
  --brand-accent-light: #451a03;
  --brand-blue: #38bdf8;
  --brand-blue-light: #082f49;
  --brand-purple: #a78bfa;

  --tag-strict-bg: #450a0a;
  --tag-strict-text: #fca5a5;
  --tag-vuln-bg: #451a03;
  --tag-vuln-text: #fcd34d;
  --tag-safe-bg: #052e16;
  --tag-safe-text: #86efac;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Reglas estructurales del layout */
body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.card-subtitle-heading,
.seo-guide-heading,
.modal-heading {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-top: 0;
}

.mono,
.pill-number,
.stat-metric-number,
.badge-mm {
  font-family: var(--font-mono);
}

/* Envoltura principal del tool layout */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-main-content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Barra de pestañas táctiles con scroll horizontal suave */
.tool-nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 2px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.tool-nav-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 40px;
}

.tab-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border-color: rgba(16, 185, 129, 0.3);
}

.tab-btn span#sightings-count-badge {
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-weight: 700;
}

/* Contenido de pestañas */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cabecera introductoria de sección */
.section-intro-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.intro-text {
  flex: 1 1 300px;
  min-width: 0;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.stats-pill-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.85rem;
}

.pill-number {
  font-weight: 700;
  color: var(--brand-primary);
}

.pill-label {
  color: var(--text-muted);
}

/* ==========================================================================
   Panel de Filtros y Controles
   ========================================================================== */
.filters-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.filter-group.full-width {
  grid-column: 1 / -1;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.input-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-search-wrapper .search-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-dim);
  pointer-events: none;
}

.text-input,
.select-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font-family: var(--font-main);
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  min-height: 42px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.select-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.input-search-wrapper .text-input {
  padding-left: 2.5rem;
  padding-right: 2.2rem;
}

.btn-clear-input {
  position: absolute;
  right: 0.6rem;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.select-input {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.filters-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ==========================================================================
   Botones de Acción Canónicos
   ========================================================================== */
.btn-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--brand-primary);
  color: #ffffff;
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 42px;
  transition: background 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}

.btn-primary-action:hover {
  background: var(--brand-primary-hover);
}

.btn-secondary-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.btn-secondary-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--text-dim);
}

.btn-danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}

.btn-danger-action:hover {
  background: #b91c1c;
}

.btn-danger-text {
  background: transparent;
  border: none;
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}

.btn-danger-text:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Cuadrícula de Fichas de Mariposas
   ========================================================================== */
.butterflies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.butterfly-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  position: relative;
  min-width: 0;
}

.butterfly-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-primary);
}

.card-visual-header {
  position: relative;
  background: #0f172a;
  aspect-ratio: 16 / 10.5;
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.butterfly-real-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.butterfly-card:hover .butterfly-real-img {
  transform: scale(1.06);
}

.butterfly-silhouette-svg {
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25));
  transition: transform 0.25s ease;
}

.butterfly-card:hover .butterfly-silhouette-svg {
  transform: scale(1.05);
}

.card-top-badges {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  right: 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  z-index: 2;
}

.badge-continent {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.modal-photo-hero {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  background: #0f172a;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.compare-photo-cell img {
  width: 100%;
  max-width: 260px;
  height: 170px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #0f172a;
}

.badge-family {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-protection-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
}

.badge-protection-pill.strict {
  background: var(--tag-strict-bg);
  color: var(--tag-strict-text);
}

.badge-protection-pill.vulnerable {
  background: var(--tag-vuln-bg);
  color: var(--tag-vuln-text);
}

.badge-protection-pill.least_concern {
  background: var(--tag-safe-bg);
  color: var(--tag-safe-text);
}

.card-info-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.card-common-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.15rem 0;
  line-height: 1.3;
}

.card-scientific-name {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.card-metrics-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.metric-chip svg {
  color: var(--text-dim);
}

.card-plant-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0 0 0.75rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flight-months-chips {
  display: flex;
  gap: 2px;
}

.month-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-color);
}

.month-dot.active {
  background: var(--brand-accent);
}

.btn-card-details {
  background: transparent;
  border: none;
  color: var(--brand-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0;
}

.btn-card-details:hover {
  text-decoration: underline;
}

/* Estado vacío */
.empty-state-box {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  margin: 2rem 0;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.empty-state-desc {
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 1.25rem;
}

/* ==========================================================================
   Pestaña 2: Comparador Anatómico
   ========================================================================== */
.compare-selectors-bar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.compare-select-item {
  flex: 1 1 0%;
  min-width: 0;
}

.compare-vs-badge {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--brand-accent);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.preset-pairs-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-buttons-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-preset-pair {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  color: var(--text-main);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-preset-pair:hover {
  background: var(--brand-primary-light);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.comparison-table thead th {
  background: var(--bg-subtle);
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 2px solid var(--border-color);
}

.comparison-table .col-feature {
  width: 25%;
  font-weight: 600;
  color: var(--text-muted);
}

.comparison-table .col-sp1,
.comparison-table .col-sp2 {
  width: 37.5%;
}

.diff-highlight {
  background: var(--brand-accent-light);
  color: var(--brand-accent);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}

/* ==========================================================================
   Pestaña 3: Cuaderno de Campo
   ========================================================================== */
.cuaderno-actions-top {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-file-label {
  margin: 0;
  cursor: pointer;
}

.sighting-form-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.card-subtitle-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.form-col.flex-1 { flex: 1 1 0%; }
.form-col.flex-2 { flex: 2 1 0%; }
.form-col.full-width { flex: 1 1 100%; width: 100%; }

.form-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.sightings-list-wrapper {
  margin-top: 1.5rem;
}

.sightings-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.sightings-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sighting-item-row {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color 0.15s ease;
}

.sighting-item-row:hover {
  border-color: var(--brand-primary);
}

.sighting-item-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1 1 auto;
  min-width: 0;
}

.sighting-thumb-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: #0f172a;
}

.sighting-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sighting-date-badge {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.65rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  flex-shrink: 0;
}

.sighting-info-block {
  min-width: 0;
}

.sighting-title-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}

.sighting-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.sighting-scientific {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
}

.sighting-place-line {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sighting-notes-bubble {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.25rem;
}

.sighting-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-remove-sighting {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
}

.btn-remove-sighting:hover {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

/* ==========================================================================
   Pestaña 4: Estadísticas de Colección
   ========================================================================== */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card-metric {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1rem;
  text-align: center;
}

.stat-metric-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand-primary);
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.stat-metric-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.stat-metric-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.families-progress-section {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.families-progress-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.family-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.family-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
}

.family-progress-track {
  height: 10px;
  background: var(--border-color);
  border-radius: 9999px;
  overflow: hidden;
}

.family-progress-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* ==========================================================================
   Pestaña 5: Legislación y Protección
   ========================================================================== */
.legal-notice-box-callout {
  display: flex;
  gap: 1.25rem;
  background: var(--tag-strict-bg);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.legal-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.legal-text h4 {
  color: var(--tag-strict-text);
  margin-bottom: 0.35rem;
}

.legal-text p {
  color: var(--text-main);
  font-size: 0.95rem;
  margin: 0;
  line-height: 1.5;
}

.badge-tag-strict {
  background: var(--tag-strict-bg);
  color: var(--tag-strict-text);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
}

.ethical-guidelines-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.ethical-list {
  padding-left: 1.25rem;
  margin: 0;
}

.ethical-list li {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
}

/* ==========================================================================
   Tablas SEO Canónicas
   ========================================================================== */
.seo-table-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  margin: 1.25rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.seo-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 0.92rem;
  text-align: left;
}

.seo-table th,
.seo-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.seo-table thead th {
  background: var(--bg-subtle);
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 2px solid var(--border-color);
}

/* ==========================================================================
   Sección SEO Guía y Acordeón FAQ
   ========================================================================== */
.seo-guide-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.seo-guide-heading {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.seo-faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.seo-faq-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.seo-faq-question {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.seo-faq-question::-webkit-details-marker {
  display: none;
}

.seo-faq-question::after {
  content: "+";
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--brand-primary);
  margin-left: 0.5rem;
}

.seo-faq-item[open] .seo-faq-question::after {
  content: "−";
}

.seo-faq-answer {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.seo-faq-answer p:first-child {
  margin-top: 0;
}

/* ==========================================================================
   Modales Nativos (Ficha de Mariposa y Confirmación)
   ========================================================================== */
.custom-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 23, 0.75);
  backdrop-filter: blur(4px);
}

.modal-dialog-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  z-index: 10;
  overflow: hidden;
  box-sizing: border-box;
}

.modal-dialog-box.modal-wide {
  max-width: 680px;
}

.modal-dialog-box.modal-small {
  max-width: 440px;
}

.modal-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-heading {
  font-size: 1.35rem;
  margin: 0;
}

.modal-subheading {
  font-size: 0.95rem;
  color: var(--text-dim);
  font-style: italic;
}

.btn-close-modal,
.btn-close-confirm {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.btn-close-modal:hover,
.btn-close-confirm:hover {
  color: var(--text-main);
}

.modal-body-content {
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-footer-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.modal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.modal-detail-item {
  background: var(--bg-subtle);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.modal-detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.modal-detail-val {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-key-box {
  background: var(--brand-accent-light);
  border-left: 4px solid var(--brand-accent);
  padding: 0.85rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1rem 0;
  font-size: 0.92rem;
}

/* ==========================================================================
   Contenedor del Escaparate de Afiliados
   ========================================================================== */
.affiliate-wrapper-box {
  margin: 2.5rem 0 1rem;
}

/* ==========================================================================
   Media Queries Responsivas
   ========================================================================== */
@media (min-width: 1536px) {
  .tool-with-sidebar {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
  }
}

@media (max-width: 992px) {
  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .card-main {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .filters-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .compare-selectors-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .compare-vs-badge {
    align-self: center;
    margin: 0.25rem 0;
  }

  .stats-overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cuaderno-actions-top {
    width: 100%;
  }

  .btn-primary-action,
  .btn-secondary-outline,
  .btn-danger-action {
    width: 100%;
    min-height: 42px;
  }

  .sighting-item-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .sighting-item-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
    border-top: 1px dashed var(--border-subtle);
    padding-top: 0.5rem;
  }
}
