:root {
  /* Operational color system */
  --bg: #090d16;
  --panel: rgba(15, 23, 42, 0.55);
  --panel-strong: rgba(16, 24, 39, 0.78);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --muted: #94a3b8;
  --emerald: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% -10%, rgba(6, 182, 212, 0.16), transparent 32rem),
    radial-gradient(circle at 86% 12%, rgba(16, 185, 129, 0.13), transparent 34rem),
    linear-gradient(180deg, #090d16 0%, #070a11 100%);
  color: var(--text);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1880px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.glass-panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.7), rgba(15, 23, 42, 0.42));
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(24px);
  border-radius: 8px;
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,0.12), transparent 18%, transparent 78%, rgba(6,182,212,0.08));
  opacity: 0.5;
}

/* Command header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 16px 20px;
}

.brand-block,
.system-strip,
.profile,
.date-time,
.live-status {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 14px;
  min-width: 260px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(6, 182, 212, 0.36);
  border-radius: 8px;
  background: radial-gradient(circle, rgba(6,182,212,0.32), rgba(16,185,129,0.08));
  color: #7dd3fc;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 0 34px rgba(6, 182, 212, 0.18);
}

.brand-block h1,
.brand-block p,
.map-header h2,
.panel-title span,
.panel-title small {
  margin: 0;
}

.brand-block h1 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  line-height: 1;
}

.brand-block p,
.panel-title small,
.eyebrow,
.map-chip,
.date-time span {
  color: var(--muted);
}

.brand-block p {
  margin-top: 5px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.system-strip {
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.live-status {
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid rgba(16, 185, 129, 0.22);
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.1);
  color: #86efac;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.live-status span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 18px var(--emerald);
  animation: statusPulse 1.8s infinite;
}

.date-time {
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 132px;
}

.date-time strong {
  font-size: 0.85rem;
}

.date-time span {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: rgba(6, 182, 212, 0.42);
  box-shadow: 0 0 24px rgba(6, 182, 212, 0.14);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.alert-button span {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.55);
}

.battery {
  position: relative;
  width: 42px;
  height: 20px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 5px;
}

.battery::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 8px;
  margin: 3px 0 0 39px;
  border-radius: 0 3px 3px 0;
  background: rgba(255,255,255,0.35);
}

.battery span {
  display: block;
  width: 78%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--emerald), #bef264);
}

.profile {
  gap: 10px;
  padding-left: 4px;
}

.profile span {
  max-width: 145px;
  color: #cbd5e1;
  font-size: 0.82rem;
  white-space: nowrap;
}

.profile strong {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(6,182,212,0.32), rgba(245,158,11,0.22));
  border: 1px solid rgba(255,255,255,0.14);
  font-size: 0.78rem;
}

/* Animated executive KPI row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.kpi-card {
  position: relative;
  min-height: 112px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(145deg, rgba(15,23,42,0.74), rgba(16,24,39,0.46));
  box-shadow: 0 16px 45px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
  overflow: hidden;
  transform: translateY(14px);
  opacity: 0;
  animation: cardIn 700ms ease forwards;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.kpi-card:hover,
.recommendation-card:hover,
.chart-card:hover,
.forecast-card:hover {
  transform: translateY(-4px);
  border-color: rgba(6, 182, 212, 0.26);
  box-shadow: 0 22px 70px rgba(0,0,0,0.42), 0 0 32px rgba(6,182,212,0.1);
}

.kpi-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -45% 24%;
  height: 86px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  opacity: 0.22;
  filter: blur(10px);
}

.kpi-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: 14px;
  font-size: clamp(1.85rem, 3vw, 2.7rem);
  font-weight: 850;
  letter-spacing: 0;
}

.kpi-subtext {
  margin-top: 6px;
  color: #cbd5e1;
  font-size: 0.82rem;
}

/* Desktop command-center shell */
.dashboard-grid {
  display: grid;
  grid-template-columns: 255px minmax(560px, 1fr) 390px;
  gap: 16px;
  align-items: stretch;
}

.sidebar,
.map-panel,
.analytics-stack,
.recommendations {
  min-width: 0;
}

.sidebar {
  padding: 18px;
}

.panel-title {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 15px;
}

.panel-title span {
  font-size: 0.88rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-title small {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layer-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
}

.layer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #dbeafe;
  font-size: 0.9rem;
}

