body {
  background: #131315;
}

.glass-card {
  background: rgba(31, 31, 33, 0.72);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.priority-glow-red {
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.22);
  border-left: 4px solid #ef4444;
}

.priority-glow-amber {
  border-left: 4px solid #f59e0b;
}

.priority-glow-blue {
  border-left: 4px solid #3b82f6;
}

.map-preview {
  background:
    radial-gradient(circle at 20% 20%, rgba(190, 198, 224, 0.12), transparent 22%),
    radial-gradient(circle at 72% 62%, rgba(59, 130, 246, 0.15), transparent 18%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(19, 19, 21, 0.98)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 42px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 1px,
      transparent 1px,
      transparent 42px
    );
}

.map-overview {
  min-height: 32rem;
  background:
    radial-gradient(circle at 50% 48%, rgba(239, 68, 68, 0.13), transparent 10%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(19, 19, 21, 0.98)),
    repeating-linear-gradient(
      90deg,
      rgba(59, 130, 246, 0.12) 0,
      rgba(59, 130, 246, 0.12) 1px,
      transparent 1px,
      transparent 52px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(59, 130, 246, 0.08) 0,
      rgba(59, 130, 246, 0.08) 1px,
      transparent 1px,
      transparent 52px
    );
}

.map-detail {
  position: relative;
  min-height: 20rem;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, rgba(239, 68, 68, 0.18), transparent 10%),
    radial-gradient(circle at 52% 48%, rgba(255, 255, 255, 0.07), transparent 6%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(19, 19, 21, 0.98)),
    repeating-linear-gradient(
      120deg,
      rgba(34, 211, 238, 0.08) 0,
      rgba(34, 211, 238, 0.08) 2px,
      transparent 2px,
      transparent 68px
    ),
    repeating-linear-gradient(
      60deg,
      rgba(34, 211, 238, 0.08) 0,
      rgba(34, 211, 238, 0.08) 2px,
      transparent 2px,
      transparent 68px
    );
}

.incident-detail-map {
  position: absolute;
  inset: 0;
}

.incident-detail-map__overlay {
  position: relative;
  z-index: 2;
}

.maplibregl-popup-content {
  background: #10192d;
  color: #eef2ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  padding: 0;
}

.maplibregl-popup-tip {
  border-top-color: #10192d;
}

.map-shell {
  display: grid;
  gap: 1rem;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.map-toolbar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.incident-map-canvas {
  min-height: 34rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.12), transparent 16%),
    radial-gradient(circle at 78% 18%, rgba(168, 85, 247, 0.11), transparent 14%),
    linear-gradient(180deg, #111827 0%, #0f172a 100%);
}

.incident-marker-live {
  --marker-color: #a855f7;
  --marker-glow: rgba(168, 85, 247, 0.22);
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.incident-marker-live__pulse,
.incident-marker-live__dot {
  position: absolute;
  inset: 50%;
  border-radius: 9999px;
  transform: translate(-50%, -50%);
}

.incident-marker-live__pulse {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--marker-glow);
  animation: map-pulse 2.8s ease-out infinite;
}

.incident-marker-live__dot {
  width: 0.95rem;
  height: 0.95rem;
  background: var(--marker-color);
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.04);
}

.incident-marker-live:focus-visible {
  outline: none;
}

.map-card-rail {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.map-incident-card {
  width: 100%;
  text-align: left;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(31, 31, 33, 0.86);
  padding: 1rem;
  color: #e4e2e4;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.map-incident-card:hover,
.map-incident-card:focus-visible {
  border-color: rgba(184, 196, 255, 0.4);
  background: rgba(42, 42, 43, 0.96);
  transform: translateY(-1px);
  outline: none;
}

.map-incident-card__meta {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #b8c4ff;
}

.map-incident-card__title {
  margin-top: 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f5f7fb;
}

.map-incident-card__text {
  margin-top: 0.4rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: #c6c6cd;
}

.map-incident-card__time {
  margin-top: 0.7rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  color: #909097;
}

.incident-popup {
  min-width: 220px;
  max-width: 280px;
  padding: 0.95rem 1rem;
}

.incident-popup__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9aa4c7;
}

.incident-popup__title {
  margin-top: 0.45rem;
  font-size: 1rem;
  font-weight: 700;
  color: #eef2ff;
}

.incident-popup__text {
  margin-top: 0.45rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: #d7dcef;
}

.incident-popup__meta {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  color: #9aa4c7;
}

.incident-popup__actions {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.85rem;
}

.incident-popup__actions a {
  font-size: 0.82rem;
  font-weight: 600;
  color: #b8c4ff;
  text-decoration: none;
}

.incident-popup__actions a:hover {
  color: #dde1ff;
}

.map-stage {
  position: relative;
  min-height: 36rem;
  background:
    radial-gradient(circle at 18% 20%, rgba(59, 130, 246, 0.16), transparent 20%),
    radial-gradient(circle at 76% 24%, rgba(168, 85, 247, 0.14), transparent 18%),
    radial-gradient(circle at 54% 70%, rgba(239, 68, 68, 0.1), transparent 20%),
    linear-gradient(180deg, #17181d 0%, #111216 100%);
}

.map-stage__hud {
  position: absolute;
  inset: 1.5rem 1.5rem auto 1.5rem;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.map-stage__eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(190, 198, 224, 0.76);
}

.map-stage__title {
  margin-top: 0.45rem;
  max-width: 20rem;
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 700;
  color: #f5f7fb;
}

.map-stage__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(13, 14, 19, 0.72);
  padding: 0.45rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #d9dfef;
  backdrop-filter: blur(10px);
}

.legend-chip::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 9999px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.06);
}

