:root {
  --bg: #0f1320;
  --card: #1a2030;
  --line: #2a3346;
  --text: #e6eaf2;
  --muted: #8a93a6;
  --accent: #3a7afe;
  --error: #ff6b6b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.muted { color: var(--muted); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}
.login { width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; }
.login p { margin: 0 0 6px; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c1018; color: var(--text); font-size: 15px;
}
input:focus { outline: none; border-color: var(--accent); }
button {
  padding: 11px 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button.link { background: none; color: var(--muted); padding: 6px 10px; font-weight: 400; }
.error {
  background: rgba(255, 107, 107, .12); border: 1px solid var(--error);
  color: var(--error); padding: 9px 12px; border-radius: 8px; font-size: 13px;
}
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { font-weight: 700; }
.spacer { flex: 1; }
.btn-refresh {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--text); text-decoration: none; font-size: 13px; white-space: nowrap;
}
.btn-refresh:hover { background: rgba(58, 122, 254, .14); border-color: var(--accent); }
.refresh-age { white-space: nowrap; }
.grid {
  display: grid; gap: 18px; padding: 28px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); max-width: 1100px; margin: 0 auto;
}
.grid-section {
  grid-column: 1 / -1; margin: 12px 0 0; padding-top: 20px; border-top: 1px solid var(--line);
  font-size: 18px; color: var(--muted);
}
.module { position: relative; text-decoration: none; color: var(--text); }
.module h2 { margin: 0 0 8px; font-size: 17px; }
.module p { margin: 0; font-size: 13px; }
.module.disabled { opacity: .6; pointer-events: none; }
.badge {
  position: absolute; top: 16px; right: 16px; font-size: 11px;
  background: var(--line); color: var(--muted); padding: 3px 8px; border-radius: 20px;
}
.badge-on { background: rgba(58, 122, 254, .18); color: #9cc0ff; }
a.brand { text-decoration: none; color: var(--text); }

/* Контент-страницы (список, карточка) */
.content { max-width: 1100px; margin: 0 auto; padding: 24px; }
.content h2 { font-size: 16px; margin: 22px 0 10px; }
.muted-h { color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.search {
  flex: 1; max-width: 360px; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #0c1018; color: var(--text);
}
.nowrap { white-space: nowrap; }
.range-input { min-width: 320px; cursor: pointer; }
.small { font-size: 12px; }

/* Таблица */
.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.grid-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.grid-table tr.row { cursor: pointer; }
.grid-table tr.row:hover { background: rgba(58, 122, 254, .08); }
.grid-table.compact td { padding: 5px 10px; }

/* Карточка события */
.event { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-top: 12px; }
.event h1 { font-size: 22px; margin: 10px 0 6px; }
.event h3 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); }
.event-media { position: relative; }
.event .logo { max-height: 120px; border-radius: 10px; }
.preview { color: #c7cedd; margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { background: var(--line); color: #c7cedd; font-size: 12px; padding: 4px 10px; border-radius: 20px; }
.chip-alt { background: rgba(58, 122, 254, .16); color: #9cc0ff; }
.props { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; margin: 12px 0; font-size: 14px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
.description { white-space: pre-wrap; line-height: 1.5; color: #d7ddea; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.photos img { width: 100%; height: auto; display: block; border-radius: 12px; border: 1px solid var(--line); cursor: zoom-in; }

/* Кнопки действий */
.btn {
  display: inline-block; text-decoration: none; padding: 9px 16px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; border: 0; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; filter: none; }
.card-actions { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; }
.btn-edit {
  text-decoration: none; font-size: 13px; color: #9cc0ff;
  background: rgba(58, 122, 254, .14); padding: 4px 10px; border-radius: 6px; white-space: nowrap;
}
.btn-edit:hover { background: rgba(58, 122, 254, .28); }
.btn-edit.disabled { color: var(--muted); background: var(--line); cursor: not-allowed; }

/* Форма редактирования */
.eform { display: flex; flex-direction: column; gap: 14px; max-width: 760px; margin-top: 8px; }
.eform label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.eform input, .eform textarea, .eform select {
  padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: #0c1018; color: var(--text); font-size: 14px; font-family: inherit;
}
.eform input:focus, .eform textarea:focus, .eform select:focus { outline: none; border-color: var(--accent); }
.eform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.eform .checkbox { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.eform .checkbox input { width: auto; }
.ro-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--text); }
.ro-block legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
.ro-row { font-size: 14px; padding: 2px 0; }
.form-actions { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.notice { background: rgba(58, 122, 254, .12); border: 1px solid var(--accent); color: #cfe0ff; padding: 12px 14px; border-radius: 8px; }
@media (max-width: 640px) { .eform .row2 { grid-template-columns: 1fr; } }

/* Проверка спек — сетка карточек 3-в-ряд */
.spec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 12px; }
.spec-card { margin-top: 0; padding: 16px; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.spec-img { width: 100%; max-height: 160px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.spec-name { font-size: 16px; margin: 12px 0 6px; color: var(--text); }
.spec-card .preview { font-size: 13px; }
.spec-props { grid-template-columns: 90px 1fr; gap: 4px 12px; font-size: 13px; margin: 8px 0; }
.spec-desc-title { font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.spec-desc { font-size: 13px; max-height: 220px; overflow-y: auto; padding-right: 6px; }
.spec-card .card-actions { margin-top: auto; padding-top: 10px; }
@media (max-width: 1000px) { .spec-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .spec-grid { grid-template-columns: minmax(0, 1fr); } }

/* Модалка инлайн-редактирования */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-body .eform { max-width: 100%; }

/* Адаптивная лента — вид Telegram (телефонная колонка на фоне чата ТГ) */
.tg-page {
  margin-top: 14px;
  padding: 22px 10px;
  border-radius: 14px;
  background: transparent;  /* без обоев — мешали и перебивали кнопки */
}
.tg-feed { max-width: 400px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.tg-item { display: flex; flex-direction: column; gap: 6px; }
.tg-post {
  background: #17212b; border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.tg-photos { display: flex; flex-direction: column; }
.tg-photos a, .tg-photos img { display: block; width: 100%; }
.tg-photos img { max-height: 520px; object-fit: cover; }
.tg-text {
  padding: 10px 12px 12px; color: #e9eef3;
  white-space: pre-wrap; line-height: 1.45; font-size: 14px;
}
.tg-meta { margin-top: 8px; font-size: 11px; color: #6d7f8f; }
.tg-empty { color: #8a93a6; font-size: 13px; }
.tg-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 2px; }
.tg-actions details { width: 100%; }
.tg-actions .eform { max-width: 100%; }
@media (max-width: 430px) { .tg-feed { max-width: 100%; } }

/* Подсветка проблемной конверсии в воронке рефералов */
td.warn { color: #c0392b; font-weight: 600; }

/* Борд «Инвестор»: Executive-сводка, зоны a16z, недельные кривые */
.inv-disclaimer {
  background: rgba(245, 158, 11, .12); border: 1px solid #b45309; color: #fcd34d;
  padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 4px 0 18px;
}
.kpi-grid {
  display: grid; gap: 14px; margin: 6px 0 8px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: 12px; padding: 16px 18px;
}
.kpi .kpi-val { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .kpi-lbl { font-size: 13px; color: var(--muted); margin-top: 6px; }
.kpi .kpi-def { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.35; }
.kpi .kpi-zone { font-size: 11px; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.kpi.zone-great { border-left-color: #16a34a; }
.kpi.zone-good { border-left-color: #4ade80; }
.kpi.zone-ok { border-left-color: #f59e0b; }
.kpi.zone-red { border-left-color: var(--error); }
.kpi.zone-na, .kpi.pending { border-left-color: var(--line); opacity: .8; }
.kpi-zone.zone-great { background: rgba(22, 163, 74, .2); color: #4ade80; }
.kpi-zone.zone-good { background: rgba(74, 222, 128, .16); color: #86efac; }
.kpi-zone.zone-ok { background: rgba(245, 158, 11, .18); color: #fcd34d; }
.kpi-zone.zone-red { background: rgba(255, 107, 107, .16); color: var(--error); }
.kpi-zone.zone-na { background: var(--line); color: var(--muted); }
.kpi .kpi-pending { font-size: 11px; color: #fcd34d; margin-top: 8px; }
.weeks { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.week-cell {
  flex: 1; min-width: 120px; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; text-align: center;
}
.week-cell .wk { font-size: 12px; color: var(--muted); }
.week-cell .wv { font-size: 22px; font-weight: 700; margin-top: 4px; }
.week-cell.zone-great { border-color: #16a34a; }
.week-cell.zone-good { border-color: #4ade80; }
.week-cell.zone-ok { border-color: #f59e0b; }
.week-cell.zone-red { border-color: var(--error); }

/* Глоссарий: кликабельные термины + модалка с пояснением «что это и зачем». */
.gloss { cursor: help; border-bottom: 1px dashed var(--muted); }
.gloss:hover { color: var(--accent); border-bottom-color: var(--accent); }
th .gloss { border-bottom-color: var(--line); white-space: nowrap; }
.gmodal-back {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  background: rgba(0, 0, 0, .55); display: none; align-items: center; justify-content: center;
}
.gmodal-back.open { display: flex; }
.gmodal {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  max-width: 460px; width: 100%; padding: 22px 24px;
}
.gmodal h3 { margin: 0 0 10px; font-size: 17px; }
.gmodal p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--text); }
.gmodal-close {
  float: right; background: none; border: 0; padding: 0;
  cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1;
}
.gmodal-close:hover { color: var(--text); }
.hint { font-size: 12px; }

/* Инфографика статистики интересов */
.viz { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 14px 0; }
.viz h3 { margin: 0 0 10px; font-size: 15px; }
.viz-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.viz-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; }
.i-int { background: #2ecc71; } .i-ni { background: var(--error); } .i-gray { background: #3a4256; }
.viz-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.viz-row .nm { width: 200px; flex: none; font-size: 13px; text-align: right; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-bar { flex: 1; display: flex; height: 18px; border-radius: 5px; overflow: hidden; background: #11151f; min-width: 60px; }
.viz-bar > span { height: 100%; transition: width .2s; display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 13px; line-height: 1; font-weight: 700; white-space: nowrap; }
.viz-bar .s-int { background: #2ecc71; color: #06341a; }
.viz-bar .s-gray { background: #3a4256; color: #eef1f7; }
.viz-bar .s-ni { background: var(--error); color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.viz-num { width: 118px; flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
.viz-num b { color: #2ecc71; } .viz-num em { color: var(--error); font-style: normal; }
.hist { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 18px 4px 0; overflow-x: auto; }
.hist-col { flex: 1 0 26px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hist-pair { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.hist-pair span { width: 9px; border-radius: 3px 3px 0 0; min-height: 1px; }
.hist-pair .h-th { background: var(--accent); } .hist-pair .h-fm { background: #a855f7; }
.hist-x { font-size: 10px; color: var(--muted); white-space: nowrap; }
.viz-switch { display: inline-flex; gap: 4px; align-items: center; }
.viz-switch button { background: #11151f; color: var(--muted); border: 1px solid var(--line);
  padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 6px; }
.viz-switch button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.viz-legend .sort-btn { display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: #11151f; color: var(--muted); border: 1px solid var(--line);
  padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 6px; }
.viz-legend .sort-btn i { margin: 0; }
.viz-legend .sort-btn.active { color: var(--text); border-color: var(--accent); background: #1a2233; }
.basis-radio { display: inline-flex; margin-left: 12px; vertical-align: middle; font-size: 13px; font-weight: 400;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.basis-radio label { padding: 6px 14px; color: var(--muted); cursor: pointer; background: #11151f; }
.basis-radio label + label { border-left: 1px solid var(--line); }
.basis-radio input { display: none; }
.basis-radio label:has(input:checked) { background: var(--accent); color: #fff; }
.donut-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.donut-item { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 96px; }
.donut { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; position: relative; }
.donut::after { content: ""; position: absolute; inset: 15px; border-radius: 50%; background: var(--card); }
.donut em { position: relative; z-index: 1; font-size: 10px; font-style: normal; color: var(--text); }
.donut-lbl { font-size: 11px; color: var(--muted); text-align: center; max-width: 96px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz.two-col { display: flex; gap: 28px; flex-wrap: wrap; }
.viz.two-col > div { flex: 1; min-width: 260px; }
table.heat { border-collapse: collapse; font-size: 12px; }
table.heat th { color: var(--muted); font-weight: 500; padding: 4px 8px; text-align: center; }
table.heat td { width: 46px; height: 34px; text-align: center; color: var(--text);
  border: 1px solid var(--bg); border-radius: 3px; }

/* Схема на неделю (дайджесты) + обратная связь */
table.digest-schedule, table.digest-preview, table.digest-feedback { border-collapse: collapse;
  width: 100%; font-size: 13px; margin: 8px 0 20px; }
table.digest-schedule th, table.digest-preview th, table.digest-feedback th { text-align: left;
  color: var(--muted); font-weight: 500; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.digest-schedule td, table.digest-preview td, table.digest-feedback td { padding: 6px 10px;
  vertical-align: top; border-bottom: 1px solid var(--bg); }
table.digest-preview td { width: 25%; }
.digest-list { margin: 0; padding-left: 16px; }
.digest-list li { margin: 0 0 6px; }
.nowrap { white-space: nowrap; }

/* Аналитика ленты */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 6px; }
.kpi { flex: 1; min-width: 120px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 22px; color: var(--text); }
.kpi span { font-size: 11px; color: var(--muted); }
.colchart { display: flex; align-items: flex-end; gap: 3px; height: 140px; overflow-x: auto;
  border-bottom: 1px solid var(--line); padding: 4px 0; }
.colchart .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-width: 16px; height: 100%; }
.col-bar { width: 12px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.col-lbl { font-size: 9px; color: var(--muted); margin-top: 3px; white-space: nowrap;
  transform: rotate(-60deg); transform-origin: top left; height: 20px; }
.heat-scroll { overflow-x: auto; }
table.heat.heat-sm td { width: 20px; height: 20px; border: 1px solid var(--bg); }
table.heat.heat-sm th { padding: 2px 4px; font-size: 10px; }

/* Когортный ретеншн */
table.cohort { border-collapse: collapse; font-size: 12px; }
table.cohort th { color: var(--muted); font-weight: 500; padding: 4px 8px; text-align: center; }
table.cohort td { width: 42px; height: 26px; text-align: center; color: var(--text);
  border: 1px solid var(--bg); }

/* Кнопки-фильтры и панель периода — общий стандарт блоков (эталон — /statistics/traffic).
   Вторичные кнопки (Сброс, пресеты, тумблеры) + «нажатое» состояние активного пресета. */
.btn-soft { background: transparent; border: 1px solid #2a2a2a; color: inherit }
.btn-soft:hover { border-color: #2ea043 }
.btn-soft.active { background: rgba(46,160,67,.85); border-color: transparent; color: #fff }
/* Подсветка поля периода, когда выбран не-дефолтный диапазон. */
#range.sel { border-color: #2ea043; box-shadow: 0 0 0 2px rgba(46,160,67,.35) }
.range-badge { color: #2ea043; font-weight: 600 }

/* Сегмент-тумблер когорты «С 1 июля 2026 / Все» — общий стандарт блоков (эталон — /dashboard).
   Ставится сразу под заголовком страницы, НАД контентом. Кнопки — ТОЛЬКО <button>: у <a>
   браузер рисует другой шрифт и метрики, один-в-один не выйдет. */
.seg { display:inline-flex; background:#141414; border:1px solid #2a2a2a; border-radius:11px; padding:3px; gap:3px; margin:14px 0 4px }
.seg-b { border:0; background:transparent; color:#9a9a9a; font-size:13px; padding:7px 15px; border-radius:8px; cursor:pointer }
.seg-b.active { background:#2b3a4a; color:#eaf3fb }
