:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.08);
  --primary: #038db2;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --victim: #22c55e;
  --aggressor: #ef4444;
  --radius: 16px;

  --alerts-top-desktop: 190px;
  --alerts-top-tablet: 170px;
  --alerts-top-mobile: 96px;
  --alerts-panel-width: 390px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(3, 141, 178, 0.16), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

/* =========================
   Layout base
========================= */

.map-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand-block h1 {
  margin: 0;
  font-size: 24px;
}

.brand-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

/* =========================
   Switch sonido
========================= */

.sound-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.7);
  border: 1px solid var(--line);
}

.sound-switch input {
  display: none;
}

.switch-slider {
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: #334155;
  border: 1px solid var(--line);
  position: relative;
  transition: 0.2s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 2px;
  border-radius: 999px;
  background: white;
  transition: 0.2s ease;
}

.sound-switch input:checked + .switch-slider {
  background: var(--danger);
}

.sound-switch input:checked + .switch-slider::before {
  transform: translateX(19px);
}

.switch-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

/* =========================
   Resumen superior
========================= */

.summary-grid {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.summary-grid.summary-collapsed,
.summary-grid.hidden-by-default {
  display: none;
}

.summary-card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.summary-card strong {
  font-size: 24px;
}

.summary-card.ok {
  border-color: rgba(34, 197, 94, 0.35);
}

.summary-card.danger {
  border-color: rgba(239, 68, 68, 0.45);
}

.summary-card.warning {
  border-color: rgba(245, 158, 11, 0.45);
}

/* =========================
   Banner alerta
========================= */

.alert-banner {
  flex-shrink: 0;
  border: 1px solid rgba(239, 68, 68, 0.55);
  background:
    linear-gradient(90deg, rgba(239, 68, 68, 0.22), rgba(239, 68, 68, 0.08));
  color: #fecaca;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: alertPulse 1.2s infinite;
}

.alert-banner strong {
  color: #ffffff;
  letter-spacing: 0.04em;
}

.alert-banner.hidden {
  display: none;
}

@keyframes alertPulse {
  0% {
    box-shadow: 0 0 0 rgba(239, 68, 68, 0);
  }

  50% {
    box-shadow: 0 0 24px rgba(239, 68, 68, 0.35);
  }

  100% {
    box-shadow: 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* =========================
   Layout principal
========================= */

.map-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 12px;
  position: relative;
}

/* Panel izquierdo */

.side-panel {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: none;
}

.panel-section h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.pairs-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pairs-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 6px;
}

select {
  width: 100%;
  background: #020617;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
}

.quick-actions {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.full-btn {
  width: 100%;
}

/* Mapa */

.map-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #020617;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

/* =========================
   Panel derecho de alarmas
========================= */

.right-alerts-panel {
  position: fixed;
  top: var(--alerts-top-desktop);
  right: 16px;
  bottom: 16px;
  width: var(--alerts-panel-width);
  max-height: calc(100vh - var(--alerts-top-desktop) - 16px);
  z-index: 900;

  background: rgba(17, 24, 39, 0.97);
  border: 1px solid rgba(239, 68, 68, 0.30);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.map-layout.alerts-hidden .right-alerts-panel {
  display: none;
}

.right-alerts-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0)
  );
}

.right-alerts-header h2 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.2;
}

.right-alerts-header span {
  color: var(--muted);
  font-size: 12px;
  display: inline-block;
}

.right-alerts-header .btn {
  flex-shrink: 0;
}

.right-alerts-header .btn-mini {
  padding: 6px 10px;
}

.pending-alarms-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
}

.alarm-item {
  border: 1px solid rgba(239, 68, 68, 0.42);
  background: rgba(239, 68, 68, 0.08);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}

.alarm-title {
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 8px;
  color: #fecaca;
  letter-spacing: 0.04em;
}

.alarm-meta {
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.alarm-meta div {
  margin-bottom: 4px;
}

.alarm-meta strong {
  color: #e5e7eb;
}

.alarm-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.floating-alerts-btn {
  position: fixed;
  right: 18px;
  top: var(--alerts-top-desktop);
  z-index: 901;
  border: 1px solid rgba(239, 68, 68, 0.40);
  background: rgba(127, 29, 29, 0.96);
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.floating-alerts-btn span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 11px;
}

.floating-alerts-btn.hidden {
  display: none;
}

/* =========================
   Pares
========================= */

.pair-item {
  border: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.52);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}

.pair-item:hover {
  border-color: rgba(3, 141, 178, 0.45);
}

.pair-item.active {
  border-color: var(--primary);
  background: rgba(3, 141, 178, 0.12);
}

.pair-item.has-pending-alarm {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.10);
}

.pair-title {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 6px;
}

.pair-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* =========================
   Badges y botones
========================= */

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 800;
  margin-top: 6px;
}

.badge.danger {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
}

.badge.ok {
  color: #86efac;
  background: rgba(34, 197, 94, 0.13);
}

.badge.warning {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.16);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  border: none;
  border-radius: 10px;
  padding: 9px 11px;
  color: white;
  cursor: pointer;
  font-weight: 800;
  font-size: 12px;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--panel-soft);
}