.legend-chip-red::before {
  background: #ef4444;
}

.legend-chip-amber::before {
  background: #f59e0b;
}

.legend-chip-blue::before {
  background: #3b82f6;
}

.legend-chip-violet::before {
  background: #a855f7;
}

.map-stage__grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(125, 142, 179, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 142, 179, 0.08) 1px, transparent 1px);
  background-size: 4rem 4rem;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.65), rgba(0, 0, 0, 1));
}

.map-stage__nl-shape {
  position: absolute;
  inset: 5.2rem 11% 2.25rem 11%;
  border-radius: 2.4rem;
  background:
    radial-gradient(circle at 27% 22%, rgba(255, 255, 255, 0.16), transparent 10%),
    radial-gradient(circle at 68% 78%, rgba(59, 130, 246, 0.15), transparent 12%),
    linear-gradient(180deg, rgba(42, 45, 53, 0.96), rgba(22, 24, 30, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 80px rgba(0, 0, 0, 0.35);
  clip-path: polygon(
    23% 2%,
    34% 5%,
    42% 0,
    51% 8%,
    63% 7%,
    72% 15%,
    76% 27%,
    84% 33%,
    81% 46%,
    88% 58%,
    80% 72%,
    73% 76%,
    68% 90%,
    56% 96%,
    47% 92%,
    37% 96%,
    28% 90%,
    20% 76%,
    12% 74%,
    8% 62%,
    11% 49%,
    6% 38%,
    10% 23%,
    17% 16%
  );
}

.map-stage__empty {
  position: absolute;
  left: 50%;
  top: 54%;
  z-index: 4;
  transform: translate(-50%, -50%);
  width: min(26rem, calc(100% - 3rem));
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 20, 0.82);
  padding: 1.2rem 1.3rem;
  text-align: center;
  color: #d7dced;
  backdrop-filter: blur(12px);
}

.map-pin {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
}

.map-pin__pulse,
.map-pin__dot {
  position: absolute;
  border-radius: 9999px;
}

.map-pin__pulse {
  width: 2.35rem;
  height: 2.35rem;
  opacity: 0.3;
  animation: map-pulse 2.8s ease-out infinite;
}

.map-pin__dot {
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.04);
}

.map-pin-red .map-pin__pulse,
.map-pin-red .map-pin__dot {
  background: #ef4444;
}

.map-pin-amber .map-pin__pulse,
.map-pin-amber .map-pin__dot {
  background: #f59e0b;
}

.map-pin-blue .map-pin__pulse,
.map-pin-blue .map-pin__dot {
  background: #3b82f6;
}

.map-pin-violet .map-pin__pulse,
.map-pin-violet .map-pin__dot {
  background: #a855f7;
}

.map-pin:hover .map-pin__pulse,
.map-pin:focus-visible .map-pin__pulse {
  opacity: 0.5;
}

.map-pin:focus-visible {
  outline: none;
}

@keyframes map-pulse {
  0% {
    transform: scale(0.45);
    opacity: 0.42;
  }
  70% {
    transform: scale(1);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 3.25rem;
  height: 1.9rem;
  padding: 0.2rem;
  border-radius: 9999px;
  background: #353436;
  transition: background-color 160ms ease;
}

.switch-thumb {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #ffffff;
  transition: transform 160ms ease;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .switch-track {
  background: #b8c4ff;
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(1.3rem);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  height: 0.5rem;
  border-radius: 9999px;
  background: #353436;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #bec6e0;
  box-shadow: 0 0 16px rgba(190, 198, 224, 0.45);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: 9999px;
  background: #bec6e0;
  box-shadow: 0 0 16px rgba(190, 198, 224, 0.45);
  cursor: pointer;
}

@media (max-width: 768px) {
  .incident-map-canvas {
    min-height: 28rem;
  }

  .map-detail {
    min-height: 17rem;
  }

  .map-toolbar {
    align-items: flex-start;
  }

  .map-stage {
    min-height: 30rem;
  }

  .map-stage__hud {
    position: static;
    padding: 1.25rem 1.25rem 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .map-stage__legend {
    justify-content: flex-start;
  }

  .map-stage__nl-shape {
    inset: 8.2rem 0.9rem 1.1rem;
    clip-path: polygon(
      21% 4%,
      35% 8%,
      43% 2%,
      52% 10%,
      63% 10%,
      72% 18%,
      76% 31%,
      84% 36%,
      80% 48%,
      86% 60%,
      79% 72%,
      72% 76%,
      66% 91%,
      55% 96%,
      46% 91%,
      38% 95%,
      28% 89%,
      20% 75%,
      11% 72%,
      8% 60%,
      10% 48%,
      6% 39%,
      10% 24%,
      17% 17%
    );
  }
}
