/* ===== ПЕРЕМЕННЫЕ ТЁМЫ ===== */
:root {
  --bg: #F8FAFC;
  --surface: #ffffff;
  --surface2: #F4F7FB;
  --border: #E2E8F0;
  --text: #1E293B;
  --muted: #64748B;
  --muted2: #94A3B8;
  --accent: #0039A6;
  --accent-dark: #002266;
  --accent2: #10B981;
  --accent2-dark: #047857;
  --shadow: rgba(0,0,0,0.06);
  --hero-from: #001a5c;
  --hero-to: #1350c8;
}
body.dark {
  --bg: #0B0F19;
  --surface: #111827;
  --surface2: #1E293B;
  --border: rgba(255,255,255,0.08);
  --text: #F1F5F9;
  --muted: #94A3B8;
  --muted2: #64748B;
  --accent: #60A5FA;
  --accent-dark: #93C5FD;
  --accent2: #34D399;
  --accent2-dark: #6EE7B7;
  --shadow: rgba(0,0,0,0.4);
  --hero-from: #091224;
  --hero-to: #0f2042;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
button, a { -webkit-tap-highlight-color: transparent; outline: none; }

/* ===== HERO ===== */
.hero {
  position: relative;
  padding: 5.5rem 2rem 5rem;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(145deg, var(--hero-from) 0%, #0039A6 50%, var(--hero-to) 100%);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 70% at 70% 30%, rgba(100,170,255,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 40% 50% at 20% 80%, rgba(0,20,100,0.3) 0%, transparent 60%);
  pointer-events: none;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.9);
  padding: .38rem 1.1rem;
  border-radius: 100px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 1.8rem;
}
.hero h1 {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(2rem, 6vw, 3.8rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.03em;
  color: #ffffff;
  margin-bottom: 1.2rem;
}
.hero-sub {
  color: rgba(255,255,255,0.75);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 auto;
}

/* ===== DARK TOGGLE ===== */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--shadow);
  transition: transform .2s, box-shadow .2s, background .3s;
}
.theme-toggle:hover { transform: scale(1.1); box-shadow: 0 8px 30px var(--shadow); color: var(--accent); }

