:root {
  color-scheme: only light;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  --accent: #ff8c42;
  --bg: #f5f7fb;
  --border: #dde3f0;
  --text: #1f2a37;
  --muted: #526074;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Espacio para el banner inferior fijo (90px + 2px borde) */
  padding-bottom: 92px;
}

header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.topbar {
  background: linear-gradient(135deg, #1f2a37, #27364b);
  color: white;
  padding: 0.6rem clamp(1rem, 4vw, 3rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.topbar-actions button {
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.topbar-actions button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
}

header h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header h1 span {
  color: var(--accent);
}

header p {
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: flex-end;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag-info {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1.5rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
}

.layout--centered-table {
  grid-template-columns: 1fr;
  justify-content: center;
}

.layout--centered-table .table-container {
  align-self: center;
}

aside {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: sticky;
  top: 1.5rem;
  height: fit-content;
}

.admin-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 1.5rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  transition: grid-template-columns 0.2s ease;
}

.admin-layout--collapsed {
  grid-template-columns: 80px 1fr;
}

.sidebar {
  gap: 1.2rem;
  max-height: calc(100vh - 3rem);
  transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.sidebar__title {
  font-weight: 600;
  color: var(--muted);
}

.sidebar__toggle {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  font-size: 0.95rem;
  line-height: 1;
}

.sidebar__toggle:hover {
  background: rgba(31, 42, 55, 0.08);
}

.sidebar--collapsed {
  width: 64px;
  padding: 1.2rem 0.75rem;
  gap: 0.75rem;
  align-items: center;
}

.sidebar--collapsed .sidebar__title {
  display: none;
}

.sidebar--collapsed .sidebar__toggle {
  transform: rotate(180deg);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar__group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar__group-button {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 0.4rem 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}

.sidebar__group-button::after {
  content: "▾";
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.sidebar__group-button[aria-expanded="false"]::after {
  transform: rotate(-90deg);
}

.sidebar__submenu {
  list-style: none;
  display: grid;
  gap: 0.3rem;
  padding-left: 0.5rem;
}

.sidebar__submenu[hidden] {
  display: none;
}

.sidebar__link {
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar__link:hover {
  background: rgba(31, 42, 55, 0.08);
}

.sidebar__link.is-active {
  background: rgba(255, 140, 66, 0.16);
  color: var(--accent);
  font-weight: 600;
}

.sidebar--collapsed .sidebar__group-button,
.sidebar--collapsed .sidebar__submenu,
.sidebar--collapsed .sidebar__link {
  display: none;
}

.main-panel {
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
}

.panel-section[hidden] {
  display: none;
}

.table-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel-section .table-container,
.panel-section .table-title,
.panel-section .table-actions-bar {
  width: 100%;
  margin: 0;
}

.table-actions-bar--aligned {
  justify-content: flex-start;
  margin: 0;
}

.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
}

.table-filters__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.table-filters__field--search input {
  min-width: clamp(180px, 28vw, 260px);
}

.table-filters input[type="search"] {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: #f7f9fc;
  font-size: 0.95rem;
}

.table-filters select {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: #f7f9fc;
  font-size: 0.95rem;
  min-width: 150px;
}

.table-filters input[type="search"]:focus,
.table-filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
  background-color: white;
}

.form-switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f9fc;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-switch-group .switch {
  margin-left: auto;
}

.modal--narrow {
  width: min(100%, 520px);
}

.detail-list {
  display: grid;
  gap: 1rem;
}

.detail-list__item {
  display: grid;
  gap: 0.2rem;
}

.detail-list__item dt {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-list__item dd {
  font-size: 0.95rem;
  color: var(--text);
}

.detail-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.detail-gallery__image {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 1px solid rgba(82, 96, 116, 0.25);
  object-fit: cover;
  background: #f0f2f8;
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.detail-gallery__image:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 18px rgba(31, 42, 55, 0.18);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pill--success {
  background: rgba(34, 197, 94, 0.15);
  color: #047857;
}

.status-pill--warning {
  background: rgba(248, 113, 113, 0.15);
  color: #b91c1c;
}

aside h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.filter-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.infinite-scroll-hint {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.75rem 1rem;
  background: rgba(82, 96, 116, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(82, 96, 116, 0.15);
}

.load-more-button {
  width: 100%;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* Filtros colapsables (acordeón) */
.filter-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  overflow: hidden;
}

.filter-accordion summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s;
}

.filter-accordion summary:hover {
  background-color: rgba(82, 96, 116, 0.04);
}

.filter-accordion summary::-webkit-details-marker {
  display: none;
}

.filter-accordion summary::after {
  content: '▼';
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s;
}

.filter-accordion[open] summary::after {
  transform: rotate(-180deg);
}

.filter-section-content {
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  background-color: #fafbfc;
}

.filter-section {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
textarea {
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: #f7f9fc;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
  background-color: white;
}

button {
  padding: 0.8rem;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #ff8c42, #ff5f6d);
  color: white;
  box-shadow: 0 10px 20px rgba(255, 98, 87, 0.2);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(255, 98, 87, 0.25);
}

.btn-secondary {
  background: #e5ecf8;
  color: var(--muted);
}

.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(82, 96, 116, 0.16);
}

.btn-tertiary {
  background: #d1fae5;
  color: #047857;
}

.btn-tertiary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(4, 120, 87, 0.16);
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.tags--status {
  justify-content: center;
}

.tag {
  background: rgba(255, 140, 66, 0.12);
  color: var(--accent);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* ── Results grid ─────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.75rem;
}

/* ── Animal card ──────────────────────────────────────────── */
.card {
  background: white;
  border-radius: 20px;
  border: 1px solid rgba(82, 96, 116, 0.08);
  box-shadow: 0 8px 24px rgba(82, 96, 116, 0.10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-7px);
  box-shadow: 0 22px 44px rgba(82, 96, 116, 0.20);
}

/* Image block */
.card-img-wrapper {
  position: relative;
  height: 230px;
  flex-shrink: 0;
  overflow: hidden;
  background: white;
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

/* Imagen por defecto — fondo blanco, sin recorte */
.img--placeholder {
  object-fit: contain !important;
}

.card:hover .card-img-wrapper img {
  transform: scale(1.04);
}

/* Gradient overlay at image bottom */
.card-img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(15,23,42,0.45) 0%, transparent 55%);
  pointer-events: none;
}

/* Species badge – top-right */
.card-species-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.90);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  line-height: 1;
}

/* Image count badge – top-left */
.card-img-count {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  line-height: 1;
}

/* Name + sex row anchored to image bottom */
.card-name-overlay {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-name-overlay h3 {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-shadow: 0 1px 6px rgba(0,0,0,0.45);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sex-icon {
  flex-shrink: 0;
  font-size: 1.05rem;
  margin-left: 0.4rem;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Info block */
.card-info {
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

/* Chip pills */
.card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.card-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--muted);
  background: #f0f4fa;
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  white-space: nowrap;
}

.card-chip .chip-icon {
  font-size: 0.8rem;
  line-height: 1;
}

/* Description */
.card-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* CTA row */
.card-cta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(82,96,116,0.08);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 50;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: white;
  border-radius: 22px;
  padding: clamp(1.2rem, 2vw, 2.2rem);
  max-width: 620px;
  width: min(100%, 620px);
  max-height: min(90vh, 800px);
  display: grid;
  gap: 1.2rem;
  position: relative;
  overflow-y: auto;
  scrollbar-width: thin;
}

.modal img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 16px;
}

.close-modal {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  font-size: 1.4rem;
  background: rgba(15, 23, 42, 0.1);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s;
}

.close-modal:hover {
  background: rgba(15, 23, 42, 0.18);
}

.modal section {
  display: grid;
  gap: 0.6rem;
}

.modal h2 {
  font-size: 3rem;
  font-weight: 700;
}

.modal .details {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.contact-card {
  border: 1px solid rgba(82, 96, 116, 0.15);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.45rem;
}

.contact-card span {
  color: var(--muted);
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

fieldset {
  border: 1px solid rgba(82, 96, 116, 0.15);
  border-radius: 16px;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

fieldset legend {
  font-weight: 600;
  padding: 0 0.5rem;
}

.form-actions {
  margin-top: 1.2rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

.form-feedback {
  min-height: 1.4rem;
  font-size: 0.9rem;
}

.form-feedback.success {
  color: #15803d;
}

.form-feedback.error {
  color: #b91c1c;
}

.textarea textarea {
  min-height: 120px;
  resize: vertical;
}

.empty-state,
.error-state {
  grid-column: 1 / -1;
  padding: 1.5rem;
  border-radius: 16px;
  background: white;
  border: 1px dashed rgba(82, 96, 116, 0.25);
  text-align: center;
  color: var(--muted);
}

.error-state {
  border-style: solid;
  color: #b91c1c;
}

.image-upload {
  display: grid;
  gap: 0.75rem;
}

.image-upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.image-upload-header span {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.image-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.btn-small {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.75rem;
}

.preview-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(82, 96, 116, 0.18);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-badge {
  position: absolute;
  inset: 10px auto auto 10px;
  background: rgba(15, 23, 42, 0.45);
  color: white;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
}

.remove-image-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.remove-image-btn:hover {
  background: rgba(15, 23, 42, 0.85);
}

.preview-placeholder {
  border: 1px dashed rgba(82, 96, 116, 0.35);
  border-radius: 14px;
  padding: 1.2rem;
  min-height: 180px;
  width: 100%;
  max-width: 220px;
  margin: 0 auto;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.preview-placeholder img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  opacity: 0.85;
}

.modal-gallery {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.modal-gallery img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  opacity: 0.7;
  transition: transform 0.2s, opacity 0.2s;
  border: 2px solid transparent;
}

.modal-gallery img.active {
  opacity: 1;
  transform: scale(1.05);
  border-color: var(--accent);
}

.gallery-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Old static hint — oculto; el JS genera .gallery-hint dinámicamente */
.modal-image-hint { display: none; }

/* ══════════════════════════════════════════════════════════
   MODAL ANIMAL — rediseño 2 columnas
   ══════════════════════════════════════════════════════════ */

/* Override base .modal para el modal de animal */
.modal--animal {
  max-width: 80vw;
  width: 80vw;
  height: min(90vh, 780px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0;
}

/* Navegación entre animales (anterior / siguiente) */
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.55);
  color: white;
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s, transform 0.2s;
}

.modal-nav:hover {
  background: rgba(15, 23, 42, 0.85);
  transform: translateY(-50%) scale(1.06);
}

.modal-nav--prev { left: 14px; }
.modal-nav--next { right: 14px; }

/* Contenedor principal dos columnas */
.modal-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Columna izquierda ────────────────────────────── */
.modal-col-left {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(82, 96, 116, 0.10);
  background: #f8fafd;
  overflow-y: auto;
  scrollbar-width: thin;
}

.modal-img-block {
  flex-shrink: 0;
  background: white;
}

/* Override del .modal img genérico */
.modal--animal #modal-img {
  width: 100%;
  height: 270px;
  max-height: none;
  object-fit: cover;
  border-radius: 0;
  display: block;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal--animal #modal-img:hover { opacity: 0.9; }

.modal--animal .modal-gallery {
  padding: 0.55rem 0.75rem;
  background: #eef2f8;
  gap: 0.45rem;
  border-top: 1px solid rgba(82,96,116,0.08);
}

.modal--animal .gallery-hint {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: #eef2f8;
  border-top: 1px solid rgba(82,96,116,0.08);
  text-align: center;
}

/* Custodio */
.modal-custodio-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem 1rem;
  border-top: 1px solid rgba(82,96,116,0.10);
  flex: 1;
}

.modal-custodio-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ffb347);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.modal-custodio-info {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}

.modal-custodio-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
}

.modal-custodio-detail {
  font-size: 0.79rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Columna derecha ──────────────────────────────── */
.modal-col-right {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-animal-name {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  padding: 1.1rem 1.4rem 0.8rem;
  padding-right: 3.5rem; /* espacio para botón cerrar */
  border-bottom: 1px solid rgba(82,96,116,0.08);
  flex-shrink: 0;
  line-height: 1.2;
}

/* Área scrollable de atributos + descripción */
.modal-details-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  scrollbar-width: thin;
}

/* Secciones generadas por formatDetails */
.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(82,96,116,0.08);
}

/* Grid 2 columnas de pills */
.modal-attr-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}

.modal-attr-pill {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  background: #f0f4fa;
  border-radius: 10px;
  padding: 0.4rem 0.65rem;
  min-width: 0;
}

.attr-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.attr-value {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Color coding Sí / No */
.modal-attr-pill--yes { background: #f0fdf4; }
.modal-attr-pill--yes .attr-value { color: #16a34a; font-weight: 600; }

.modal-attr-pill--no  { background: #fef2f2; }
.modal-attr-pill--no  .attr-value { color: #dc2626; font-weight: 600; }

/* Descripción con acento izquierdo */
.modal-desc-block {
  border-left: 3px solid var(--accent);
  padding: 0.6rem 1rem;
  background: rgba(255, 140, 66, 0.05);
  border-radius: 0 10px 10px 0;
}

.modal-desc-block p {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.65;
  font-style: italic;
}

/* Botón CTA */
.modal-cta-row {
  padding: 0.85rem 1.4rem;
  border-top: 1px solid rgba(82,96,116,0.08);
  flex-shrink: 0;
}

/* ── Responsive modal animal ─────────────────────── */
@media (max-width: 700px) {
  .modal--animal {
    width: 100%;
    height: 95vh;
    border-radius: 20px 20px 0 0;
    align-self: flex-end;
  }

  .modal-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .modal-col-left {
    border-right: none;
    border-bottom: 1px solid rgba(82,96,116,0.10);
    overflow: visible;
  }

  .modal--animal #modal-img {
    height: 210px;
  }

  .modal-animal-name {
    font-size: 1.3rem;
    padding: 0.9rem 1rem 0.6rem;
    padding-right: 3rem;
  }

  .modal-details-scroll {
    padding: 0.85rem 1rem;
    overflow: visible;
  }

  .modal-cta-row {
    padding: 0.75rem 1rem;
  }

  .modal-attr-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.auth-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 60;
}

.auth-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.auth-modal {
  background: white;
  padding: clamp(1.5rem, 3vw, 2.2rem);
  border-radius: 18px;
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
}

.auth-modal h2 {
  font-size: 1.4rem;
  font-weight: 600;
}

.auth-modal form {
  display: grid;
  gap: 0.8rem;
}

.auth-modal .form-row {
  display: grid;
  gap: 0.45rem;
}

.auth-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.auth-links {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.auth-links button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}

.auth-message {
  min-height: 1.2rem;
  font-size: 0.85rem;
}

.auth-message.success {
  color: #15803d;
}

.auth-message.error {
  color: #b91c1c;
}

.admin-panel {
  background: rgba(82, 96, 116, 0.08);
  border: 1px solid rgba(82, 96, 116, 0.1);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.image-viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.image-viewer-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.image-viewer {
  position: relative;
  max-width: min(90vw, 960px);
  max-height: 90vh;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.image-viewer img {
  width: 100%;
  height: 100%;
  max-height: 80vh;
  object-fit: contain;
  background: white;
}

.image-viewer__close,
.image-viewer__nav {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.65);
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.image-viewer__close {
  top: 12px;
  right: 12px;
}

.image-viewer__close:hover {
  background: rgba(15, 23, 42, 0.9);
}

.image-viewer__nav {
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.55);
}

.image-viewer__nav--prev {
  left: 12px;
}

.image-viewer__nav--next {
  right: 12px;
}

.image-viewer__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.image-viewer__nav:not(:disabled):hover {
  background: rgba(15, 23, 42, 0.92);
  transform: translateY(-50%) scale(1.05);
}

.image-viewer figcaption {
  padding: 0.5rem 1rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
}

@media (max-width: 640px) {
  .image-viewer__close,
  .image-viewer__nav {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
}

footer {
  text-align: center;
  padding: 1.2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.system-message {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1.5rem;
  z-index: 120;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.system-message--visible {
  opacity: 1;
  pointer-events: auto;
}

.system-message__content {
  width: min(90vw, 420px);
  margin-top: 1.5rem;
  border-radius: 14px;
  padding: 1rem 1.1rem 1rem 1.25rem;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  border: 1px solid transparent;
  color: var(--text);
  background: white;
  pointer-events: auto;
}

.system-message__icon {
  font-size: 1.25rem;
}

.system-message__text {
  flex: 1;
  line-height: 1.4;
}

.system-message__close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  padding: 0;
  line-height: 1;
}

.system-message--success .system-message__content {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.system-message--error .system-message__content {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.system-message--warning .system-message__content {
  background: #fffbeb;
  border-color: #fef3c7;
  color: #92400e;
}

.system-message--info .system-message__content {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* Estilos para la tabla de publicaciones */
.table-container {
  background: white;
  border-radius: 18px;
  border: 1px solid rgba(82, 96, 116, 0.08);
  box-shadow: 0 12px 30px rgba(82, 96, 116, 0.12);
  overflow-x: auto;
  margin: 1.5rem auto 0;
  width: min(95vw, 1400px);
}

.table-actions-bar {
  width: min(95vw, 1400px);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.table-actions-bar__group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.selection-indicator {
  font-size: 0.85rem;
  color: var(--muted);
}

.table-title {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 700;
  text-align: center;
  margin: 1rem auto 0.5rem;
  width: min(95vw, 1400px);
  color: var(--dark);
}

.publications-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.publications-table th,
.publications-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(82, 96, 116, 0.08);
  vertical-align: middle;
}

.publications-table .select-column {
  width: 48px;
  text-align: center;
}

.publications-table .select-column input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.publications-table th {
  background: rgba(255, 140, 66, 0.05);
  font-weight: 600;
  color: var(--muted);
  font-size: 0.9rem;
}

.publications-table tr:last-child td {
  border-bottom: none;
}

.publications-table tr:hover td {
  background: rgba(255, 140, 66, 0.03);
}

.publications-table .table-actions {
  white-space: nowrap;
  text-align: center;
}

.publications-table .table-actions button {
  margin: 0 0.2rem;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.btn-danger:hover {
  background: #fecaca;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

.confirm-modal {
  background: white;
  border-radius: 22px;
  padding: clamp(1.2rem, 2vw, 2.2rem);
  max-width: 420px;
  width: min(100%, 420px);
  display: grid;
  gap: 1.2rem;
  position: relative;
  overflow-y: auto;
}

.confirm-modal h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
}

.confirm-modal p {
  margin: 0;
  color: var(--muted);
}

.confirm-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
  margin-top: 0.4rem;
}

.btn-small {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .table-container {
    width: min(90vw, 100%);
  }
  .table-title {
    width: min(90vw, 100%);
  }
  .table-actions-bar {
    width: min(90vw, 100%);
  }
}

@media (max-width: 768px) {
  .table-container {
    overflow-x: auto;
    width: 100%;
  }
  .table-actions-bar {
    width: 100%;
    justify-content: space-between;
    margin-bottom: 0.5rem;
  }
  
  .publications-table {
    min-width: 600px;
  }
  
  .publications-table th,
  .publications-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  aside {
    position: static;
    order: 2;
  }

  main {
    order: 1;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
  }

  .table-filters {
    gap: 0.6rem;
  }

  .table-filters__field--search input {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .card-img-wrapper {
    height: 200px;
  }

  .card-name-overlay h3 {
    font-size: 1.1rem;
  }
}

@media (max-width: 600px) {
  .modal {
    border-radius: 16px;
    padding: 1rem;
    width: min(100%, 540px);
    max-height: 92vh;
  }
}

@media (max-height: 640px) {
  .modal {
    align-self: flex-start;
    margin-top: 2rem;
  }
}

.modal::-webkit-scrollbar {
  width: 6px;
}

.modal::-webkit-scrollbar-thumb {
  background-color: rgba(82, 96, 116, 0.35);
  border-radius: 999px;
}

/* ============================================
   Estilos para Test de Compatibilidad
   ============================================ */

.compatibility-test-form {
  max-width: 1200px;
  margin: 0 auto;
}

.test-section {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.test-section h2 {
  color: var(--accent);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-description {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.compatibility-badge {
  animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animal-card__image-container {
  position: relative;
  overflow: hidden;
}

.animal-card__details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.animal-card__details p {
  margin: 0.25rem 0;
}

.animal-card__contact {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.animal-card__contact p {
  margin: 0.25rem 0;
}

.modal--large {
  max-width: 1400px;
  width: 95%;
  max-height: 90vh;
}

.alert-info {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsividad para el test */
@media (max-width: 768px) {
  .test-section {
    padding: 1.5rem;
  }

  .test-section h2 {
    font-size: 1.3rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
    max-height: 70vh;
  }

  .modal--large {
    width: 100%;
    max-height: 95vh;
  }

  .animal-card__details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .compatibility-badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
  }
}

/* ========================================
   ESTADÍSTICAS - DASHBOARD
   ======================================== */

.stats-overview {
  padding: 1rem 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stats-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stats-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent);
}

.stats-card__metrics {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.metric:last-child {
  border-bottom: none;
}

.metric__label {
  font-size: 0.9rem;
  color: var(--muted);
}

.metric__value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.stats-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stats-section__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--accent);
}

.distribution-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.distribution-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.distribution-item__label {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.distribution-item__bar {
  flex: 2;
  height: 24px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.distribution-item__bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffb366);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
}

.distribution-item__count {
  font-weight: 600;
  color: var(--text);
  min-width: 60px;
  text-align: right;
}

.distribution-item__percentage {
  font-size: 0.85rem;
  color: white;
  font-weight: 600;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .distribution-item {
    flex-direction: column;
    align-items: stretch;
  }

  .distribution-item__bar {
    width: 100%;
  }
}

/* ==========================================================================
   BANNERS DE PUBLICIDAD — formato estándar 728 × 90 px (leaderboard)
   ========================================================================== */

.banner-zone {
  width: 100%;
  overflow: hidden;
  background: #e5e7eb;
  position: relative;
  line-height: 0; /* evita espacio bajo la imagen */
  /* Altura fija igual al estándar 728×90 */
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-zone--top {
  border-bottom: 1px solid var(--border);
}

.banner-zone--bottom {
  /* Fijo al fondo del viewport — siempre visible sin importar el scroll */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
}

.banner-slide {
  display: none;
  /* Contenedor centrado a 728 px de ancho máximo */
  width: 100%;
  max-width: 728px;
  height: 90px;
}

.banner-slide--active {
  display: block;
}

.banner-slide img {
  width: 728px;
  max-width: 100%;
  height: 90px;
  object-fit: cover;
  object-position: center;
  display: block;
  /* Centra la imagen si el viewport es más ancho */
  margin: 0 auto;
}

/* Card de publicidad intercalada — idéntica a .card de animales */
.banner-inline-card {
  cursor: pointer;
}

.banner-inline-card .card-species-badge {
  background: rgba(255, 210, 0, 0.92);
  color: #1a1a1a;
  font-weight: 700;
}

@media (max-width: 728px) {
  /* En móvil la imagen se comprime proporcionalmente manteniendo 90 px de alto */
  .banner-slide img {
    width: 100%;
    height: 90px;
  }
}