.btn-danger {
  background: var(--danger);
}

.btn-success {
  background: var(--success);
}

.btn-mini {
  padding: 7px 9px;
  font-size: 11px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px 8px;
  font-size: 13px;
}

/* =========================
   Marcadores Leaflet
========================= */

.device-marker {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 900;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 8px 20px rgba(0,0,0,0.38);
}

.device-marker.victim {
  background: var(--victim);
}

.device-marker.aggressor {
  background: var(--aggressor);
}

.victim-radius-label {
  background: rgba(17, 24, 39, 0.92);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #111827;
  color: var(--text);
}

.popup-title {
  font-weight: 900;
  margin-bottom: 6px;
}

.popup-row {
  font-size: 12px;
  color: var(--muted);
  margin: 3px 0;
}

.popup-row strong {
  color: var(--text);
}

/* =========================
   Modal alarma
========================= */

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-content {
  width: min(480px, 92vw);
  background: #111827;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
}

.modal-content h3 {
  margin: 0 0 14px;
}

.modal-info {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(2, 6, 23, 0.45);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.modal-info strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.modal-primary {
  width: auto;
  margin-top: 0;
}

textarea {
  width: 100%;
  background: #020617;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
  resize: vertical;
}

/* =========================
   Scrollbars
========================= */

.pairs-list::-webkit-scrollbar,
.pending-alarms-list::-webkit-scrollbar {
  width: 8px;
}

.pairs-list::-webkit-scrollbar-track,
.pending-alarms-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.pairs-list::-webkit-scrollbar-thumb,
.pending-alarms-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.45);
  border-radius: 999px;
}

.pairs-list::-webkit-scrollbar-thumb:hover,
.pending-alarms-list::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.65);
}

/* =========================
   Responsive
========================= */

@media (max-width: 1200px) {
  .right-alerts-panel {
    top: var(--alerts-top-tablet);
    right: 12px;
    bottom: 12px;
    width: min(var(--alerts-panel-width), calc(100vw - 24px));
    max-height: calc(100vh - var(--alerts-top-tablet) - 12px);
  }

  .floating-alerts-btn {
    top: var(--alerts-top-tablet);
    right: 14px;
  }
}

@media (max-width: 900px) {
  .map-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .map-layout,
  .map-layout.alerts-hidden {
    grid-template-columns: 1fr;
  }

  .side-panel {
    max-height: 420px;
  }

  .map-card {
    min-height: 620px;
  }

  #map {
    height: 620px;
  }

.right-alerts-panel {
  top: var(--alerts-top-mobile);
  right: 10px;
  bottom: 10px;
  width: calc(100vw - 20px);
  max-height: calc(100vh - var(--alerts-top-mobile) - 10px);
}

.floating-alerts-btn {
  top: var(--alerts-top-mobile);
  right: 12px;
}
}

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

  .topbar-actions {
    width: 100%;
  }

  .btn,
  .sound-switch {
    min-height: 38px;
  }

  .map-card {
    min-height: 520px;
  }

  #map {
    height: 520px;
  }
}

/* =========================
   Popup tarjeta ubicación
========================= */

.location-popup .leaflet-popup-content-wrapper {
  background: #ffffff;
  color: #111827;
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.location-popup .leaflet-popup-content {
  margin: 0;
  width: 100% !important;
}

.location-popup .leaflet-popup-tip {
  background: #ffffff;
}

.location-popup .leaflet-popup-close-button {
  color: #ffffff !important;
  font-size: 20px !important;
  top: 10px !important;
  right: 12px !important;
  z-index: 3;
}

.location-card {
  background: #ffffff;
  color: #111827;
  overflow: hidden;
  min-width: 330px;
}

.location-card-header {
  padding: 14px 16px;
  color: #ffffff;
}

.location-card-header.victim {
  background:
    linear-gradient(135deg, rgba(34, 197, 94, 1), rgba(21, 128, 61, 1));
}

.location-card-header.aggressor {
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 1), rgba(153, 27, 27, 1));
}

.location-role {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 4px;
}

.location-name {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
}

.location-card-body {
  padding: 14px 16px;
}

.location-row {
  margin-bottom: 12px;
}

.location-row.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.location-label {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.location-row strong,
.location-speed-row strong {
  color: #111827;
  font-size: 13px;
}

.address-box {
  display: grid;
  gap: 6px;
}

.address-text {
  color: #111827;
  font-size: 13px;
  line-height: 1.35;
}

.popup-link-btn {
  width: fit-content;
  border: none;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 11px;
  font-weight: 900;
  padding: 6px 9px;
  cursor: pointer;
}

.popup-link-btn:hover {
  background: #bae6fd;
}

.location-speed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.heading-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #111827;
  font-weight: 900;
}

.heading-arrow {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  font-size: 13px;
  transform-origin: center;
}

.location-card-footer {
  display: grid;
  grid-template-columns: 1fr 1fr 42px 42px;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  color: #111827;
  padding: 8px 9px;
  font-size: 12px;
  font-weight: 900;
}

.metric-action {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  cursor: pointer;
  font-size: 17px;
}

