body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background: #000;
  color: #fff;
  overflow: hidden;
}

#map {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Современный UI с эффектом стекла (glassmorphism) */
.control-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 380px;
  background: rgba(10, 15, 25, 0.85); /* Deep dark blue */
  backdrop-filter: blur(12px);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease, padding 0.3s ease, max-height 0.3s ease;
  z-index: 10;
  max-height: 90vh;
  overflow-y: auto;
}

.control-panel.collapsed .panel-collapsible {
  display: none;
}
.control-panel.collapsed {
  padding-bottom: 15px;
}

.panel-collapsible {
  transition: opacity 0.3s ease;
}

.lang-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a0aab5;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.lang-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.lang-btn.active {
  background: rgba(96, 239, 255, 0.15);
  border-color: rgba(96, 239, 255, 0.4);
  color: #60efff;
}

.control-panel h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #60efff, #00ff87);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.control-panel p.desc {
  margin: 0 0 20px 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

/* Переключатель Режимов (Toggle) */
.toggles-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.mode-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-toggle.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.mode-btn {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  border-radius: 7px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(96, 239, 255, 0.2) 0%, rgba(0, 255, 135, 0.2) 100%);
  color: #00ff87;
  border: 1px solid rgba(0, 255, 135, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 0 10px rgba(0, 255, 135, 0.05);
}

.mode-btn:hover:not(.active) {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Пульсирующий индикатор Live */
.btn-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 255, 135, 0.05);
  border: 1px solid rgba(0, 255, 135, 0.3);
  border-radius: 10px;
  color: #00ff87;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 24px;
  transition: 0.3s;
  box-sizing: border-box;
}

.live-dot {
  width: 8px;
  height: 8px;
  background-color: #00ff87;
  border-radius: 50%;
  margin-right: 12px;
  box-shadow: 0 0 8px #00ff87;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(0, 255, 135, 0.7); }
  70% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 6px rgba(0, 255, 135, 0); }
  100% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(0, 255, 135, 0); }
}

