:root {
  --bg: #0b1020;
  --panel: #121a33;
  --text: #e8ecf7;
  --muted: #8a93b2;
  --accent: #5ee1a1;
  --border: #1f2a4a;
  --low: #2a4a7a;
  --mid: #3d7ab8;
  --high: #e0a13d;
  --max: #e05555;
  --no-data: #2a2f45;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.logo { 
  margin: 0; 
  font-size: 16px; 
  font-weight: 600;
}
.lang-selector {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.2s;
}
.lang-selector:hover {
  background: var(--bg);
  color: var(--text);
}
.status { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  font-size: 11px; 
  color: var(--muted);
  font-weight: 500;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--panel);
}
.search { 
  padding: 8px; 
  border-bottom: 1px solid var(--border); 
}
.search input {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  font-size: 13px;
}
.country-list { 
  list-style: none; 
  margin: 0; 
  padding: 0; 
}
.country-list li {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.15s;
}
.country-list li:hover { 
  background: rgba(94, 225, 161, 0.1); 
}
.country-list li.active { 
  background: rgba(94, 225, 161, 0.2); 
  color: var(--accent); 
}

.map-area {
  position: relative;
  overflow: hidden;
  background: #080d1c;
  display: flex;
  flex-direction: column;
}
.map-header {
  padding: 6px 12px;
  background: rgba(18, 26, 51, 0.95);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

/* Фильтры показателей */
.metric-filters {
  position: absolute;
  top: 36px;
  left: 12px;
  display: flex;
  gap: 4px;
  z-index: 2;
  flex-wrap: wrap;
}
.metric-btn {
  background: rgba(18, 26, 51, 0.95);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
}
.metric-btn:hover {
  background: var(--panel);
  color: var(--text);
}
.metric-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.legend {
  position: absolute;
  top: 36px;
  right: 12px;
  background: rgba(18, 26, 51, 0.95);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  z-index: 2;
  border: 1px solid var(--border);
}
.legend-controls {
  color: var(--accent);
  font-weight: 600;
}

#map { 
  flex: 1;
  width: 100%; 
}
#map svg { 
  width: 100%; 
  height: 100%; 
}
.country { 
  stroke: #0b1020; 
  stroke-width: 0.5; 
  cursor: pointer; 
  transition: opacity 0.2s; 
}
.country:hover { 
  opacity: 0.8; 
}
.country.no-data { 
  fill: var(--no-data); 
}

/* Шкала внизу */
.legend-scale-bottom {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(18, 26, 51, 0.95);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
  border: 1px solid var(--border);
}
.swatch { 
  width: 12px; 
  height: 12px; 
  border-radius: 2px;
  display: inline-block;
}
.swatch.low { background: var(--low); }
.swatch.mid { background: var(--mid); }
.swatch.high { background: var(--high); }
.swatch.max { background: var(--max); }
.legend-note { 
  color: var(--muted);
  margin-left: 8px;
}

.panel {
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  background: var(--panel);
}
.panel-placeholder { 
  color: var(--muted); 
  font-size: 13px; 
  line-height: 1.5;
  text-align: center;
  padding: 40px 20px;
}
.panel-content h2 { 
  margin: 0 0 16px; 
  font-size: 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.indicators { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 8px; 
}
.indicator {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.indicator .label { 
  font-size: 10px; 
  color: var(--muted); 
  text-transform: uppercase; 
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.indicator .value { 
  font-size: 18px; 
  font-weight: 600; 
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.indicator .unit { 
  font-size: 11px; 
  color: var(--muted); 
  margin-left: 4px; 
}

.footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
  background: var(--panel);
}
.about { 
  margin: 0 0 6px 0; 
  font-size: 11px;
}
.about summary { 
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
}
.about p { 
  margin: 6px 0; 
  line-height: 1.5; 
}
.footer-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hidden { 
  display: none !important; 
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Языковое меню */
.lang-selector {
  position: relative;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.2s;
  user-select: none;
}
.lang-selector:hover {
  background: var(--bg);
  color: var(--text);
}
.lang-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: 120px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.lang-selector.open .lang-dropdown {
  display: block;
}
.lang-option {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 12px;
}
.lang-option:hover {
  background: rgba(94, 225, 161, 0.1);
}
.lang-option.active {
  background: rgba(94, 225, 161, 0.2);
  color: var(--accent);
}

/* RTL поддержка */
body.rtl {
  direction: rtl;
}
body.rtl .sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
}
body.rtl .panel {
  border-left: none;
  border-right: 1px solid var(--border);
}
body.rtl .lang-dropdown {
  right: auto;
  left: 0;
}
body.rtl .metric-filters {
  left: auto;
  right: 12px;
}
body.rtl .legend {
  right: auto;
  left: 12px;
}
body.rtl .legend-scale-bottom {
  left: auto;
  right: 12px;
}