/* ============================================
   style.css — UI for multilayer visualizer
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #ffffff;
  color: #1a1a2e;
}

/* ---- Canvas ---- */
#networkCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  cursor: grab;
  background: transparent;
}

/* ---- Background Map ---- */
#backgroundMap, #lvBackgroundMap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: none;
  /* hidden by default */
}

/* ---- Floating Panels (Glassmorphism) ---- */
.panel {
  position: fixed;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.04) inset;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
}

/* ============================================
   Collapsible Control Panels (top-left)
   ============================================ */
#controlPanels {
  position: fixed;
  top: 50px;
  left: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 240px;
}

.control-section {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.control-section[open] {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.control-section summary {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #1a1a2e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s ease;
}

.control-section summary::-webkit-details-marker {
  display: none;
}

.control-section summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
}

.control-section[open] summary::before {
  transform: rotate(90deg);
}

.control-section summary:hover {
  background: rgba(0, 0, 0, 0.03);
}

.section-body {
  padding: 4px 14px 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  color: #1a1a2e;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  background: rgba(0, 0, 0, 0.06);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  border-color: rgba(99, 102, 241, 0.25);
  color: #4f46e5;
}

.btn-primary:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(139, 92, 246, 0.25));
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}

.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- Select (dropdown) ---- */
.styled-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.03);
  color: #1a1a2e;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s ease;
  margin-top: 3px;
}

.styled-select:hover {
  border-color: rgba(0, 0, 0, 0.25);
}

.styled-select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* ---- File Input ---- */
.file-input-wrapper {
  position: relative;
  overflow: hidden;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ============================================
   Map Controls Float (above bottom bar)
   ============================================ */
#mapControlsFloat {
  bottom: 12px;
  left: 12px;
  padding: 0;
  z-index: 91;
  border: none;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#mapControlsFloat > div[style*="flex"] {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  padding: 8px 14px;
}

/* ============================================
   Unified Bottom Bar
   ============================================ */
#bottomBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 38px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: rgba(0,0,0,0.12);
  margin: 0 4px;
  flex-shrink: 0;
}

.zoom-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  color: #6b7280;
  transition: color 0.15s ease, background 0.15s ease;
}
.zoom-btn:hover {
  color: #1f2937;
}

/* Text-style bar button (e.g. "Reset") */
.bar-btn-text {
  width: auto;
  padding: 0 8px;
  font-size: 11px;
}

/* ── Active mode button colors ─────────────────── */
.mode-btn.active[data-mode="network"]   { color: #6d28d9; background: rgba(109, 40, 217, 0.08); }  /* violet */
.mode-btn.active[data-mode="map"]       { color: #0284c7; background: rgba(2, 132, 199, 0.08); }   /* sky blue */
.mode-btn.active[data-mode="layer"]     { color: #059669; background: rgba(5, 150, 105, 0.08); }   /* emerald */
.mode-btn.active[data-mode="meta"]      { color: #d97706; background: rgba(217, 119, 6, 0.08); }   /* amber */
.mode-btn.active[data-mode="dashboard"] { color: #dc2626; background: rgba(220, 38, 38, 0.08); }   /* red */
.mode-btn.active[data-mode="data"]      { color: #c51b7d; background: rgba(197, 27, 125, 0.08); }  /* magenta */
.mode-btn.active[data-mode="grid"]      { color: #f73ce1; background: rgba(247, 60, 225, 0.08); }   /* pink */

/* ── Alerts zone (elastic middle) ──────────────── */
#toolbarAlerts {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#dataFilterBanner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  background: rgba(254, 243, 199, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #92400e;
  white-space: nowrap;
}

#dataFilterClear {
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 4px;
  color: #92400e;
  cursor: pointer;
}
#dataFilterClear:hover {
  background: #fff;
}

#selectedNodeBanner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  background: rgba(219, 234, 254, 0.9);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #1e3a8a;
  white-space: nowrap;
  margin-left: 6px;
}

#selectedNodeClear {
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 4px;
  color: #1e3a8a;
  cursor: pointer;
}
#selectedNodeClear:hover {
  background: #fff;
}

/* ── Branding (right side of bar) ──────────────── */
#brandingGroup {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.branding-favicon {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.branding-title {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

.branding-beta {
  font-size: 13px;
  font-weight: 600;
  color: #b45309;
  margin-left: -4px;
}

.branding-version {
  font-size: 13px;
  font-weight: 500;
  color: #1a1a2e;
  margin-left: -4px;
}

.branding-link {
  display: flex;
  align-items: center;
  color: rgba(0, 0, 0, 0.35);
  transition: color 0.15s ease;
}

.branding-link:hover {
  color: #1a1a2e;
}

.branding-icon {
  height: 32px;
  width: auto;
  border-radius: 3px;
  object-fit: contain;
}

/* ============================================
   Info Panel (right side)
   ============================================ */
#infoPanel {
  top: 50px;
  right: 16px;
  padding: 18px 20px;
  width: 280px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  transform: translateX(320px);
  opacity: 0;
  pointer-events: none;
}