.metric-action:hover {
  background: #e0f2fe;
}

.metric-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 620px) {
  .location-card {
    min-width: 300px;
  }

  .location-name {
    font-size: 19px;
  }

  .location-card-footer {
    grid-template-columns: 1fr 1fr 38px 38px;
  }

  .metric-action {
    width: 38px;
  }
}

/*  ------------ PARA LOS POPUPS -------------- */
.modern-popup-card {
  width: 420px;
  max-width: 92vw;
  background: #f7f8fb;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.20);
  font-family: Inter, system-ui, sans-serif;
  color: #1f2a44;
}

.modern-popup-header {
  padding: 26px 26px 18px;
  color: #fff;
  position: relative;
}

.popup-card--victim .modern-popup-header {
  background: linear-gradient(135deg, #0a61ff, #003fcf);
}

.popup-card--aggressor .modern-popup-header {
  background: linear-gradient(135deg, #f10d1d, #b00000);
}

.modern-popup-role {
  font-size: 13px;
  letter-spacing: .18em;
  font-weight: 800;
  opacity: .95;
  margin-bottom: 10px;
}

.modern-popup-title {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  padding-right: 44px;
}

.modern-popup-close {
  position: absolute;
  top: 18px;
  right: 18px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.modern-popup-topchips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 0 26px;
  margin-top: -18px;
}

.modern-popup-chip {
  background: #fff;
  border: 1px solid #dfe5ef;
  border-radius: 18px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0,0,0,.05);
}

.modern-popup-chip.is-online .chip-icon {
  color: #27c45a;
}

.modern-popup-chip.is-offline .chip-icon {
  color: #c4c9d4;
}

.modern-popup-section,
.modern-popup-speedcard {
  margin: 16px 26px 0;
  background: #fff;
  border: 1px solid #dfe5ef;
  border-radius: 24px;
  padding: 20px;
}

.modern-popup-section {
  display: flex;
  gap: 16px;
  align-items: center;
}

.modern-popup-label {
  color: #66748f;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}

.modern-popup-value {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 700;
  color: #1f2a44;
}

.modern-popup-speedcard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #f7faff, #eef3ff);
}

.modern-popup-speed-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.modern-popup-speed-value {
  font-size: 28px;
  font-weight: 800;
  color: #0f1930;
  margin-top: 6px;
}

.modern-heading-arrow {
  width: 58px;
  height: 58px;
  border: 2px solid #2d6dff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: #2d6dff;
}

.modern-popup-detail-row {
  margin: 0 26px;
  padding: 18px 6px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #e3e8f1;
}

.modern-popup-detail-row:last-of-type {
  border-bottom: none;
}

.modern-popup-detail-label {
  color: #66748f;
  font-weight: 800;
  font-size: 13px;
}

.modern-popup-detail-value {
  color: #25314d;
  font-weight: 700;
  text-align: right;
}

.modern-popup-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 20px 26px 26px;
  background: #f7f8fb;
}

.modern-popup-action {
  min-height: 68px;
  border-radius: 20px;
  border: 1px solid #d8e0ea;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  color: #1f2a44;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 12px;
}

.modern-popup-action--primary {
  border-color: #ffd7df;
}
/*  ------------ PARA LOS POPUPS -------------- */

/* ==============================
   Modern device popup compacto
   ============================== */

.modern-leaflet-popup .leaflet-popup-content-wrapper {
  background: transparent !important;
  color: #101828 !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-radius: 22px !important;
}

.modern-leaflet-popup .leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}

.modern-leaflet-popup .leaflet-popup-tip {
  background: #f7f8fb !important;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16) !important;
}

.modern-leaflet-popup .leaflet-popup-close-button {
  display: none !important;
}

.modern-device-popup {
  width: 340px;
  max-width: 90vw;
  background: #f7f8fb;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.26);
  font-family: Arial, Helvetica, sans-serif;
  color: #111827;
}

.modern-popup-header {
  position: relative;
  padding: 18px 20px 48px;
  color: #ffffff;
}

.modern-popup-header.victim {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), transparent 45%),
    linear-gradient(135deg, #0b74ff 0%, #003bc4 100%);
}

.modern-popup-header.aggressor {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), transparent 45%),
    linear-gradient(135deg, #ef0b1a 0%, #a30000 100%);
}

.modern-popup-role {
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 900;
  opacity: 0.96;
  margin-bottom: 8px;
}

.modern-popup-name {
  font-size: 22px;
  line-height: 1.05;
  font-weight: 900;
  padding-right: 34px;
  word-break: break-word;
}

.modern-popup-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.94;
}

.modern-popup-chips {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 20px;
  margin-top: -28px;
}

.modern-chip {
  min-height: 44px;
  background: #ffffff;
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 8px 16px rgba(16, 24, 40, 0.08);
  color: #111827;
  font-size: 13px;
  min-width: 0;
}

.modern-chip strong {
  font-weight: 800;
  white-space: nowrap;
}

.modern-chip-icon.battery {
  color: #16a34a;
  font-size: 16px;
}

.modern-chip-icon.strap {
  color: #6b7ea3;
  font-size: 16px;
}

.modern-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
}

