:root {
  --bg: #071019;
  --panel: rgba(10, 20, 31, 0.88);
  --panel-strong: rgba(12, 27, 42, 0.96);
  --line: rgba(148, 163, 184, 0.22);
  --text: #eef6ff;
  --muted: #9fb1c2;
  --blue: #37a7ff;
  --cyan: #3ee8ff;
  --green: #43d779;
  --amber: #ffb02e;
  --red: #ff4e64;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 0%, #14263b 0%, var(--bg) 52%, #03070c 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 18vw) 1fr minmax(310px, 22vw);
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.side-panel {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-strong), rgba(8, 16, 26, 0.82));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.brand-block {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.overline {
  margin: 0 0 7px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(25px, 2vw, 34px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.2;
}

.summary {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 15, 24, 0.5);
  padding: 13px;
}

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

.section-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.style-list,
.station-list,
.event-log,
.layer-list,
.resource-list {
  display: grid;
  gap: 8px;
}

.style-card,
.station-row,
.event-row,
.resource-row,
.layer-toggle {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.style-card {
  display: block;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.style-card.active {
  border-color: rgba(62, 232, 255, 0.7);
  background: rgba(55, 167, 255, 0.14);
}

.style-card strong,
.station-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.style-card span,
.station-row span,
.event-row span,
.resource-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.layer-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  cursor: pointer;
}

.layer-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--cyan);
}

.station-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  cursor: pointer;
}

.station-dot,
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 18px currentColor;
}

.station-row.warning .station-dot {
  background: var(--amber);
}

.station-row.critical .station-dot {
  background: var(--red);
}

.world-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 20, 31, 0.8);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.top-bar h2 {
  font-size: clamp(20px, 2vw, 30px);
}

.top-actions {
  display: flex;
  gap: 8px;
}

.top-actions button,
.primary-action {
  border: 1px solid rgba(62, 232, 255, 0.35);
  border-radius: 7px;
  background: rgba(55, 167, 255, 0.14);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.primary-action {
  width: 100%;
  margin-top: 14px;
  background: linear-gradient(135deg, #148dff, #23d7c6);
  color: #03101a;
}

.world-frame {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border: 1px solid rgba(102, 214, 255, 0.28);
  border-radius: 8px;
  background: #071019;
  box-shadow: var(--shadow);
}

.world-frame:fullscreen {
  border-radius: 0;
  border: 0;
}

.world-frame:fullscreen #world-image {
  width: 108%;
  height: 108%;
}

#world-image {
  position: absolute;
  inset: 0;
  width: 112%;
  height: 112%;
  object-fit: cover;
  transform: translate(-4%, -4%) scale(1.02);
  animation: slowPan 18s ease-in-out infinite alternate;
  transition: opacity 240ms ease;
}

.world-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(3, 7, 12, 0.34), transparent 20%, transparent 78%, rgba(3, 7, 12, 0.34)),
    linear-gradient(180deg, rgba(3, 7, 12, 0.16), transparent 45%, rgba(3, 7, 12, 0.55));
}

.station-layer,
.asset-layer,
.route-layer {
  position: absolute;
  inset: 0;
}

.station-pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  z-index: 5;
}

.station-pulse {
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 0 9px rgba(67, 215, 121, 0.18), 0 0 30px rgba(67, 215, 121, 0.95);
  animation: pulse 1.8s ease-in-out infinite;
}

.station-pin.warning .station-pulse {
  background: var(--amber);
  box-shadow: 0 0 0 9px rgba(255, 176, 46, 0.18), 0 0 30px rgba(255, 176, 46, 0.95);
}

.station-pin.critical .station-pulse {
  background: var(--red);
  box-shadow: 0 0 0 10px rgba(255, 78, 100, 0.2), 0 0 34px rgba(255, 78, 100, 0.95);
  animation: sosPulse 0.9s ease-in-out infinite;
}

.station-label {
  max-width: 210px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(3, 9, 16, 0.78);
  padding: 7px 9px;
  text-align: left;
  backdrop-filter: blur(10px);
}