/* Статистика */
#stats-container {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  animation: fadeIn 0.8s ease forwards;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
}
.stat-label { color: rgba(255,255,255,0.5); font-weight: 500;}
.stat-value { font-weight: 700; color: #fff; font-family: 'JetBrains Mono', monospace; font-size: 16px;}

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

/* ==================== Sample Detail Panel ==================== */
#sample-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 20;
  width: 380px;
  max-height: calc(100vh - 48px);
  background: rgba(17, 25, 40, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.125);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(420px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  pointer-events: none;
}
#sample-panel.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: all;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}
.panel-place {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.panel-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'JetBrains Mono', monospace;
}
.panel-close {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.panel-back {
  background: rgba(96, 239, 255, 0.1);
  border: 1px solid rgba(96, 239, 255, 0.3);
  color: #60efff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.panel-back:hover { background: rgba(96, 239, 255, 0.2); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* List View */
.sample-list-item {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.03);
}
.sample-list-item:hover {
  background: rgba(96, 239, 255, 0.08);
  border-color: rgba(96, 239, 255, 0.3);
  transform: translateX(4px);
}
.sample-list-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.sample-list-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #00ff87;
  font-weight: 600;
  background: rgba(0, 255, 135, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}
.sample-list-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.sample-list-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sample-list-eth {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}
.snp-badge {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #60efff;
  background: rgba(96, 239, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Detail View */
.sample-detail {
  animation: fadeIn 0.3s ease;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.detail-label {
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
}
.detail-value {
  color: #fff;
  font-weight: 600;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

/* STR Grid */
.str-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.str-title {
  font-size: 12px;
  font-weight: 600;
  color: #60efff;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.str-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 4px;
}
.str-cell {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 4px;
  text-align: center;
}
.str-name {
  display: block;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  font-family: 'JetBrains Mono', monospace;
}
.str-val {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
}

/* Sidebar menu trigger */
#menu-trigger {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(17, 25, 40, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.125);
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

#menu-trigger:active { transform: scale(0.92); }
#menu-trigger.active {
  background: rgba(0, 255, 135, 0.15);
  color: #00ff87;
  border-color: rgba(0, 255, 135, 0.3);
}

@media (max-width: 768px) {
  #menu-trigger { display: flex; }

  #sample-panel { 
    width: calc(100vw - 24px); 
    right: 12px; 
    top: 12px; 
    max-height: 55vh; 
  }
  
  .control-panel { 
    width: 260px; 
    left: 12px; 
    top: 12px; 
    bottom: auto;
    padding: 16px;
    padding-top: 68px; /* Оставляем место под кнопку триггера */
    border-radius: 20px;
    background: rgba(17, 25, 40, 0.92);
    transform: translateX(-300px);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 90;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  }

  .control-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
  }

  .control-panel h1 { 
    font-size: 18px; 
    margin-bottom: 4px; 
  }
  
  .control-panel p.desc { display: none; }

  .toggles-container {
    flex-direction: column; /* Вертикально, так как панель теперь узкая */
    gap: 8px;
    margin-bottom: 12px;
  }

  .mode-toggle {
    width: 100%;
    height: 38px;
    border-radius: 10px;
  }

  .mode-btn {
    font-size: 10px;
    letter-spacing: 0.5px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mode-btn.active {
    background: linear-gradient(135deg, rgba(96, 239, 255, 0.3) 0%, rgba(0, 255, 135, 0.3) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  }

  .btn-status {
    padding: 8px 12px;
    font-size: 11px;
    margin-bottom: 0;
  }

  #stats-container {
    display: none !important;
  }
}

/* Haplogroup Path */
.haplo-path-container {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.haplo-path-title {
  font-size: 12px;
  font-weight: 600;
  color: #60efff;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.haplo-legend {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: normal;
  display: flex;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
}
.haplo-legend-item { display: flex; align-items: center; gap: 4px; }
.haplo-dot { width: 6px; height: 6px; border-radius: 50%; }
.dot-yfull { background: #00ff87; }
.dot-ftdna { background: #60efff; }
.dot-match { background: #fff; }

.haplo-path-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.path-step {
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.snp-link { text-decoration: none; transition: all 0.2s; }
.snp-link:hover { text-decoration: underline; filter: brightness(1.2); }
.snp-yfull { color: #00ff87; }
.snp-ftdna { color: #60efff; }
.snp-match { color: #fff; }
.path-arrow {
  color: rgba(255, 255, 255, 0.3);
  font-size: 10px;
}
.snp-sep { color: rgba(255, 255, 255, 0.4); margin: 0 2px; }

.g25-btn {
  background: rgba(96, 239, 255, 0.2);
  color: var(--cyan);
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.g25-btn:hover {
  background: var(--cyan);
  color: #000;
}

/* ==================== Methodology Modal ==================== */
.btn-methodology {
  background: rgba(96, 239, 255, 0.1);
  border: 1px solid rgba(96, 239, 255, 0.3);
  color: #60efff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-methodology:hover {
  background: rgba(96, 239, 255, 0.25);
  box-shadow: 0 0 10px rgba(96, 239, 255, 0.2);
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-content.meth-content {
  background: rgba(17, 25, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.meth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
}
.meth-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}
.meth-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.meth-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.meth-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
}
.meth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.6);
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.meth-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.meth-tab.active {
  color: #60efff;
  border-bottom: 2px solid #60efff;
  background: rgba(96, 239, 255, 0.05);
}

.meth-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
}
.meth-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}
.meth-pane.active {
  display: block;
}

.meth-pane h3 {
  color: #fff;
  font-size: 18px;
  margin-top: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
}
.meth-pane h4 {
  color: #00ff87;
  font-size: 15px;
  margin-top: 24px;
  margin-bottom: 8px;
}
.meth-pane p {
  margin-top: 0;
  margin-bottom: 16px;
}
.meth-pane strong {
  color: #fff;
}

@media (max-width: 768px) {
  .meth-tabs {
    flex-wrap: wrap;
  }
  .meth-tab {
    flex: 1 1 50%;
    padding: 12px 0;
    font-size: 13px;
  }
  .modal-content.meth-content {
    width: 95%;
    max-height: 90vh;
  }
}