.switch {
  position: relative;
  width: 45px;
  height: 24px;
}

.switch input {
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  box-shadow: inset 0 0 16px rgba(0,0,0,0.35);
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease;
}

.slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.switch input:checked + .slider {
  border-color: rgba(6,182,212,0.48);
  background: rgba(6,182,212,0.2);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(6,182,212,0.75);
}

.map-panel {
  padding: 18px;
}

.map-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.map-header h2 {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.map-chip {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid rgba(6,182,212,0.22);
  border-radius: 8px;
  background: rgba(6,182,212,0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

/* Synthetic satellite terrain */
.map-canvas {
  position: relative;
  min-height: 670px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 28%, rgba(16,185,129,0.12), transparent 15rem),
    radial-gradient(circle at 74% 52%, rgba(245,158,11,0.1), transparent 18rem),
    linear-gradient(145deg, #060917, #0d1322 54%, #080b14);
  overflow: hidden;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.65);
}

.terrain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.terrain-noise {
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px),
    radial-gradient(circle at center, transparent, rgba(0,0,0,0.45));
  background-size: 38px 38px, 100% 100%;
  opacity: 0.18;
}

.terrain-grid {
  background-image:
    linear-gradient(rgba(6,182,212,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(6,182,212,0.08) 1px, transparent 1px);
  background-size: 62px 62px;
  opacity: 0.28;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.terrain-topography {
  background:
    repeating-radial-gradient(ellipse at 20% 72%, transparent 0 18px, rgba(148,163,184,0.08) 19px 20px),
    repeating-radial-gradient(ellipse at 76% 25%, transparent 0 22px, rgba(16,185,129,0.08) 23px 24px);
  opacity: 0.55;
  transition: opacity 220ms ease;
}

.terrain-rain {
  background-image: linear-gradient(115deg, rgba(6,182,212,0.06) 0 1px, transparent 1px 18px);
  opacity: 0.5;
  transition: opacity 220ms ease;
}

.terrain-ndvi {
  background: radial-gradient(circle at 36% 38%, rgba(16,185,129,0.17), transparent 14rem);
  opacity: 0.65;
  transition: opacity 220ms ease;
}

.terrain-water {
  background: radial-gradient(circle at 18% 62%, rgba(6,182,212,0.18), transparent 18rem);
  opacity: 0.58;
  transition: opacity 220ms ease;
}

.layer-off-ndvi .terrain-ndvi,
.layer-off-rainfall .terrain-rain,
.layer-off-water .terrain-water,
.layer-off-administrative .boundary,
.layer-off-risk .node-core::after {
  opacity: 0;
}

.layer-off-sch .node[data-layer-sch],
.layer-off-sth .node[data-layer-sth] {
  filter: saturate(0.62);
}

.map-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.river {
  fill: none;
  stroke-linecap: round;
  opacity: 0.72;
}

.river-primary {
  stroke: rgba(37, 99, 235, 0.48);
  stroke-width: 2.1;
  filter: drop-shadow(0 0 10px rgba(37,99,235,0.45));
}

.river-secondary {
  stroke: rgba(6, 182, 212, 0.18);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

#networkLine {
  fill: none;
  stroke: rgba(6, 182, 212, 0.72);
  stroke-width: 0.28;
  stroke-dasharray: 2 2;
  filter: drop-shadow(0 0 7px rgba(6,182,212,0.9));
}

.boundary {
  position: absolute;
  border: 1px dashed rgba(255,255,255,0.13);
  border-radius: 43% 57% 50% 50%;
  opacity: 0.7;
  transition: opacity 220ms ease;
}

.boundary-one {
  width: 58%;
  height: 54%;
  left: 12%;
  top: 22%;
  transform: rotate(-11deg);
}

.boundary-two {
  width: 45%;
  height: 42%;
  right: 8%;
  bottom: 12%;
  transform: rotate(18deg);
}

.map-nodes {
  position: absolute;
  inset: 0;
}

.node {
  position: absolute;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: white;
  cursor: pointer;
  transition: transform 180ms ease;
}

.node:hover {
  transform: translate(-50%, -50%) scale(1.08);
}

.node-core {
  position: absolute;
  inset: 16%;
  display: grid;
  place-items: center;
  border: 2px solid var(--node-color);
  border-radius: 50%;
  background: rgba(15,23,42,0.88);
  background: color-mix(in srgb, var(--node-color) 22%, rgba(15,23,42,0.88));
  box-shadow: 0 0 26px rgba(6,182,212,0.35);
  box-shadow: 0 0 26px color-mix(in srgb, var(--node-color) 70%, transparent);
  font-size: clamp(0.62rem, 0.8vw, 0.82rem);
  font-weight: 900;
  z-index: 2;
}

.node-core::after,
.node-core::before {
  content: "";
  position: absolute;
  inset: -18%;
  border: 1px solid var(--node-color);
  border-radius: 50%;
  animation: nodePulse 2.1s infinite;
}

.node-core::before {
  inset: -42%;
  opacity: 0.24;
  animation-delay: 650ms;
}

.node.severe .node-core {
  background: rgba(239, 68, 68, 0.32);
}

.node-popup {
  position: absolute;
  z-index: 5;
  width: min(340px, calc(100% - 28px));
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.node-popup.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.popup-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.popup-title strong {
  font-size: 1.05rem;
}

.risk-pill {
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.16);
  background: color-mix(in srgb, var(--risk-color) 22%, transparent);
  color: var(--risk-color);
  border: 1px solid rgba(6, 182, 212, 0.32);
  border: 1px solid color-mix(in srgb, var(--risk-color) 45%, transparent);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.popup-grid div,
.trigger-box {
  padding: 9px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.42);
  border: 1px solid rgba(255,255,255,0.08);
}

.popup-grid span,
.trigger-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.trigger-box {
  margin-top: 10px;
  color: #e2e8f0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.hotspot-alert {
  margin: 0 0 10px;
  color: #fca5a5;
  font-weight: 850;
}

/* Right-side intelligence panels */
.analytics-stack {
  display: grid;
  grid-template-rows: minmax(230px, auto) minmax(260px, auto) minmax(210px, auto) minmax(178px, auto);
  gap: 16px;
}

.chart-card,
.forecast-card {
  padding: 16px;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chart-card canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: 190px;
}

.wide-chart canvas {
  max-height: 210px;
}

.chart-wrap {
  position: relative;
  z-index: 1;
}

.lag-annotation {
  position: absolute;
  top: 12%;
  left: 45%;
  color: #cbd5e1;
  border-top: 1px dashed rgba(226,232,240,0.48);
  padding-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

.importance-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 11px;
}

.importance-row {
  display: grid;
  grid-template-columns: 128px 1fr 38px;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  font-size: 0.8rem;
}

.importance-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
}

.importance-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--emerald));
  box-shadow: 0 0 14px rgba(6,182,212,0.48);
  animation: growBar 1s ease forwards;
}

