.admin-wrap {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--avesmap-dorian);
  padding: 1.5rem 1rem;
}

.admin-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-sidebar a {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  color: var(--avesmap-slate);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}

.admin-sidebar a:hover {
  background: var(--avesmap-dorian);
  color: var(--avesmap-onyx);
}

.admin-sidebar a.active {
  background: var(--avesmap-dorian);
  color: var(--avesmap-blue);
  font-weight: 600;
}

.admin-sidebar a.active::before {
  content: '';
  position: absolute;
  left: -0.55rem;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(104deg, #2fb0ef 13.23%, #69a647 163.77%);
}

.btn-gradient-key {
  background: linear-gradient(104deg, #2fb0ef 13.23%, #69a647 163.77%) !important;
  border: none !important;
  color: #fff !important;
}

.btn-gradient-key:hover {
  filter: brightness(1.05);
}

.nav-ms-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-link-soon {
  cursor: default;
}

.nav-link-soon:hover {
  background: #f8fafc !important;
  color: #94a3b8 !important;
}

.admin-sidebar .logout {
  color: var(--avesmap-light-slate);
  font-size: 0.9rem;
}

.admin-main {
  flex: 1;
  padding: 1.5rem 2rem;
  background: var(--avesmap-cloud);
  position: relative;
  z-index: 1;
}

.admin-topbar {
  background: #fff;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-topbar-left {
  min-width: 0;
}

.admin-topbar-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  font-weight: 600;
  color: #0f172a;
}

.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--avesmap-dorian);
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--avesmap-slate);
  cursor: pointer;
  transition: all 0.2s ease;
}

.admin-topbar-btn:hover {
  background: #f8fafc;
}

