:root {
  color-scheme: dark;
  --bg: #07130f;
  --panel: #0d1c17;
  --panel-2: #10231d;
  --line: rgba(163, 230, 197, 0.16);
  --text: #e8fff4;
  --muted: #8ba99b;
  --accent: #7cf7a8;
  --accent-2: #6ec6ff;
  --critical: #ff4d5f;
  --high: #ff9f43;
  --medium: #ffe66d;
  --low: #6ee7b7;
  --info: #93c5fd;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

/* Local Leaflet core fallback. Without these positioning rules, map tiles render as ordinary images. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile::selection {
  background: transparent;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-container .leaflet-overlay-pane svg {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
  width: auto;
  padding: 0;
}

.leaflet-tile {
  filter: inherit;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-map-pane canvas {
  z-index: 100;
}

.leaflet-map-pane svg {
  z-index: 200;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
  margin-right: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-zoom-animated {
  transform-origin: 0 0;
}

.leaflet-interactive {
  cursor: pointer;
}

.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
  pointer-events: none;
}

.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
  pointer-events: auto;
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  padding: 1px;
  text-align: left;
  border-radius: 12px;
}

.leaflet-popup-content {
  margin: 13px 24px 13px 20px;
  line-height: 1.3;
  min-height: 1px;
}

.leaflet-popup-tip-container {
  width: 40px;
  height: 20px;
  position: absolute;
  left: 50%;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  padding: 1px;
  margin: -10px auto 0;
  transform: rotate(45deg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 5%, rgba(124, 247, 168, 0.12), transparent 28rem),
    radial-gradient(circle at 95% 0%, rgba(110, 198, 255, 0.10), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 19, 15, 0.86);
  backdrop-filter: blur(18px);
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(124, 247, 168, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(124, 247, 168, 0.78), transparent 52%),
    linear-gradient(315deg, rgba(110, 198, 255, 0.62), transparent 58%),
    #0a1813;
  box-shadow: 0 0 28px rgba(124, 247, 168, 0.22);
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

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

.icon-button,
.segmented button {
  border: 1px solid var(--line);
  background: rgba(16, 35, 29, 0.82);
  color: var(--text);
  border-radius: 7px;
  min-height: 36px;
  padding: 0 12px;
}

.icon-button:hover,
.segmented button:hover {
  border-color: rgba(124, 247, 168, 0.42);
}

.status-pill {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(124, 247, 168, 0.35);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(124, 247, 168, 0.08);
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.degraded {
  border-color: rgba(255, 159, 67, 0.42);
  color: var(--high);
  background: rgba(255, 159, 67, 0.08);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(460px, 1fr) minmax(300px, 390px);
  grid-template-rows: minmax(0, 1fr);
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.side-panel,
.feed-panel {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(8, 21, 17, 0.9);
}

.feed-panel {
  border-right: 0;
  border-left: 1px solid var(--line);
}

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

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.module h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.summary-tile {
  min-height: 58px;
  border: 1px solid rgba(163, 230, 197, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 8px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.summary-tile strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  line-height: 1;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(124, 247, 168, 0.55);
  outline-offset: 2px;
}

.layer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  margin-bottom: 14px;
}

.layer-grid h3 {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layer-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  border: 1px solid rgba(163, 230, 197, 0.10);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  padding: 7px 9px;
  color: #dff8ed;
  font-size: 13px;
}

.layer-grid input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.filter-row label span,
.toggle-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.filter-row .wide-filter {
  grid-column: 1 / -1;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  margin-top: 10px;
  color: #dff8ed;
  font-size: 13px;
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.toggle-row span {
  margin-bottom: 0;
}

.map-stage {
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #0a1512;
}

#globe {
  position: absolute;
  inset: 0;
  display: none;
  background: #020807;
}

.map-stage.globe-mode #map {
  visibility: hidden;
}

.map-stage.globe-mode #globe {
  display: block;
}

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.segmented,
.legend,
.timeline-control {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 21, 17, 0.84);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  padding: 4px;
}

.segmented button {
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
}

.segmented button.active {
  color: #04100c;
  background: var(--accent);
}

.legend {
  flex-wrap: wrap;
  padding: 8px 10px;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.timeline-control {
  gap: 8px;
  padding: 6px 8px;
}

.timeline-control span {
  width: 28px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.timeline-control input {
  width: 120px;
  min-height: 24px;
  padding: 0;
  accent-color: var(--accent);
}

.timeline-control div {
  display: flex;
  gap: 4px;
}

.timeline-control button {
  min-height: 26px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  padding: 0 7px;
  font-size: 11px;
}

.timeline-control button.active {
  color: #04100c;
  background: var(--accent);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}

.critical {
  background: var(--critical);
}

.high {
  background: var(--high);
}

.medium {
  background: var(--medium);
}

.low {
  background: var(--low);
}

.info {
  background: var(--info);
}

.event-feed,
.source-list {
  display: grid;
  gap: 10px;
}

.feed-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.feed-actions select {
  width: 118px;
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.feed-actions .muted {
  white-space: nowrap;
}

.event-card,
.source-card,
.weather-card {
  border: 1px solid rgba(163, 230, 197, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  padding: 11px;
}

.event-card {
  display: grid;
  gap: 8px;
}

.event-card.selected {
  border-color: rgba(124, 247, 168, 0.42);
  background: rgba(124, 247, 168, 0.07);
}

.incident-card {
  border-left: 3px solid var(--accent-2);
}

.event-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.event-card h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.event-card p,
.weather-card p {
  margin: 0;
  color: #bbd4c8;
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #06110d;
  white-space: nowrap;
}

.badge.critical {
  background: var(--critical);
}

.badge.high {
  background: var(--high);
}

.badge.medium {
  background: var(--medium);
}

.badge.low {
  background: var(--low);
}

.badge.info {
  background: var(--info);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.event-card button {
  width: fit-content;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: rgba(124, 247, 168, 0.08);
  padding: 0 10px;
}

.source-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  align-items: center;
}

.source-card strong {
  font-size: 13px;
}

.source-card span {
  color: var(--muted);
  font-size: 12px;
}

.source-state {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  text-transform: uppercase;
  background: rgba(124, 247, 168, 0.10);
  color: var(--accent);
}

.source-state.degraded {
  color: var(--high);
  background: rgba(255, 159, 67, 0.10);
}

.source-state.booting {
  color: var(--info);
  background: rgba(147, 197, 253, 0.10);
}

.weather-panel {
  min-height: 100px;
}

.platform-panel,
.watch-list,
.weather-card {
  display: grid;
  gap: 10px;
}

.platform-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(163, 230, 197, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 9px;
}

.platform-row strong,
.platform-row span {
  display: block;
}

.platform-row strong {
  font-size: 13px;
  line-height: 1.3;
}

.platform-row span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.platform-state {
  border-radius: 999px;
  padding: 5px 8px;
  color: #06110d !important;
  background: var(--accent-2);
  white-space: nowrap;
}

.watch-editor {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.watch-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.watch-card {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(163, 230, 197, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.watch-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.watch-card button {
  border: 0;
  color: var(--text);
  background: transparent;
  padding: 0;
  text-align: left;
}

.watch-card button[data-focus-watch] {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.watch-card button[data-remove-watch] {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(163, 230, 197, 0.14);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
}

.watch-card p {
  margin: 0;
  color: #bbd4c8;
  font-size: 12px;
  line-height: 1.4;
}

.weather-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  border: 1px solid rgba(163, 230, 197, 0.10);
  border-radius: 7px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.14);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.empty-state {
  min-height: 84px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(163, 230, 197, 0.18);
  border-radius: 8px;
  font-size: 13px;
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding-top: 10vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.command-palette[hidden] {
  display: none;
}

.command-box {
  width: min(720px, calc(100vw - 28px));
  border: 1px solid rgba(163, 230, 197, 0.22);
  border-radius: 8px;
  background: #0a1813;
  box-shadow: var(--shadow);
  padding: 10px;
}

.command-results {
  display: grid;
  gap: 6px;
  max-height: min(54vh, 460px);
  overflow: auto;
  margin-top: 10px;
}

.command-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(163, 230, 197, 0.10);
  border-radius: 7px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
  text-align: left;
}

.command-result:hover,
.command-result.active {
  border-color: rgba(124, 247, 168, 0.42);
  background: rgba(124, 247, 168, 0.08);
}

.command-result strong,
.command-result span {
  display: block;
}

.command-result span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.command-result kbd {
  color: var(--muted);
  font-size: 11px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0d1c17;
  color: var(--text);
  border: 1px solid var(--line);
}

.leaflet-container {
  font: inherit;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .feed-panel {
    grid-column: 1 / -1;
    min-height: 300px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

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

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .side-panel,
  .feed-panel {
    min-height: auto;
    max-height: none;
    overflow: visible;
    border-right: 0;
  }

  .map-stage {
    height: 68vh;
    min-height: 480px;
    order: -1;
    flex: 0 0 auto;
  }

  .map-toolbar {
    flex-direction: column;
    right: auto;
  }

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

  .legend {
    max-width: min(92vw, 420px);
  }
}
