:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090d14;
  color: #e5edf7;
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #090d14;
  overflow: hidden;
}

/* Local Leaflet layout fallback. Without these rules, map tiles flow like normal images. */
.leaflet-container {
  position: relative;
  overflow: hidden;
  outline: 0;
  touch-action: none;
  background: #07101d;
  font: inherit;
}

.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 img,
.leaflet-container canvas {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  user-select: none;
  visibility: hidden;
}

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

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

.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-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

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

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

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

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

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

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

.leaflet-control-zoom {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
}

.leaflet-control-zoom a {
  display: block;
  width: 34px;
  height: 34px;
  color: #e5edf7;
  line-height: 34px;
  text-align: center;
  text-decoration: none;
}

.leaflet-control-attribution {
  padding: 3px 6px;
  border-radius: 6px 0 0 0;
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
  font-size: 11px;
}

.leaflet-control-attribution a {
  color: #bfdbfe;
}

.public-hidden {
  display: none !important;
}

body.public-readonly .panel {
  display: none;
}

body.public-readonly .shell {
  grid-template-columns: 1fr;
}

body.public-readonly .map-wrap,
body.public-readonly #map {
  height: 100vh;
  min-height: 100vh;
}

button,
textarea {
  font: inherit;
}

button {
  border: 1px solid #334155;
  border-radius: 8px;
  background: #111827;
  color: #e5edf7;
  cursor: pointer;
  padding: 10px 12px;
}

button:hover {
  border-color: #64748b;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.shell {
  display: grid;
  grid-template-columns: minmax(330px, 410px) 1fr;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid #1f2937;
  background: #0f172a;
  overflow: auto;
  min-height: 0;
}

.brand {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.eyebrow,
.section-title {
  margin: 0 0 6px;
  color: #93a4b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.08;
}

.status-pill {
  white-space: nowrap;
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 6px 10px;
  color: #cbd5e1;
  font-size: 12px;
}

.status-pill.ok {
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}

.notice {
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.09);
  color: #fde68a;
  padding: 12px;
  line-height: 1.45;
}

.composer,
.selected,
.source-card,
.time-card,
.impact-card {
  display: grid;
  gap: 10px;
}

.source-card,
.time-card,
.impact-card {
  border: 1px solid #243244;
  border-radius: 8px;
  padding: 12px;
  background: #111827;
}

.source-card strong {
  display: block;
  margin-bottom: 4px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d7e3f3;
  font-size: 13px;
  font-weight: 700;
}

.inline-check input {
  width: 15px;
  height: 15px;
  accent-color: #38bdf8;
}

label {
  color: #cbd5e1;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #e5edf7;
  padding: 12px;
  line-height: 1.45;
}

input[type="datetime-local"] {
  width: 100%;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #e5edf7;
  padding: 10px 12px;
  color-scheme: dark;
}

input[type="file"] {
  width: 100%;
  border: 1px dashed #334155;
  border-radius: 8px;
  background: #0b1220;
  color: #cbd5e1;
  padding: 9px;
}

body.impact-placement #map {
  cursor: crosshair;
}

.impact-row {
  border-color: rgba(56, 189, 248, 0.24);
}

.impact-popup {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.impact-popup strong {
  color: #111827;
  font-size: 18px;
}

.impact-popup small,
.impact-popup p {
  margin: 0;
  color: #475569;
}

.impact-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.impact-gallery img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 6px;
  background: #e2e8f0;
}

.impact-leaflet-popup .leaflet-popup-content {
  width: min(720px, calc(100vw - 92px)) !important;
  max-height: min(78vh, 680px);
  overflow: auto;
}

.impact-delete {
  min-height: 30px;
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.timeline-strip {
  display: grid;
  gap: 6px;
}

.timeline-strip input[type="range"] {
  width: 100%;
  accent-color: #38bdf8;
}

.timeline-strip input[type="range"]:disabled {
  opacity: 0.45;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  font-size: 12px;
}

.timelapse-speed {
  display: flex;
  gap: 6px;
}

.timelapse-speed button {
  min-height: 30px;
  padding: 5px 10px;
  border-color: #334155;
  background: #0b1220;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 800;
}

.timelapse-speed button.active {
  border-color: rgba(56, 189, 248, 0.72);
  background: rgba(56, 189, 248, 0.16);
  color: #e0f2fe;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions.compact {
  flex-wrap: wrap;
}

.primary {
  background: #2563eb;
  border-color: #3b82f6;
  font-weight: 700;
}

.ghost {
  background: transparent;
}

.muted {
  color: #94a3b8;
}

#apiOutput {
  max-height: 220px;
  overflow: auto;
  margin: 0;
  border: 1px solid #1f2937;
  border-radius: 8px;
  background: #070b13;
  color: #d1e3ff;
  padding: 12px;
  font-size: 12px;
}