.admin-main .card,
article {
  background: #fff;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* === Estadísticas: KPI cards y gráficos estilizados === */
.stat-card {
  position: relative;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: none;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(14, 14, 44, 0.08);
}
.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
  color: #fff;
}
.stat-card .stat-icon svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}
.stat-card .stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-card-blue { background: linear-gradient(135deg, #2699d1 0%, #1e7ab0 100%); box-shadow: 0 4px 14px rgba(38, 153, 209, 0.35); }
.stat-card-onyx { background: linear-gradient(135deg, #0e0e2c 0%, #1e1e3f 100%); box-shadow: 0 4px 14px rgba(14, 14, 44, 0.3); }
.stat-card-green { background: linear-gradient(135deg, #2db87a 0%, #22a16a 100%); box-shadow: 0 4px 14px rgba(45, 184, 122, 0.35); }
.stat-card-iba { background: linear-gradient(135deg, #7fbc5d 0%, #69a647 100%); box-shadow: 0 4px 14px rgba(127, 188, 93, 0.35); }

.chart-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--avesmap-dorian);
  box-shadow: 0 1px 3px rgba(14, 14, 44, 0.04);
  padding: 1.25rem 1.5rem;
  transition: box-shadow 0.2s ease;
}
.chart-card:hover {
  box-shadow: 0 4px 12px rgba(14, 14, 44, 0.06);
}
.chart-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--avesmap-onyx);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.chart-card-title .chart-icon {
  width: 28px;
  height: 28px;
  padding: 4px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chart-card-title .chart-icon svg {
  width: 18px;
  height: 18px;
}
.chart-card-subtitle {
  font-size: 0.75rem;
  color: var(--avesmap-light-slate);
  margin-bottom: 1rem;
}

.chart-card .text-slate-500.text-center {
  padding: 2.5rem 1rem;
  font-size: 0.875rem;
  color: var(--avesmap-light-slate);
  background: linear-gradient(180deg, transparent 0%, rgba(248,250,252,0.8) 100%);
  border-radius: 8px;
  margin-top: 0.5rem;
}

/* Mobile header & menú hamburguesa */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--avesmap-dorian);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-header .logo-header {
  height: 48px;
}

.btn-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 8px;
  background: #fff;
  color: var(--avesmap-onyx);
  cursor: pointer;
}

.btn-menu:hover {
  background: var(--avesmap-dorian);
}

.btn-menu svg {
  width: 24px;
  height: 24px;
}

/* Threats page - Stitch style */
.threats-stitch-panel {
  background: #fff;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.threat-select {
  width: 100%;
  border: 1px solid transparent;
  background: var(--avesmap-dorian);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 0.875rem;
  color: var(--avesmap-slate);
  outline: none;
}

.threat-select:focus {
  border-color: var(--avesmap-blue);
  box-shadow: 0 0 0 3px rgba(38, 153, 209, 0.18);
  background: #fff;
}

.threat-status-chip {
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.42rem 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease, transform 0.12s ease;
  box-shadow: none;
}

.threat-status-chip:hover {
  transform: translateY(-1px);
  border-color: #9ca3af;
  color: #475569;
  background: #e5e7eb;
}

.threat-status-chip.is-active {
  background: var(--avesmap-blue);
  border-color: var(--avesmap-blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(38, 153, 209, 0.2);
}

.threat-status-chip[data-status="PENDING"].is-active {
  background: var(--avesmap-blue);
  border-color: var(--avesmap-blue);
  box-shadow: 0 8px 18px rgba(38, 153, 209, 0.24);
}

.threat-status-chip[data-status="APPROVED"].is-active {
  background: var(--avesmap-blue);
  border-color: var(--avesmap-blue);
  box-shadow: 0 8px 18px rgba(38, 153, 209, 0.24);
}

.threat-status-chip[data-status="REJECTED"].is-active {
  background: var(--avesmap-blue);
  border-color: var(--avesmap-blue);
  box-shadow: 0 8px 18px rgba(38, 153, 209, 0.24);
}

.threat-status-chip[data-status="ASK_FOR_DELETE"].is-active {
  background: var(--avesmap-blue);
  border-color: var(--avesmap-blue);
  box-shadow: 0 8px 18px rgba(38, 153, 209, 0.24);
}

.notify-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  padding: 0.6rem 0.7rem;
}

button.notify-item {
  width: 100%;
  cursor: pointer;
  transition: all 0.2s ease;
}

button.notify-item:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.notify-item-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.notify-item-count {
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15rem 0.45rem;
}

.notify-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.help-modal-content {
  max-width: 860px;
}

.help-modal-body {
  max-height: calc(90vh - 80px);
}

.help-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--avesmap-dorian);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.help-section h4 {
  font-size: 0.97rem;
  font-weight: 700;
  color: var(--avesmap-onyx);
  margin-bottom: 0.35rem;
}

.help-section p {
  font-size: 0.86rem;
  color: var(--avesmap-slate);
  margin-bottom: 0.6rem;
}

.help-section img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--avesmap-dorian);
  background: #fff;
}

.threats-stitch-table-wrap {
  background: transparent;
}

.threat-row-stitch td {
  border-bottom: 1px solid #f1f5f9;
}

.stitch-icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.2s ease;
}

.stitch-icon-btn .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
}

.stitch-icon-btn:hover {
  background: #eef4f8;
  color: var(--avesmap-blue);
}

.stitch-icon-btn.approve-btn:hover {
  color: #16a34a;
}

.stitch-icon-btn.reject-btn:hover {
  color: #dc2626;
}

.stitch-icon-btn.delete-btn {
  background: transparent !important;
  border: 1px solid #d1d5db;
  color: #94a3b8;
}

.stitch-icon-btn.delete-btn:hover {
  background: #f8fafc !important;
  border-color: #9ca3af;
  color: #475569;
}

.threats-filters-body {
  display: none !important;
}

.threats-filters-body.is-visible {
  display: grid !important;
}

