/* Audit Ledger, Status Indicators, Leaflet Popups & Layers Modal */
.audit-ledger-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: #94A3B8;
}

.audit-ledger-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audit-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748B;
  flex-shrink: 0;
}

.audit-dot.live {
  background: #38BDF8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.85);
}

.audit-dot.poor,
.audit-dot.pending {
  background: #64748B;
  box-shadow: none;
}

.audit-dot.poor::after,
.audit-dot.pending::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid #38BDF8;
  animation: mapAuditSonarPing 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

.audit-dot.offline {
  background: #64748B;
  box-shadow: none;
}

@keyframes mapAuditSonarPing {
  0% { transform: scale(0.65); opacity: 0.95; }
  80%, 100% { transform: scale(2.15); opacity: 0; }
}

.audit-source-pill {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 9px;
  letter-spacing: 0.4px;
  color: #CBD5E1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-indicator.green { color: #81C784; }
.status-indicator.orange { color: #FFB74D; }
.status-indicator.red { color: #EF5350; }
.status-indicator.gray { color: #90A4AE; }

.status-location-name {
  font-size: 12px;
  color: #CBD5E1;
  font-weight: 600;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-reason-text {
  font-size: 12.5px;
  color: #ECEFF1;
  line-height: 1.4;
  margin-top: 2px;
}

.safety-ring-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #252D3A;
}

.legend-stat-chip {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10.5px;
  color: #94A3B8;
}

.legend-chip-btn {
  cursor: pointer;
  color: #7DD3FC;
  border-color: rgba(56, 189, 248, 0.38);
  background: rgba(56, 189, 248, 0.14);
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.legend-chip-btn:hover,
.legend-chip-btn[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.28);
  border-color: #38BDF8;
  color: #E0F2FE;
}

.legend-chip-btn:active {
  scale: 0.97;
}

.apparatus-chip-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.apparatus-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 10px;
  color: #CBD5E1;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.apparatus-chip:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.1);
}

.apparatus-chip:active {
  scale: 0.97;
}

.apparatus-chip.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38BDF8;
  color: #FFF;
}

/* Position Leaflet Zoom Controls clear of Bottom Sheet on Mobile */
@media (max-width: 640px) {
  .leaflet-bottom.leaflet-right {
    margin-bottom: calc(255px + env(safe-area-inset-bottom, 0px));
    transition: margin-bottom 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  body.sheet-collapsed .leaflet-bottom.leaflet-right {
    margin-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }
}

/* Leaflet Custom Marker & Popup Overrides */
.leaflet-popup-content-wrapper {
  background: #141820 !important;
  color: #ECEFF1 !important;
  border-radius: 12px !important;
  border: 1px solid #2C3646 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-tip {
  background: #141820 !important;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #90A4AE !important;
  padding: 8px !important;
}

.user-pulse-marker {
  width: 16px;
  height: 16px;
  background: #2E7D32;
  border: 2px solid #FFF;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(46, 125, 50, 0.4);
  animation: pulseUser 1.8s infinite;
}

.user-pulse-marker.gray {
  background: #64748B;
}

.user-pulse-marker.orange {
  background: #EA580C;
}

.user-pulse-marker.red {
  background: #C62828;
  box-shadow: 0 0 0 rgba(198, 40, 40, 0.4);
}

@keyframes pulseUser {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
  70% { box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Coordinate Tap Inspection Reticle */
.tap-reticle-container {
  pointer-events: none;
}

.tap-reticle {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reticle-ring {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #38BDF8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6), inset 0 0 8px rgba(56, 189, 248, 0.3);
  animation: reticlePulse 1.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.reticle-crosshair-v {
  position: absolute;
  width: 1.5px;
  height: 100%;
  background: linear-gradient(180deg, transparent, #38BDF8 30%, #38BDF8 70%, transparent);
  box-shadow: 0 0 6px #38BDF8;
}

.reticle-crosshair-h {
  position: absolute;
  width: 100%;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, #38BDF8 30%, #38BDF8 70%, transparent);
  box-shadow: 0 0 6px #38BDF8;
}

.reticle-center-dot {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FFF;
  box-shadow: 0 0 8px #FFF, 0 0 14px #38BDF8;
}

@keyframes reticlePulse {
  0% { transform: scale(0.65); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.65); opacity: 0.3; }
}

/* FAB Highlight button */
.fab-highlight {
  border-color: rgba(249, 115, 22, 0.55) !important;
  background: rgba(249, 115, 22, 0.18) !important;
  color: #FB923C !important;
}

.fab-highlight:hover {
  background: rgba(249, 115, 22, 0.3) !important;
  border-color: #F97316 !important;
  color: #FFF !important;
}

/* Native Top-Layer Compact Floating Panel <dialog> */
dialog.layers-dialog {
  margin: 58px 12px auto auto;
  width: min(92vw, 380px);
  max-height: calc(100dvh - 78px);
  background: rgba(18, 22, 31, 0.96);
  color: #ECEFF1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.72);
}

@media (max-width: 520px) {
  dialog.layers-dialog { margin: auto; width: min(94vw, 420px); max-height: min(82dvh, 620px); }
}

dialog.layers-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.14);
  backdrop-filter: none;
}

.station-map-pin { position: relative; }
.station-cluster-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  background: #0284C7;
  color: #FFF;
  border: 1px solid #0F172A;
  border-radius: 999px;
  padding: 0 4px;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
}
.leaflet-tooltip.burn-geo-tooltip,
.burn-geo-tooltip {
  background: rgba(15, 23, 42, 0.94) !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(56, 189, 248, 0.45) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  white-space: pre !important;
  width: max-content !important;
  min-width: max-content !important;
  max-width: min(320px, 85vw) !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55) !important;
}
.burn-geo-tooltip::before { border-top-color: rgba(56, 189, 248, 0.45) !important; }

.layers-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.layers-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: #F8FAFC;
}

.layers-modal-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  color: #CBD5E1;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, color 0.2s;
}

.layers-modal-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #FFF;
}