.active-list {
  display: grid;
  gap: 8px;
}

.active-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  border: 1px solid #243244;
  border-radius: 8px;
  padding: 10px;
  background: #111827;
}

.active-row span {
  color: #fecaca;
  font-weight: 700;
}

.active-row small {
  grid-column: 1 / -1;
  color: #94a3b8;
}

.drone-list .active-row span {
  color: #fde68a;
}

.drone-row {
  border-color: rgba(251, 191, 36, 0.28);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(17, 24, 39, 0.92));
}

.drone-marker {
  position: relative;
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.45));
}

.drone-glyph {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 20px;
  height: 20px;
  background: #fbbf24;
  transform: rotate(var(--angle));
  transform-origin: 50% 50%;
  mask: url("/src/assets/drone-uav.svg") center / contain no-repeat;
  -webkit-mask: url("/src/assets/drone-uav.svg") center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 0 10px rgba(251, 191, 36, 0.55);
}

.drone-marker.hornet .drone-glyph {
  mask: url("/src/assets/drone-hornet.svg") center / contain no-repeat;
  -webkit-mask: url("/src/assets/drone-hornet.svg") center / contain no-repeat;
}

.drone-marker.recon .drone-glyph {
  background: #67e8f9;
  mask: url("/src/assets/drone-recon.svg") center / contain no-repeat;
  -webkit-mask: url("/src/assets/drone-recon.svg") center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 0 10px rgba(103, 232, 249, 0.5);
}

.drone-marker.fpv .drone-glyph {
  background: #fb7185;
  mask: url("/src/assets/drone-fpv.svg") center / contain no-repeat;
  -webkit-mask: url("/src/assets/drone-fpv.svg") center / contain no-repeat;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9), 0 0 10px rgba(251, 113, 133, 0.55);
}

.map-wrap {
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.map-wrap::after {
  content: "";
  position: absolute;
  inset: -160px;
  z-index: 480;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='180' viewBox='0 0 280 180'%3E%3Cg transform='translate(140 90) rotate(-24)'%3E%3Ctext x='0' y='0' text-anchor='middle' font-family='Inter, Arial, sans-serif' font-size='19' font-weight='800' letter-spacing='1.6' fill='%23e5edf7' fill-opacity='0.42'%3Eargusmap.online%3C/text%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 280px 180px;
  background-position: 0 0;
}

.admin-stats {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
}

.admin-stats .muted {
  display: grid;
  gap: 4px;
}

#map {
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #0b1120;
}

.layer-toggle,
.legend {
  position: absolute;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}

.layer-toggle {
  left: 16px;
  top: 16px;
  padding: 8px;
}

.layer-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border-radius: 7px;
  padding: 0 9px;
  color: #d7e3f3;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.layer-toggle label:hover {
  background: rgba(148, 163, 184, 0.12);
}

.layer-toggle input {
  width: 15px;
  height: 15px;
  accent-color: #38bdf8;
}

.legend {
  right: 16px;
  bottom: 16px;
  padding: 10px 12px;
  color: #cbd5e1;
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.swatch.alert {
  background: rgba(239, 68, 68, 0.46);
}

.swatch.threat {
  background: rgba(245, 158, 11, 0.46);
}

.swatch.drone {
  background: #fbbf24;
  clip-path: polygon(50% 0, 64% 36%, 100% 45%, 65% 58%, 58% 100%, 50% 72%, 42% 100%, 35% 58%, 0 45%, 36% 36%);
}

.swatch.selected {
  background: #38bdf8;
}

@media (max-width: 860px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid #1f2937;
  }

  #map {
    height: 62vh;
    min-height: 62vh;
  }

  .map-wrap {
    height: 62vh;
  }

  .map-wrap::after {
    inset: -220px;
    background-size: 220px 150px;
  }

  .legend {
    right: 10px;
    bottom: 10px;
    flex-wrap: wrap;
    max-width: calc(100% - 20px);
  }

  .layer-toggle {
    top: 10px;
    left: 10px;
    flex-wrap: wrap;
    max-width: calc(100% - 68px);
  }

  .impact-leaflet-popup .leaflet-popup-content {
    width: min(520px, calc(100vw - 72px)) !important;
  }

  .impact-gallery {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .impact-gallery img {
    height: 130px;
  }
}