#infoPanel.visible {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

#infoPanel h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  padding-left: 28px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.info-section {
  margin-bottom: 14px;
}

.info-section h4 {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.5);
  margin-bottom: 6px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 12.5px;
}

.info-row .info-key {
  color: rgba(0, 0, 0, 0.6);
  font-weight: 400;
}

.info-row .info-value {
  color: #1a1a2e;
  font-weight: 500;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.info-connections {
  list-style: none;
  padding: 0;
}

.info-connections li {
  font-size: 12px;
  padding: 3px 0;
  color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  gap: 5px;
}

.info-connections li::before {
  content: '→';
  color: rgba(0, 0, 0, 0.4);
  font-size: 10px;
}

.collapse-info-btn {
  position: absolute;
  top: 12px;
  left: 10px;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}

.collapse-info-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

#infoPanel.visible.collapsed {
  transform: translateX(256px);
}

#infoPanel.visible.collapsed #infoTitle,
#infoPanel.visible.collapsed #infoContent {
  visibility: hidden;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1a1a2e;
}

/* ---- Layer Popout Close Buttons ---- */
#layerCloseButtons {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  /* Above canvas, below Leaflet markers */
}

.popout-close-btn {
  position: absolute;
  width: 20px;
  height: 20px;
  border: none;
  background: rgba(255, 60, 60, 0.85);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(14px, -14px);
  /* Push slightly top-right of the anchor */
  pointer-events: auto;
  transition: all 0.15s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.popout-close-btn:hover {
  background: rgba(255, 20, 20, 1);
  transform: translate(14px, -14px) scale(1.1);
}

/* ---- Map Markers Overlay ---- */
.map-marker {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #6366f1;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  transition: all 0.15s ease;
}

.map-marker:hover {
  background: #4f46e5;
  transform: translate(-50%, -50%) scale(1.3);
}

.map-marker-label {
  position: absolute;
  transform: translate(12px, -50%);
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ---- Map mode layer list ---- */
.map-layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.map-layer-item:hover {
  background: #f0f0ff;
  border-color: #c7c7f0;
}
.map-layer-item.active {
  background: #ebebff;
  border-color: #4f46e5;
  font-weight: 600;
}
.map-layer-item .map-layer-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #4f46e5;
}
.map-layer-item.active .map-layer-dot {
  background: #22c55e;
}
.map-layer-item .map-layer-close {
  margin-left: auto;
  font-size: 11px;
  color: #999;
  line-height: 1;
  padding: 1px 3px;
  border-radius: 3px;
}
.map-layer-item .map-layer-close:hover {
  color: #ef4444;
  background: #fee2e2;
}

@keyframes pulseGlow {
  0% {
    opacity: 0.6;
    text-shadow: 0 0 0 rgba(234, 88, 12, 0);
  }

  50% {
    opacity: 1;
    text-shadow: 0 0 6px rgba(234, 88, 12, 0.4);
  }

  100% {
    opacity: 0.6;
    text-shadow: 0 0 0 rgba(234, 88, 12, 0);
  }
}

.pulse-highlight {
  animation: pulseGlow 2s infinite ease-in-out;
}

/* ---- Scrollbar ---- */
#infoPanel::-webkit-scrollbar {
  width: 4px;
}

