:root {
  --bg: #050914;
  --panel: rgba(9, 15, 29, 0.88);
  --card: rgba(15, 23, 42, 0.78);
  --card-hover: rgba(24, 36, 63, 0.88);
  --border: rgba(148, 163, 184, 0.16);
  --border-bright: rgba(56, 189, 248, 0.42);
  --text: #eef4ff;
  --muted: #94a3b8;
  --cyan: #2dd4bf;
  --sky: #38bdf8;
  --indigo: #818cf8;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #070c18;
}

.leaflet-container {
  background: #070c18;
  font-family: var(--sans);
}
.leaflet-top.leaflet-right {
  top: 74px !important;
  right: 12px !important;
}
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45) !important;
}
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
  font-size: 15px !important;
}
.leaflet-control-zoom a:hover {
  background: rgba(56, 189, 248, 0.18) !important;
  color: #fff !important;
}
.leaflet-control-attribution {
  background: rgba(5, 9, 20, 0.72) !important;
  color: #64748b !important;
  font-size: 10px !important;
  border-top-left-radius: 6px;
}
.leaflet-control-attribution a { color: #94a3b8 !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(9, 15, 29, 0.96);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}
.leaflet-popup-content { margin: 11px 14px; font-size: 12px; line-height: 1.45; }

/* Top HUD */
.topbar {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 1; min-width: 0; }
.brand-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 35%, #5eead4, #0ea5e9);
  box-shadow: 0 0 14px rgba(45, 212, 191, 0.85);
}
.brand-title { font-weight: 800; font-size: 14.5px; letter-spacing: -0.02em; white-space: nowrap; }
.brand-sub { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 3px; background: rgba(6, 10, 20, 0.7); padding: 3px; border-radius: 10px; border: 1px solid var(--border); flex-shrink: 0; }
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5.5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.tab.active {
  color: #04121e;
  background: linear-gradient(135deg, #2dd4bf, #38bdf8);
  box-shadow: 0 2px 12px rgba(45, 212, 191, 0.35);
}

.top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.status-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; color: #cbd5e1;
  padding: 5px 10px; border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  white-space: nowrap;
}
@media (max-width: 1220px) {
  .brand-sub { display: none; }
}
.pulse-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.gh-btn {
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.15s;
}
.gh-btn:hover { border-color: var(--border-bright); background: rgba(56, 189, 248, 0.12); }

/* Left Floating Panel */
.panel {
  position: fixed;
  top: 76px;
  left: 12px;
  bottom: 52px;
  width: 416px;
  z-index: 15;
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.panel.collapsed { transform: translateX(calc(-100% - 2px)); }
.panel-toggle {
  position: absolute;
  right: -28px;
  top: 20px;
  width: 28px;
  height: 44px;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.panel-toggle:hover { color: var(--text); }
.panel.collapsed .panel-toggle { transform: rotate(180deg); border-radius: 9px 0 0 9px; border-left: 1px solid var(--border); border-right: 0; }

.tab-pane {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.tab-pane.active { display: block; }
.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 6px; }

.hero-box {
  background: linear-gradient(155deg, rgba(16, 28, 52, 0.88), rgba(10, 17, 34, 0.85));
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 14px;
}
.hero-box.compact { padding: 13px; }
.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan);
  margin-bottom: 6px;
}
.hero-box h1 { margin: 0 0 8px; font-size: 18px; line-height: 1.24; letter-spacing: -0.02em; }
.hero-box h2 { margin: 0 0 7px; font-size: 16px; line-height: 1.25; }
.lead { margin: 0 0 12px; font-size: 12.5px; color: #cbd5e1; line-height: 1.5; }
.hero-box.compact .lead { margin-bottom: 0; }

.cta-row { display: flex; gap: 8px; align-items: center; }
.btn-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  color: #03131f;
  background: linear-gradient(135deg, #2dd4bf, #38bdf8);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(45, 212, 191, 0.35);
  transition: transform 0.12s, filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9.5px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--border-bright); background: rgba(56, 189, 248, 0.12); }
.btn-secondary.active {
  border-color: var(--rose);
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
}