.modern-dot.online {
  background: #32d65a;
}

.modern-dot.offline {
  background: #c9ced8;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.15);
}

.modern-popup-body {
  padding: 14px 14px 0;
}

.modern-info-card {
  background: #ffffff;
  border: 1px solid #dfe6f0;
  border-radius: 16px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.modern-info-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #f2f6fb;
  color: #0b74ff;
  font-size: 17px;
  box-shadow: 0 7px 12px rgba(16, 24, 40, 0.08);
  flex: 0 0 auto;
}

.modern-info-main {
  min-width: 0;
}

.modern-label {
  font-size: 10px;
  font-weight: 900;
  color: #667085;
  letter-spacing: 0.13em;
  margin-bottom: 5px;
}

.modern-value {
  font-size: 14px;
  line-height: 1.22;
  font-weight: 800;
  color: #111827;
  word-break: break-word;
}

.modern-coords-link {
  border: 0;
  background: transparent;
  color: #111827;
  padding: 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.22;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  word-break: break-word;
}

.modern-coords-link:hover {
  color: #0b74ff;
  text-decoration: underline;
}

.modern-speed-card {
  margin-bottom: 10px;
  background:
    radial-gradient(circle at right bottom, rgba(11, 116, 255, 0.10), transparent 34%),
    linear-gradient(180deg, #f9fbff, #eef5ff);
  border: 1px solid #cfe0ff;
  border-radius: 16px;
  padding: 10px 12px;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modern-speed-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.modern-speed-icon {
  width: 39px;
  height: 39px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, #0b74ff, #003bc4);
  font-size: 17px;
  box-shadow: 0 10px 18px rgba(11, 116, 255, 0.20);
}

.modern-speed-value {
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
  color: #111827;
}

.modern-heading-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.modern-heading-wrap strong {
  color: #111827;
  font-size: 12px;
  min-width: 28px;
}

.modern-heading-circle {
  width: 42px;
  height: 42px;
  border: 2px solid #0b74ff;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ffffff;
  flex: 0 0 42px;
}

.modern-heading-arrow {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #0b74ff;
  font-size: 22px;
  line-height: 1;
  transform-origin: center center;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.modern-details {
  padding: 0 2px 0;
}

.modern-detail-row {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 31px;
  border-bottom: 1px solid #e2e8f0;
}

.modern-detail-row:last-child {
  border-bottom: 0;
}

.modern-detail-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0b74ff;
  box-shadow: 0 5px 10px rgba(16, 24, 40, 0.08);
  font-size: 10px;
}

.modern-detail-label {
  font-size: 10px;
  font-weight: 900;
  color: #667085;
  letter-spacing: 0.08em;
}

.modern-detail-value {
  font-size: 12px;
  color: #344054;
  font-weight: 900;
  text-align: right;
}

.modern-popup-actions {
  margin-top: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid #e2e8f0;
  background: #f7f8fb;
  display: grid;
  grid-template-columns: 1fr 0.72fr;
  gap: 8px;
}

.modern-action {
  min-height: 43px;
  border-radius: 13px;
  border: 1px solid #dbe3ee;
  background: #ffffff;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  cursor: pointer;
  box-shadow: 0 6px 13px rgba(16, 24, 40, 0.06);
  font-size: 11px;
  min-width: 0;
  overflow: hidden;
}

.modern-action strong {
  font-weight: 900;
  line-height: 1.05;
}

.modern-action:disabled {
  opacity: 1;
  cursor: default;
}

.modern-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 17px rgba(16, 24, 40, 0.10);
}

.modern-action.wide {
  grid-column: span 1;
}

.modern-action-icon {
  color: #0b74ff;
  font-weight: 900;
  font-size: 14px;
  flex: 0 0 auto;
}

.modern-action-icon.pin {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0b74ff, #003bc4);
  color: #ffffff;
}

.modern-action-icon.current {
  color: #f43f5e;
  font-size: 17px;
}

.modern-signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 28px;
  height: 20px;
  flex: 0 0 auto;
}

.modern-signal-bars i {
  display: block;
  width: 5px;
  border-radius: 2px 2px 0 0;
  background: #0b74ff;
}

.modern-signal-bars i:nth-child(1) {
  height: 5px;
}

.modern-signal-bars i:nth-child(2) {
  height: 9px;
}

.modern-signal-bars i:nth-child(3) {
  height: 14px;
}

.modern-signal-bars i:nth-child(4) {
  height: 19px;
}

@media (max-width: 520px) {
  .modern-device-popup {
    width: 90vw;
  }

  .modern-popup-name {
    font-size: 20px;
  }

  .modern-popup-chips {
    padding: 0 14px;
    gap: 6px;
  }

  .modern-chip {
    font-size: 12px;
  }

  .modern-popup-actions {
    grid-template-columns: 1fr 1fr;
  }
}

.modern-popup-footer {
  margin-top: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid #e2e8f0;
  background: #f7f8fb;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.modern-indicators {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 8px;
}

.modern-indicator {
  min-height: 34px;
  border-radius: 12px;
  border: 1px solid #e3e8f2;
  background: #f2f4f7;
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11px;
  min-width: 0;
  box-shadow: none;
}

