:root {
  --bg: #0b0d10;
  --panel: #101318;
  --muted: #7b8394;
  --text: #e6eaf2;
  --accent: #2765e7;
  --accent-2: #2d7aff;
  --success: #2ad19a;
  --danger: #ff5b6e;
}

/* Reset / base */
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  margin: 0;
  overflow: hidden;
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica, Arial;
  letter-spacing: 0.1px;
}
a {
  color: var(--text);
  text-decoration: none;
}

/* Loader (full-screen) */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: radial-gradient(
      1200px 600px at 50% -200px,
      rgba(39, 101, 231, 0.08),
      transparent 60%
    ),
    radial-gradient(
      1000px 600px at 150% 50%,
      rgba(39, 101, 231, 0.06),
      transparent 50%
    ),
    radial-gradient(
      1000px 600px at -50% 80%,
      rgba(39, 101, 231, 0.06),
      transparent 50%
    ),
    #06080b;
}
.loader-inner {
  text-align: center;
  padding: 24px 28px;
  border-radius: 16px;
  background: linear-gradient(180deg, #0c1117 0%, #0a0e14 100%);
  border: 1px solid #141c29;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.loader-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 10px;
  background: radial-gradient(
      60% 60% at 30% 30%,
      var(--accent-2),
      transparent 60%
    ),
    radial-gradient(
      60% 60% at 80% 70%,
      rgba(39, 101, 231, 0.7),
      transparent 60%
    ),
    linear-gradient(135deg, rgba(39, 101, 231, 0.35), rgba(45, 122, 255, 0.05));
  outline: 1px solid rgba(39, 101, 231, 0.35);
  box-shadow: 0 0 0 3px rgba(39, 101, 231, 0.1),
    inset 0 10px 30px rgba(39, 101, 231, 0.18);
}
.loader-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.loader-sub {
  color: #a2aec1;
  margin-top: 4px;
}

.loader-anim {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 18px auto 10px;
  filter: drop-shadow(0 0 24px rgba(39, 101, 231, 0.35));
}
.orbit {
  position: absolute;
  inset: 0;
  border: 1.5px solid rgba(39, 101, 231, 0.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 2.8s linear infinite;
}
.orbit-2 {
  inset: 12px;
  animation-duration: 3.6s;
  opacity: 0.8;
}
.orbit-3 {
  inset: 24px;
  animation-duration: 4.4s;
  opacity: 0.6;
}
.orbit-holder {
  position: absolute;
  inset: 0;
  animation: spin 2.8s linear infinite;
}
.dot {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 28px var(--accent);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-bar {
  position: relative;
  width: min(320px, 70vw);
  height: 6px;
  margin: 10px auto 6px;
  background: #0c121a;
  border: 1px solid #162238;
  border-radius: 999px;
  overflow: hidden;
}
.loader-bar span {
  position: absolute;
  inset: 0;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s ease;
  background: linear-gradient(
    90deg,
    rgba(39, 101, 231, 0.15),
    rgba(39, 101, 231, 0.95),
    rgba(39, 101, 231, 0.15)
  );
}
.loader-tip {
  color: #9fb0cf;
  font-size: 12px;
}

.loader.hide {
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .orbit,
  .orbit-holder {
    animation: none;
  }
  .loader-bar span {
    transition: none;
  }
}

/* Layout */
.app {
  height: 100vh;
  width: 100vw;
  display: grid;
  gap: 12px;
  padding: 12px;
  grid-template-columns: 320px minmax(0, 1fr) 360px;
  grid-template-rows: 64px minmax(0, 1fr) 40px;
  grid-template-areas: "top top top" "left map right" "footer footer footer";
}

/* Header */
.top {
  grid-area: top;
  border-radius: 14px;
  background: linear-gradient(180deg, #0e1116 0%, #0b0d10 100%);
  border: 1px solid #141821;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: radial-gradient(
      60% 60% at 30% 30%,
      var(--accent-2),
      transparent 60%
    ),
    radial-gradient(
      60% 60% at 80% 70%,
      rgba(39, 101, 231, 0.7),
      transparent 60%
    ),
    linear-gradient(135deg, rgba(39, 101, 231, 0.35), rgba(45, 122, 255, 0.05));
  outline: 1px solid rgba(39, 101, 231, 0.35);
  box-shadow: 0 0 0 2px rgba(39, 101, 231, 0.08),
    0 10px 30px rgba(39, 101, 231, 0.15) inset;
}
.title {
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.title .name {
  font-size: 16px;
}
.title .tag {
  color: #7b8394;
  font-size: 12px;
  font-weight: 500;
  background: #0f141d;
  padding: 4px 8px;
  border: 1px solid #141b27;
  border-radius: 999px;
}

.header-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f141d;
  border: 1px solid #141b27;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: inset 0 8px 24px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
.chip.warn {
  border-color: #332222;
  background: #160d0f;
}

/* Left panel */
.left {
  grid-area: left;
  background: var(--panel);
  border: 1px solid #141821;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #9aa3b5;
}
.control {
  background: #0f141a;
  border: 1px solid #151b23;
  border-radius: 12px;
  padding: 12px;
}
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed #1a2230;
}
.toggle:last-child {
  border-bottom: 0;
}
.toggle label {
  color: #cbd3e1;
}
.switch {
  inline-size: 44px;
  block-size: 24px;
  border-radius: 999px;
  background: #0a0e14;
  border: 1px solid #1b2330;
  position: relative;
  cursor: pointer;
}
.switch input {
  display: none;
}
.knob {
  position: absolute;
  inset-inline-start: 2px;
  inset-block-start: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1b2330;
  transition: all 0.25s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(255, 255, 255, 0.02) inset;
}
.switch input:checked + .knob {
  inset-inline-start: 22px;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(39, 101, 231, 0.65);
}

/* Map */
.map-wrap {
  grid-area: map;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid #141821;
  background: radial-gradient(
      1200px 600px at 50% -200px,
      rgba(39, 101, 231, 0.06),
      transparent 60%
    ),
    #06080b;
}
#map {
  position: absolute;
  inset: 0;
}
.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
      600px 300px at 70% -100px,
      rgba(39, 101, 231, 0.15),
      transparent 60%
    ),
    linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.2),
      rgba(0, 0, 0, 0) 30%,
      rgba(0, 0, 0, 0.2) 100%
    );
}
.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 60px 60px, 60px 60px;
  mask-image: radial-gradient(80% 60% at 50% 50%, black 60%, transparent 100%);
}

