:root {
  /* тёмная тема (по умолчанию) */
  --bg: #0e1117;
  --bg2: #161b24;
  --card: #1a2130;
  --line: #263042;
  --text: #e8ecf4;
  --muted: #8b96ab;
  --accent: #b85c49;
  --accent2: #3fa7ff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #c47d74;
  --ar: #3fa7ff;
  --co: #f2b338;
  /* сайдбар тёмный в обеих темах (стиль Pult) */
  --side-bg: #161b24;
  --side-card: #1a2130;
  --side-line: #263042;
  --side-text: #e8ecf4;
  --side-muted: #8b96ab;
}
body.light {
  /* светлая рабочая область в стиле Pult: белые карточки, тонкие линии */
  --bg: #f1f4f8;
  --bg2: #ffffff;
  --card: #ffffff;
  --line: #dde4ee;
  --text: #1d2634;
  --muted: #5d6d84;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }

.login-screen {
  /* было тёплое тёмное пятно-градиент — в светлой теме превращалось в грязное бурое пятно
     на белом фоне (градиент был на фиксированный тёмный цвет, не завязан на тему). Плоский
     фон по теме — надёжно в обоих режимах. */
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 320px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px 28px; display: flex; flex-direction: column; gap: 12px;
}
.login-sub { color: var(--muted); font-size: 12px; margin: -6px 0 10px; }
.login-card input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.login-card button {
  background: var(--accent); border: 0; color: #fff; padding: 10px;
  border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.login-error { color: var(--bad); font-size: 12px; min-height: 16px; }

.logo { font-size: 22px; font-weight: 800; letter-spacing: -0.5px;
  font-style: italic; text-transform: uppercase; color: #f2b338; }
.logo span { color: var(--text); }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; background: var(--side-bg); border-right: 1px solid var(--side-line);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo span { color: var(--side-text); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; min-height: 0; }
.sidebar nav a {
  color: var(--side-muted); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-weight: 500;
}
.sidebar nav a:hover { color: var(--side-text); background: var(--side-card); }
.sidebar nav a.active { color: var(--side-text); background: var(--side-card); border-left: 3px solid var(--accent); }
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; }
.who { color: var(--side-muted); font-size: 12px; }
.ghost {
  background: transparent; border: 1px solid var(--side-line); color: var(--side-muted);
  border-radius: 8px; padding: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
/* обводка фокуса — своя и одинаковая в обеих темах (браузерная в тёмной схеме белёсая,
   в светлой синяя — «кнопки меняются»; фиксируем вид светлой версии, решение 26.08) */
.ghost:focus, .side-toggle:focus, .chip:focus, button.action:focus {
  outline: 2px solid var(--accent2); outline-offset: 1px;
}
.delta { font-size: 11px; font-weight: 700; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.kpi .spark { margin-top: 6px; width: 100%; height: 26px; }
.kpi .spark polyline { fill: none; stroke: var(--accent2); stroke-width: 1.6; }
.kpi .spark polygon { fill: rgba(63,167,255,.12); stroke: none; }
.kpi-row.secondary .kpi { padding: 10px 14px; }
.kpi-row.secondary .v { font-size: 16px; }

.content { flex: 1; padding: 22px 28px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.topbar h1 { font-size: 20px; }
/* wrap обязателен: без него ряд чипов периода вылезал за экран телефона и тянул горизонтальный скролл */
.period { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); }
.period input[type=date] {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 8px; font-size: 12px;
}
.chip {
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 12px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* flex вместо grid: карточки растягиваются, последний ряд заполняет всю ширину — без «одиноких» карточек с дырами */
.kpi-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.kpi-row .kpi { flex: 1 1 170px; min-width: 0; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .s { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Сетка карточек. База — телефон/узкий экран: одна колонка (min() вместо голых 350px,
   иначе на 375px вылезал горизонтальный скролл). Дальше число колонок задано ЯВНО по
   брейкпоинтам (700 → 2, 1500 → 3): при auto-fit колонок нельзя предсказать, а нам нужно
   знать их количество, чтобы дотягивать «одинокую» последнюю карточку и не оставлять дыру. */
.grid2 {
  display: grid; gap: 14px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(min(350px, 100%), 1fr));
}
/* 2 колонки: последняя карточка нечётная (3-я из 3, 5-я из 5) → на всю строку */
@media (min-width: 700px) and (max-width: 1499px) {
  .grid2 { grid-template-columns: repeat(2, 1fr); }
  .grid2 > .card:nth-child(odd):last-child { grid-column: 1 / -1; }
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
/* без min-width:0 широкая таблица внутри карточки распирает свою колонку grid и колонки
   расходятся по ширине; так колонки равные, а таблица скроллится внутри .table-scroll */
.grid2 > .card { min-width: 0; }
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.4px; }
.card .chart-wrap { position: relative; height: 260px; }
.card .chart-wrap.tall { height: 380px; } /* LTV-кривые: нужен запас по высоте */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 7px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; position: sticky; top: 0; background: var(--card); }
th:first-child, td:first-child { text-align: left; }
/* итоговая строка («Итого» в «Статистике»): не липнет к верху, в отличие от шапки */
tfoot th { position: static; color: var(--text); font-size: 12px; text-transform: none;
           border-top: 1px solid var(--line); }
tr:hover td { background: rgba(255,255,255,0.02); }
/* Прокрутка таблицы внутри карточки + ЛИПКИЕ шапка и первая колонка (просьба CBO 23.09):
   на широкой таблице «Потоков» при листании уезжали и заголовки, и название потока — непонятно,
   где что. max-height делает контейнер собственным скроллом, иначе sticky не за что цепляться.
   Шапка липнет ВЕЗДЕ (th уже sticky top:0), первая колонка — только у широких таблиц с классом
   .sticky-col: на узких вертикальная линия слева выглядела бы мусором. */
.table-scroll { overflow: auto; max-height: 78vh; }
thead th { z-index: 2; }

table.sticky-col th:first-child,
table.sticky-col td:first-child {
  position: sticky; left: 0; z-index: 1;
  background-color: var(--card);          /* непрозрачный фон: иначе под колонкой просвечивают ячейки */
  box-shadow: 1px 0 0 var(--line);        /* граница — видно, что колонка закреплена */
}
table.sticky-col thead th:first-child { z-index: 3; }   /* угол поверх и шапки, и колонки */
/* оттенки строк поверх непрозрачного фона липкой ячейки — иначе она выпадает из полосатости */
table.sticky-col tr.flow-child td:first-child {
  background-image: linear-gradient(rgba(127,127,127,.05), rgba(127,127,127,.05)); }
table.sticky-col tr.flow-parent.expandable:hover td:first-child {
  background-image: linear-gradient(rgba(127,127,127,.06), rgba(127,127,127,.06)); }
table.sticky-col tr.row-total td:first-child {
  background-image: linear-gradient(rgba(127,127,127,.07), rgba(127,127,127,.07)); }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.good { background: rgba(52,211,153,.14); color: var(--ok); }
.badge.work { background: rgba(63,167,255,.14); color: var(--accent2); }
.badge.weak { background: rgba(248,113,113,.14); color: var(--bad); }
.badge.na { background: rgba(139,150,171,.14); color: var(--muted); }
/* «Действие» на «Потоках»: зелёный — расти, синий — не трогать, жёлтый — чинить, красный — резать */
.badge.act-scale { background: rgba(52,211,153,.14); color: var(--ok); }
.badge.act-keep { background: rgba(63,167,255,.14); color: var(--accent2); }
.badge.act-cut { background: rgba(242,179,56,.16); color: var(--warn); }
.badge.act-stop { background: rgba(248,113,113,.14); color: var(--bad); }
.badge.act-fix { background: rgba(139,123,255,.18); color: #a99bff; }
.badge.act-wait { background: rgba(139,150,171,.14); color: var(--muted); }
.geo-ar { color: var(--ar); font-weight: 700; }
.geo-co { color: var(--co); font-weight: 700; }

.note { color: var(--muted); font-size: 12px; margin: 8px 0 14px; }
.freshness { color: var(--muted); font-size: 11px; margin-top: 26px; border-top: 1px solid var(--line); padding-top: 10px; }
.controls { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.controls input[type=text] {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 12px; min-width: 260px;
}
button.action {
  background: var(--accent); border: 0; color: #fff; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-weight: 600;
}
pre.log { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px; white-space: pre-wrap; color: var(--muted); }
.select {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; max-width: 240px;
}
.scope-bar { align-items: center; }
/* мульти-выбор байеров/партнёров на Главной (Инхаус/Партнёры): кнопка + выпадающая панель с чекбоксами */
.multiselect { position: relative; }
.multiselect-btn { display: inline-flex; align-items: center; gap: 4px; }
.multiselect-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 200px; max-height: 260px;
  overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 2px;
}
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.ms-opt:hover { background: var(--bg2); }
.ms-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.seg-card.seg-a { border-top: 3px solid var(--accent); }
.seg-card.seg-b { border-top: 3px solid var(--accent2); }
.seg-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-period-presets .chip-sm { padding: 4px 10px; font-size: 11px; }
/* периоды A/B не совпадают — предупреждение, чтобы цифры в таблице не приняли за один и тот же срез */
.note.period-mismatch { color: var(--warn); font-weight: 600; }
.note.period-mismatch-len { color: var(--bad); }
.cmp-table td.cmp-win { color: var(--ok); font-weight: 700; }
.cmp-table td:first-child { color: var(--muted); }
.ai-answer { line-height: 1.6; margin: 6px 0 10px; }
/* свёрнутая карточка истории AI: строка «вопрос · время», раскрытие стрелочкой браузера */
details.ai-hist { padding: 10px 16px; }
details.ai-hist summary {
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  list-style-position: inside;
}
details.ai-hist .ai-hist-q { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.ai-hist[open] .ai-hist-q { white-space: normal; }
details.ai-hist .ai-hist-body { margin-top: 8px; }
details.ai-hist .ai-hist-body h3 { display: none; } /* вопрос уже в summary */
.ai-answer table { margin: 10px 0; }
details summary { cursor: pointer; }

/* ---------- плавающая кнопка «Спросить AI» + выезжающая панель ---------- */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  background: var(--accent); border: 0; color: #fff; border-radius: 999px;
  padding: 12px 20px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.ai-fab:hover { filter: brightness(1.08); }
.ai-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100%; z-index: 50;
  background: var(--bg2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px;
  transform: translateX(102%); transition: transform .22s ease; box-shadow: -8px 0 24px rgba(0,0,0,.28);
}
.ai-drawer.open { transform: none; }
.ai-drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ai-drawer-head h2 { font-size: 16px; }
.ai-drawer-body { overflow-y: auto; flex: 1; }
.ai-drawer .controls input[type=text] { min-width: 0; flex: 1; }
.ai-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45; }
@media (max-width: 760px) {
  .ai-drawer { width: 100%; border-left: 0; }
  .ai-fab { right: 14px; bottom: 14px; padding: 10px 16px; }
}

/* широкие экраны: максимум 3 графика в ряд (6 графиков = 3+3), сами графики выше.
   Хвост неполной строки растягиваем: 1 карточка (4-я из 4) — на всю ширину, 2 — на две колонки. */
@media (min-width: 1500px) {
  .grid2 { grid-template-columns: repeat(3, 1fr); }
  .grid2 > .card:nth-child(3n+1):last-child { grid-column: 1 / -1; }
  .grid2 > .card:nth-child(3n+2):last-child { grid-column: span 2; }
  .card .chart-wrap { height: 300px; }
  .card .chart-wrap.tall { height: 440px; }
}

/* выпадающий список периода — виден только на мобильном (см. медиа-запрос ниже) */
.period-select-mobile { display: none; }

/* планшет/мобила: сайдбар становится верхней панелью */
@media (max-width: 820px) {
  /* полное меню с текстом и раскрывающимися группами не помещается по ширине и наезжает
     на контент — на мобильном сайдбар всегда в «свёрнутом» виде: узкая колонка иконок слева
     (тот же набор, что и при ручном сворачивании на десктопе), контент — справа от неё,
     заголовок страницы и фильтры периода остаются как есть сверху контента */
  .sidebar {
    width: 52px; flex-shrink: 0; padding: 12px 6px; gap: 10px;
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar .logo, .sidebar #nav, #side-collapse, .side-expand { display: none; }
  #nav-mini { display: flex !important; flex: 1; overflow-y: auto; }
  .sidebar-footer { flex-direction: column; gap: 6px; }
  .sidebar-footer .foot-row { flex-direction: column; }
  .sidebar-footer .who { display: none; }
  .sidebar-footer .btn-label { display: none; }
  .content { padding: 14px 12px; }
  .topbar h1 { font-size: 17px; }
  .card .chart-wrap { height: 210px; }
  .kpi .v { font-size: 18px; }
  /* мелкий служебный текст снизу десктопных страниц — на мобильном шумит больше, чем помогает */
  .freshness { display: none; }
  /* длинные пояснительные заметки (методология, свежесть, «как считается») — только десктоп;
     на мобильном загромождают экран, их роль по сути справочная, не критичная для работы */
  .note-long { display: none; }
  /* период в одну строку: вместо пяти чипов — один выпадающий список + компактные даты */
  .period { flex-wrap: nowrap; gap: 6px; width: 100%; }
  .period .chip[data-days] { display: none; }
  .period-select-mobile { display: block; flex: 1 1 auto; min-width: 0; }
  .period input[type=date] { flex: 1 1 auto; min-width: 0; padding: 6px 4px; font-size: 11px; }
}

/* воронка привлечения на главной: шаги слева направо, конверсия под цифрой */
.funnel-card { margin-bottom: 18px; }
.funnel-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0 2px; }
.fstep { min-width: 110px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; }
.fstep .fv { font-size: 20px; font-weight: 700; }
.fstep .fl { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.fstep .fc { color: var(--accent2); font-size: 12px; font-weight: 600; margin-top: 2px; }
.farrow { color: var(--muted); font-size: 18px; }

/* когортный треугольник: компактные ячейки, подписи недель слева */
.cohort-table td, .cohort-table th { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
.cohort-table td:empty { background: transparent; }

/* группированное меню: заголовки-разворачивашки, подпункты с отступом */
.sidebar .logo { text-align: center; }
.nav-group-title {
  color: var(--side-muted); font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; padding: 12px 12px 4px; cursor: pointer;
  display: flex; justify-content: space-between; user-select: none;
}
.nav-group-title:hover { color: var(--side-text); }
.tri { width: 14px; height: 14px; flex-shrink: 0; transition: transform .15s ease; }
.nav-group.open .tri { transform: rotate(90deg); }
.nav-group .nav-sub { display: none; flex-direction: column; gap: 2px; }
.nav-group.open .nav-sub { display: flex; }
/* группа явно свёрнута кликом, но в ней активная страница — сама страница остаётся видна одной
   строкой под заголовком (не весь список, не пусто); стрелка при этом остаётся «свёрнутой» */
.nav-group.collapsed-active .nav-sub { display: flex; }
.nav-group .nav-sub a { padding-left: 20px; font-size: 13.5px; }
.sidebar nav a.ai-link { color: var(--accent2); font-weight: 600; }
.sidebar nav a.ai-link:hover { color: var(--accent2); }

/* сворачивание сайдбара */
.side-toggle {
  background: transparent; border: 1px solid var(--side-line); color: var(--side-muted);
  border-radius: 8px; width: 26px; height: 26px; cursor: pointer; line-height: 1;
}
/* стрелочка выше линии логотипа, логотип чуть ниже — их горизонтальные полосы не пересекаются */
#side-collapse { position: absolute; top: 6px; right: 10px; }
.sidebar .logo { margin-top: 14px; }
.sidebar { position: sticky; }
.app.side-collapsed .sidebar { width: 46px; padding: 14px 6px; }
.app.side-collapsed .sidebar .logo, .app.side-collapsed .sidebar #nav,
.app.side-collapsed #side-collapse { display: none; }
/* подвал в свёрнутом виде НЕ прячем (запрос 28.08: кнопки темы/SYNC/EXIT «исчезали») —
   выстраиваем те же кнопки столбиком маленьких иконок, без подписей и без имени пользователя */
.app.side-collapsed .sidebar-footer { padding: 0; }
.app.side-collapsed .sidebar-footer .foot-row { flex-direction: column; gap: 4px; }
.app.side-collapsed .sidebar-footer .btn-label,
.app.side-collapsed .sidebar-footer #who { display: none; }
.app.side-collapsed .sidebar-footer .ghost {
  width: 34px; height: 34px; padding: 0; justify-content: center; margin: 0 auto 4px;
}
.side-expand { position: fixed; top: 14px; left: 10px; z-index: 60; background: var(--side-card); color: var(--side-muted); border-color: var(--side-line); }

/* столбик иконок при свёрнутом сайдбаре — та же навигация, без подписей и группировки.
   margin-top отодвигает первую иконку («Главная») ниже стрелочки-разворота (она position:fixed
   поверх сайдбара) — без отступа стрелка перекрывала иконку. */
#nav-mini { display: none; flex-direction: column; gap: 4px; }
.app.side-collapsed #nav-mini { display: flex; margin-top: 34px; }
#nav-mini a {
  display: flex; align-items: center; justify-content: center; height: 34px; border-radius: 8px;
  color: var(--side-muted); text-decoration: none;
}
#nav-mini a:hover { color: var(--side-text); background: var(--side-card); }
#nav-mini a.active { color: var(--side-text); background: var(--side-card); }
#nav-mini a.ai-link { color: var(--accent2); }

/* иконки в развёрнутом меню — рядом с подписью */
.sidebar nav a { display: flex; align-items: center; gap: 10px; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* подвал сайдбара: тема-иконка, синк, выход в один ряд — единый размер шрифта/иконок на все три
   кнопки, не зависит от темы (светлая/тёмная меняют только цвет, не размер), ~30% меньше прежнего */
.foot-row { display: flex; gap: 6px; }
.foot-row .ghost { flex: 1 1 0; min-width: 0; padding: 5px; font-size: 10px; font-weight: 600; letter-spacing: .2px; }
.foot-row .ghost .nav-icon { width: 11px; height: 11px; }
/* ☾/☀ — разной ширины глифы в одном и том же шрифте: без фикс-ширины кнопка «дышит» при
   переключении темы и отжимает соседнюю SYNC. Фиксированная ширина+центрирование — глиф всегда
   в одной точке, размер кнопки не меняется от того, какой символ внутри. */
.foot-row #theme-toggle {
  flex: 0 0 34px; width: 34px; color: var(--warn);
  display: inline-flex; align-items: center; justify-content: center;
}
.sync-btn { color: var(--warn); border-color: var(--warn); }
.sync-btn .nav-icon { color: var(--warn); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }

.sidebar-footer .who { text-align: center; }

/* «Сравнение»: карточки сегментов A и B всегда одинаковые (без растягивания последней) */
.grid2.equal2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid2.equal2 > .card { grid-column: auto !important; }
@media (max-width: 700px) { .grid2.equal2 { grid-template-columns: 1fr !important; } }
/* EXIT — та же кнопка, что SYNC/тема: одинаковый размер шрифта и иконки (решение 26.08,
   отменяет более ранний «покрупнее» — теперь единообразие важнее) */
.sidebar-footer #logout { padding: 5px; font-size: 10px; font-weight: 600; letter-spacing: .2px; }
.sidebar-footer #logout .nav-icon { width: 11px; height: 11px; }

/* активные GEO-чипы светятся цветом рынка (AR — голубой, CO — жёлтый), на всех страницах */
.chip.active[data-main-geo="AR"], .chip.active[data-stat-geo="AR"],
.chip.active[data-games-geo="AR"], .chip.active[data-coh-geo="AR"] {
  background: var(--ar); border-color: var(--ar); color: #fff;
}
.chip.active[data-main-geo="CO"], .chip.active[data-stat-geo="CO"],
.chip.active[data-games-geo="CO"], .chip.active[data-coh-geo="CO"] {
  background: var(--co); border-color: var(--co); color: #1d2634;
}
/* неактивные — цветной текст-подсказка, чтобы связь с графиками читалась заранее */
.chip[data-main-geo="AR"]:not(.active), .chip[data-stat-geo="AR"]:not(.active),
.chip[data-games-geo="AR"]:not(.active), .chip[data-coh-geo="AR"]:not(.active) { color: var(--ar); }
.chip[data-main-geo="CO"]:not(.active), .chip[data-stat-geo="CO"]:not(.active),
.chip[data-games-geo="CO"]:not(.active), .chip[data-coh-geo="CO"]:not(.active) { color: var(--co); }

/* перезагрузка той же страницы: контент стоит на месте, чуть гаснет, сверху бежит полоска */
.page.reloading { opacity: .55; pointer-events: none; transition: opacity .15s; }
.page.reloading::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 70;
  background: linear-gradient(90deg, transparent 0%, var(--accent2) 50%, transparent 100%);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: loadbar 1s linear infinite;
}
@keyframes loadbar { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* скелет при переходе между страницами: пульсирующие заглушки на месте будущих карточек */
.skel { position: relative; overflow: hidden; }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(139,150,171,.10), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* индикатор свежести под заголовком страницы */
.fresh-top { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.fresh-top b { color: var(--text); font-weight: 600; }
.fresh-top .stale { color: var(--bad); }

/* логин-экран: крупный центрованный логотип, всё капсом, без подписи */
.login-logo { font-size: 34px; text-align: center; margin-bottom: 14px; }
.login-card input::placeholder { text-transform: uppercase; letter-spacing: .5px; font-size: 12px; }
.login-card button { text-transform: uppercase; letter-spacing: .6px; }

/* универсальные GEO-чипы (data-geo-chip) — те же цвета рынков */
.chip.active[data-geo-chip="AR"] { background: var(--ar); border-color: var(--ar); color: #fff; }
.chip.active[data-geo-chip="CO"] { background: var(--co); border-color: var(--co); color: #1d2634; }
.chip[data-geo-chip="AR"]:not(.active) { color: var(--ar); }
.chip[data-geo-chip="CO"]:not(.active) { color: var(--co); }

/* AI-чат: действия под ответом (эскалация на другую модель) */
.ai-actions { margin: 6px 0; }
.ai-actions .ai-escalate { font-size: 12px; padding: 5px 10px; }
.ai-actions .ai-escalate:disabled { opacity: .7; cursor: default; }

/* глушим все анимации, пока приложение инициализируется (F5-фикс: сайдбар/меню не «ездят»
   при перезагрузке — стартовое состояние из localStorage применяется мгновенно) */
body.no-anim *, body.no-anim *::before, body.no-anim *::after {
  transition: none !important;
  animation: none !important;
}

/* картинка-слепок графика в восстановленном виде страницы (см. saveSnap в app.js) */
.chart-wrap .snap-img { width: 100%; height: 100%; object-fit: contain; }

/* разворот потоков на «Потоках»: строка-родитель кликабельна, дочерние строки приглушены */
tr.flow-parent.expandable { cursor: pointer; }
tr.flow-parent.expandable:hover { background: var(--card2, rgba(127,127,127,.06)); }
tr.flow-parent .tw { color: var(--muted); font-size: 11px; }
tr.flow-child { background: rgba(127,127,127,.05); }
tr.flow-child td { font-size: 12px; }
.muted-small { color: var(--muted); font-size: 11px; }

/* экспорт таблиц + галочка-фильтр (04.09) */
.export-btns { display: inline-flex; gap: 4px; margin-left: 10px; vertical-align: middle; }
.card h3 .export-btns { float: right; margin-top: -3px; }
.ghost.xs { padding: 2px 7px; font-size: 10px; border-radius: 6px; letter-spacing: .3px; color: var(--muted); border-color: var(--line, var(--side-line)); }
.ghost.xs:hover { color: var(--text); border-color: var(--accent); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px 8px; border: 1px solid var(--line, var(--side-line)); border-radius: 999px; }
.chk input { accent-color: var(--accent); margin: 0; }
.ratio-hi { color: var(--ok); font-weight: 600; }
/* сверка чистого дохода с NGR (07.09): зелёное — расхождение в норме, красное — смотреть данные */
.note b.ok { color: var(--ok); }
.note b.bad { color: var(--bad); }

/* Справка (07.09): читаемая ширина, оглавление, списки */
.help-card { max-width: 900px; }
.help-card p { color: var(--text); font-size: 13px; line-height: 1.65; margin: 0 0 10px; }
.help-card p:last-child { margin-bottom: 0; }
.help-card h3 { margin-top: 0; }
.help-card table { font-size: 12.5px; }
.help-card td { line-height: 1.5; padding-top: 7px; padding-bottom: 7px; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; }
.help-toc a { font-size: 12px; color: var(--muted); text-decoration: none; padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px; }
.help-toc a:hover { color: var(--text); border-color: var(--accent); }
.help-list { margin: 0; padding-left: 18px; color: var(--text); font-size: 13px; line-height: 1.65; }
.help-list li { margin-bottom: 8px; }
.help-list li:last-child { margin-bottom: 0; }

/* сито риска платформы (10.09) */
.seg-high td { background: rgba(232,103,74,.14); }

/* чипы режимов сверки: процент сверху, сумма среза мелким снизу (просьба CBO 10.09 — под скрин) */
.chip-2line { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.25; padding: 5px 12px; }
.chip-2line .chip-sub { font-size: 10px; font-weight: 600; opacity: .75; }

/* итоговая строка внутри tbody (SLA выплат): та же роль, что tfoot, но строкой сверху */
tr.row-total td { font-weight: 700; border-bottom: 1px solid var(--line); }

/* Сортируемые заголовки (15.09): стрелка появляется на наведении, у активной колонки — всегда */
th.th-sort { cursor: pointer; user-select: none; }
/* стрелка видна СРАЗУ (правка CBO 16.09): иначе не понять, что колонку вообще можно сортировать */
th.th-sort::after { content: " ↕"; opacity: .4; font-size: 10px; }
th.th-sort:hover::after { opacity: .75; }
th.th-sort.sorted { color: var(--text); }
th.th-sort.sorted::after { opacity: .9; }
th.th-sort.sorted[data-dir="asc"]::after { content: " ▲"; }
th.th-sort.sorted[data-dir="desc"]::after { content: " ▼"; }

/* агрегат читается лучше, чем его крупный поток — знак рядом со статусом партнёра */
.warn-mark { color: var(--warn); cursor: help; font-size: 12px; }

/* Светофор на метриках «Потоков» (16.09): заливка мягкая, чтобы таблица читалась, а не мигала */
td.lv-good { background: rgba(52,211,153,.13); }
td.lv-ok   { background: rgba(251,191,36,.13); }
td.lv-bad  { background: rgba(196,125,116,.16); }
td.lv-na   { color: var(--muted); }
td.lv-lt   { opacity: .62; }
/* те же цвета кружками в легенде под таблицей */
.lv-chip { padding: 1px 7px; border-radius: 999px; font-size: 11px; }
.lv-chip.lv-good { background: rgba(52,211,153,.18); color: var(--ok); }
.lv-chip.lv-ok   { background: rgba(251,191,36,.18); color: var(--warn); }
.lv-chip.lv-bad  { background: rgba(196,125,116,.22); color: var(--bad); }
.lv-chip.lv-na   { background: rgba(139,150,171,.16); color: var(--muted); }

/* «Справка раздела» — длинная методология под кнопкой (16.09) */
.help-box { margin: 0 0 12px; }
.help-toggle { font-size: 12px; padding: 4px 11px; }
.help-body { margin-top: 8px; }

/* предупреждение внутри карточки: что-то ещё не согласовано и использовать нельзя */
.note.note-warn { color: var(--bad); border-left: 2px solid var(--bad); padding-left: 10px; }

/* мелкие чипы-кнопки (выгрузка сегментов): те же, что в пресетах периода, но доступны везде */
.chip-sm { padding: 4px 10px; font-size: 11px; }
a.chip { text-decoration: none; display: inline-block; }
.chip[disabled] { opacity: .45; cursor: not-allowed; }

/* свёрнутый блок: содержимое скрыто, заголовок со счётчиком остаётся */
.collapsed-hidden { display: none !important; }
.collapse-mark { color: var(--muted); font-size: 11px; }

/* выбор сегментов для выгрузки: строка = галочка, название, число игроков */
.seg-pick { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.seg-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; }
.seg-row:hover { background: rgba(127,127,127,.06); }
.seg-row .seg-name { min-width: 260px; }
.seg-row .seg-cnt { color: var(--text); font-weight: 600; min-width: 110px; }
.chip[disabled] { opacity: .45; cursor: not-allowed; }

/* «Акция против контроля» (02.10, замечание CBO «плохо читается, слова наезжают»): компактнее по
   высоте, но шрифт крупнее; длинное «как выдаётся» переносится, а не наезжает на соседей */
.effect-table td, .effect-table th { font-size: 13.5px; padding: 7px 9px; line-height: 1.3; vertical-align: middle; }
.effect-table th { white-space: nowrap; }
.effect-table td.how { white-space: normal; max-width: 280px; min-width: 200px; font-size: 12px; color: var(--muted); text-align: left; }
.effect-table .muted-small { font-size: 11.5px; }
