/* ===========================================================
   ИРЦА · Stylesheet v2 — Sidebar SPA, light/dark
   =========================================================== */

/* ---------- Reset / Base ---------- */
*,*::before,*::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Tokens · Light ---------- */
:root, :root[data-theme="light"] {
  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --surface-2:    #fbfcfe;
  --surface-alt:  #f0f2f7;
  --border:       #e3e6ee;
  --border-2:     #eceff5;
  --text:         #0f1722;
  --text-mid:     #4a5468;
  --text-muted:   #6b7588;
  --text-faint:   #9aa3b5;

  --accent:       #3b6fd4;
  --accent-hover: #2e5cba;
  --accent-soft:  #eaf0fb;
  --accent-2:     #8b5cf6;

  --pos:          #27ae60;
  --pos-soft:     #e8f6ee;
  --neg:          #e74c3c;
  --neg-soft:     #fdebe9;
  --warn:         #f59e0b;
  --warn-soft:    #fef5e6;
  --neutral:      #6b7588;

  --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:       0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg:    0 12px 32px rgba(15, 23, 42, 0.12);

  --radius:       8px;
  --radius-lg:    12px;
  --radius-sm:    6px;

  --sidebar-w:    220px;
  --topbar-h:     76px;

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- Tokens · Dark ---------- */
:root[data-theme="dark"] {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface-2:    #1c222b;
  --surface-alt:  #1f2731;
  --border:       #2a3140;
  --border-2:     #232a36;
  --text:         #e6edf3;
  --text-mid:     #c1cad9;
  --text-muted:   #8b95a7;
  --text-faint:   #5d6577;

  --accent:       #5b9cf6;
  --accent-hover: #7eb1f9;
  --accent-soft:  rgba(91, 156, 246, 0.14);
  --accent-2:     #a78bfa;

  --pos:          #4ade80;
  --pos-soft:     rgba(74, 222, 128, 0.14);
  --neg:          #f87171;
  --neg-soft:     rgba(248, 113, 113, 0.14);
  --warn:         #fbbf24;
  --warn-soft:    rgba(251, 191, 36, 0.14);

  --shadow:       0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-lg:    0 12px 32px rgba(0, 0, 0, 0.55);
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- App Frame ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 12px;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 12px;
}
.brand-logo { display: flex; align-items: center; justify-content: center; }
.brand-title { text-transform: uppercase; font-weight: 900; letter-spacing: 0.05em;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  line-height: 1;
}
.brand-sub {
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 18px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item svg { flex-shrink: 0; opacity: 0.9; }
.nav-item.active svg { color: var(--accent); }

.sidebar-section {
  padding: 12px 4px 0;
  border-top: 1px solid var(--border-2);
}
.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 10px;
  padding: 0 6px;
}
.filter-group { margin-bottom: 12px; padding: 0 4px; }
.filter-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}
.filter-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text);
}
.filter-select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filter-checks { display: flex; flex-direction: column; gap: 5px; }
.check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 13px; height: 13px; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px 4px 4px;
  border-top: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.data-updated {
  flex: 1;
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.35;
}
.data-updated strong {
  color: var(--text-mid);
  font-weight: 600;
  font-size: 11.5px;
}
.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot.live {
  background: var(--pos);
  box-shadow: 0 0 0 0 var(--pos);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(39,174,96,0.45); }
  70% { box-shadow: 0 0 0 6px rgba(39,174,96,0); }
  100% { box-shadow: 0 0 0 0 rgba(39,174,96,0); }
}

.theme-toggle {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-mid);
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--surface-alt); color: var(--text); }

/* ---------- Canonical one-header layout guard ----------
   The live product uses one top header with the "Разделы" dropdown.
   The old left sidebar/mobile burger must never be visible or reintroduced
   in the public desktop/mobile UI. */