.modern-indicator strong {
  font-weight: 900;
  line-height: 1;
}

.modern-satellite-icon {
  font-size: 14px;
  line-height: 1;
}

.modern-actions-compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modern-actions-compact .modern-action {
  min-height: 40px;
}

.modern-popup-actions {
  display: none !important;
}

/* =========================
   Modo pantalla completa del mapa
========================= */

.fullscreen-exit-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1200;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(17, 24, 39, 0.94);
  color: #ffffff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.fullscreen-exit-btn.hidden {
  display: none;
}

body.map-fullscreen {
  overflow: hidden;
}

body.map-fullscreen .map-shell {
  height: 100vh;
  padding: 0;
  gap: 0;
}

body.map-fullscreen .topbar,
body.map-fullscreen .summary-grid,
body.map-fullscreen .side-panel {
  display: none;
}

body.map-fullscreen .map-layout {
  flex: 1;
  height: 100vh;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

body.map-fullscreen .map-card {
  border: 0;
  border-radius: 0;
}

body.map-fullscreen #map {
  height: 100vh;
  min-height: 100vh;
}

body.map-fullscreen .alert-banner {
  position: fixed;
  left: 14px;
  right: 14px;
  top: 0;
  z-index: 1200;
  max-width: none;
  min-height: 44px;
  padding: 12px 18px 14px;
  border: 0;
  border-bottom: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 0 0 18px 18px;
  background: linear-gradient(180deg, rgba(218, 6, 6, 0.98), rgba(191, 7, 7, 0.98));
  color: #fff3f3;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  animation: none;
}

body.map-fullscreen .alert-banner strong {
  color: #ffffff;
  font-size: 15px;
  line-height: 1;
}

body.map-fullscreen .alert-banner span {
  color: rgba(255, 255, 255, 0.96);
  font-size: 14px;
}

body.map-fullscreen.alert-banner-active .leaflet-top,
body.map-fullscreen.alert-banner-active .leaflet-control-container .leaflet-top {
  top: 58px;
}

body.map-fullscreen .right-alerts-panel {
  top: 64px;
  bottom: 16px;
  max-height: calc(100vh - 80px);
}

body.map-fullscreen .floating-alerts-btn {
  top: 64px;
}

body.map-fullscreen.alert-banner-active .right-alerts-panel {
  top: 78px;
  max-height: calc(100vh - 94px);
}

body.map-fullscreen.alert-banner-active .floating-alerts-btn {
  top: 78px;
}

@media (max-width: 900px) {
  body.map-fullscreen .map-shell {
    min-height: 100vh;
    overflow: hidden;
  }

  body.map-fullscreen .map-card,
  body.map-fullscreen #map {
    height: 100vh;
    min-height: 100vh;
  }

  body.map-fullscreen .alert-banner {
    left: 10px;
    right: 10px;
    top: 0;
    padding: 11px 14px 12px;
    border-radius: 0 0 16px 16px;
  }

  body.map-fullscreen.alert-banner-active .leaflet-top,
  body.map-fullscreen.alert-banner-active .leaflet-control-container .leaflet-top {
    top: 72px;
  }

  body.map-fullscreen .right-alerts-panel {
    top: 112px;
    max-height: calc(100vh - 122px);
  }

  body.map-fullscreen .floating-alerts-btn {
    top: 112px;
  }

  body.map-fullscreen.alert-banner-active .right-alerts-panel {
    top: 126px;
    max-height: calc(100vh - 136px);
  }

  body.map-fullscreen.alert-banner-active .floating-alerts-btn {
    top: 126px;
  }
}


/* =========================
   Notificaciones críticas
========================= */

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  opacity: 0.92;
}


#btnTestNotification {
  white-space: nowrap;
}


/* =========================
   Barra superior compacta
========================= */

.critical-alert-switch {
  border-color: rgba(239, 68, 68, 0.30);
}

.critical-alert-switch input:checked + .switch-slider {
  background: var(--danger);
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.40);
}

.critical-alert-switch input:checked ~ .switch-label {
  color: #ffffff;
}

.icon-btn {
  width: 42px;
  min-width: 42px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

#btnRefresh {
  font-size: 22px;
}

#btnLogout {
  font-size: 21px;
  transform: rotate(180deg);
}

@media (max-width: 1100px) {
  .critical-alert-switch .switch-label {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}


/* =========================
   Íconos consistentes
========================= */

a.icon-btn {
  text-decoration: none;
}

#btnMapFullscreen {
  font-size: 19px;
}

.topbar-actions .icon-btn {
  border-radius: 12px;
}


body.map-fullscreen #btnMapFullscreen {
  font-size: 24px;
  font-weight: 700;
}


/* =========================
   Testigo ONLINE / OFFLINE
========================= */

.modern-chip.modern-online-chip {
  border: 1px solid transparent;
  cursor: default;
  user-select: none;
  pointer-events: none;
}

.modern-online-chip strong {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.modern-online-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
  flex: 0 0 auto;
}

