:root,
[data-theme="dark"] {
  --bg-primary: #05060a;
  --bg-secondary: #0a0c12;
  --bg-tertiary: #0f1117;
  --bg-elevated: #14161e;
  --bg-glass: rgba(10, 12, 18, 0.72);
  --border-primary: rgba(48, 54, 61, 0.66);
  --border-soft: rgba(230, 237, 243, 0.1);
  --text-primary: #e6edf3;
  --text-secondary: #b1bac4;
  --text-muted: #7d8590;
  --text-faint: #484f58;
  --accent-green: #238636;
  --accent-green-bright: #3fb950;
  --accent-blue: #58a6ff;
  --accent-purple: #bc8cff;
  --accent-pink: #f778ba;
  --accent-orange: #d29922;
  --accent-yellow: #f7c35c;
  --glow-green: rgba(63, 185, 80, 0.26);
  --glow-blue: rgba(88, 166, 255, 0.18);
  --glow-purple: rgba(188, 140, 255, 0.16);
  --glow-orange: rgba(210, 153, 34, 0.18);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-logo: "Rajdhani", var(--font-body);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.4, 1.05);
}

[data-theme="light"] {
  --bg-primary: #f4f7fb;
  --bg-secondary: #ffffff;
  --bg-tertiary: #edf2f7;
  --bg-elevated: #f9fbfd;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --border-primary: rgba(21, 31, 45, 0.13);
  --border-soft: rgba(21, 31, 45, 0.1);
  --text-primary: #111827;
  --text-secondary: #3f4a5a;
  --text-muted: #667085;
  --text-faint: #98a2b3;
  --accent-green: #238636;
  --accent-green-bright: #1f9d45;
  --accent-blue: #0969da;
  --accent-purple: #8250df;
  --accent-pink: #bf3989;
  --accent-orange: #9a6700;
  --accent-yellow: #b7791f;
  --glow-green: rgba(31, 157, 69, 0.16);
  --glow-blue: rgba(9, 105, 218, 0.13);
  --glow-purple: rgba(130, 80, 223, 0.12);
  --glow-orange: rgba(154, 103, 0, 0.14);
}

.topology-panel {
  position: relative;
  min-height: 410px;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 50% 45%, rgba(63, 185, 80, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012) 44%),
    rgba(10, 12, 18, 0.82);
  box-shadow:
    0 24px 62px rgba(0, 0, 0, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  isolation: isolate;
}

[data-theme="light"] .topology-panel {
  background:
    radial-gradient(circle at 50% 45%, rgba(31, 157, 69, 0.09), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.46) 44%),
    rgba(255, 255, 255, 0.76);
  box-shadow:
    0 24px 62px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.topology-panel::before,
.topology-panel::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(88, 166, 255, 0.16);
  border-radius: 50%;
  animation: topologyFloat 8s ease-in-out infinite alternate;
}

.topology-panel::after {
  inset: 24%;
  border-color: rgba(63, 185, 80, 0.18);
  animation-duration: 6s;
  animation-direction: alternate-reverse;
}

.topology-lines {
  position: absolute;
  inset: clamp(1.25rem, 3vw, 2rem);
  width: calc(100% - clamp(2.5rem, 6vw, 4rem));
  height: calc(100% - clamp(2.5rem, 6vw, 4rem));
  z-index: 3;
  pointer-events: none;
  overflow: visible;
  opacity: 0.76;
}

.topology-lines path {
  fill: none;
  stroke: rgba(63, 185, 80, 0.28);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 8 12;
  animation: topologyDash 9s linear infinite;
}

.topology-lines path:nth-child(2) {
  stroke: rgba(88, 166, 255, 0.28);
  animation-duration: 11s;
}

.topology-lines path:nth-child(3) {
  stroke: rgba(188, 140, 255, 0.24);
  animation-duration: 10s;
  animation-direction: reverse;
}

.topology-lines path:nth-child(4) {
  stroke: rgba(210, 153, 34, 0.24);
  animation-duration: 12s;
}

[data-theme="light"] .topology-lines path {
  stroke-opacity: 0.72;
}

.topology-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  opacity: 0.42;
}

