:root {
  --glass: rgba(255, 255, 255, 0.06);
  --glass2: rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

/* ensure particle canvas stays behind */
#particles {
  width: 100vw;
  height: 100vh;
}

canvas.chart {
  width: 100%;
  display: block;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.55), rgba(2, 6, 23, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.10);
}
canvas.chart.chart--compact {
  height: 150px;
  min-height: 150px;
  max-height: 150px;
  border-radius: 12px;
}

.card--signal .card-h {
  padding: 10px 10px 8px;
}
.card--signal .card-b {
  padding: 8px 10px 10px;
}
.card--signal .pill {
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
}
.card--signal .wave-toggle {
  width: 28px;
  height: 28px;
  font-size: 16px;
  border-radius: 9px;
}
.card--signal .metric {
  padding: 6px 6px;
}
.card--signal .metric-k {
  font-size: 9px;
  letter-spacing: 0.06em;
}
.card--signal .metric-v {
  margin-top: 4px;
  font-size: 11px;
}
.signal-card-sub {
  font-size: 10px;
  line-height: 1.25;
  margin-top: 2px;
  opacity: 0.88;
}

.card {
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(10px);
}
.card-h {
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.card-b {
  padding: 14px 16px 16px;
}

.btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  user-select: none;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.18), 0 0 22px rgba(56, 189, 248, 0.12);
}
.btn:active {
  transform: translateY(0px) scale(0.99);
}
.btn-primary {
  border-color: rgba(56, 189, 248, 0.35);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.12), rgba(99, 102, 241, 0.08));
}
.btn-danger {
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.08);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 9999px;
  box-shadow: 0 0 16px currentColor;
}
.dot-cyan {
  color: rgb(34 211 238);
  background: rgb(34 211 238);
}
.dot-indigo {
  color: rgb(129 140 248);
  background: rgb(129 140 248);
}
.dot-slate {
  color: rgb(148 163 184);
  background: rgb(148 163 184);
  box-shadow: none;
}
.dot-rose {
  color: rgb(251 113 133);
  background: rgb(251 113 133);
}

.btn-sos {
  border-color: rgba(244, 63, 94, 0.45);
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.22), rgba(244, 63, 94, 0.08));
  animation: sosPulse 2.2s ease-in-out infinite;
}
.btn-sos:hover {
  animation: none;
  box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.35), 0 0 26px rgba(244, 63, 94, 0.22);
}

@keyframes sosPulse {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.25), 0 0 16px rgba(244, 63, 94, 0.15);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.45), 0 0 28px rgba(244, 63, 94, 0.28);
  }
}

.sos-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.sos-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.sos-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}
.sos-modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid rgba(244, 63, 94, 0.22);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(2, 6, 23, 0.92));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.12), 0 24px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.sos-modal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.sos-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sos-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}
.sos-tools-input {
  min-height: 44px;
}

.sos-email-panel {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 260px);
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(244, 63, 94, 0.06);
}
@media (max-width: 720px) {
  .sos-email-panel {
    grid-template-columns: 1fr;
  }
}
.sos-email-input {
  min-height: 44px;
}
.sos-email-history-aside {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.22);
  padding: 10px 12px;
  min-height: 120px;
  max-height: 160px;
  display: flex;
  flex-direction: column;
}
.sos-email-history {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sos-email-history li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.sos-email-history button.sos-email-pick {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.95);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sos-email-history button.sos-email-pick:hover {
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.1);
}
.sos-email-history button.sos-email-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: rgba(226, 232, 240, 0.85);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.sos-email-history button.sos-email-remove:hover {
  border-color: rgba(244, 63, 94, 0.4);
  color: #fecdd3;
}

.sos-map {
  flex: 0 0 auto;
  min-height: 260px;
  height: min(42vh, 340px);
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
}
.sos-modal-foot {
  padding: 10px 18px 14px;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(148, 163, 184, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 0;
}

/* Leaflet inside dark modal */
.sos-map .leaflet-container {
  background: #0a1020;
  font-family: inherit;
}
.sos-map .leaflet-control-zoom a {
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.12);
}
.sos-map .leaflet-control-zoom a:hover {
  background: rgba(30, 41, 59, 0.95);
  color: #f8fafc;
}
.sos-map .leaflet-popup-content-wrapper {
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.sos-map .leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.95);
}

/* Animated “Uber-style” route — dashed line flows along the polyline */
.sos-map svg path.sos-route-base {
  stroke: rgba(251, 113, 133, 0.5) !important;
  stroke-width: 12px !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sos-map svg path.sos-route-flow {
  /* Black dotted “progress” line — faint light halo keeps it readable on dark basemap */
  stroke: #000000 !important;
  stroke-width: 5px !important;
  stroke-opacity: 1 !important;
  fill: none !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 0.75px rgba(255, 255, 255, 0.85)) drop-shadow(0 0 2px rgba(255, 255, 255, 0.35));
  /* Round caps + evenly spaced pills; period must match keyframe offset for a seamless loop */
  stroke-dasharray: 6 16;
  stroke-dashoffset: 0;
  animation: sosRouteFlowMove 1.35s linear infinite;
  will-change: stroke-dashoffset;
}