.layers-modal-scroll {
  padding: 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.layers-modal-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 10px;
  font-weight: 800;
  color: #F97316;
  letter-spacing: 0.8px;
}

.layer-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.layer-switch-row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}

.layer-switch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layer-switch-name {
  font-size: 13px;
  font-weight: 700;
  color: #ECEFF1;
}

.layer-switch-desc {
  font-size: 11px;
  color: #94A3B8;
}

.layer-checkbox {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  accent-color: #0288D1;
  cursor: pointer;
  flex-shrink: 0;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

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

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
}

.legend-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.legend-badge.green { background: #81C784; box-shadow: 0 0 6px rgba(129, 199, 132, 0.5); }
.legend-badge.orange { background: #FFB74D; box-shadow: 0 0 6px rgba(255, 183, 77, 0.5); }
.legend-badge.red { background: #EF5350; box-shadow: 0 0 6px rgba(239, 83, 80, 0.5); }
.legend-badge.gray { background: #90A4AE; box-shadow: 0 0 6px rgba(144, 164, 174, 0.5); }
.legend-badge.city-cutout {
  background: rgba(245, 158, 11, 0.25);
  border: 2px dashed #F59E0B;
}

.legend-item-wide {
  margin-top: 2px;
}

.legend-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-item-title {
  font-size: 11px;
  font-weight: 700;
  color: #ECEFF1;
}

.legend-item-desc {
  font-size: 10px;
  color: #94A3B8;
  line-height: 1.3;
}

.zoom-tiers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 14px;
}

.zoom-tier-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.zoom-tier-level {
  font-weight: 800;
  color: #38BDF8;
  white-space: nowrap;
}

.zoom-tier-desc {
  color: #CBD5E1;
  text-align: right;
}

.noaa-radio-card {
  margin-top: 8px;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(14, 165, 233, 0.08);
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.noaa-radio-card:hover {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(56, 189, 248, 0.48);
}

.noaa-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  cursor: pointer;
}

.noaa-map-player-mount[hidden] { display: none; }

.fire-station-details-mount {
  display: block !important;
  block-size: auto;
  block-size: calc-size(auto, size);
  overflow: hidden;
  margin-top: 6px;
  opacity: 1;
  visibility: visible;
  transition:
    block-size 240ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-top 240ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 180ms ease-out,
    visibility 240ms;
}

.fire-station-details-mount[hidden] {
  display: block !important;
  block-size: 0;
  margin-top: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.fire-station-details-deck {
  padding: 8px 10px;
  background: rgba(10, 13, 18, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.26);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: default;
}

.station-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 10.5px;
  line-height: 1.35;
  color: #CBD5E1;
}

.station-detail-icon { flex-shrink: 0; line-height: 1.3; }
.station-detail-body strong { color: #E2E8F0; }

.station-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.station-action-link,
.station-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 700;
  color: #7DD3FC;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.station-action-link:hover,
.station-action-btn:hover {
  background: rgba(56, 189, 248, 0.24);
  color: #FFFFFF;
}

.station-action-link:active,
.station-action-btn:active {
  scale: 0.97;
}

.station-detail-advisory {
  margin: 2px 0 0;
  font-size: 10px;
  color: #94A3B8;
  line-height: 1.3;
}

.noaa-freq-badge {
  background: rgba(56, 189, 248, 0.16);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  text-decoration: none;
  flex-shrink: 0;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.noaa-freq-badge:hover,
.noaa-freq-badge[aria-pressed="true"] {
  background: rgba(56, 189, 248, 0.3);
  color: #E0F2FE;
  border-color: #38BDF8;
}

.noaa-freq-badge:active {
  scale: 0.96;
}

.noaa-player-deck {
  display: flex !important;
  flex-direction: column;
  gap: 6px;
  block-size: auto;
  block-size: calc-size(auto, size);
  overflow: hidden;
  margin-top: 6px;
  padding: 8px 10px;
  background: rgba(10, 13, 18, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 8px;
  opacity: 1;
  visibility: visible;
  transition:
    block-size 240ms cubic-bezier(0.22, 1, 0.36, 1),
    margin-top 240ms cubic-bezier(0.22, 1, 0.36, 1),
    padding-top 240ms cubic-bezier(0.22, 1, 0.36, 1),
    padding-bottom 240ms cubic-bezier(0.22, 1, 0.36, 1),
    border-width 240ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 180ms ease-out,
    visibility 240ms;
}

.noaa-player-deck[hidden] {
  display: flex !important;
  block-size: 0;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.noaa-deck-top,
.noaa-deck-status-wrap,
.noaa-deck-controls,
.noaa-vol-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.noaa-deck-top,
.noaa-deck-controls {
  justify-content: space-between;
  flex-wrap: wrap;
}

.noaa-led {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #64748B;
  flex-shrink: 0;
}

.noaa-led.connecting { background: #F59E0B; box-shadow: 0 0 6px #F59E0B; }
.noaa-led.live { background: #10B981; box-shadow: 0 0 8px #10B981; animation: noaaPulseMap 1.4s infinite; }
.noaa-led.live.voice { background: #38BDF8; box-shadow: 0 0 8px #38BDF8; }
.noaa-led.warn { background: #EF4444; box-shadow: 0 0 6px #EF4444; }

@keyframes noaaPulseMap {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .noaa-led.live, .audit-dot.poor::after, .audit-dot.pending::after { animation: none; }
  .fire-station-details-mount, .noaa-player-deck { transition: none !important; }
}

.noaa-mode-pill {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.45px;
  color: #7DD3FC;
}

.noaa-ext-link {
  font-size: 10.5px;
  font-weight: 700;
  color: #94A3B8;
  text-decoration: none;
}

.noaa-ext-link:hover { color: #E0F2FE; text-decoration: underline; }

.noaa-deck-status {
  font-size: 10.5px;
  color: #CBD5E1;
  line-height: 1.3;
}

.noaa-play-btn {
  background: #0284C7;
  color: #FFFFFF;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, scale 150ms ease-out;
}

.noaa-play-btn:hover { background: #0369A1; }
.noaa-play-btn:active { scale: 0.97; }
.noaa-play-btn[aria-pressed="true"] { background: #B91C1C; border-color: rgba(252, 165, 165, 0.45); }

.noaa-vol-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #94A3B8;
}

.noaa-vol-slider {
  width: 78px;
  accent-color: #38BDF8;
  cursor: pointer;
}

@supports not (accent-color: #38BDF8) {
  .noaa-vol-slider { -webkit-appearance: none; appearance: none; background: transparent; height: 14px; }
  .noaa-vol-slider::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(to right, #38BDF8 var(--vol-pct, 85%), #334155 var(--vol-pct, 85%));
  }
  .noaa-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #38BDF8;
    margin-top: -3.5px;
  }
}

.portal-modal-link {
  justify-content: flex-start;
  text-decoration: none;
}

:where(a, button, input, [tabindex]):focus-visible {
  outline: 2px solid #38BDF8;
  outline-offset: 2px;
}