#infoPanel::-webkit-scrollbar-track {
  background: transparent;
}

#infoPanel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
}

/* ---- Checkbox ---- */
.checkbox-row {
  margin-bottom: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #1a1a2e;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: #6366f1;
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ---- Toggle Buttons ---- */
.toggle-group {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.toggle-btn {
  border: none;
  border-radius: 0;
  padding: 5px 10px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.03);
  color: rgba(0, 0, 0, 0.55);
  transition: all 0.15s ease;
}

.toggle-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: none;
  border: none;
}

.toggle-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
  color: #4f46e5;
  font-weight: 600;
  border: none;
}

.toggle-btn+.toggle-btn {
  border-left: 1px solid rgba(0, 0, 0, 0.1);
}

/* ---- Slider ---- */
.slider {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(0, 0, 0, 0.1);
  outline: none;
  margin-top: 4px;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  border: none;
}

/* ---- Tooltip (for hover info) ---- */
#tooltip {
  position: fixed;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  font-size: 11.5px;
  color: #1a1a2e;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.15s ease;
  max-width: 200px;
  white-space: nowrap;
}

#tooltip.visible {
  opacity: 1;
}

/* ============================================
   Export Dialog
   ============================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-box {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  padding: 24px 28px;
  width: 360px;
  box-sizing: border-box;
  overflow: hidden;
  text-align: left;
}

#demoDialog .dialog-box {
  width: 540px;
}

#demoDatasetList .btn {
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  white-space: normal;
  justify-content: flex-start;
}

#demoDatasetList .demo-info-btn {
  justify-content: center;
}

/* Domain-tinted load buttons */
.btn-domain-ecology {
  background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(16,185,129,0.12));
  border-color: rgba(34,197,94,0.28);
  color: #166534;
}
.btn-domain-ecology:hover {
  background: linear-gradient(135deg, rgba(34,197,94,0.22), rgba(16,185,129,0.22));
  border-color: rgba(34,197,94,0.4);
  box-shadow: 0 4px 15px rgba(34,197,94,0.15);
}
.btn-domain-microbiology {
  background: linear-gradient(135deg, rgba(6,182,212,0.12), rgba(14,165,233,0.12));
  border-color: rgba(6,182,212,0.28);
  color: #0e7490;
}
.btn-domain-microbiology:hover {
  background: linear-gradient(135deg, rgba(6,182,212,0.22), rgba(14,165,233,0.22));
  border-color: rgba(6,182,212,0.4);
  box-shadow: 0 4px 15px rgba(6,182,212,0.15);
}
.btn-domain-biomedicine {
  background: linear-gradient(135deg, rgba(244,63,94,0.10), rgba(251,113,133,0.10));
  border-color: rgba(244,63,94,0.25);
  color: #be123c;
}
.btn-domain-biomedicine:hover {
  background: linear-gradient(135deg, rgba(244,63,94,0.20), rgba(251,113,133,0.20));
  border-color: rgba(244,63,94,0.38);
  box-shadow: 0 4px 15px rgba(244,63,94,0.15);
}
.btn-domain-neuroscience {
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(167,139,250,0.12));
  border-color: rgba(139,92,246,0.28);
  color: #6d28d9;
}
.btn-domain-neuroscience:hover {
  background: linear-gradient(135deg, rgba(139,92,246,0.22), rgba(167,139,250,0.22));
  border-color: rgba(139,92,246,0.4);
  box-shadow: 0 4px 15px rgba(139,92,246,0.15);
}
.btn-domain-population-genetics {
  background: linear-gradient(135deg, rgba(245,158,11,0.11), rgba(251,191,36,0.11));
  border-color: rgba(245,158,11,0.27);
  color: #b45309;
}
.btn-domain-population-genetics:hover {
  background: linear-gradient(135deg, rgba(245,158,11,0.21), rgba(251,191,36,0.21));
  border-color: rgba(245,158,11,0.4);
  box-shadow: 0 4px 15px rgba(245,158,11,0.15);
}
.btn-domain-molecular-biology {
  background: linear-gradient(135deg, rgba(235,52,210,0.11), rgba(235,52,210,0.15));
  border-color: rgba(235,52,210,0.27);
  color: #9b1599;
}
.btn-domain-molecular-biology:hover {
  background: linear-gradient(135deg, rgba(235,52,210,0.21), rgba(235,52,210,0.25));
  border-color: rgba(235,52,210,0.4);
  box-shadow: 0 4px 15px rgba(235,52,210,0.15);
}