.attack-dot {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(39, 101, 231, 0.9), 0 0 24px rgba(39, 101, 231, 0.4);
}
.attack-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: pulse 1200ms ease-out forwards;
  border: 2px solid rgba(39, 101, 231, 0.6);
}
@keyframes pulse {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  70% {
    transform: scale(2.4);
    opacity: 0.25;
  }
  100% {
    transform: scale(3.2);
    opacity: 0;
  }
}

/* Right panel */
.right {
  grid-area: right;
  background: var(--panel);
  border: 1px solid #141821;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.feed {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #151b23;
  background: #0b1017;
  border-radius: 12px;
  cursor: pointer;
}
.item .type {
  font-size: 11px;
  color: #a9b3c5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.item .geo {
  color: #dfe6f5;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item .time {
  font-size: 12px;
  color: #8f9bb0;
}
.item:hover {
  border-color: #1c2940;
  box-shadow: 0 0 0 1px rgba(39, 101, 231, 0.25);
}

/* Footer */
.footer {
  grid-area: footer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #7b8394;
  opacity: 0.9;
  padding: 0 4px;
}
.footer a {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr) 300px;
  }
}
@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 64px minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "map" "right" "left";
  }
  .left,
  .right {
    min-height: 200px;
  }
  body {
    overflow: auto;
  }
}

/* Leaflet tweaks */
.leaflet-container {
  background: #06080b;
  filter: saturate(0.9) contrast(1.05) brightness(0.9);
}
.leaflet-control-attribution {
  display: none;
}
.leaflet-marker-pane > * {
  will-change: transform;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}
.modal.open {
  display: grid;
}
.sheet {
  width: min(720px, 92vw);
  background: #0e131b;
  color: #eaf0ff;
  border: 1px solid #152033;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #162238;
}
.sheet-body {
  padding: 16px;
  display: grid;
  gap: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f141d;
  border: 1px solid #141b27;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: #c8d3e8;
}
.kvs {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 12px;
}
.close {
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #1b2a47;
  background: #0b111a;
  color: #c8d3e8;
}
.close:hover {
  border-color: #24407b;
}
