:root {
  --accent: #11d5ff;
  --danger: #ff4a7d;
  --success: #5cff95;
  --text: #e5edf8;
  --muted: #8ca1be;
  --line: #233149;
  --panel: rgba(10, 16, 29, 0.82);
  --panel-strong: rgba(13, 21, 37, 0.9);
  --bg-a: #09101d;
  --bg-b: #040811;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: #3a4e6f transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  color: var(--text);
  background:
    radial-gradient(
      60rem 45rem at 6% -10%,
      rgba(17, 213, 255, 0.18) 0%,
      rgba(6, 14, 28, 0.15) 44%,
      transparent 72%
    ),
    radial-gradient(48rem 38rem at 88% 110%, rgba(255, 74, 125, 0.17) 0%, transparent 66%),
    radial-gradient(circle at 12% -8%, #132847 0%, var(--bg-a) 32%, var(--bg-b) 100%);
}

h1,
h2,
h3,
h4,
.eyebrow,
.badge,
.heat-pill {
  font-family: 'Space Grotesk', 'IBM Plex Sans', sans-serif;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(88, 126, 186, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(88, 126, 186, 0.09) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at 50% 30%, black, transparent 90%);
  animation: gridDrift 22s linear infinite;
}

@keyframes gridDrift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-10px, -8px, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

.topbar {
  position: relative;
  z-index: 2;
  padding: 18px 22px 10px;
  width: min(100%, 1880px);
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
  margin-right: 10px;
}

.legal-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
}

.legal-links a {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 180ms ease, border-color 180ms ease;
}

.legal-links a:hover,
.legal-links a:focus-visible {
  color: #dbe7ff;
  border-color: rgba(219, 231, 255, 0.55);
}

.badge,
.status-chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 17, 30, 0.92);
  padding: 7px 12px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.telemetry-chip {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  column-gap: 12px;
  row-gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(10, 17, 30, 0.92);
}

.telemetry-chip p {
  margin: 0;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.telemetry-chip span {
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.telemetry-chip strong {
  font-size: 0.76rem;
  color: #dbe7ff;
  white-space: nowrap;
}

@media (max-width: 1680px) {
  .badge {
    display: none;
  }
}

@media (max-width: 1120px) {
  .legal-links {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa9bf;
  transition: background-color 220ms ease;
}

.layout {
  position: relative;
  z-index: 2;
  height: calc(100dvh - 92px);
  max-height: calc(100dvh - 92px);
  padding: 8px 22px 10px;
  width: min(100%, 1880px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 36vw, 620px);
  gap: 16px;
}

.map-panel,
.side-panel {
  min-height: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  box-shadow:
    0 22px 55px rgba(2, 6, 13, 0.6),
    inset 0 0 0 1px rgba(17, 213, 255, 0.04);
}

.map-panel {
  position: relative;
  overflow: hidden;
}

.map-surface {
  height: 100%;
  width: 100%;
  filter: saturate(1.05) brightness(0.74) contrast(1.16);
}

#attackCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 420;
}

.map-header-card {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 500;
  background: rgba(9, 15, 27, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  max-width: min(420px, 90%);
}

.map-header-card h2 {
  margin: 2px 0;
  font-size: 1rem;
}

.subline {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.map-stats-row {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 500;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 14, 26, 0.9);
  padding: 8px 10px;
}

.metric-chip p {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-chip strong {
  margin-top: 2px;
  display: block;
  font-size: 1rem;
}

.metric-wide strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(260px, 1fr);
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  min-width: 0;
}

.panel-block {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 12px;
  padding: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  min-width: 0;
}

.panel-block.grow {
  min-height: 0;
  flex: 1;
}

.block-title-row,
.stream-head,
.threat-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.block-title-row h3,
.panel-block h4 {
  margin: 0;
  font-size: 0.9rem;
}

.micro-note {
  font-size: 0.72rem;
  color: var(--muted);
}

.control-row {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.range {
  margin-top: 8px;
  width: 100%;
}

.control-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.control-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  gap: 10px;
}

.control-field select {
  border: 1px solid var(--line);
  background: #0b1526;
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  padding: 4px 8px;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
}

.toggle input {
  accent-color: var(--accent);
}

.threat-values {
  margin-top: 8px;
  flex-wrap: wrap;
}

.threat-values strong {
  font-size: 1.7rem;
}

.threat-values p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: auto;
  text-align: right;
}

.heat-pill {
  font-size: 0.67rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #3f77c9;
  color: #7ab2ff;
  letter-spacing: 0.08em;
}

.heat-meter {
  margin-top: 8px;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0b1423;
}

.heat-meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #49b179 0%, #f2b63f 55%, #d64545 100%);
  transition: width 420ms ease;
}

.pulse-wrap {
  margin-top: 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1526;
  padding: 4px 6px;
}

#pulseCanvas {
  width: 100%;
  height: 50px;
  display: block;
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.mini-item,
.attack-item,
.ban-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: rgba(8, 14, 26, 0.94);
  animation: slideIn 320ms ease;
}

.mini-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.mini-item span:last-child {
  color: #8dc0ff;
  font-weight: 600;
}

.mini-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 82%;
}

.mini-value {
  min-width: 3.2rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stream-head {
  margin-bottom: 8px;
}

.stream-head span {
  font-size: 0.75rem;
  color: var(--muted);
}

.stream {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stream.short {
  min-height: 0;
}

.split {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.split.grow .stream {
  flex: 1;
}

.logs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.logs-grid .split {
  min-height: 0;
  min-width: 0;
}

.logs-grid .stream {
  flex: 1;
  min-height: 0;
}

@media (max-width: 1600px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) clamp(340px, 40vw, 520px);
  }
}

@media (max-width: 1440px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) clamp(320px, 44vw, 500px);
  }
}

.attack-item .headline,
.ban-item .headline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.attack-item .headline strong,
.ban-item .headline strong {
  font-size: 0.82rem;
}

.attack-item .headline span,
.ban-item .headline span {
  color: var(--muted);
  font-size: 0.72rem;
}

.attack-item p,
.ban-item p {
  margin: 0;
  font-size: 0.76rem;
  color: #c2d3ea;
}

.attack-item p + p,
.ban-item p + p {
  margin-top: 3px;
}

.hq-pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(21, 127, 91, 0.45);
  animation: breathe 2.8s ease-in-out infinite;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  border-radius: 10px;
}

.leaflet-control-attribution {
  background: rgba(7, 12, 22, 0.78) !important;
  color: #8ea3bf !important;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(21, 127, 91, 0.45);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(21, 127, 91, 0);
  }
}

.fade-in {
  animation: fadeIn 520ms ease both;
}

.fade-in-delayed {
  animation: fadeIn 760ms ease 120ms both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1260px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: calc(100vh - 92px);
  }

  .map-panel {
    min-height: 62vh;
  }

  .side-panel {
    display: flex;
    flex-direction: column;
    min-height: 600px;
    overflow: visible;
  }

  .map-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-right: 0;
  }

  .legal-links {
    gap: 14px;
  }

  .telemetry-chip {
    grid-template-columns: 1fr;
    width: 100%;
  }

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

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

  .map-panel {
    min-height: 70vh;
  }
}