.dialog-box h4 {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 6px;
  text-align: center;
}

.dialog-box p {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.5);
  margin-bottom: 16px;
}

.dialog-options {
  margin-bottom: 14px;
  text-align: left;
}

.dialog-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================
   Citation Button + Dialog
   ============================================ */
.branding-cite-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.10), rgba(168, 85, 247, 0.10));
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 999px;
  color: #4338ca;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, transform 0.08s ease;
}
.branding-cite-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.22));
  border-color: rgba(99, 102, 241, 0.5);
  color: #3730a3;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.18);
}
.branding-cite-btn:active {
  transform: translateY(1px);
}
.branding-cite-btn svg {
  flex-shrink: 0;
}
.branding-cite-label {
  line-height: 1;
}

#citeDialog .cite-dialog-box {
  width: 520px;
  max-width: calc(100vw - 32px);
  padding: 22px 24px 18px;
  position: relative;
}

.cite-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.cite-close-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1a1a2e;
}

.cite-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
  margin: 0 0 4px;
  text-align: center;
}

.dialog-box p.cite-subtitle {
  font-size: 14px;
  font-weight: 700;
  color: #6d28d9;
  text-align: center;
  margin: 0 0 14px;
}

.cite-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.cite-meta-row {
  display: contents;
}
.cite-meta-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 1px;
}
.cite-meta-value {
  font-size: 12.5px;
  color: #1a1a2e;
}
.cite-meta-link {
  font-size: 12.5px;
  color: #4338ca;
  text-decoration: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.cite-meta-link:hover {
  text-decoration: underline;
}

.cite-section {
  margin-bottom: 12px;
}
.cite-section:last-of-type {
  margin-bottom: 14px;
}
.cite-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.cite-block-wrap {
  position: relative;
}
.cite-block {
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  padding: 12px 14px;
  padding-right: 70px;
  border-radius: 10px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}
.cite-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, transform 0.08s ease;
}
.cite-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}
.cite-copy-btn:active {
  transform: translateY(1px);
}
.cite-copy-btn.copied {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
}

.cite-buttons {
  justify-content: flex-end;
}
.cite-buttons .btn-primary {
  text-decoration: none;
}

/* ---- Dashboard Mode ---- */
#dashboardContainer {
  position: absolute;
  top: 38px; left: 0; right: 0; bottom: 0;
  background: #f3f4f8;
  overflow-y: auto;
  display: none;
  z-index: 5;
}

.db-root {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

.db-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}