.modern-online-chip.is-online {
  background: linear-gradient(180deg, #ecfdf3, #dcfce7);
  border-color: rgba(34, 197, 94, 0.28);
  color: #14532d;
}

.modern-online-chip.is-online .modern-online-dot {
  background: #22c55e;
  box-shadow:
    0 0 0 5px rgba(34, 197, 94, 0.13),
    0 0 12px rgba(34, 197, 94, 0.45);
  animation: onlineWitnessPulse 1.6s ease-in-out infinite;
}

.modern-online-chip.is-offline {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-color: rgba(100, 116, 139, 0.25);
  color: #64748b;
}

.modern-online-chip.is-offline .modern-online-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.14);
}

.modern-online-chip.is-unknown {
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border-color: rgba(245, 158, 11, 0.28);
  color: #92400e;
}

.modern-online-chip.is-unknown .modern-online-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14);
}

@keyframes onlineWitnessPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow:
      0 0 0 5px rgba(34, 197, 94, 0.13),
      0 0 12px rgba(34, 197, 94, 0.45);
  }

  50% {
    transform: scale(1.12);
    box-shadow:
      0 0 0 7px rgba(34, 197, 94, 0.09),
      0 0 18px rgba(34, 197, 94, 0.55);
  }
}


/* =========================
   Testigo de conexión con tolerancia
   TCP ACTIVO / RECIENTE / INTERMITENTE / SIN SESIÓN
========================= */

.modern-chip.modern-online-chip {
  min-width: 104px;
}

.modern-online-chip.is-online {
  background: linear-gradient(180deg, #ecfdf3, #dcfce7);
  border-color: rgba(34, 197, 94, 0.28);
  color: #14532d;
}

.modern-online-chip.is-online .modern-online-dot {
  background: #22c55e;
  box-shadow:
    0 0 0 5px rgba(34, 197, 94, 0.13),
    0 0 12px rgba(34, 197, 94, 0.45);
  animation: onlineWitnessPulse 1.6s ease-in-out infinite;
}

.modern-online-chip.is-recent {
  background: linear-gradient(180deg, #eff6ff, #dbeafe);
  border-color: rgba(59, 130, 246, 0.28);
  color: #1e3a8a;
}

.modern-online-chip.is-recent .modern-online-dot {
  background: #3b82f6;
  box-shadow:
    0 0 0 5px rgba(59, 130, 246, 0.12),
    0 0 12px rgba(59, 130, 246, 0.35);
}

.modern-online-chip.is-intermittent {
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border-color: rgba(245, 158, 11, 0.30);
  color: #92400e;
}

.modern-online-chip.is-intermittent .modern-online-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14);
}

.modern-online-chip.is-offline {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-color: rgba(100, 116, 139, 0.25);
  color: #64748b;
}

.modern-online-chip.is-offline .modern-online-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.14);
}

.modern-online-chip.is-unknown {
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border-color: rgba(100, 116, 139, 0.25);
  color: #64748b;
}

.modern-online-chip.is-unknown .modern-online-dot {
  background: #cbd5e1;
  box-shadow: 0 0 0 5px rgba(148, 163, 184, 0.12);
}


/* =========================
   Tooltip de fecha/hora
========================= */

.modern-time-value {
  cursor: help;
}


/* =========================
   Integración recorrido histórico
========================= */

.modern-actions-compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modern-actions-compact .modern-action {
  min-height: 38px;
  padding: 6px 5px;
  gap: 4px;
  font-size: 10px;
}

.modern-actions-compact .modern-action strong {
  font-size: 10px;
  letter-spacing: -0.01em;
}

.modern-action-icon.history {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #038db2, #206491);
  color: #ffffff;
  font-size: 14px;
}

.history-modal.hidden {
  display: none;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 2500;
}

.history-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(3px);
}

.history-modal-window {
  position: absolute;
  inset: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 22px;
  background: #0f172a;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.history-modal-header {
  flex: 0 0 auto;
  min-height: 56px;
  padding: 10px 14px 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #e5e7eb;
  background: linear-gradient(180deg, #111827, #0f172a);
  border-bottom: 1px solid rgba(148, 163, 184, 0.20);
}

.history-modal-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.history-modal-header span {
  display: block;
  margin-top: 3px;
  color: #9ca3af;
  font-size: 12px;
}

.history-modal-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.history-modal-close:hover {
  background: rgba(239, 68, 68, 0.92);
  border-color: rgba(239, 68, 68, 0.92);
}

.history-modal-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #0f172a;
}

body.history-modal-open {
  overflow: hidden;
}

@media (max-width: 900px) {
  .history-modal-window {
    inset: 10px;
    border-radius: 16px;
  }

  .history-modal-header {
    min-height: 52px;
  }
}

@media (max-width: 520px) {
  .modern-actions-compact .modern-action strong {
    font-size: 9px;
  }

  .modern-actions-compact .modern-action {
    padding-left: 3px;
    padding-right: 3px;
  }
}


/* =========================
   Modal histórico sin encabezado duplicado
========================= */

.history-modal-header {
  display: none;
}

.history-modal-window {
  padding: 0;
}

.history-modal-frame {
  height: 100%;
}

.history-modal-floating-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.92);
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.34);
}