.app {
  grid-template-columns: 1fr !important;
}
.sidebar,
.mobile-burger {
  display: none !important;
}

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
  width: 100%;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  min-height: var(--topbar-h);
  box-sizing: border-box;
  width: 100%;
  overflow: visible;
  max-width: 100%;
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; flex: 1; }
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-home-link {
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.brand-home-link:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 4px;
}
.topbar-brand-text { display: flex; flex-direction: column; gap: 1px; }
.topbar-title {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.1;
}
.topbar-sub {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.country-tabs {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.country-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-mid);
  border-radius: var(--radius-sm);
  transition: background 120ms, color 120ms;
}
.country-tab:hover { background: var(--surface); color: var(--text); }
.country-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.flag-emoji { font-size: 14px; line-height: 1; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-back-home {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn-back-home.visible { display: inline-flex; }
.btn-back-home:hover { background: var(--surface-alt); color: var(--accent); }
.sections-wrap { position: relative; display: inline-flex; }
.btn-sections {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn-sections:hover { background: var(--surface-alt); }
.sections-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 220;
}
.sections-menu.open { display: grid; gap: 6px; }
.section-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}
.section-menu-item:hover { background: var(--surface-alt); color: var(--text); }
.section-menu-item.active { background: var(--accent-soft); color: var(--accent); }
.sections-menu-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border-2);
  color: var(--text-muted);
  font-size: 12px;
}
.sections-menu-meta strong { color: var(--text); font-weight: 800; white-space: nowrap; }
.section-menu-theme { border-top: 1px solid var(--border-2); margin-top: 2px; }
.period-dropdown {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 120ms, transform 80ms;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface-alt);
  color: var(--text-mid);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- Page container ---------- */
.page-container {
  padding: 20px 20px 60px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* ---------- Page Title ---------- */
.page-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 22px;
}

/* ---------- Grid (Overview hero) ---------- */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-bottom: 16px;
  min-width: 0;
}
.signals-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* signals-row responsive */

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  letter-spacing: 0.01em;
}
.card-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin: 0;
}
.card-pill {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 3px 7px;
  border-radius: 999px;
}