.topology-grid span {
  border-right: 1px solid rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}

[data-theme="light"] .topology-grid span {
  border-color: rgba(17, 24, 39, 0.045);
}

.topology-core {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 160px;
  min-height: 112px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(63, 185, 80, 0.36);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(63, 185, 80, 0.16), transparent 68%),
    rgba(5, 6, 10, 0.86);
  box-shadow:
    0 0 0 1px rgba(63, 185, 80, 0.08),
    0 18px 42px rgba(0, 0, 0, 0.42),
    0 0 38px rgba(63, 185, 80, 0.1);
  z-index: 4;
}

[data-theme="light"] .topology-core {
  background:
    radial-gradient(circle at 50% 0%, rgba(31, 157, 69, 0.14), transparent 68%),
    rgba(255, 255, 255, 0.88);
  box-shadow:
    0 0 0 1px rgba(31, 157, 69, 0.08),
    0 18px 42px rgba(15, 23, 42, 0.12),
    0 0 34px rgba(31, 157, 69, 0.08);
}

.topology-core p,
.topology-node span:last-child {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0;
}

.topology-core strong {
  font-size: 0.98rem;
}

.core-pulse {
  width: 11px;
  height: 11px;
  margin-bottom: var(--space-3);
  border-radius: 50%;
  background: var(--accent-green-bright);
  box-shadow: 0 0 18px var(--accent-green-bright);
  animation: pulseNode 1.7s ease-in-out infinite;
}

.topology-ring {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.topology-node {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.56rem 0.72rem;
  border: 1px solid var(--node-border, rgba(88, 166, 255, 0.34));
  border-radius: 999px;
  background: rgba(5, 6, 10, 0.76);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  translate: 0 0;
  animation: nodeFloat 6.5s ease-in-out infinite;
}

.topology-node:nth-child(1) { top: 14%; left: 7%; animation-delay: -0.4s; }
.topology-node:nth-child(2) { top: 20%; right: 6%; animation-delay: -1.1s; }
.topology-node:nth-child(3) { bottom: 23%; left: 8%; animation-delay: -2.1s; }
.topology-node:nth-child(4) { bottom: 15%; right: 6%; animation-delay: -3s; }
.topology-node:nth-child(5) { top: 45%; left: 3%; animation-delay: -1.7s; }
.topology-node:nth-child(6) { top: 45%; right: 3%; animation-delay: -2.6s; }

[data-theme="light"] .topology-node {
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.node-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--node-color, var(--accent-blue));
  box-shadow: 0 0 14px var(--node-color, var(--accent-blue));
  flex: 0 0 auto;
}

.accent-green { --node-color: var(--accent-green-bright); --node-border: rgba(63, 185, 80, 0.42); --node-glow: var(--glow-green); }
.accent-blue { --node-color: var(--accent-blue); --node-border: rgba(88, 166, 255, 0.42); --node-glow: var(--glow-blue); }
.accent-purple { --node-color: var(--accent-purple); --node-border: rgba(188, 140, 255, 0.42); --node-glow: var(--glow-purple); }
.accent-orange { --node-color: var(--accent-orange); --node-border: rgba(210, 153, 34, 0.42); --node-glow: var(--glow-orange); }
.accent-yellow { --node-color: var(--accent-yellow); --node-border: rgba(247, 195, 92, 0.42); --node-glow: rgba(247, 195, 92, 0.18); }
.accent-pink { --node-color: var(--accent-pink); --node-border: rgba(247, 120, 186, 0.42); --node-glow: rgba(247, 120, 186, 0.18); }

@keyframes topologyFloat {
  from { transform: rotate(0deg) scale(1); opacity: 0.52; }
  to { transform: rotate(8deg) scale(1.04); opacity: 0.86; }
}

@keyframes topologyDash {
  to { stroke-dashoffset: -80; }
}

@keyframes nodeFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

@keyframes pulseNode {
  0%, 100% { transform: scale(0.9); opacity: 0.68; }
  50% { transform: scale(1.24); opacity: 1; }
}

@media(max-width: 768px) {
  .topology-panel {
    min-height: 560px;
  }
}