.history-modal-floating-close:hover {
  background: rgba(239, 68, 68, 0.94);
  border-color: rgba(239, 68, 68, 0.94);
}


/* =========================
   Cintilla inferior de alertas generales
========================= */

.general-alerts-ticker {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 12px;
  z-index: 1700;
  min-height: 44px;
  display: grid;
  grid-template-columns: 42px auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(127, 29, 29, 0.95), rgba(17, 24, 39, 0.96) 34%, rgba(15, 23, 42, 0.96));
  color: #ffffff;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.general-alerts-ticker.is-collapsed {
  width: auto;
  right: auto;
  grid-template-columns: 42px auto;
}

.general-alerts-ticker.is-collapsed .general-alerts-viewport {
  display: none;
}

.general-alerts-toggle {
  width: 34px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

.general-alerts-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.general-alerts-pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.18);
  animation: generalAlertPulse 1.4s ease-in-out infinite;
}

.general-alerts-viewport {
  overflow: hidden;
  min-width: 0;
}

.general-alerts-track {
  min-width: 0;
}

.general-alerts-marquee {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 100%;
  animation: generalAlertsTickerMove 42s linear infinite;
}

.general-alerts-marquee:hover {
  animation-play-state: paused;
}

.general-alert-pill {
  min-height: 30px;
  max-width: 480px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.general-alert-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(30, 41, 59, 0.92);
}

.general-alert-pill strong {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.general-alert-pill span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.general-alert-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: #94a3b8;
}

.general-alert-pill.is-critical .general-alert-dot {
  background: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.72);
}

.general-alert-pill.is-warning .general-alert-dot {
  background: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.56);
}

.general-alert-pill.is-info .general-alert-dot {
  background: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.48);
}

.general-alerts-empty {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.general-alerts-error {
  color: #fecaca;
}

.general-alert-detail-content {
  max-width: 620px;
}

.general-alert-detail-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.general-alert-detail-header h3 {
  margin: 0 0 4px;
}

.general-alert-detail-header span {
  color: #64748b;
  font-size: 12px;
}

.general-alert-detail-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #0f172a;
  color: #ffffff;
  font-size: 22px;
  cursor: pointer;
}

.general-alert-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.general-alert-detail-grid div {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}

.general-alert-detail-grid strong {
  display: block;
  color: #64748b;
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.general-alert-detail-grid span {
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
}

.general-alert-detail-text {
  min-height: 90px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  color: #0f172a;
  white-space: pre-wrap;
}

@keyframes generalAlertPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.62;
    transform: scale(1.16);
  }
}

@keyframes generalAlertsTickerMove {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-35%);
  }
}

body.map-fullscreen .general-alerts-ticker {
  left: 14px;
  right: 14px;
  bottom: 12px;
}

@media (max-width: 700px) {
  .general-alerts-ticker {
    left: 8px;
    right: 8px;
    bottom: 8px;
    grid-template-columns: 36px auto minmax(0, 1fr);
    gap: 7px;
    padding: 7px;
  }

  .general-alerts-label {
    font-size: 11px;
  }

  .general-alert-pill {
    max-width: 300px;
    font-size: 11px;
  }

  .general-alert-detail-grid {
    grid-template-columns: 1fr;
  }
}


/* =========================
   Alertas generales v2
========================= */

.general-alert-process-comment {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
}

.general-alert-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.general-alert-map-modal.hidden {
  display: none;
}

.general-alert-map-modal {
  position: fixed;
  inset: 0;
  z-index: 2800;
}

.general-alert-map-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
}

.general-alert-map-window {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(820px, calc(100vw - 36px));
  height: min(560px, calc(100vh - 48px));
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: #0f172a;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.general-alert-map-header {
  flex: 0 0 auto;
  min-height: 56px;
  padding: 10px 14px 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, #111827, #0f172a);
  color: #e5e7eb;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.general-alert-map-header h3 {
  margin: 0;
  font-size: 17px;
}

.general-alert-map-header span {
  display: block;
  margin-top: 3px;
  color: #9ca3af;
  font-size: 12px;
}

.general-alert-map-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.general-alert-mini-map {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #020617;
}

.general-alert-pill strong + span {
  max-width: 360px;
}

@media (max-width: 700px) {
  .general-alert-map-window {
    width: calc(100vw - 18px);
    height: calc(100vh - 36px);
    border-radius: 16px;
  }

  .general-alert-actions {
    justify-content: stretch;
  }

  .general-alert-actions .btn {
    flex: 1 1 auto;
  }
}


/* =========================
   Mapa de alerta integrado al modal de detalle
========================= */

.general-alert-detail-dialog {
  max-width: calc(100vw - 28px);
}

.general-alert-detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.70);
}

.general-alert-detail-content {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  overflow: hidden;
  transition: width 180ms ease;
}

.general-alert-detail-dialog.is-map-visible .general-alert-detail-content {
  width: min(1120px, calc(100vw - 28px));
}

.general-alert-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 0;
  gap: 0;
  transition: grid-template-columns 180ms ease, gap 180ms ease;
}