/* ---------- KPI Card ---------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.kpi-value {
  font-family: var(--font-body);
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}
.kpi-value.positive { color: var(--pos); }
.kpi-value.negative { color: var(--neg); }
.kpi-value.neutral { color: var(--neutral); }
.kpi-scale {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -4px;
}
.kpi-meta { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.kpi-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}
.kpi-meta-row strong { color: var(--text-mid); font-weight: 600; }
.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-size: 12px;
}
.delta.up { color: var(--pos); }
.delta.down { color: var(--neg); }
.delta.flat { color: var(--neutral); }

/* ---------- Signals ---------- */
.signals-list { display: flex; flex-direction: column; gap: 10px; }
.signal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.signal.high { border-left-color: var(--neg); }
.signal.med { border-left-color: var(--warn); }
.signal.low { border-left-color: var(--pos); }
.signal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.signal-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.signal-level {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.signal-level.high { background: var(--neg-soft); color: var(--neg); }
.signal-level.med  { background: var(--warn-soft); color: var(--warn); }
.signal-level.low  { background: var(--pos-soft); color: var(--pos); }
.signal-body {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.signal-action {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}
.signal-action:hover { text-decoration: underline; }

/* ---------- Calibration ---------- */
.calibration-list { display: flex; flex-direction: column; gap: 8px; }
.calibration-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-mid);
}
.calibration-row .check-mark {
  width: 14px; height: 14px;
  border-radius: 4px;
  background: var(--pos-soft);
  color: var(--pos);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

/* ---------- Chart ---------- */
.chart-host {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-host.tall { height: 340px; }
.chart-host.compact { height: 180px; }

.chart-toggle {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.chart-toggle button {
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-radius: 4px;
  font-weight: 500;
}
.chart-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Subindices ---------- */
.subindex-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.sub {
  appearance: none;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: inherit;
  font: inherit;
  text-align: left;
}
.sub-clickable {
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.sub-clickable:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  background: var(--surface-alt);
}
.sub-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.sub-head { display: flex; align-items: center; justify-content: space-between; }
.sub-code {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 11.5px;
  color: white;
}
.sub-name {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.sub-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.sub-value.positive { color: var(--pos); }
.sub-value.negative { color: var(--neg); }
.sub-value.neutral  { color: var(--neutral); }
.sub-spark-wrap {
  position: relative;
  width: 100%;
  height: 32px;
}
.sub-spark {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 32px !important;
}

/* ---------- Bottom row ---------- */
.bottom-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

/* Narratives */
.narrative {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-2);
}
.narrative-clickable {
  width: 100%;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 160ms ease, transform 160ms ease;
}
.narrative-clickable:hover {
  background: var(--surface-alt);
  transform: translateX(2px);
}
.narrative-muted {
  color: var(--text-muted);
}
.narrative:last-child { border-bottom: none; }
.narrative-text { font-size: 13px; color: var(--text); font-weight: 500; flex: 1; min-width: 0; }
.narrative-detail {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.youth-platform-card {
  border-radius: 12px;
  padding: 12px 10px;
  margin: 0 0 8px;
  border: 1px solid var(--border-2);
}
.youth-platform-card:last-child { margin-bottom: 0; }
.youth-platform-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.youth-platform-share {
  font-size: 11.5px;
  color: var(--text-muted);
  min-width: 42px;
  text-align: right;
  font-weight: 700;
}
.narrative-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.narrative-bar {
  width: 80px; height: 4px;
  background: var(--surface-alt);
  border-radius: 2px;
  overflow: hidden;
}
.narrative-bar > span { display: block; height: 100%; border-radius: 2px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; min-height: 172px; }
.donut-canvas-wrap { position: relative; width: 160px; height: 160px; flex-shrink: 0; }
.donut-canvas-wrap canvas { position: absolute !important; inset: 0; width: 160px !important; height: 160px !important; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.donut-legend-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text-mid);
}
.donut-legend-clickable {
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 160ms ease;
}
.donut-legend-clickable:hover { background: var(--surface-alt); }
.donut-legend-row .swatch {
  width: 10px; height: 10px; border-radius: 3px;
  flex-shrink: 0;
}
.donut-legend-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend-target {
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}
.donut-legend-row .val {
  font-weight: 600;
  color: var(--text);
  min-width: 34px;
  text-align: right;
}

/* Narrative evidence panel */
.evidence-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1900;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.evidence-panel {
  position: relative;
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.evidence-panel-wide {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
}
.evidence-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
}
.evidence-kicker {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}
.evidence-panel h3 {
  margin: 0 44px 16px 0;
  font-size: 22px;
  line-height: 1.2;
  color: var(--text);
}
.evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.evidence-grid > div {
  background: var(--surface-alt);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  padding: 10px;
}
.evidence-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.evidence-grid strong {
  color: var(--text);
  font-size: 18px;
}
.evidence-grid strong.up { color: var(--pos); }
.evidence-grid strong.down { color: var(--neg); }
.evidence-grid strong.neutral { color: var(--neutral); }
.evidence-note,
.evidence-breakdown {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-mid);
}
.evidence-note {
  padding: 12px;
  background: var(--surface-alt);
  border-radius: 12px;
}
.evidence-breakdown { margin-top: 10px; }
.evidence-section-title {
  margin: 16px 0 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.evidence-list {
  display: grid;
  gap: 8px;
}
.evidence-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background: var(--surface-alt);
}
.evidence-list-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}
.evidence-list-item span {
  color: var(--text-muted);
  font-size: 12px;
}
.evidence-tone-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.evidence-tone-dot.up { background: var(--pos); }
.evidence-tone-dot.down { background: var(--neg); }
.evidence-tone-dot.neutral { background: var(--neutral); }
.evidence-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 13px;
}
.evidence-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.evidence-actions button {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.evidence-actions .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.evidence-actions .btn-secondary {
  background: var(--surface);
  color: var(--text);
}

/* ---------- Media page ---------- */
.media-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.source-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-2);
}
.source-row:last-child { border-bottom: none; }
.source-flag { font-size: 16px; }
.source-name { font-weight: 600; color: var(--text); font-size: 13px; flex: 1; }
.source-handle { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.source-tone {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
}
.source-tone.pos { background: var(--pos-soft); color: var(--pos); }
.source-tone.neg { background: var(--neg-soft); color: var(--neg); }
.source-tone.neu { background: var(--surface-alt); color: var(--text-muted); }
.source-affiliation {
  display: inline-flex;
  align-items: center;
  max-width: 260px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  white-space: normal;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
}
.source-affiliation.pro-russian,
.source-card-affiliation strong.pro-russian { color: #15803d; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.28); }
.source-affiliation.critical,
.source-card-affiliation strong.critical { color: #b42318; background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.28); }
.source-affiliation.pro-turkish,
.source-card-affiliation strong.pro-turkish { color: #9a3412; background: rgba(249,115,22,.12); border-color: rgba(249,115,22,.28); }
.source-affiliation.state,
.source-card-affiliation strong.state { color: #1d4ed8; background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.28); }
.source-affiliation.neutral,
.source-card-affiliation strong.neutral { color: #475569; background: rgba(100,116,139,.10); border-color: rgba(100,116,139,.24); }
.source-affiliation.unknown,
.source-card-affiliation strong.unknown { color: #6b7280; background: rgba(107,114,128,.08); border-color: rgba(107,114,128,.18); }
.source-activity {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 60px;
  text-align: right;
}
.headline {
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-2);
  font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
}
.headline:last-child { border-bottom: none; }
.headline-tone-dot {
  width: 6px; height: 6px; border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.headline-text { flex: 1; color: var(--text); line-height: 1.5; }
.headline-src { display: block; color: var(--text-faint); font-size: 11px; margin-top: 2px; }

/* ---------- ИИМ page ---------- */
.fimi-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.disarm-list { display: flex; flex-direction: column; gap: 8px; }
.disarm-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.disarm-row strong { color: var(--text); font-weight: 600; }
.disarm-row .val {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-mid);
}

/* Risks compact */
.risks-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.risks-table th, .risks-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-2);
}
.risks-table th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.risks-table td.level { font-weight: 600; }
.risks-table td.level.high { color: var(--neg); }
.risks-table td.level.med  { color: var(--warn); }

/* ---------- Sources page ---------- */
.sources-filter { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.src-filter-btn {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  font-weight: 500;
}
.src-filter-btn:hover { background: var(--surface-alt); color: var(--text); }
.src-filter-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.sources-country-block { margin-bottom: 18px; }
.sources-country-title {
  font-size: 13px; font-weight: 700;
  margin: 0 0 10px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.sources-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.sources-table th, .sources-table td {
  padding: 9px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-2);
  text-align: left;
}
.sources-table th {
  background: var(--surface-2);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}
.sources-table tr:last-child td { border-bottom: none; }
.sources-table tr:hover td { background: var(--surface-alt); }

/* ---------- Surveys ---------- */
.survey-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px;
}
.survey-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-2);
  font-size: 12.5px;
}
.survey-row:last-child { border-bottom: none; }
.survey-row strong { color: var(--text); font-weight: 600; }
.survey-row .val { font-weight: 700; }
.survey-source-list {
  display: grid;
  gap: 10px;
}
.survey-metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.survey-metric-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: 12.5px;
}
.survey-metric-item strong {
  display: block;
  color: var(--text);
  font-weight: 650;
}
.survey-metric-item span,
.survey-metric-item small {
  color: var(--text-muted);
}
.survey-metric-value {
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
}
.survey-source-item {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(160px, 0.9fr);
  gap: 8px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-2);
  font-size: 12.5px;
}
.survey-source-item:last-child { border-bottom: none; }
.survey-source-item strong {
  display: block;
  color: var(--text);
  font-weight: 650;
}
.survey-source-item span,
.survey-source-item small {
  color: var(--text-muted);
}
.survey-source-item small {
  grid-column: 1 / -1;
  line-height: 1.45;
}