@keyframes sosRouteFlowMove {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -22;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sos-map svg path.sos-route-flow {
    animation: none;
    stroke-dasharray: none;
    filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.55));
  }
}

.sos-hosp-details {
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.18);
}

/* NOVA assistant */
.nova-dock {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
.nova-dock > * {
  pointer-events: auto;
}

.nova-fab {
  position: relative;
  height: 52px;
  padding: 0 18px;
  border-radius: 9999px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.2));
  color: #e0f2fe;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.2), 0 12px 40px rgba(0, 0, 0, 0.45);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.nova-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35), 0 16px 48px rgba(56, 189, 248, 0.18);
}
.nova-fab-text {
  position: relative;
  z-index: 1;
}
.nova-fab-glow {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 30%, rgba(34, 211, 238, 0.35), transparent 55%);
  opacity: 0.9;
  pointer-events: none;
}

.nova-sheet {
  width: min(400px, calc(100vw - 36px));
  max-height: min(560px, calc(100vh - 100px));
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(165deg, rgba(12, 18, 34, 0.96), rgba(4, 6, 10, 0.94));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(56, 189, 248, 0.12);
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.nova-sheet[hidden] {
  display: none !important;
}
.nova-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.nova-sheet-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #e0f2fe;
}
.nova-sheet-sub {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(148, 163, 184, 0.95);
  max-width: 280px;
}
.nova-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.nova-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nova-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.nova-chip {
  border-radius: 9999px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.08);
  color: #bae6fd;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 11px;
  cursor: pointer;
  letter-spacing: 0.02em;
}
.nova-chip:hover {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.14);
}

.nova-messages {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nova-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.nova-msg-user {
  align-self: flex-end;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #f0f9ff;
}
.nova-msg-nova {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(226, 232, 240, 0.95);
}
.nova-msg-meta {
  font-size: 10px;
  opacity: 0.65;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nova-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.2);
}
.nova-input {
  flex: 1;
  min-height: 44px;
}

.sos-hosp-marker {
  background: transparent !important;
  border: none !important;
}
.sos-hosp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fb7185;
  border: 2px solid #fecdd3;
  box-shadow: 0 0 12px rgba(251, 113, 133, 0.65);
}

.pill {
  padding: 6px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}
.pill-cyan {
  border-color: rgba(34, 211, 238, 0.25);
  color: rgba(165, 243, 252, 0.95);
}
.pill-emerald {
  border-color: rgba(52, 211, 153, 0.25);
  color: rgba(167, 243, 208, 0.95);
}
.pill-rose {
  border-color: rgba(251, 113, 133, 0.25);
  color: rgba(254, 202, 202, 0.95);
}
.pill-amber {
  border-color: rgba(250, 204, 21, 0.35);
  color: rgba(253, 224, 71, 0.96);
}

.wave-toggle {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.28);
  color: rgba(248, 250, 252, 0.95);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.wave-toggle:hover {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
}
.wave-toggle[aria-pressed="false"] {
  opacity: 0.75;
  color: rgba(148, 163, 184, 0.95);
}

.metric {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(0, 0, 0, 0.18);
  padding: 10px 12px;
}
.metric-k {
  color: rgba(203, 213, 225, 0.75);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric-v {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.field {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.92);
  outline: none;
}
.field:focus {
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.badge {
  padding: 6px 10px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.badge-idle {
  background: rgba(148, 163, 184, 0.10);
  color: rgba(226, 232, 240, 0.92);
  border-color: rgba(148, 163, 184, 0.22);
}
.badge-ok {
  background: rgba(34, 197, 94, 0.10);
  color: rgba(187, 247, 208, 0.92);
  border-color: rgba(34, 197, 94, 0.22);
}
.badge-warn {
  background: rgba(251, 191, 36, 0.10);
  color: rgba(254, 243, 199, 0.92);
  border-color: rgba(251, 191, 36, 0.22);
}
.badge-bad {
  background: rgba(244, 63, 94, 0.10);
  color: rgba(255, 228, 230, 0.92);
  border-color: rgba(244, 63, 94, 0.22);
}

.pad {
  height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.pad:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.30);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.16), 0 0 20px rgba(56, 189, 248, 0.10);
}
.pad:active {
  transform: translateY(0px) scale(0.99);
}
.pad-stop {
  border-color: rgba(244, 63, 94, 0.35);
  background: rgba(244, 63, 94, 0.08);
}
.pad-mid {
  border-color: rgba(129, 140, 248, 0.35);
  background: rgba(129, 140, 248, 0.08);
}

#log .row {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
#log .ts {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 11px;
  color: rgba(148, 163, 184, 0.95);
  white-space: nowrap;
}
#log .msg {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.92);
  flex: 1;
}