.progress-wrap { margin-top: 11px; }
.progress-bar { height: 5px; background: rgba(148, 163, 184, 0.18); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #2dd4bf, #38bdf8); transition: width 0.18s ease; }
.progress-text { margin-top: 5px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.small { font-size: 12px; line-height: 1.45; margin: 6px 0 9px; }
.muted { color: var(--muted); }

/* Spoof Drawer */
.spoof-box {
  background: rgba(45, 11, 24, 0.72);
  border: 1px solid rgba(244, 63, 94, 0.38);
  border-radius: 11px;
  padding: 12px;
  margin-bottom: 13px;
}
.spoof-header { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: #fecdd3; }
.link-btn {
  background: none; border: 0; color: var(--sky);
  font-size: 11.5px; font-weight: 600; cursor: pointer; padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s;
}
.chip:hover { border-color: var(--sky); color: #fff; background: rgba(56, 189, 248, 0.18); }

.verdict-card {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.45;
}
.verdict-card.ok {
  background: rgba(13, 148, 136, 0.18);
  border: 1px solid rgba(45, 212, 191, 0.45);
  color: #ccfbf1;
}
.verdict-card.bad {
  background: rgba(225, 29, 72, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.55);
  color: #ffe4e6;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 13px;
}
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
}
.metric-card.highlight {
  border-color: rgba(45, 212, 191, 0.36);
  background: rgba(13, 35, 48, 0.78);
}
.metric-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.metric-val { font-size: 15px; font-weight: 700; margin-top: 3px; color: #fff; }
.metric-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.info-banner {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 11.5px;
  color: #bae6fd;
  margin-bottom: 12px;
  line-height: 1.45;
}

/* Section Headers & Anchor List */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.badge {
  background: rgba(56, 189, 248, 0.14);
  color: var(--sky);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.anchor-list { display: flex; flex-direction: column; gap: 6px; }
.anchor-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  cursor: pointer;
  transition: all 0.14s;
}
.anchor-row:hover { background: var(--card-hover); border-color: rgba(148, 163, 184, 0.32); }
.anchor-row.violated { border-color: rgba(244, 63, 94, 0.65); background: rgba(65, 13, 28, 0.72); }
.anchor-row.focused { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.3); }

.anchor-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.anchor-name { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.anchor-rtt { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--cyan); }
.anchor-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 3px; font-size: 11px; color: var(--muted); }
.tee-tag {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 5px;
}
.tee-tdx { background: rgba(56, 189, 248, 0.18); color: #7dd3fc; }
.tee-snp { background: rgba(129, 140, 248, 0.2); color: #c7d2fe; }
.tee-aws { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

.rtt-bar-track {
  margin-top: 6px;
  height: 4px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}
.rtt-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease;
}

/* Mesh Picker */
.mesh-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.mesh-btn {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.14s;
}
.mesh-btn:hover { border-color: var(--border-bright); }
.mesh-btn.active {
  border-color: var(--cyan);
  background: rgba(13, 45, 58, 0.85);
}
.mesh-btn-city { font-size: 12px; font-weight: 700; }
.mesh-btn-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* Code / Verify */
.code-input {
  width: 100%;
  min-height: 92px;
  background: #060b16;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 11px;
  resize: vertical;
}
.code-out {
  background: #060b16;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: #cbd5e1;
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
}
.code-block-card {
  background: #060b16;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 11px;
}
.code-block-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 11px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 600; color: #cbd5e1;
}
.copy-btn {
  background: rgba(56, 189, 248, 0.15);
  color: var(--sky);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(56, 189, 248, 0.28); }
.code-block-card pre {
  margin: 0; padding: 11px;
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  overflow-x: auto; color: #93c5fd;
}

.why-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.why-card h3 { margin: 0 0 8px; font-size: 13px; color: var(--cyan); }
.why-card ul { margin: 0; padding-left: 16px; font-size: 12px; color: #cbd5e1; line-height: 1.5; }
.why-card li { margin-bottom: 6px; }

/* Bottom Floating Controls */
.bottom-controls {
  position: fixed;
  right: 12px;
  bottom: 28px;
  z-index: 15;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 6px 8px 6px 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.control-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.segmented { display: flex; gap: 3px; }
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.14s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: rgba(56, 189, 248, 0.22); color: #7dd3fc; }

/* Map Legend */
.map-legend {
  position: fixed;
  left: 12px;
  bottom: 10px;
  z-index: 15;
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  padding: 6px 13px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: #cbd5e1;
}
.leg-item { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Custom Leaflet Markers */
.anchor-pin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #040914;
  box-shadow: 0 0 12px currentColor;
}
.anchor-label {
  background: rgba(6, 11, 22, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 6px;
  padding: 2px 6px;
  color: #e2e8f0;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
}
.est-pulse {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2dd4bf;
  border: 3px solid #042f2e;
  box-shadow: 0 0 0 6px rgba(45, 212, 191, 0.3), 0 0 22px rgba(45, 212, 191, 0.9);
}
.spoof-pin {
  width: 18px; height: 18px; border-radius: 50%;
  background: #f43f5e;
  border: 3px solid #4c0519;
  box-shadow: 0 0 0 6px rgba(244, 63, 94, 0.35), 0 0 22px rgba(244, 63, 94, 0.95);
}

@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .brand-sub, .status-pill { display: none; }
  .tabs { width: 100%; overflow-x: auto; }
  .panel {
    top: auto;
    bottom: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    height: 46vh;
  }
  .panel.collapsed { transform: translateY(calc(100% + 16px)); }
  .panel-toggle { display: none; }
  .map-legend { display: none; }
  .bottom-controls { bottom: calc(46vh + 18px); right: 10px; }
}