/* ---------- Reports library ---------- */
.reports-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.reports-toolbar strong {
  display: inline-flex;
  min-width: 34px;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
}
.reports-toolbar span {
  color: var(--text-muted);
  font-size: 12.5px;
}
.reports-refresh {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.reports-refresh:hover { color: var(--accent); border-color: var(--accent); }
.reports-list {
  display: grid;
  gap: 12px;
}
.report-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.report-card-main { min-width: 0; }
.report-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.report-mode {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}
.report-date {
  color: var(--text-muted);
  font-size: 12px;
}
.report-title {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
}
.report-meta-line {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.4;
}
.report-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}
.report-metrics span {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-mid);
  font-size: 11.5px;
  font-weight: 700;
}
.report-actions {
  display: flex;
  gap: 8px;
}
.report-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-alt);
  font-size: 12.5px;
  font-weight: 800;
  text-decoration: none;
}
.report-action.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.report-action:hover { transform: translateY(-1px); }
.empty-state {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 720px;
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-muted);
  background: var(--surface-alt);
}
.modal-close:hover { background: var(--border-2); color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.6;
}
.modal-body h3 {
  font-size: 13px; font-weight: 700;
  color: var(--text); margin: 18px 0 6px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.modal-body h3:first-child { margin-top: 0; }
.modal-body code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--surface-alt);
  padding: 1px 5px; border-radius: 4px;
  color: var(--accent);
}
.modal-body ul { padding-left: 18px; margin: 6px 0; }
.modal-body li { margin: 3px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 30px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms, opacity 200ms;
  z-index: 2000;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile burger ---------- */
.mobile-burger {
  display: none;
  position: fixed;
  top: 64px; left: 12px;
  width: 38px; height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  z-index: 50;
  align-items: center; justify-content: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .overview-grid { grid-template-columns: 1fr; }
  .signals-row { grid-template-columns: 1fr 1fr; }
  .subindex-grid { grid-template-columns: repeat(3, 1fr); }
  .bottom-row { grid-template-columns: 1.2fr 1fr; }
  .media-grid { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-burger { display: none !important; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(290px, 1fr) auto minmax(360px, 1fr);
    padding: 14px 32px;
  }
  .topbar-left { display: contents; }
  .topbar-brand { grid-column: 1; min-width: 0; }
  .country-tabs { grid-column: 2; justify-self: center; }
  .topbar-right { grid-column: 3; justify-self: end; }
}

@media (max-width: 700px) {
  .signals-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .donut-wrap { align-items: stretch; }
  .reports-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .reports-refresh { width: 100%; }
  .report-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .report-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .report-action { min-width: 0; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-burger { display: none !important; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 10px;
    padding: 12px 20px 14px;
  }
  .topbar-left { display: contents; }
  .topbar-brand {
    order: 1;
    width: 100%;
    min-width: 0;
  }
  .topbar-sub {
    max-width: min(300px, calc(100vw - 92px));
  }
  .topbar-right {
    order: 2;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(112px, 1fr) minmax(88px, .8fr) minmax(118px, 1fr);
    gap: 8px;
    justify-content: stretch;
  }
  .btn-back-home.visible {
    grid-column: 1 / -1;
    min-height: 40px;
  }
  .sections-wrap,
  .export-wrap { width: 100%; min-width: 0; }
  .btn-sections,
  .period-dropdown,
  .btn-export {
    width: 100%;
    min-height: 42px;
    justify-content: center;
    box-sizing: border-box;
  }
  .sections-menu {
    left: 0;
    right: auto;
    width: min(300px, calc(100vw - 40px));
  }
  .country-tabs {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    box-sizing: border-box;
  }
  .country-tab {
    justify-content: center;
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
    white-space: nowrap;
  }
  .page-container { padding: 16px 14px 60px; }
  .kpi-row { grid-template-columns: 1fr; }
  .subindex-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 46px; }
  .survey-grid { grid-template-columns: 1fr; }
  .survey-metric-list { grid-template-columns: 1fr; }
  .survey-source-item { grid-template-columns: 1fr; }
  .fimi-stats { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .subindex-grid { grid-template-columns: 1fr 1fr; }
  .topbar { padding-left: 20px; padding-right: 20px; }
  .country-tabs { flex-wrap: nowrap; }
  .btn-sections,
  .period-dropdown,
  .btn-export {
    font-size: 12.5px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .donut-wrap {
    flex-direction: column;
    align-items: center;
  }
  .donut-legend { width: 100%; }
  .donut-legend-target { display: none; }
  .evidence-panel {
    padding: 20px;
    max-height: 86vh;
    overflow: auto;
  }
  .evidence-grid { grid-template-columns: 1fr; }
  .evidence-actions { flex-direction: column; }
  .evidence-actions button { width: 100%; }
}

/* ── Sources Registry v2 ── */
.sources-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.sources-filter, .sources-country-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.src-filter-btn { padding: 5px 11px; font-size: 12px; font-weight: 500; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text-mid); cursor: pointer; transition: all 120ms; white-space: nowrap; }
.src-filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.src-filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sources-country-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; overflow-x: auto; }
.sources-country-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sources-country-title { margin: 0; font-size: 16px; font-weight: 700; }
.src-count { font-size: 12px; color: var(--text-muted); background: var(--surface-alt); padding: 3px 10px; border-radius: 20px; }

.sources-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sources-table th { text-align: left; padding: 7px 10px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--border); }
.sources-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sources-table tr:last-child td { border-bottom: none; }
.sources-table tr.src-inactive td { opacity: 0.45; }
.sources-table tr.src-row:hover td { background: var(--surface-alt); }

.src-name-link { color: var(--text); text-decoration: none; }
.src-name-link:hover { color: var(--accent); text-decoration: underline; }
.src-handle { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.src-platform-badge { font-size: 12px; color: var(--text-mid); white-space: nowrap; }
.src-reach { font-size: 12px; color: var(--text-muted); text-align: right; }
.src-delete-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; transition: color 120ms, background 120ms; }
.src-delete-btn:hover { color: #dc2626; background: #fef2f2; }

.src-add-btn { margin-top: 12px; padding: 8px 16px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1.5px dashed var(--accent); border-radius: var(--radius-sm); cursor: pointer; width: 100%; text-align: center; transition: background 120ms; }
.src-add-btn:hover { background: #dbeafe; }

/* Модал добавления */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 28px 24px; width: min(480px, 95vw); box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-title { margin: 0 0 18px; font-size: 17px; font-weight: 700; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.modal-form input, .modal-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; background: var(--surface-alt); color: var(--text); }
.modal-form input:focus, .modal-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-modal-cancel { padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; cursor: pointer; background: var(--surface); color: var(--text-mid); }
.btn-modal-ok { padding: 8px 20px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-modal-ok:hover { background: var(--accent-hover); }

@media (max-width: 760px) {
  .sources-country-block { padding: 14px; }
  .sources-table { min-width: 920px; }
  .source-affiliation { max-width: 220px; }
}

/* ══════════════════════════════════════════════════════════════
   INDEX DRAWER
   ══════════════════════════════════════════════════════════════ */

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  opacity: 0;
  transition: opacity .25s ease;
}
.drawer-overlay.open { display: block; opacity: 1; }

.index-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 420px;
  max-width: 95vw;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0,0,0,.18);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.index-drawer.open { transform: translateX(0); }

/* Header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title-block { display: flex; align-items: center; gap: 12px; }
.drawer-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.drawer-badge.mirca { background: var(--accent-youth, #7c3aed); }
.drawer-title { font-size: 15px; font-weight: 700; color: var(--text); line-height: 1.2; }
.drawer-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.drawer-close {
  width: 30px; height: 30px;
  border: none; background: var(--surface-alt);
  border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.drawer-close:hover { background: var(--border); color: var(--text); }

/* KPI hero */
.drawer-kpi {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-kpi-value {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -.02em;
}
.drawer-kpi-scale { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.drawer-kpi-ci {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 5px 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  display: inline-block;
}

/* Tabs */
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-tab {
  flex: 1;
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.drawer-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.drawer-tab:hover:not(.active) { color: var(--text); }

/* Tab content */
.drawer-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
}
.drawer-tab-content.active { display: block; }

.drawer-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

/* Subindices breakdown */
.drawer-subindices { display: flex; flex-direction: column; gap: 8px; }
.drawer-si-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px 54px;
  align-items: center;
  gap: 8px;
}
.drawer-si-badge {
  width: 24px; height: 24px;
  border-radius: 6px;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.drawer-si-name { font-size: 13px; font-weight: 500; color: var(--text); }
.drawer-si-bar-wrap {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
}
.drawer-si-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}
.drawer-si-val {
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

/* Sources list */
.drawer-sources-list { display: flex; flex-direction: column; gap: 10px; }
.drawer-source-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: start;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: 10px;
}
.drawer-source-name { font-size: 13px; font-weight: 600; color: var(--text); }
.drawer-source-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.drawer-source-n { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.drawer-source-irca { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* Methodology */
.drawer-formula {
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.6;
  color: var(--accent);
  margin-bottom: 14px;
}
.drawer-method-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
}
.drawer-method-cell {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.drawer-method-cell .mc-key {
  font-size: 18px; font-weight: 900;
  line-height: 1;
}
.drawer-method-cell .mc-label {
  font-size: 10px; color: var(--text-muted);
  margin-top: 4px;
}
.drawer-method-cell .mc-weight {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
}
.drawer-method-list {
  margin: 0; padding-left: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.drawer-method-list li { font-size: 12px; color: var(--text); line-height: 1.5; }
.drawer-note {
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-radius: 8px;
}

/* Clickable KPI values */
.kpi-value-clickable {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 4px;
  transition: opacity .15s;
}
.kpi-value-clickable:hover { opacity: .75; }

/* ══════════════════════════════════════════════════════════════
   SOURCE MINI-CARD (внутри Drawer)
   ══════════════════════════════════════════════════════════════ */

.source-card {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 95vw;
  height: 100dvh;
  background: var(--surface);
  z-index: 210;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.12);
  border-left: 1px solid var(--border);
  animation: slideInRight .22s ease;
}
@keyframes slideInRight {
  from { transform: translateX(24px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.source-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.source-card-back {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.source-card-ext {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.source-card-ext:hover { text-decoration: underline; }
.source-card-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 24px;
  min-width: 0;
}
.source-card-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.source-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.source-card-platform {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 4px;
}
.source-card-affiliation {
  display: grid;
  gap: 5px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
}
.source-card-affiliation span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.source-card-affiliation strong {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}
.source-card-affiliation small {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}
.source-card-tone-bar {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  height: 8px;
  margin-bottom: 6px;
}
.tone-seg { height: 100%; transition: width .4s ease; }
.tone-seg.pos { background: var(--pos); }
.tone-seg.neg { background: var(--neg); }
.tone-seg.neu { background: var(--border); }
.tone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
}
.tone-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}
.source-card-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 4px 0 10px;
}
.source-card-posts { display: flex; flex-direction: column; gap: 10px; }
.source-post {
  padding: 11px 13px;
  background: var(--surface-alt);
  border-radius: 10px;
  border-left: 3px solid var(--border);
}
.source-post.pos { border-left-color: var(--pos); }
.source-post.neg { border-left-color: var(--neg); }
.source-post.neutral { border-left-color: var(--border); }
.source-post-text {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
}
.source-post-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  display: flex;
  justify-content: space-between;
}
.source-post-sentiment {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}
.source-post-sentiment.pos { background: #dcfce7; color: #15803d; }
.source-post-sentiment.neg { background: #fee2e2; color: #dc2626; }
.source-post-sentiment.neutral { background: var(--surface-alt); color: var(--text-muted); }
.drawer-source-row { cursor: pointer; transition: background .15s; }
.drawer-source-row:hover { background: var(--border); }

/* ── Generation Gap — платформы ─────────────────────────────── */
.gap-platforms { display: flex; flex-direction: column; gap: 10px; }
.gap-plat-row {
  display: grid;
  grid-template-columns: 150px 1fr 54px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: 8px;
}
.gap-plat-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.gap-plat-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.gap-plat-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.gap-plat-bar { height: 100%; border-radius: 4px; min-width: 3px; }
.gap-youth-tag {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #7c3aed;
  background: #ede9fe;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 5px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════════
   EXPORT BUTTON & MENU
   ══════════════════════════════════════════════════════════════ */
.export-wrap { position: relative; }

.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn-export:hover { opacity: .88; }

.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px); right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 9999;
}
.export-menu.open { display: block; }
.export-menu-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  padding: 4px 8px 6px;
}
.export-menu button {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 8px 10px;
  background: none; border: none; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text); cursor: pointer; text-align: left;
  transition: background .12s;
}
.export-menu button:hover { background: var(--surface-alt); color: var(--accent); }