.general-alert-detail-dialog.is-map-visible .general-alert-detail-layout {
  grid-template-columns: minmax(430px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
}

.general-alert-detail-main {
  min-width: 0;
  max-height: calc(100vh - 78px);
  overflow: auto;
  padding-right: 2px;
}

.general-alert-inline-map-panel {
  min-width: 0;
  display: none;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #0f172a;
}

.general-alert-detail-dialog.is-map-visible .general-alert-inline-map-panel {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.general-alert-inline-map-header {
  flex: 0 0 auto;
  min-height: 54px;
  padding: 10px 12px 9px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: #e5e7eb;
  background: linear-gradient(180deg, #111827, #0f172a);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.general-alert-inline-map-header h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.1;
}

.general-alert-inline-map-header span {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
  font-size: 12px;
}

.general-alert-inline-map-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.general-alert-inline-map-close:hover {
  background: rgba(239, 68, 68, 0.94);
  border-color: rgba(239, 68, 68, 0.94);
}

.general-alert-detail-dialog .general-alert-mini-map {
  flex: 1;
  width: 100%;
  min-height: 0;
  background: #020617;
}

/* Se deshabilita visualmente el modal flotante anterior si quedó en caché */
.general-alert-map-modal {
  display: none !important;
}

@media (max-width: 980px) {
  .general-alert-detail-content,
  .general-alert-detail-dialog.is-map-visible .general-alert-detail-content {
    width: min(720px, calc(100vw - 22px));
    max-height: calc(100vh - 24px);
  }

  .general-alert-detail-layout,
  .general-alert-detail-dialog.is-map-visible .general-alert-detail-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .general-alert-detail-dialog.is-map-visible .general-alert-inline-map-panel {
    min-height: 360px;
  }

  .general-alert-detail-main {
    max-height: none;
  }
}


/* =========================
   Corrección: expansión real del modal de alerta con mapa
   El <dialog> también debe crecer, no solo el form interno.
========================= */

.general-alert-detail-dialog {
  width: min(640px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: visible;
}

.general-alert-detail-dialog.is-map-visible {
  width: min(1120px, calc(100vw - 28px));
}

.general-alert-detail-dialog .general-alert-detail-content {
  width: 100%;
  max-width: none;
  max-height: calc(100vh - 36px);
}

.general-alert-detail-dialog.is-map-visible .general-alert-detail-content {
  width: 100%;
  max-width: none;
}

.general-alert-detail-dialog.is-map-visible .general-alert-detail-layout {
  grid-template-columns: minmax(420px, 0.88fr) minmax(440px, 1.12fr);
}

.general-alert-detail-dialog.is-map-visible .general-alert-inline-map-panel {
  min-width: 440px;
}

/* En pantallas medianas se mantiene a la derecha, pero ajustando proporciones */
@media (max-width: 1050px) {
  .general-alert-detail-dialog.is-map-visible {
    width: calc(100vw - 18px);
  }

  .general-alert-detail-dialog.is-map-visible .general-alert-detail-layout {
    grid-template-columns: minmax(390px, 0.92fr) minmax(390px, 1.08fr);
  }

  .general-alert-detail-dialog.is-map-visible .general-alert-inline-map-panel {
    min-width: 390px;
  }
}

/* En pantallas chicas sí baja el mapa debajo para evitar salirse */
@media (max-width: 860px) {
  .general-alert-detail-dialog,
  .general-alert-detail-dialog.is-map-visible {
    width: calc(100vw - 18px);
  }

  .general-alert-detail-dialog.is-map-visible .general-alert-detail-layout {
    grid-template-columns: 1fr;
  }

  .general-alert-detail-dialog.is-map-visible .general-alert-inline-map-panel {
    min-width: 0;
    min-height: 360px;
  }
}


/* =========================
   Cintilla inteligente con pausa inicial/final
   - No se mueve si todo cabe en pantalla.
   - Si hay overflow, espera al inicio para que se vea la primera alerta.
   - Al llegar al final, espera antes de reiniciar para que se vea la última alerta.
========================= */

.general-alerts-marquee {
  animation: none !important;
  transform: translateX(0);
  will-change: transform;
}

.general-alerts-marquee.fits-content {
  justify-content: flex-start;
  width: 100%;
}

.general-alerts-marquee.should-scroll {
  width: max-content;
  min-width: 100%;
  animation: generalAlertsTickerMoveWithPauses var(--ticker-scroll-duration, 58s) ease-in-out infinite !important;
}

.general-alerts-marquee.should-scroll:hover {
  animation-play-state: paused !important;
}

@keyframes generalAlertsTickerMoveWithPauses {
  0%,
  12% {
    transform: translateX(0);
  }

  88%,
  100% {
    transform: translateX(calc(-1 * var(--ticker-scroll-distance, 35%)));
  }
}

.general-alert-actions .btn {
  min-width: 128px;
  white-space: nowrap;
}

#btnProcessGeneralAlert {
  background: #038db2;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

#btnProcessGeneralAlert:not(:disabled) {
  opacity: 1;
  cursor: pointer;
}

#btnProcessGeneralAlert:not(:disabled):hover {
  filter: brightness(1.08);
}

#btnProcessGeneralAlert:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}