/* ===== NAV ===== */
.nav-wrap {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  transition: background .3s, border-color .3s;
}
body.dark .nav-wrap { background: rgba(11,15,25,0.97); }
.nav-tabs {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  padding: 1.2rem 1.4rem;
  font-size: .88rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  transition: all .2s;
  white-space: nowrap;
  position: relative;
  top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-tab:hover { color: var(--accent); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== LAYOUT ===== */
main { }
.tab-section { display: none; max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.tab-section.active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ===== SECTION INTRO ===== */
.section-intro {
  background: linear-gradient(135deg, #0039A6 0%, #1a5fd6 100%);
  border-radius: 18px;
  padding: 2rem 2.2rem;
  margin-bottom: 1.75rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: background 0.3s, border 0.3s;
}
body.dark .section-intro {
  background: linear-gradient(135deg, #111827 0%, #1E293B 100%);
  border: 1px solid rgba(96,165,250,0.2);
}
.section-intro::before {
  content: '';
  position: absolute;
  right: -30px; top: -30px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
}
.section-intro::after {
  content: '';
  position: absolute;
  left: -20px; bottom: -40px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.section-intro-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,0.65);
  margin-bottom: .55rem;
  position: relative;
  z-index: 1;
}
.section-intro h2 {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .85rem;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}
.section-intro p {
  font-size: .88rem;
  color: rgba(255,255,255,0.82);
  line-height: 1.75;
  font-weight: 500;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

/* ===== CARDS ===== */
.section-title { font-family:'Unbounded',sans-serif; font-size:1.2rem; font-weight:700; margin-bottom:.35rem; color:var(--accent-dark); }
.section-sub { color:var(--muted); font-size:.85rem; margin-bottom:1.8rem; line-height:1.5; font-weight:500; }

.dcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 15px var(--shadow);
  transition: background .3s, border-color .3s;
}
.dcard h3 { font-family:'Unbounded',sans-serif; font-size:.85rem; font-weight:700; margin-bottom:1.4rem; color:var(--text); text-transform:uppercase; letter-spacing:.06em; }

.grid-responsive { display: grid; gap: 1.5rem; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.grid-cols-3 { grid-template-columns: repeat(3,1fr); }
.grid-cols-oa { grid-template-columns: 1fr 2fr; }

/* ===== SDG ===== */
.sdg-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.chart-wrapper { position:relative; height:470px; width:100%; }
#combo-chart-container { width:100%; height:520px; }
.sticky-panel { position:-webkit-sticky; position:sticky; top:70px; }
.metric-block { margin-bottom:1.4rem; }
.metric-lbl { font-size:.68rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.08em; margin-bottom:.25rem; }
.metric-val { font-family:'Unbounded',sans-serif; font-size:1.9rem; font-weight:700; color:var(--text); }
#details-title { font-family:'Unbounded',sans-serif; font-size:.95rem; font-weight:700; margin-bottom:1.4rem; line-height:1.4; color:var(--accent-dark); }
.sdg-hint { font-size:.72rem; color:var(--muted); margin-top:1.5rem; line-height:1.7; border-top:1px solid var(--border); padding-top:.85rem; }

/* ===== TABLES ===== */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:12px; }
table { width:100%; border-collapse:collapse; font-size:.82rem; }
th,td { padding:.8rem .9rem; text-align:left; border-bottom:1px solid var(--border); vertical-align:top; }
th { background:var(--surface2); color:var(--muted); font-weight:700; font-size:.68rem; text-transform:uppercase; letter-spacing:.06em; white-space:nowrap; }
tr:last-child td { border-bottom:none; }
tr:hover td { background:rgba(0,57,166,0.03); }
body.dark tr:hover td { background: rgba(79,142,247,0.04); }

/* ===== FRONTIERS ===== */
.topic-wrapper { max-width:320px; }
.topic-header { display:flex; align-items:flex-start; gap:8px; justify-content:space-between; }
.topic-name { font-weight:700; color:var(--text); line-height:1.4; }
.topic-id { font-size:.68rem; color:var(--muted); margin-top:2px; font-weight:600; }
.info-toggle-btn {
  display:inline-flex; justify-content:center; align-items:center;
  width:24px; height:24px; border-radius:50%;
  background:rgba(0,57,166,0.08); color:var(--accent);
  font-size:13px; font-weight:700; font-style:italic;
  cursor:pointer; border:1px solid rgba(0,57,166,0.15);
  transition:all .2s; flex-shrink:0; padding:0;
}
body.dark .info-toggle-btn { background:rgba(79,142,247,0.1); border-color:rgba(79,142,247,0.2); }
.info-toggle-btn:hover { background:rgba(0,57,166,0.15); }
.info-toggle-btn.active { background:var(--accent); color:#fff; transform:rotate(45deg); font-style:normal; }
.topic-description {
  display:none; margin-top:10px; padding:10px 12px;
  background:rgba(0,57,166,0.04); border-left:3px solid var(--accent);
  border-radius:0 6px 6px 0; font-size:.78rem; color:var(--muted);
  line-height:1.6; animation:fadeInRow .2s ease; font-weight:500;
}
body.dark .topic-description { background:rgba(79,142,247,0.06); }
.topic-description.show { display:block; }
@keyframes fadeInRow { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }

.text-world { color:var(--accent); font-weight:700; }
.text-russia { color:var(--accent2); font-weight:700; }
.metric-group { text-align:right; }
.bar-wrapper { display:flex; align-items:center; gap:8px; }
.bar-bg { width:80px; height:6px; background:var(--border); border-radius:3px; overflow:hidden; }
.bar-fill { height:100%; background:var(--accent2); border-radius:3px; }
.percent-label { font-size:.78rem; font-weight:700; color:var(--text); width:40px; text-align:right; }
.badge-pct { background:rgba(0,57,166,0.08); color:var(--accent); padding:3px 8px; border-radius:100px; font-size:.7rem; font-weight:700; border:1px solid rgba(0,57,166,0.15); white-space:nowrap; }
body.dark .badge-pct { background:rgba(79,142,247,0.1); border-color:rgba(79,142,247,0.2); }

/* ===== PLOTLY LEGEND ===== */
.legend-row { display:flex; justify-content:center; gap:1.5rem; flex-wrap:wrap; margin-top:1rem; font-size:.8rem; font-weight:600; color:var(--muted); }
.legend-dot { width:13px; height:13px; border-radius:50%; display:inline-block; vertical-align:middle; margin-right:5px; }

/* ===== TANZANIA TABS ===== */
.tz-tab-btn { padding:.6rem 1.1rem; font-size:.78rem; font-weight:700; cursor:pointer; border:none; background:transparent; color:var(--muted); border-bottom:2px solid transparent; transition:all .2s; font-family:'Montserrat',sans-serif; }
.tz-tab-btn.active { color:var(--accent); border-bottom-color:var(--accent); }
.tz-tab-content { display:none; }
.tz-tab-content.active { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:1rem; margin-top:1rem; }

/* ===== CIT LINKS ===== */
.cit-link {
  display:flex; justify-content:space-between; align-items:flex-start;
  gap:1rem; border:1px solid var(--border); border-radius:12px;
  padding:1.2rem; transition:all .2s; text-decoration:none;
  background:var(--surface); box-shadow:0 2px 8px var(--shadow);
}
.cit-link:hover { border-color:var(--accent) !important; transform:translateY(-2px); box-shadow:0 6px 15px rgba(0,57,166,0.1); }

/* ===== RID SPECIFIC ===== */
.rid-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.rid-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; text-align: center; transition: transform 0.2s; box-shadow: 0 4px 15px var(--shadow); }
.rid-stat-card:hover { transform: translateY(-5px); }
.rid-stat-icon { color: var(--accent); display: flex; justify-content: center; margin-bottom: 0.8rem; }
.rid-stat-val { font-family: 'Unbounded', sans-serif; font-size: 1.8rem; font-weight: 800; color: var(--text); display: block; line-height: 1.1; }
.rid-stat-lbl { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.5rem; line-height: 1.3; }
.filter-bar { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-input { flex: 1; min-width: 200px; padding: 0.7rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: 'Montserrat', sans-serif; font-size: 0.85rem; }
.filter-select { padding: 0.7rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-family: 'Montserrat', sans-serif; font-size: 0.85rem; cursor: pointer; }

/* ===== FOOTER ===== */
footer { text-align:center; padding:3rem 1.5rem; background-color:#0F172A; color:var(--muted2); font-size:.8rem; max-width:100%; margin:0; line-height:1.6; }
body.dark footer { background-color:#04070E; }

/* ===== DESKTOP SDG ===== */
@media(min-width:801px) {
  .sdg-layout { display:grid; grid-template-columns:1fr 300px; align-items:start; }
}

/* ===== MOBILE ===== */
@media(max-width:800px) {
  .grid-responsive.grid-cols-2,
  .grid-responsive.grid-cols-3,
  .grid-responsive.grid-cols-oa { grid-template-columns:1fr !important; }
  .hero { padding:3.5rem 1.2rem 3rem; }
  .tab-section { padding:1.5rem 0.75rem; }
  .dcard { padding:1.25rem; }
  .section-intro { padding:1.5rem 1.2rem; }
  .section-intro h2 { font-size:.95rem; }

  .nav-wrap { position:static; padding:1rem; border-bottom:none; background:transparent !important; box-shadow:none; }
  .nav-tabs { display:flex; flex-wrap:wrap; gap:0.5rem; overflow:visible; justify-content:center; }
  .nav-tab { white-space:normal; padding:0.85rem 0.5rem; font-size:0.75rem; border:1px solid var(--border) !important; border-radius:10px; line-height:1.3; background:var(--surface); box-shadow:0 2px 5px rgba(0,0,0,0.03); text-align:center; flex: 1 1 calc(33% - 0.5rem); justify-content: center; }
  .nav-tab.active { background:rgba(0,57,166,0.05); border-color:var(--accent) !important; color:var(--accent); }
  body.dark .nav-tab.active { background:rgba(79,142,247,0.06); }

  .rid-stats-grid { grid-template-columns: 1fr 1fr; }

  .sdg-layout .sticky-panel { order:-1; position:static; margin-bottom:0; }
  .chart-wrapper { height:320px; }
  #combo-chart-container { height:380px; }

  table thead { display:none; }
  table, tbody, tr, td { display:block; width:100%; }
  tr { margin-bottom:1rem; background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:0.5rem 1rem; box-shadow:0 2px 8px var(--shadow); }
  td { display:flex; justify-content:space-between; align-items:center; padding:0.8rem 0; border-bottom:1px solid var(--border); text-align:right !important; gap:1rem; }
  td:last-child { border-bottom:none; }
  td::before { content:attr(data-label); font-size:0.7rem; font-weight:700; color:var(--muted); text-transform:uppercase; text-align:left; flex-shrink:0; max-width:45%; line-height:1.3; }
  .td-block { display:block; text-align:left !important; padding:1rem 0; }
  .td-block::before { display:none; }
  .topic-wrapper { max-width:100%; }
  .bar-wrapper { justify-content:flex-end; width:100%; }
  .metric-group { text-align:right; }
  .cit-link { flex-direction:column; align-items:center; text-align:center; }
  .cit-link > div:first-child { display:flex; flex-direction:column; align-items:center; }
  .cit-link > div:last-child { width:100%; margin-top:0.5rem; }
  .tz-tab-content.active { grid-template-columns:1fr; }
  
  .theme-toggle { bottom:1rem; right:1rem; width:44px; height:44px; }
}
/* ===== КНОПКА "НАВЕРХ" ===== */
.scroll-to-top {
  position: fixed;
  bottom: 5.5rem; /* Располагаем над кнопкой переключения темы */
  right: 1.5rem;
  z-index: 9998;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--shadow);
  transition: opacity 0.3s, transform 0.2s, background 0.3s;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}
.scroll-to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-to-top:hover {
  color: var(--accent);
  transform: scale(1.1);
}
body.dark .scroll-to-top {
  background: var(--surface2);
}

@media(max-width:800px) {
  .scroll-to-top {
    bottom: 4.5rem;
    right: 1rem;
    width: 44px; 
    height: 44px;
  }
}
/* ===== КНОПКА ЯЗЫКА ===== */
.lang-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 101;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.2s;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.lang-toggle:hover {
  background: #fff;
  color: var(--accent);
}
@media(max-width:800px) {
  .lang-toggle { top: 1rem; right: 1rem; padding: 0.3rem 0.6rem; font-size: 0.75rem; }
}
/* ===== КНОПКА "НА ГЛАВНУЮ" (АРХИВ) ===== */
.home-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 101;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.home-btn:hover {
  background: #fff;
  color: var(--accent);
}
@media(max-width:800px) {
  .home-btn { top: 1rem; left: 1rem; padding: 0.3rem 0.6rem; font-size: 0.75rem; }
}
/* ===== ИСПРАВЛЕНИЕ ЗАГОЛОВКА ДЛЯ АЙФОНОВ (БЕЗ ПЕРЕНОСОВ) ===== */
@media(max-width: 800px) {
  .hero h1 {
    white-space: nowrap !important;
    font-size: 6vw !important; /* Уменьшили до 6%, чтобы точно влезло */
    letter-spacing: -0.03em !important; /* Чуть-чуть плотнее ставим буквы */
  }
}

/* Отдельное правило для самых маленьких экранов (например, iPhone SE) */
@media(max-width: 400px) {
  .hero h1 {
    font-size: 5.3vw !important; 
  }
}
/* ===== ИСПРАВЛЕНИЕ РАЗРЫВА ЦИФР В ТАБЛИЦЕ НА МОБИЛЬНЫХ ===== */
@media(max-width: 800px) {
  td.metric-group {
    justify-content: flex-end !important;
    gap: 0.2rem !important; /* Убираем огромные пробелы между цифрами и слешем */
  }
  td.metric-group::before {
    margin-right: auto; /* Жестко прижимаем название строки к левому краю */
  }
}