:root {
  --bg: #06111f;
  --bg-soft: #0b1c31;
  --panel: rgba(8, 19, 35, 0.84);
  --panel-strong: rgba(10, 24, 43, 0.96);
  --line: rgba(129, 185, 255, 0.15);
  --text: #eef5ff;
  --muted: #92a7c7;
  --core: #f472b6;
  --edge: #55a2ff;
  --user: #ffd166;
  --route: #56d2ff;
  --route-core: #f472b6;
  --good: #6ee7b7;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(85, 162, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(244, 114, 182, 0.12), transparent 32%),
    linear-gradient(180deg, #05101d 0%, #081522 100%);
  color: var(--text);
}

button {
  font: inherit;
}

.page-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.control-panel,
.detail-panel {
  padding: 24px;
}

.map-column {
  min-width: 0;
}

.map-stage {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 40px);
  min-height: 720px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(16, 37, 65, 0.95), rgba(6, 17, 31, 0.95)),
    radial-gradient(circle at 20% 20%, rgba(86, 210, 255, 0.1), transparent 25%);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8ac8ff;
}

.control-panel h1,
.map-header h2,
.detail-panel h2,
.detail-panel h3 {
  margin: 10px 0 0;
}

.control-panel h1 {
  font-size: 2rem;
  line-height: 1;
}

.lede,
#helper-copy,
.detail-empty p {
  color: var(--muted);
  line-height: 1.6;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(110, 231, 183, 0.16);
  background: rgba(10, 34, 33, 0.42);
  color: #c8f7e7;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.7);
  animation: pulse 1.8s infinite;
}

.button-stack {
  display: grid;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.text-btn {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 14px 16px;
  font-weight: 700;
}

.primary-btn {
  background: linear-gradient(135deg, #4d8fff, #56d2ff);
  color: #02111f;
  box-shadow: 0 12px 26px rgba(85, 162, 255, 0.3);
}

.secondary-btn {
  background: rgba(85, 162, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(85, 162, 255, 0.2);
}

.ghost-btn,
.text-btn {
  background: transparent;
  color: var(--muted);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
}

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

.stat-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 19, 35, 0.74);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-header h2 {
  font-size: 1rem;
}

.history-panel,
.legend-panel {
  margin-top: 22px;
}

.decision-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  max-height: 330px;
  overflow: auto;
}

.decision-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(86, 210, 255, 0.14);
  background: rgba(7, 17, 31, 0.88);
}

.decision-item strong,
.decision-route {
  display: block;
}

.decision-route {
  margin-top: 6px;
  color: #bfe6ff;
}

.decision-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.legend-core {
  background: var(--core);
}

.legend-edge {
  background: var(--edge);
}

.legend-user {
  background: var(--user);
}

.map-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.map-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(129, 185, 255, 0.14);
  background:
    radial-gradient(circle at 20% 20%, rgba(86, 210, 255, 0.12), transparent 20%),
    radial-gradient(circle at 75% 18%, rgba(244, 114, 182, 0.12), transparent 20%),
    linear-gradient(180deg, rgba(8, 17, 31, 0.95), rgba(5, 11, 20, 0.98));
}

#network-map {
  width: 100%;
  height: 100%;
  display: block;
}

.map-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(5, 10, 20, 0.92);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 20px 35px rgba(0, 0, 0, 0.35);
}

.detail-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 20px;
  border: 1px dashed rgba(129, 185, 255, 0.18);
  border-radius: 22px;
  background: rgba(8, 19, 35, 0.45);
  margin-top: 16px;
}

.detail-content {
  margin-top: 16px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.detail-type,
.detail-coords,
#decision-count,
#detail-ring-state {
  color: var(--muted);
  font-size: 0.84rem;
}

.detail-chip {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-chip.core {
  background: rgba(244, 114, 182, 0.14);
  color: #ffb1da;
}

.detail-chip.edge {
  background: rgba(85, 162, 255, 0.14);
  color: #bfe6ff;
}

.metro-card {
  margin-top: 20px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(7, 18, 32, 0.88);
}

.metro-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.84rem;
}

#metro-diagram {
  width: 100%;
  display: block;
}

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

.telemetry-item {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(8, 19, 35, 0.7);
}

.telemetry-item span {
  display: block;
}

.telemetry-label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.telemetry-value {
  font-weight: 700;
}

.telemetry-wide {
  grid-column: 1 / -1;
}

.capacity-bar {
  margin-top: 10px;
  height: 8px;
  border-radius: 999px;
  background: rgba(129, 185, 255, 0.12);
  overflow: hidden;
}

.capacity-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #56d2ff, #f472b6);
}

.map-ocean {
  fill: rgba(4, 10, 18, 0.5);
}

.map-grid {
  stroke: rgba(129, 185, 255, 0.08);
  stroke-width: 1;
}

.continent {
  fill: rgba(24, 52, 88, 0.55);
  stroke: rgba(133, 181, 244, 0.16);
  stroke-width: 1.4;
}

.region-label {
  fill: rgba(190, 223, 255, 0.34);
  font-size: 18px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-width: 3;
  opacity: 0.88;
}

.route-line.user-edge {
  stroke: var(--route);
}

.route-line.edge-core {
  stroke: var(--route-core);
  stroke-dasharray: 8 10;
}

.route-line.animating {
  stroke-dasharray: 12 12;
  animation: dash 1.1s linear infinite;
}

.node-group,
.user-group {
  cursor: pointer;
}

.node-pulse {
  animation: pulse-ring 2.2s infinite;
  transform-origin: center;
}

.node-core {
  fill: var(--core);
}

.node-edge {
  fill: var(--edge);
}

.node-shape {
  stroke: rgba(4, 10, 18, 0.8);
  stroke-width: 3;
}

.user-marker {
  fill: var(--user);
  stroke: rgba(4, 10, 18, 0.9);
  stroke-width: 3;
}

.user-label,
.node-label {
  fill: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 700;
}

.map-click-mode {
  cursor: crosshair;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.7);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(110, 231, 183, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(110, 231, 183, 0);
  }
}

@keyframes pulse-ring {
  0% {
    opacity: 0.34;
    transform: scale(0.9);
  }
  75% {
    opacity: 0;
    transform: scale(1.9);
  }
  100% {
    opacity: 0;
    transform: scale(1.9);
  }
}

@keyframes dash {
  to {
    stroke-dashoffset: -24;
  }
}

@media (max-width: 1180px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .map-stage {
    height: auto;
    min-height: 640px;
  }

  .control-panel,
  .detail-panel {
    order: -1;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 12px;
    gap: 12px;
  }

  .control-panel,
  .detail-panel,
  .map-stage {
    padding: 16px;
  }

  .map-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid,
  .telemetry-grid {
    grid-template-columns: 1fr;
  }
}