.forecast-card {
  display: grid;
  align-content: center;
  gap: 10px;
  background: linear-gradient(145deg, rgba(239,68,68,0.13), rgba(15,23,42,0.56));
}

.forecast-kicker {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.forecast-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.forecast-main strong {
  font-size: 3.8rem;
  line-height: 0.9;
}

.forecast-main span {
  color: #fca5a5;
  font-weight: 900;
  letter-spacing: 0.08em;
}

/* Intervention dispatch queue */
.recommendations {
  margin-top: 16px;
  padding: 18px;
}

.recommendation-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.recommendation-card {
  position: relative;
  min-height: 164px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.36);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

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

.rec-heading strong {
  font-size: 1.02rem;
}

.rec-body {
  color: #dbeafe;
  line-height: 1.5;
}

.rec-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 0.78rem;
}

.rec-meta b {
  display: block;
  color: #f8fafc;
  margin-top: 3px;
}

@keyframes statusPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.45; }
}

@keyframes cardIn {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes nodePulse {
  0% { transform: scale(0.86); opacity: 0.9; }
  100% { transform: scale(1.7); opacity: 0; }
}

@keyframes growBar {
  to { width: var(--bar-width); }
}

@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: 230px minmax(480px, 1fr);
  }

  .analytics-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar,
  .map-header {
    align-items: stretch;
    flex-direction: column;
  }

  .system-strip {
    justify-content: flex-start;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .map-panel {
    grid-row: 1;
  }

  .sidebar {
    grid-row: 2;
  }

  .map-canvas {
    min-height: 560px;
  }

  .analytics-stack,
  .recommendation-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .profile span,
  .map-chip {
    display: none;
  }

  .map-canvas {
    min-height: 480px;
  }

  .popup-grid,
  .forecast-main {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .importance-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