.station-label strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.station-label span {
  display: none;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.station-pin.warning .station-label span,
.station-pin.critical .station-label span {
  display: block;
}

.station-pin.critical .station-label {
  border-color: rgba(255, 78, 100, 0.55);
  box-shadow: 0 0 28px rgba(255, 78, 100, 0.18);
}

.hide-labels .station-label {
  display: none;
}

.hide-alerts .station-pin.warning .station-label span,
.hide-alerts .station-pin.critical .station-label span,
.hide-alerts .sos {
  display: none;
}

.sos {
  display: inline-block;
  margin-left: 6px;
  color: var(--red);
  font-size: 11px;
  animation: blink 0.8s linear infinite;
}

.route-line {
  position: absolute;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  filter: drop-shadow(0 0 8px rgba(62, 232, 255, 0.8));
  opacity: 0.8;
  transform-origin: left center;
}

.route-a {
  left: 24%;
  top: 40%;
  width: 48%;
  transform: rotate(14deg);
}

.route-b {
  left: 38%;
  top: 67%;
  width: 30%;
  transform: rotate(-26deg);
}

.team-marker {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 58px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: rgba(7, 16, 25, 0.9);
  color: #fff;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.38);
  z-index: 4;
}

.team-marker::before {
  content: "";
  width: 20px;
  height: 24px;
  border-radius: 11px 11px 7px 7px;
  background:
    linear-gradient(#f8d6b7 0 26%, transparent 27%),
    linear-gradient(90deg, #1468b9 0 45%, #1d8adb 45% 100%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.22);
}

.team-marker.vehicle::before {
  width: 25px;
  height: 16px;
  border-radius: 4px;
  background:
    radial-gradient(circle at 20% 100%, #111 0 14%, transparent 15%),
    radial-gradient(circle at 78% 100%, #111 0 14%, transparent 15%),
    linear-gradient(90deg, #f4f8fb 0 60%, #148dff 60% 100%);
}

.team-marker.drone::before {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #27d7ff 0 20%, transparent 21%),
    linear-gradient(45deg, transparent 0 42%, #e8f7ff 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 0 42%, #e8f7ff 43% 57%, transparent 58%);
}

.team-one {
  animation: moveOne 9s linear infinite;
}

.team-two {
  animation: moveTwo 12s linear infinite;
}

.team-three {
  animation: moveThree 10s linear infinite;
}

.world-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(4, 10, 18, 0.78);
  padding: 12px 14px;
  backdrop-filter: blur(12px);
}

.world-caption strong {
  color: var(--cyan);
}

.world-caption span {
  color: var(--muted);
  font-size: 13px;
}

.mini-controller {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 7;
}

.mini-controller button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(4, 10, 18, 0.75);
  color: var(--text);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.detail-grid div {
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

dt {
  color: var(--muted);
  font-size: 11px;
}

dd {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 760;
}

.status {
  border-radius: 99px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  color: #041018;
}

.status.normal {
  background: var(--green);
}

.status.warning {
  background: var(--amber);
}

.status.critical {
  background: var(--red);
  color: #fff;
}

pre {
  min-height: 166px;
  overflow: auto;
  margin: 0;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.28);
  color: #c8f6ff;
  padding: 12px;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.event-log {
  max-height: 190px;
  overflow: auto;
}

.event-row {
  padding: 9px;
}

.resource-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px;
}

.resource-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.resource-row b {
  color: var(--cyan);
  font-size: 13px;
}

.event-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

@keyframes slowPan {
  from {
    transform: translate(-5%, -4%) scale(1.03);
  }
  to {
    transform: translate(-8%, -7%) scale(1.08);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.18);
  }
}

@keyframes sosPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 7px rgba(255, 78, 100, 0.12), 0 0 22px rgba(255, 78, 100, 0.7);
  }
  50% {
    transform: scale(1.35);
    box-shadow: 0 0 0 18px rgba(255, 78, 100, 0), 0 0 48px rgba(255, 78, 100, 1);
  }
}

@keyframes blink {
  0%,
  45% {
    opacity: 1;
  }
  46%,
  100% {
    opacity: 0.28;
  }
}

@keyframes moveOne {
  0% {
    left: 18%;
    top: 62%;
  }
  50% {
    left: 54%;
    top: 51%;
  }
  100% {
    left: 18%;
    top: 62%;
  }
}

@keyframes moveTwo {
  0% {
    left: 68%;
    top: 34%;
  }
  50% {
    left: 48%;
    top: 66%;
  }
  100% {
    left: 68%;
    top: 34%;
  }
}

@keyframes moveThree {
  0% {
    left: 78%;
    top: 70%;
  }
  45% {
    left: 35%;
    top: 42%;
  }
  100% {
    left: 78%;
    top: 70%;
  }
}

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

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

  .world-stage {
    min-height: 72vh;
  }

  .world-frame {
    min-height: 62vh;
  }

  .top-bar,
  .world-caption {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .top-actions button {
    flex: 1;
  }
}