.db-sec-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  cursor: pointer;
  user-select: none;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.db-sec-hd:hover { background: #f3f4f6; }

.db-sec-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.db-chevron { font-size: 12px; color: #9ca3af; }

.db-sec-bd { padding: 16px; }

/* KPI cards */
.db-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.db-card {
  flex: 1 1 110px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
}

.db-kpi-v {
  font-size: 20px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.3;
}

.db-kpi-l {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 3px;
}

.db-kpi-sub {
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
  display: block;
}

.db-badge {
  display: inline-block;
  background: #ede9fe;
  color: #6366f1;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  margin-right: 4px;
}

/* Charts */
.db-charts-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.db-chart-box { flex: 1 1 250px; min-width: 0; }

.db-chart-hl {
  outline: 2px solid #6366f1;
  border-radius: 8px;
  padding: 8px;
}

.db-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 6px;
}

/* Presence matrix */
.db-matrix-wrap {
  overflow: auto;
  max-height: 460px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.db-matrix-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.db-sort-btn {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  line-height: 1.4;
}

.db-sort-btn:hover { background: #f3f4f6; }

.db-sort-btn.active {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.db-weight-select {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  cursor: pointer;
  max-width: 220px;
}

.db-heatmap-col {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ============================================
   Data Mode
   ============================================ */

#dataModePanel {
  position: absolute;
  top: 38px; left: 0; right: 0; bottom: 0;
  z-index: 5;
  background: #fff;
  display: flex;
  flex-direction: column;
  font-family: 'Inter', system-ui, sans-serif;
}

/* Tab bar */
.dm-tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 16px 0;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
  flex-shrink: 0;
}

.dm-tab {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.dm-tab:hover { color: #1a1a2e; }

.dm-tab-active {
  color: #1a1a2e;
  border-bottom-color: #6366f1;
}

.dm-export-btn {
  margin-left: auto;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 6px;
}

.dm-export-btn:hover { background: #f3f4f6; color: #1a1a2e; }

/* Row count */
.dm-row-count {
  padding: 6px 16px;
  font-size: 12px;
  color: #9ca3af;
  flex-shrink: 0;
}

/* Table container */
.dm-table-container {
  flex: 1;
  overflow: auto;
  padding: 0 16px 16px;
}

.dm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dm-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

.dm-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  text-transform: capitalize;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.dm-th-label {
  cursor: pointer;
}

.dm-th-label:hover { color: #111827; }

.dm-table th.dm-sorted .dm-th-label { color: #6366f1; }

.dm-table th.dm-numeric,
.dm-table td.dm-numeric { text-align: right; }

/* Funnel icon button */
.dm-funnel {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding: 2px;
  border: none;
  background: none;
  color: #d1d5db;
  cursor: pointer;
  border-radius: 3px;
  vertical-align: middle;
  transition: color 0.15s, background 0.15s;
}

.dm-funnel:hover { color: #6b7280; background: #f3f4f6; }

.dm-funnel-active { color: #6366f1; }

/* Filter popup */
.dm-filter-popup {
  z-index: 300;
  min-width: 200px;
  max-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dm-popup-search {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.dm-popup-search:focus { border-color: #6366f1; }

.dm-popup-actions {
  display: flex;
  gap: 8px;
  font-size: 11px;
}

.dm-popup-actions button {
  background: none;
  border: none;
  color: #6366f1;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
}

.dm-popup-actions button:hover { text-decoration: underline; }

.dm-popup-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.dm-popup-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: #374151;
}

.dm-popup-item:hover { background: #f9fafb; }

.dm-popup-cb { margin: 0; accent-color: #6366f1; }

.dm-popup-label {
  font-size: 11px;
  color: #9ca3af;
  padding: 2px 0;
}

.dm-popup-input {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.dm-popup-input:focus { border-color: #6366f1; }

.dm-popup-footer {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 4px;
  border-top: 1px solid #f3f4f6;
}

.dm-popup-btn-primary,
.dm-popup-btn-secondary {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid;
}

.dm-popup-btn-primary {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}

.dm-popup-btn-primary:hover { background: #4f46e5; }

.dm-popup-btn-secondary {
  background: #fff;
  color: #6b7280;
  border-color: #d1d5db;
}

.dm-popup-btn-secondary:hover { background: #f9fafb; }

/* Selection action bar */
.dm-sel-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
  font-size: 13px;
  font-weight: 500;
  color: #4338ca;
  flex-shrink: 0;
}

.dm-sel-action {
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid #6366f1;
  background: #6366f1;
  color: #fff;
  transition: background 0.15s;
}

.dm-sel-action:hover { background: #4f46e5; }

.dm-sel-clear {
  background: #fff;
  color: #6b7280;
  border-color: #d1d5db;
}

.dm-sel-clear:hover { background: #f9fafb; }

.dm-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #1f2937;
  max-width: 200px;
}

.dm-table tbody tr { cursor: pointer; }

.dm-table tbody tr:hover { background: #f9fafb; }

.dm-row-selected { background: #eef2ff !important; }

.dm-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Color picker in layers table */
.dm-color-picker {
  width: 28px;
  height: 22px;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 4px;
  padding: 1px;
  cursor: pointer;
  background: none;
}

/* Type pills */
.dm-pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.dm-pill-intra { background: #dbeafe; color: #1e40af; }
.dm-pill-inter { background: #ffedd5; color: #c2410c; }

/* (dataFilterBanner styles moved to bottom bar section) */

/* Legend scale-type pill toggle (Continuous / Discrete) */
.ltp-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 1px 3px;
  cursor: pointer;
  height: 18px;
}
.ltp-pill .ltp-opt {
  padding: 0 5px;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 9px;
  line-height: 16px;
  white-space: nowrap;
}
.ltp-pill .ltp-opt.ltp-active {
  background: white;
  color: #1a1a2e;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Branding home link (favicon + title) */
.branding-home-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}

/* EMLN mode styles */
.emln-data-msg {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
  padding: 4px 0;
}
.emln-data-msg a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}
.emln-data-msg a:hover {
  text-decoration: underline;
}

/* ---- Legend categorical color picker ---- */
.legend-color-pick {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  background: none;
}
.legend-color-pick::-webkit-color-swatch-wrapper { padding: 0; }
.legend-color-pick::-webkit-color-swatch { border: none; border-radius: 50%; }
.legend-color-pick::-moz-color-swatch     { border: none; border-radius: 50%; }

/* ---- Tour ---- */
#tourBtn {
  width: auto;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #6366f1;
  border: 1.5px solid rgba(99, 102, 241, 0.4);
}
#tourBtn:hover {
  color: #4f46e5;
  border-color: rgba(99, 102, 241, 0.65);
  background: rgba(99, 102, 241, 0.06);
}

@keyframes arrowBounceUp {
  0%   { opacity: 0; transform: translateY(0); }
  5%   { opacity: 1; transform: translateY(0); }
  14%  { opacity: 1; transform: translateY(-9px); }
  23%  { opacity: 1; transform: translateY(0); }
  32%  { opacity: 1; transform: translateY(-9px); }
  41%  { opacity: 1; transform: translateY(0); }
  50%  { opacity: 1; transform: translateY(-9px); }
  59%  { opacity: 1; transform: translateY(0); }
  68%  { opacity: 1; transform: translateY(-9px); }
  77%  { opacity: 1; transform: translateY(0); }
  86%  { opacity: 1; transform: translateY(-9px); }
  95%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(0); }
}
@keyframes arrowBounceLeft {
  0%   { opacity: 0; transform: translateX(0); }
  5%   { opacity: 1; transform: translateX(0); }
  14%  { opacity: 1; transform: translateX(-9px); }
  23%  { opacity: 1; transform: translateX(0); }
  32%  { opacity: 1; transform: translateX(-9px); }
  41%  { opacity: 1; transform: translateX(0); }
  50%  { opacity: 1; transform: translateX(-9px); }
  59%  { opacity: 1; transform: translateX(0); }
  68%  { opacity: 1; transform: translateX(-9px); }
  77%  { opacity: 1; transform: translateX(0); }
  86%  { opacity: 1; transform: translateX(-9px); }
  95%  { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(0); }
}
.bounce-arrow-fixed {
  position: fixed;
  pointer-events: none;
  font-size: 28px;
  line-height: 1;
  z-index: 9999;
  color: #6366f1;
  animation: arrowBounceUp 3.5s ease-out forwards;
}
.bounce-arrow-inline {
  display: inline-block;
  margin-left: auto;
  padding-left: 8px;
  font-size: 22px;
  color: #1e64dc;
  animation: arrowBounceLeft 3.5s ease-out forwards;
}

#tourHighlight {
  display: none;
  position: fixed;
  z-index: 9000;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.48);
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

#tourPopover {
  display: none;
  position: fixed;
  z-index: 9001;
  width: 280px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 14px;
  padding: 16px 18px 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  color: #1f2937;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.tour-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#tourTitle {
  font-weight: 700;
  font-size: 12px;
  color: #6366f1;
  line-height: 1.4;
  flex: 1;
}

#tourBody {
  margin: 0 0 12px;
  line-height: 1.6;
  color: #374151;
}

.tour-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#tourCounter {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
}

.tour-nav {
  display: flex;
  gap: 6px;
}