@media (max-width: 768px) {
  .threats-stitch-panel {
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .admin-wrap {
    flex-direction: column;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 85vw;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
  }

  .admin-sidebar.is-open {
    transform: translateX(0);
  }

  .admin-sidebar nav {
    flex-direction: column;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(14, 14, 44, 0.4);
    z-index: 150;
  }

  .sidebar-backdrop.is-visible {
    display: block;
  }

  .admin-main {
    padding: 1rem;
    min-height: 100vh;
    padding-top: 0.5rem;
  }

  .admin-topbar {
    padding: 0.55rem 0.7rem;
  }

  .admin-topbar-search {
    min-width: 120px;
    width: 120px;
  }
}

/* Modal detalle amenaza — estilo TailAdmin / AvesMap */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 44, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.modal-overlay.is-closing {
  opacity: 0;
  visibility: hidden;
}
.modal-overlay.hidden {
  display: none !important;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(14, 14, 44, 0.2), 0 8px 24px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(12px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.modal-overlay.is-open .modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.modal-overlay.is-closing .modal-content {
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition-duration: 0.2s;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--avesmap-dorian);
  background: linear-gradient(180deg, #fff 0%, var(--avesmap-cloud) 100%);
}
.modal-header h3 {
  color: var(--avesmap-onyx);
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}
.modal-close-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--avesmap-light-slate);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.modal-close-btn:hover {
  color: var(--avesmap-onyx);
  background: var(--avesmap-dorian);
}
.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
}
/* Secciones del detalle */
.detail-section {
  margin-bottom: 1.5rem;
  animation: detailSectionIn 0.4s ease backwards;
}
.detail-section:nth-child(1) { animation-delay: 0.05s; }
.detail-section:nth-child(2) { animation-delay: 0.1s; }
.detail-section:nth-child(3) { animation-delay: 0.15s; }
.detail-section:nth-child(4) { animation-delay: 0.2s; }
.detail-section:nth-child(5) { animation-delay: 0.25s; }
.detail-section:nth-child(6) { animation-delay: 0.3s; }
@keyframes detailSectionIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.detail-section:last-child {
  margin-bottom: 0;
}
.detail-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--avesmap-blue);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--avesmap-dorian);
}
.detail-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
  align-items: flex-start;
}
.detail-row:last-child {
  margin-bottom: 0;
}
.detail-row-block {
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}
.detail-row-block .detail-value-block {
  margin-top: 0;
}
.modal-body .detail-label {
  font-weight: 600;
  color: var(--avesmap-onyx);
  min-width: 115px;
  flex-shrink: 0;
}
.modal-body .detail-value {
  color: var(--avesmap-slate);
  flex: 1;
  word-break: break-word;
}
.modal-body .detail-value.mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
}
.detail-value-block {
  background: var(--avesmap-cloud);
  border: 1px solid var(--avesmap-dorian);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--avesmap-slate);
  line-height: 1.5;
}
/* Galería de imágenes */
.detail-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.detail-media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.detail-media-input {
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  background: #fff;
}

.detail-media-upload {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(104deg, #2fb0ef 13.23%, #69a647 163.77%);
  cursor: pointer;
}

.detail-media-upload:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.detail-empty-media {
  color: var(--avesmap-light-slate);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

.detail-media-card {
  position: relative;
}

.detail-media-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  background: rgba(220, 38, 38, 0.92);
  cursor: pointer;
}

.detail-video-card {
  align-content: center;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--avesmap-dorian);
  background: var(--avesmap-cloud);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.detail-video-card:hover {
  box-shadow: 0 4px 12px rgba(14, 14, 44, 0.08);
  transform: translateY(-2px);
}

.detail-image-card {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--avesmap-dorian);
  background: var(--avesmap-cloud);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.detail-image-card:hover {
  box-shadow: 0 4px 12px rgba(14, 14, 44, 0.08);
  transform: translateY(-2px);
}
.detail-image-link {
  display: block;
  text-decoration: none;
  color: var(--avesmap-blue);
  font-size: 0.8rem;
}
.detail-image-link img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.detail-image-link span {
  display: block;
  padding: 0.4rem 0.5rem;
  text-align: center;
}
.btn-view-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--avesmap-dorian);
  border-radius: 6px;
  background: #fff;
  color: var(--avesmap-slate);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-view-detail:hover {
  background: var(--avesmap-dorian);
  color: var(--avesmap-blue);
}
.btn-view-detail svg {
  width: 18px;
  height: 18px;
}

/* Botones Aprobar / Rechazar — acorde al diseño AvesMaps */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-action svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn-action:hover {
  opacity: 0.9;
  filter: brightness(1.05);
}
.btn-action:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.btn-action.approve-btn {
  background: var(--avesmap-evergreen);
  color: #fff;
}
.btn-action.approve-btn:hover {
  background: #26a36a;
}
.btn-action.reject-btn {
  background: #dc2626;
  color: #fff;
}
.btn-action.reject-btn:hover {
  background: #b91c1c;
}
.btn-action.delete-btn {
  background: #64748b;
  color: #fff;
}
.btn-action.delete-btn:hover {
  background: #475569;
}

