/* Кабинет Лидера — стили */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Тематические переменные. Дефолт = зелёный. ────────────────────────── */
/* Пастельные палитры — мягкие приглушённые тона.
   --accent держим средне-насыщенным (на нём белый текст кнопок),
   фоны/границы — нежные. */
:root {
  /* 🌿 Шалфейно-зелёный */
  --accent:        #7aa37f;
  --accent-dark:   #5f8a64;
  --accent-light:  #a6c8aa;
  --accent-soft:   #f0f6f0;
  --accent-soft2:  #e4efe5;
  --accent-border: #d3e3d5;
  --accent-text:   #4a6a4e;
  --accent-text2:  #7d9a80;
  --accent-link:   #5f9065;
  --bg-gradient:   linear-gradient(135deg, #f5f1e8 0%, #eef6ef 100%);
}
html.theme-orange {
  /* 🍑 Персиково-терракотовый */
  --accent: #d49d72; --accent-dark: #bd8456; --accent-light: #ecc6a4;
  --accent-soft: #fbf3ea; --accent-soft2: #f6e7d6; --accent-border: #edd7bf;
  --accent-text: #7a5532; --accent-text2: #ab8763; --accent-link: #c2824f;
  --bg-gradient: linear-gradient(135deg, #fbf3ea 0%, #f7ead9 100%);
}
html.theme-purple {
  /* 💜 Лавандовый */
  --accent: #a98fd0; --accent-dark: #8e74bb; --accent-light: #cab7e6;
  --accent-soft: #f4f0fa; --accent-soft2: #eae1f4; --accent-border: #ddd0ee;
  --accent-text: #574080; --accent-text2: #8a76ab; --accent-link: #8163b3;
  --bg-gradient: linear-gradient(135deg, #f4f0fa 0%, #ece4f5 100%);
}
html.theme-blue {
  /* 💙 Пыльно-голубой */
  --accent: #7fa8cc; --accent-dark: #6690b8; --accent-light: #aacae2;
  --accent-soft: #eef5fb; --accent-soft2: #dfeaf5; --accent-border: #cadcec;
  --accent-text: #3a5a7a; --accent-text2: #6f90ad; --accent-link: #5a85ad;
  --bg-gradient: linear-gradient(135deg, #eef5fb 0%, #e1ecf6 100%);
}
html.theme-yellow {
  /* 💛 Мягкая горчица / песочный */
  --accent: #cdb46a; --accent-dark: #b39c54; --accent-light: #e3d29c;
  --accent-soft: #faf6e9; --accent-soft2: #f3ead1; --accent-border: #e8dcb8;
  --accent-text: #6e5a28; --accent-text2: #9a8a5a; --accent-link: #ab964a;
  --bg-gradient: linear-gradient(135deg, #faf6e9 0%, #f4edd6 100%);
}
html.theme-red {
  /* ❤️ Пыльная роза */
  --accent: #d2929a; --accent-dark: #ba7880; --accent-light: #e7babf;
  --accent-soft: #fbeef0; --accent-soft2: #f5dfe1; --accent-border: #edcace;
  --accent-text: #7a4248; --accent-text2: #ab777c; --accent-link: #bd6a72;
  --bg-gradient: linear-gradient(135deg, #fbeef0 0%, #f6e0e3 100%);
}
html.theme-gray {
  /* 🌫 Тёплый серый */
  --accent: #9aa0a8; --accent-dark: #7e8590; --accent-light: #c1c6cd;
  --accent-soft: #f4f5f6; --accent-soft2: #e9ebed; --accent-border: #d7dade;
  --accent-text: #4a4f57; --accent-text2: #80868f; --accent-link: #6b7079;
  --bg-gradient: linear-gradient(135deg, #f4f5f6 0%, #e9ebed 100%);
}

html, body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  color: #2d3e2f;
}

a { color: var(--accent-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Шестерёнка настроек в шапке === */
.settings-gear {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  text-decoration: none; font-size: 17px; line-height: 1;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--accent-border, #d4e1d6);
  transition: all 0.15s; color: #3d5a40;
}
.settings-gear:hover {
  background: var(--accent-soft, #f3f8f3);
  border-color: var(--accent, #6ea676);
  transform: rotate(40deg); text-decoration: none;
}
html.dark-active .settings-gear {
  background: var(--d-surface-2); border-color: var(--d-border-2); color: var(--d-text);
}

/* === Имя+аватар в шапке (клик → Мой кабинет) === */
.hello-link {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; padding: 4px 10px 4px 4px;
  border-radius: 22px; transition: all 0.15s;
  border: 1px solid transparent;
}
.hello-link:hover {
  background: rgba(255,255,255,0.55);
  border-color: var(--accent-border, #d4e1d6);
  text-decoration: none;
}
.hello-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.7);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.hello-avatar-ph { color: #fff; font-size: 13px; font-weight: 600; }
.hello-name { font-size: 14px; color: var(--accent-text, #4a6b4d); font-weight: 500; }
html.dark-active .hello-link:hover { background: var(--d-surface-2); border-color: var(--d-border-2); }
html.dark-active .hello-name { color: var(--d-text); }
html.dark-active .hello-avatar { border-color: rgba(120,160,130,0.3); }

/* === Переключатель темы (legacy, на странице настроек) === */
.theme-switcher { position: relative; display: inline-block; z-index: 3000; }
.theme-switcher-floating {
  position: fixed; bottom: 18px; left: 18px; z-index: 1000;
}
.theme-switcher-floating .theme-menu {
  bottom: calc(100% + 6px); right: auto; left: 0;
}
.theme-btn {
  min-width: 44px; height: 36px; padding: 0 10px;
  border-radius: 20px; gap: 6px;
  background: white; border: 1px solid var(--accent-border);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.15s;
  box-shadow: 0 2px 8px rgba(60,100,60,0.08);
}
.theme-btn:hover { border-color: var(--accent); transform: scale(1.05); }
.theme-dot {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid white; box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.theme-mode-icon { font-size: 14px; line-height: 1; }
.theme-menu {
  position: absolute; bottom: calc(100% + 6px); right: 0;
  background: white; border: 1px solid #e0eae2; border-radius: 12px;
  box-shadow: 0 12px 28px rgba(60,100,60,0.14);
  z-index: 3001; min-width: 220px; padding: 6px;
}
.theme-switcher:not(.theme-switcher-floating) .theme-menu {
  top: calc(100% + 4px); bottom: auto;
}
.theme-menu-title { font-size: 11px; color: #8aa68d; text-transform: uppercase; padding: 8px 12px 4px; letter-spacing: 0.4px; }
.theme-menu-sep { height: 1px; background: #e8ede9; margin: 4px 8px; }
.theme-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border: none; background: none; cursor: pointer;
  border-radius: 8px; color: #3d5a40; font-size: 14px; text-align: left;
}
.theme-opt:hover { background: #f3f8f3; }
.theme-opt-active { background: #eaf3eb; font-weight: 600; }
.theme-opt .theme-dot { width: 16px; height: 16px; }
.theme-mode-emoji { font-size: 16px; width: 16px; text-align: center; }
.theme-check { margin-left: auto; color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════
   🌙 НОЧНОЙ РЕЖИМ — полноценный
   Включается классом html.dark-active (его вешает theme.js при режиме
   "Тёмная" ИЛИ "Как в системе"+системная тёмная). Один источник правды.
   ═══════════════════════════════════════════════════════════════ */
html.dark-active {
  color-scheme: dark;
  --bg-gradient: linear-gradient(160deg, #14201a 0%, #0c1410 100%);
  /* Тёмные поверхности */
  --d-surface:   #1b2721;     /* карточки */
  --d-surface-2: #223029;     /* приподнятые блоки / hover */
  --d-surface-3: #16201b;     /* инпуты, утопленные */
  --d-border:    rgba(120,160,130,0.16);
  --d-border-2:  rgba(120,160,130,0.28);
  --d-text:      #dde6df;     /* основной текст */
  --d-text-strong:#eef4ef;    /* заголовки */
  --d-text-dim:  #93a89a;     /* подписи */
}
html.dark-active body { color: var(--d-text); }

/* Текст / заголовки / подписи (широкий охват) */
html.dark-active h1, html.dark-active h2, html.dark-active h3,
html.dark-active h4 { color: var(--d-text-strong) !important; }
html.dark-active .subtitle, html.dark-active .tile-desc,
html.dark-active .cat-sub, html.dark-active .dash-sub,
html.dark-active .tg-chat-last, html.dark-active .tg-username,
html.dark-active .field-hint, html.dark-active .new-meta,
html.dark-active .dash-title, html.dark-active .lead-meta,
html.dark-active .subtask-meta, html.dark-active .today-details,
html.dark-active .today-meta, html.dark-active .info-label,
html.dark-active .uplink-meta, html.dark-active .step-hint,
html.dark-active label, html.dark-active .field label,
html.dark-active .td-meta, html.dark-active .stat-time,
html.dark-active .member-block h3, html.dark-active .group-ref,
html.dark-active .rec-row .rec-vol, html.dark-active .crm-strip-link {
  color: var(--d-text-dim) !important;
}
html.dark-active .new-name, html.dark-active .new-name-link,
html.dark-active .lead-name, html.dark-active .tile-title,
html.dark-active .tg-chat-name, html.dark-active .group-label,
html.dark-active .dash-value, html.dark-active .uplink-name,
html.dark-active .subtask-name, html.dark-active .today-task-title,
html.dark-active .hello, html.dark-active .top-left,
html.dark-active .info-line, html.dark-active .stat b,
html.dark-active .ct-table td, html.dark-active .ph-table td {
  color: var(--d-text-strong) !important;
}

/* Поверхности-карточки (всё, что было белым/светлым) */
html.dark-active .card,
html.dark-active .tile,
html.dark-active .dash-card,
html.dark-active .member-block,
html.dark-active .today-block,
html.dark-active .today-task,
html.dark-active .today-done-block,
html.dark-active .tg-chat-row,
html.dark-active .tg-msg-in .tg-msg-bubble,
html.dark-active .new-card,
html.dark-active .group-card,
html.dark-active .lead-row,
html.dark-active .broadcast-filters,
html.dark-active .broadcast-message,
html.dark-active .add-group-card,
html.dark-active .presets,
html.dark-active .connect-block,
html.dark-active .ph-card,
html.dark-active .status-card,
html.dark-active .level-card,
html.dark-active .service-card,
html.dark-active .search-result-card,
html.dark-active .recipients-block,
html.dark-active .preview-summary,
html.dark-active .crm-strip,
html.dark-active .tg-actions,
html.dark-active .tg-send-form,
html.dark-active .empty-state,
html.dark-active .av-modal,
html.dark-active .inv-modal,
html.dark-active .bd-modal {
  background: var(--d-surface) !important;
  border-color: var(--d-border) !important;
  box-shadow: none !important;
}
/* Приподнятые / вложенные */
html.dark-active .subtask,
html.dark-active .today-snooze-menu,
html.dark-active .theme-menu,
html.dark-active .fab-panel,
html.dark-active .dash-green,
html.dark-active .dash-orange,
html.dark-active .dash-pink,
html.dark-active .dash-primary,
html.dark-active .tg-chat-count,
html.dark-active .recruit-count {
  background: var(--d-surface-2) !important;
  border-color: var(--d-border) !important;
  color: var(--d-text) !important;
}
/* Hover-состояния */
html.dark-active .tile:hover,
html.dark-active .dash-card:hover,
html.dark-active .tg-chat-row:hover,
html.dark-active .uplink-row:hover,
html.dark-active .subtask-action:hover,
html.dark-active .theme-opt:hover,
html.dark-active .preset:hover { background: var(--d-surface-3) !important; }

/* Поля ввода */
html.dark-active input,
html.dark-active textarea,
html.dark-active select,
html.dark-active .filter-input,
html.dark-active .broadcast-textarea,
html.dark-active .tg-send-form textarea {
  background: var(--d-surface-3) !important;
  color: var(--d-text-strong) !important;
  border-color: var(--d-border-2) !important;
}
html.dark-active input::placeholder,
html.dark-active textarea::placeholder { color: #6f8478 !important; }

/* Хедер */
html.dark-active .top {
  background: rgba(20,30,25,0.75) !important;
  border-bottom-color: var(--d-border) !important;
}
html.dark-active .back-arrow,
html.dark-active .theme-btn,
html.dark-active .btn-ghost,
html.dark-active .today-add-btn,
html.dark-active .today-expand-btn,
html.dark-active .group-sync-btn,
html.dark-active .preset,
html.dark-active .subtask-action,
html.dark-active .new-action-btn,
html.dark-active .open-card-btn,
html.dark-active .tg-open-btn {
  background: var(--d-surface-2) !important;
  color: var(--d-text) !important;
  border-color: var(--d-border-2) !important;
}

/* Таблицы */
html.dark-active table th { color: var(--d-text-dim) !important; border-bottom-color: var(--d-border) !important; }
html.dark-active table td { border-bottom-color: var(--d-border) !important; }
html.dark-active .ct-table tr:hover,
html.dark-active .ph-table tbody tr:hover { background: var(--d-surface-2) !important; }

/* Прогресс-бары / разделители */
html.dark-active .today-progress-bar { background: rgba(120,160,130,0.15) !important; }
html.dark-active .theme-menu-sep,
html.dark-active .new-actions,
html.dark-active .tg-limits { border-color: var(--d-border) !important; }
html.dark-active .today-subtasks { border-left-color: var(--d-border-2) !important; }

/* Ссылки */
html.dark-active a { color: #7fc98a; }
html.dark-active .uplink-name,
html.dark-active .new-name-link,
html.dark-active .ct-table a,
html.dark-active .sponsor-link { color: var(--d-text-strong) !important; }

/* Капсулы-чипы — слегка приглушаем фон */
html.dark-active .badge,
html.dark-active .tg-chip-empty,
html.dark-active .lead-tag { background: var(--d-surface-3) !important; color: var(--d-text-dim) !important; border-color: var(--d-border) !important; }

/* Превью-маска дохода и прочие приглушённые */
html.dark-active .income-mask { color: #4a5a4f !important; }
html.dark-active .income-eye { background: var(--d-surface-3) !important; border-color: var(--d-border-2) !important; }

/* Переписка в тёмной теме — входящие пузыри читаемые */
html.dark-active .tg-msg-in .tg-msg-bubble {
  background: var(--d-surface-2) !important;
  color: var(--d-text-strong) !important;
  border-color: var(--d-border) !important;
}
html.dark-active .tg-msg-time { color: var(--d-text-dim) !important; opacity: 0.95; }
/* Исходящие — акцент + белый (var(--accent) сам по теме) */
html.dark-active .tg-msg-out .tg-msg-bubble { color: #fff !important; }

/* Полноэкранные центрированные страницы (landing, login) */
.page-center {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 60px 50px;
  max-width: 520px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(60, 80, 60, 0.08);
}
.emoji { font-size: 64px; margin-bottom: 20px; }
h1 { font-size: 32px; font-weight: 600; margin-bottom: 12px; color: #3d5a40; }
.subtitle { font-size: 17px; color: #6b8e6f; margin-bottom: 28px; line-height: 1.55; }
.btn {
  display: inline-block; background: var(--accent); color: white;
  padding: 14px 32px; border-radius: 14px; font-weight: 500;
  border: none; cursor: pointer; transition: transform 0.1s;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--accent-text2);
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--accent-border);
  cursor: pointer; font: inherit;
}
.btn-ghost:hover { background: var(--accent-soft); }
.footer { margin-top: 36px; color: #8aa68d; font-size: 13px; }
.tg-widget { margin: 12px 0 8px; min-height: 56px; }
.error {
  background: #fde8e8; color: #8a3030;
  padding: 14px 18px; border-radius: 12px; margin: 16px 0;
  font-size: 14px;
}
.hint { color: #6b8e6f; font-size: 14px; margin: 16px 0; }
.hint code {
  background: #eaf4eb; padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace;
}

/* Кабинет — header + tiles */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid rgba(60, 100, 60, 0.08);
  backdrop-filter: blur(8px);
  /* backdrop-filter создаёт stacking-context — поднимаем хедер над карточками
     из <main>, иначе выпадающее меню темы прячется под ними */
  position: relative; z-index: 1000;
}
.top-left { font-size: 18px; color: var(--accent-text, #3d5a40); }
.top-right { display: flex; align-items: center; gap: 16px; }
.hello { color: #4a6b4d; font-size: 14px; }
.badge {
  background: #d4e8d6; color: #2d5a32;
  padding: 3px 10px; border-radius: 10px; font-size: 11px;
  margin-left: 4px;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 40px 24px; }
.hero { text-align: center; margin-bottom: 48px; }
.hero h1 { font-size: 36px; margin-bottom: 10px; }
.hero .subtitle { max-width: 640px; margin: 0 auto; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.tile {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: left;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid rgba(60, 100, 60, 0.06);
}
.tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(60, 100, 60, 0.08);
}
.tile-emoji { font-size: 40px; margin-bottom: 14px; }
.tile-title { font-size: 18px; font-weight: 600; color: var(--accent-text, #3d5a40); margin-bottom: 8px; }
.tile-desc { font-size: 14px; color: #6b8e6f; line-height: 1.5; }
.tile-status {
  position: absolute; top: 20px; right: 20px;
  background: #eaf0e9; color: #5a7a5d;
  padding: 3px 10px; border-radius: 8px; font-size: 11px;
}
.tile.soon { opacity: 0.85; }

/* ═══════════════════════════════════════════════════════════════
   📱 МОБИЛЬНАЯ АДАПТАЦИЯ
   Telegram / VK / iOS-Safari / Chrome Android
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Общее */
  .wrap { padding: 16px 12px; max-width: 100%; }
  h1 { font-size: 22px; line-height: 1.25; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }
  .subtitle { font-size: 14px; line-height: 1.5; }

  /* Шапка — переносим в 2 строки + уменьшаем */
  .top {
    flex-wrap: wrap; padding: 10px 14px; gap: 8px;
    font-size: 14px;
  }
  .top-left { font-size: 14px; min-width: 0; flex: 1; }
  .top-left b { font-size: 14px; }
  .top-right { gap: 6px; flex-wrap: wrap; }
  .hello { font-size: 12px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  .btn-ghost { padding: 6px 10px; font-size: 12px; }
  /* Скрываем разделители «/» в крошках на узких экранах */
  .top-left > span[style*="opacity"] { display: none; }

  /* Hero */
  .hero { margin-bottom: 16px; }
  .hero h1 { font-size: 22px; }

  /* Дашборд: 1 колонка */
  .dash-grid, .tiles {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .dash-card, .tile { padding: 14px 16px !important; }
  .dash-emoji, .tile-emoji { font-size: 28px !important; margin-bottom: 4px !important; }
  .dash-value { font-size: 22px !important; }
  .dash-title, .tile-title { font-size: 15px !important; }
  .dash-sub, .tile-desc { font-size: 12.5px !important; }

  /* «Что важно сегодня» */
  .today-block { padding: 14px 14px; border-radius: 12px; }
  .today-head { gap: 8px; }
  .today-title h2 { font-size: 17px; }
  .today-meta { font-size: 11.5px; }
  .today-add-btn { padding: 6px 10px; font-size: 12px; }
  .today-task { padding: 10px 12px; gap: 10px; }
  .today-task-title { font-size: 14px; }
  .today-details { font-size: 12px; }

  /* Кнопки */
  .btn { padding: 10px 18px; font-size: 14px; }

  /* Карточка участника / лида / новых */
  .new-card, .group-card, .lead-row { padding: 12px 14px !important; }
  .new-card-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .new-pv { align-self: flex-end; margin-top: -28px; }
  .new-actions { gap: 6px; }
  .new-action-btn { padding: 5px 9px; font-size: 11.5px; }

  /* Сегментация: фильтры под сообщение, не рядом */
  .broadcast-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .broadcast-filters, .broadcast-message { padding: 14px !important; }
  .preset { padding: 5px 10px; font-size: 12px; }
  .presets { padding: 10px 12px; }
  .recipients-list { max-height: 220px; }
  .rec-row { font-size: 13px; }
  .rec-row .rec-vol { display: block; margin-top: 2px; }

  /* Переписка */
  .tg-chat-row { padding: 10px 12px !important; gap: 10px !important; }
  .tg-chat-avatar { width: 36px !important; height: 36px !important; font-size: 15px !important; }
  .tg-chat-name { font-size: 14px !important; }
  .tg-chat-last { font-size: 12px !important; }
  .tg-chip { font-size: 10.5px; padding: 2px 7px; }
  .tg-msg { max-width: 88%; }

  /* CRM-полоска внутри чата */
  .crm-strip { padding: 12px; }
  .crm-stages-row { gap: 4px; }
  .crm-stage-step { padding: 6px 8px; font-size: 11.5px; }
  .crm-step-label { font-size: 11.5px; }

  /* Таблицы — в горизонтальный скролл */
  .ph-table, .placements-table, .registrations-table,
  table:not(.calendar):not(.tg-table) {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .ph-table th, .ph-table td { padding: 6px 8px; }

  /* Чаты → воронка */
  .add-group-row { flex-direction: column; align-items: stretch; }
  .add-group-row .btn { width: 100%; height: auto !important; align-self: auto !important; }
  .group-head { flex-direction: column; align-items: flex-start; }
  .group-actions { width: 100%; justify-content: space-between; }
  .group-sync-btn { flex: 1; }

  /* Дерево — даём scroll */
  #treeSvg, #treeContainer, .tree-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* График дохода — сжимаем */
  canvas { max-width: 100% !important; height: auto !important; }

  /* fab-chat сделаем чуть меньше и сместим выше theme-switcher не мешать */
  .fab-chat { width: 48px; height: 48px; font-size: 22px; right: 14px; bottom: 14px; }
  .fab-panel { right: 8px !important; bottom: 70px !important; width: calc(100vw - 16px) !important; max-width: 380px; }

  /* Тёмный/светлый переключатель — компактнее */
  .theme-switcher-floating { bottom: 14px; left: 14px; }
  .theme-btn { min-width: 38px; height: 32px; padding: 0 8px; }

  /* Стрелка назад — мельче */
  .back-arrow { width: 28px; height: 28px; font-size: 15px; margin-right: 6px; }

  /* Range-toggle (новые/неделя/месяц) */
  .range-toggle { flex-wrap: wrap; gap: 4px; }
  .range-btn { padding: 5px 10px; font-size: 12px; }

  /* Notif bell */
  .notif-bell { width: 32px; height: 32px; font-size: 16px; }

  /* Empty-state — мельче эмодзи на телефоне */
  .empty-state { padding: 30px 16px; }
  .empty-state .emoji, .today-empty-emoji { font-size: 36px !important; }

  /* Calculator */
  .calc-grid, .income-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
}

/* Узкий мобильный (≤400) — ещё компактнее */
@media (max-width: 400px) {
  h1 { font-size: 20px; }
  .top-left { font-size: 13px; }
  .top-left b { font-size: 13px; }
  .dash-value { font-size: 20px !important; }
  .crm-stages-row { flex-direction: column; }
  .crm-stage-step { width: 100%; justify-content: flex-start; padding: 7px 10px; }
}

/* Telegram WebApp: убираем горизонтальный paddings, цвет фона = telegram */
@media (display-mode: standalone), (display-mode: minimal-ui) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}
.is-tma .top { display: none; }     /* В Mini App шапка от Telegram сама */
.is-tma .wrap { padding-top: 12px; }

/* Чат с помощником */
.chat-wrap {
  max-width: 820px; margin: 0 auto;
  display: flex; flex-direction: column;
  height: calc(100vh - 64px); padding: 0 16px;
}
.chat-list {
  flex: 1; overflow-y: auto; padding: 24px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.empty-state {
  text-align: center; max-width: 480px; margin: 60px auto;
  color: #6b8e6f;
}
.empty-state .emoji { font-size: 56px; margin-bottom: 14px; }
.empty-state h2 { font-size: 22px; color: #3d5a40; margin-bottom: 10px; font-weight: 600; }
.empty-state p { font-size: 15px; line-height: 1.55; }

.msg { display: flex; flex-direction: column; max-width: 76%; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-user .msg-bubble {
  background: #4a7a4f; color: white;
  border-bottom-right-radius: 6px;
}
.msg-assistant .msg-bubble {
  background: rgba(255,255,255,0.85);
  color: #2d3e2f;
  border: 1px solid rgba(60,100,60,0.08);
  border-bottom-left-radius: 6px;
}
.msg-pending .msg-bubble {
  background: rgba(255,255,255,0.6);
  color: #6b8e6f;
  font-size: 18px; letter-spacing: 4px;
  animation: thinking-pulse 1.4s ease-in-out infinite;
}
@keyframes thinking-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

.chat-form {
  padding: 16px 0 20px;
  border-top: 1px solid rgba(60,100,60,0.08);
}
.input-wrap { display: flex; flex-direction: column; gap: 10px; }
.input-row { display: flex; gap: 10px; align-items: flex-end; }
.attach-btn {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.85);
  border: 1px solid #c8dcc9;
  border-radius: 14px;
  cursor: pointer; font-size: 22px;
  transition: background 0.15s, border-color 0.15s;
}
.attach-btn:hover { background: #f0f7f1; border-color: #4a7a4f; }
.attach-btn.recording {
  background: #fde4e4 !important;
  border-color: #d66464 !important;
  color: #c44 !important;
  animation: rec-pulse 1.2s ease-in-out infinite;
}
@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 100, 100, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(214, 100, 100, 0); }
}

.chat-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid #c8dcc9;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit; font-size: 15px;
  background: rgba(255,255,255,0.85);
  color: #2d3e2f;
  min-height: 48px; max-height: 200px;
  outline: none;
}
.chat-form textarea:focus { border-color: #4a7a4f; }
.chat-form button[type="submit"] {
  background: #4a7a4f; color: white;
  border: none; border-radius: 14px;
  padding: 0 24px; height: 48px;
  font: inherit; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.chat-form button[type="submit"]:hover { background: #3d6842; }
.chat-form button[type="submit"]:disabled { background: #b0c8b3; cursor: wait; }

/* Превью прикреплённой картинки */
.image-preview {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.85);
  border: 1px solid #c8dcc9;
  border-radius: 12px;
  padding: 8px 12px 8px 8px;
  align-self: flex-start;
  max-width: 100%;
}
.image-preview img {
  max-height: 64px; max-width: 100px;
  border-radius: 6px; object-fit: cover;
}
.image-preview button {
  background: none; border: none;
  font-size: 22px; color: #6b8e6f;
  cursor: pointer; padding: 4px 8px;
  line-height: 1;
}
.image-preview button:hover { color: #c44; }

/* Картинка в сообщении */
.msg-image {
  max-width: 280px; max-height: 280px;
  border-radius: 14px; margin-bottom: 6px;
  object-fit: cover;
  background: rgba(0,0,0,0.04);
  box-shadow: 0 2px 8px rgba(60,100,60,0.10);
}
.msg-user .msg-image {
  border-bottom-right-radius: 6px;
}
.msg-assistant .msg-image {
  border-bottom-left-radius: 6px;
}

/* Карточки сводки и графики */
.summary-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 24px 22px;
  border: 1px solid rgba(60,100,60,0.06);
}
.stat-num {
  font-size: 36px; font-weight: 600; color: #3d5a40;
  line-height: 1.1; margin-bottom: 6px;
}
.stat-label { color: #6b8e6f; font-size: 14px; }

.chart-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px 28px;
  margin-bottom: 24px;
  border: 1px solid rgba(60,100,60,0.06);
}
.chart-block h2 { font-size: 20px; font-weight: 600; color: #3d5a40; margin-bottom: 16px; }
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 12px;
}
.chart-header h2 { margin-bottom: 0; }
.chart-canvas { position: relative; height: 280px; }

.range-toggle {
  display: inline-flex; background: #eaf0e9;
  border-radius: 10px; padding: 3px; gap: 2px;
}
.range-btn {
  background: transparent; border: none;
  padding: 7px 14px; border-radius: 8px;
  color: #5a7a5d; font: inherit; font-size: 14px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.range-btn:hover { background: rgba(255,255,255,0.5); }
.range-btn.active {
  background: white; color: #3d5a40;
  box-shadow: 0 2px 6px rgba(60,100,60,0.08);
}
/* Кнопки гранулярности (недели/месяцы/...) */
.gran-btn {
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--accent-border, #d4e1d6);
  padding: 6px 13px; border-radius: 16px;
  color: var(--accent-text, #5a7a5d); font: inherit; font-size: 13px;
  cursor: pointer; transition: all 0.15s;
}
.gran-btn:hover { background: var(--accent-soft, #f3f8f3); border-color: var(--accent, #6ea676); }
.gran-btn.active {
  background: var(--accent, #6ea676); color: #fff; border-color: var(--accent, #6ea676);
}
html.dark-active .gran-btn { background: var(--d-surface-2); color: var(--d-text); border-color: var(--d-border-2); }
html.dark-active .gran-btn.active { background: var(--accent, #6ea676); color: #fff; }

/* Плавающий чат на каждой странице */
.fab-chat { position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--accent-light, #6ea676), var(--accent-dark, #3d6842)); color: white; font-size: 26px; cursor: pointer; z-index: 999; box-shadow: 0 8px 24px rgba(60,100,60,0.32); transition: transform 0.15s, box-shadow 0.15s; display: flex; align-items: center; justify-content: center; }
.fab-chat:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 12px 32px rgba(60,100,60,0.42); }
.fab-panel { position: fixed; right: 22px; bottom: 22px; width: 380px; max-width: calc(100vw - 32px); height: 540px; max-height: calc(100vh - 60px); background: white; border-radius: 18px; box-shadow: 0 18px 48px rgba(60,100,60,0.28); z-index: 1000; display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(60,100,60,0.10); }
.fab-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: linear-gradient(135deg, var(--accent-soft, #eef5ee), var(--accent-soft2, #d4e8d6)); border-bottom: 1px solid rgba(60,100,60,0.08); font-size: 15px; color: var(--accent-text, #3d5a40); }
.fab-head > span:first-child { flex: 1; }
.fab-open-full, .fab-close { background: transparent; border: none; font-size: 18px; color: #6b8e6f; cursor: pointer; padding: 4px 8px; text-decoration: none; line-height: 1; }
.fab-close { font-size: 22px; }
.fab-open-full:hover, .fab-close:hover { color: #3d5a40; }
.fab-list { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.fab-empty { text-align: center; padding: 24px 8px; color: #6b8e6f; font-size: 13px; line-height: 1.6; }
.fab-msg { display: flex; }
.fab-msg-user { justify-content: flex-end; }
.fab-msg-assistant { justify-content: flex-start; }
.fab-bubble { max-width: 84%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.fab-msg-user .fab-bubble { background: var(--accent, #4a7a4f); color: white; border-bottom-right-radius: 4px; }
.fab-msg-assistant .fab-bubble { background: #f0f7f1; color: #2d3e2f; border-bottom-left-radius: 4px; }
.fab-pending .fab-bubble { background: #eaf0e9; color: #6b8e6f; letter-spacing: 3px; font-size: 16px; animation: thinking-pulse 1.4s ease-in-out infinite; }
.fab-bubble a { color: #3d7a45; text-decoration: underline; }
.fab-msg-user .fab-bubble a { color: #d4e8d6; }
.fab-bubble code { background: rgba(60,100,60,0.10); padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 0.9em; }
.fab-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(60,100,60,0.08); }
.fab-form textarea { flex: 1; padding: 9px 12px; border: 1px solid #c8dcc9; border-radius: 12px; font: inherit; font-size: 14px; background: white; color: #2d3e2f; outline: none; resize: none; min-height: 38px; max-height: 120px; }
.fab-form textarea:focus { border-color: #4a7a4f; }
.fab-form button { background: #4a7a4f; color: white; border: none; border-radius: 12px; width: 44px; font-size: 20px; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.fab-form button:hover { background: #3d6842; }
.fab-form button:disabled { background: #b0c8b3; cursor: wait; }
@media (max-width: 540px) { .fab-panel { right: 10px; bottom: 10px; left: 10px; width: auto; max-width: none; height: 70vh; } }

/* Telegram Business чаты */
.connect-block { background: rgba(255,255,255,0.85); border-radius: 18px; padding: 32px; border: 1px solid rgba(60,100,60,0.06); max-width: 720px; }
.connect-block h2 { color: #3d5a40; font-size: 22px; margin-bottom: 10px; text-align: center; }
.connect-emoji { font-size: 56px; margin-bottom: 14px; text-align: center; }
.connect-steps { padding-left: 24px; margin: 18px 0; }
.connect-steps li { margin: 12px 0; line-height: 1.5; color: #3d5a40; }
.connect-steps .step-hint { font-size: 13px; color: #8aa68d; margin-top: 4px; }
.connect-steps code { background: #f0f7f1; color: #3d5a40; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.connect-note { margin-top: 18px; padding: 14px 18px; background: #eef5ee; border-radius: 12px; font-size: 13px; color: #4a6b4d; line-height: 1.6; }

.connect-only-you { margin: 22px 0 18px; padding: 18px 20px; background: linear-gradient(135deg, #fff5f7 0%, #fef0f4 100%); border-radius: 14px; border: 1px solid rgba(220,150,170,0.18); }
.only-you-label { font-size: 13px; font-weight: 600; color: #b85a7a; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }
.connect-only-you .connect-steps { margin: 0; }
.connect-only-you .connect-steps li::marker { color: #b85a7a; font-weight: 700; }

.connect-bot-does { margin: 14px 0 18px; padding: 18px 20px; background: linear-gradient(135deg, #f3f8f3 0%, #e9f3ec 100%); border-radius: 14px; border: 1px solid rgba(60,140,80,0.15); }
.bot-does-label { font-size: 13px; font-weight: 600; color: #3d7a48; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }
.bot-does-list { margin: 0; padding-left: 20px; }
.bot-does-list li { margin: 6px 0; color: #4a6b4d; font-size: 14px; line-height: 1.5; }
.bot-does-list li::marker { color: #6ea676; }

.connect-status { margin-top: 22px; padding: 14px 18px; background: rgba(255,255,255,0.6); border: 1px dashed rgba(60,140,80,0.3); border-radius: 12px; text-align: center; font-size: 14px; color: #5a7a5e; display: flex; align-items: center; justify-content: center; gap: 10px; }
.pulse-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #6ea676; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); box-shadow: 0 0 12px rgba(110,166,118,0.6); }
}

.tg-chats-list { display: flex; flex-direction: column; gap: 8px; }
.tg-chat-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: rgba(255,255,255,0.85); border-radius: 14px; border: 1px solid rgba(60,100,60,0.06); text-decoration: none; color: inherit; transition: all 0.15s; }
.tg-chat-row:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(60,100,60,0.08); text-decoration: none; }
.tg-chat-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #4a7a4f, #3d6842); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; flex-shrink: 0; }
.tg-chat-body { flex: 1; min-width: 0; }
.tg-chat-name { font-size: 15px; font-weight: 600; color: #3d5a40; }
.tg-chat-name .tg-username { color: #8aa68d; font-weight: 400; font-size: 13px; }
.tg-chat-last { font-size: 13px; color: #6b8e6f; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-chat-meta { flex: 0 0 auto; }
.tg-chat-count { background: #eaf0e9; color: #5a7a5d; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.tg-chat-thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.tg-msg { display: flex; }
.tg-msg-in { justify-content: flex-start; }
.tg-msg-out { justify-content: flex-end; }
.tg-msg-bubble { max-width: 75%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; position: relative; }
.tg-msg-in .tg-msg-bubble { background: rgba(255,255,255,0.95); color: #2d3e2f; border: 1px solid rgba(60,100,60,0.08); border-bottom-left-radius: 4px; }
.tg-msg-out .tg-msg-bubble { background: var(--accent, #4a7a4f); color: white; border-bottom-right-radius: 4px; }
.tg-msg-time { font-size: 11px; opacity: 0.7; margin-top: 4px; }
.tg-chat-hint { padding: 12px 16px; background: rgba(255,255,255,0.6); border-radius: 12px; color: #6b8e6f; font-size: 13px; text-align: center; }

/* ЛРП */
.lrp-block { background: rgba(255,255,255,0.85); backdrop-filter: blur(8px); border-radius: 18px; padding: 24px 28px; margin-bottom: 20px; border: 1px solid rgba(60,100,60,0.06); }
.lrp-block h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.lrp-block .subtitle { font-size: 13px; color: #6b8e6f; margin-bottom: 14px; }
.lrp-list { display: flex; flex-direction: column; gap: 8px; }
.lrp-row-link { text-decoration: none; color: inherit; }
.lrp-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: rgba(255,255,255,0.6); border: 1px solid rgba(60,100,60,0.06); border-radius: 12px; transition: background 0.15s; }
.lrp-row:hover { background: rgba(234,245,235,0.7); }
.lrp-day { flex: 0 0 40px; background: #fff4e0; color: #c47a20; padding: 6px 10px; border-radius: 10px; font-weight: 600; font-size: 16px; text-align: center; line-height: 1.1; }
.lrp-body { flex: 1; min-width: 0; }
.lrp-name { font-size: 15px; font-weight: 600; color: #3d5a40; }
.lrp-meta { font-size: 12px; color: #6b8e6f; margin-top: 3px; }
.lrp-contacts { flex: 0 0 auto; }
.lrp-contacts a { margin: 0 4px; font-size: 12px; font-weight: 500; color: #3d7a45; }

/* Лиды-воронка */
.leads-stages-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.stage-tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: rgba(255,255,255,0.7); border: 1px solid rgba(60,100,60,0.08); border-radius: 20px; color: #4a6b4d; font-size: 13px; text-decoration: none; transition: all 0.15s; }
.stage-tab:hover { background: white; text-decoration: none; }
.stage-tab.active { background: var(--stage-color, #3d5a40); color: white; border-color: var(--stage-color, #3d5a40); }
.stage-tab.active .stage-count { background: rgba(255,255,255,0.25); color: white; }
.stage-count { background: #eaf0e9; color: #5a7a5d; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.leads-list { display: flex; flex-direction: column; gap: 10px; }
.lead-row-link { text-decoration: none; color: inherit; }
.lead-row { background: rgba(255,255,255,0.85); border-radius: 14px; padding: 14px 18px; border: 1px solid rgba(60,100,60,0.06); border-left: 4px solid var(--stage-color, #b0c8b3); display: flex; align-items: center; gap: 16px; transition: transform 0.15s, box-shadow 0.15s; }
.lead-row:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(60,100,60,0.08); }
.lead-stage-pill { flex: 0 0 auto; background: var(--stage-color, #b0c8b3); color: white; padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.lead-body { flex: 1; min-width: 0; }
.lead-name { font-size: 15px; font-weight: 600; color: #3d5a40; }
.lead-meta { font-size: 12px; color: #6b8e6f; margin-top: 3px; }
.lead-note { margin-top: 6px; font-size: 13px; color: #5a7a5d; font-style: italic; }
.lead-tag { background: #d4e8d6; color: #2d5a32; padding: 4px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.lead-stage-block { background: rgba(255,255,255,0.85); border-radius: 16px; padding: 20px 24px; border: 1px solid rgba(60,100,60,0.06); margin-top: 20px; }
.stage-flow { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-pill { padding: 8px 14px; background: white; border: 1px solid rgba(60,100,60,0.10); border-radius: 14px; font: inherit; font-size: 13px; color: #4a6b4d; cursor: pointer; transition: all 0.15s; }
.stage-pill:hover { background: #f0f7f1; }
.stage-pill-active { background: var(--stage-color, #3d5a40); color: white; border-color: var(--stage-color, #3d5a40); }
.match-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(60,100,60,0.06); }
.match-row:last-child { border-bottom: none; }
.event-row { padding: 10px 14px; border-radius: 10px; margin: 8px 0; border-left: 3px solid #c8dcc9; background: #fafdfa; }
.event-note { background: #fff8e0; border-left-color: #e8c474; }
.event-stage { background: #eaf5eb; border-left-color: #4a7a4f; }
.event-converted { background: #d4e8d6; border-left-color: #2d5a32; }
.event-time { font-size: 11px; color: #8aa68d; margin-bottom: 4px; }
.event-text { font-size: 14px; color: #3d5a40; line-height: 1.4; }

/* Рассылка */
.broadcast-grid {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 20px;
}
@media (max-width: 800px) { .broadcast-grid { grid-template-columns: 1fr; } }
.broadcast-filters, .broadcast-message {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px 28px;
  border: 1px solid rgba(60,100,60,0.06);
}
.broadcast-filters h3, .broadcast-message h3 { color: #3d5a40; font-size: 16px; font-weight: 600; }
.filter-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid #c8dcc9; border-radius: 10px;
  font: inherit; font-size: 14px;
  background: rgba(255,255,255,0.85);
  color: #2d3e2f; outline: none;
}
.filter-input:focus { border-color: #4a7a4f; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #6b8e6f; margin-bottom: 5px; }
.preview-summary {
  margin-top: 16px; padding: 14px 16px;
  background: #eaf5eb; border-radius: 12px;
  font-size: 14px; line-height: 1.5;
}
.ps-row { margin: 4px 0; color: #3d5a40; }
.ps-list { margin-top: 8px; color: #6b8e6f; font-size: 13px; }
.broadcast-textarea {
  width: 100%; padding: 14px 18px;
  border: 1px solid #c8dcc9; border-radius: 12px;
  font: inherit; font-size: 15px; line-height: 1.5;
  background: rgba(255,255,255,0.85); color: #2d3e2f;
  outline: none; resize: vertical; min-height: 200px;
}
.broadcast-textarea:focus { border-color: #4a7a4f; }
.broadcast-hint {
  margin-top: 10px; font-size: 12px; color: #8aa68d;
  padding: 10px 14px; background: #f7faf7; border-radius: 8px;
}
.send-result {
  margin-top: 14px; padding: 14px 16px;
  background: #d4e8d6; border-radius: 12px;
  font-size: 14px;
}
.sr-line { margin: 4px 0; color: #2d5a32; }

/* Поиск участника */
.search-form { display: flex; gap: 10px; align-items: center; }
.search-input-big {
  flex: 1; width: 100%; padding: 20px 24px;
  border: 2px solid var(--accent-border, #c8dcc9); border-radius: 18px;
  font: inherit; font-size: 20px;
  background: rgba(255,255,255,0.9);
  color: #2d3e2f; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input-big::placeholder { font-size: 18px; color: #9ab2a0; }
.search-input-big:focus {
  border-color: var(--accent, #4a7a4f);
  box-shadow: 0 0 0 3px rgba(110,166,118,0.15);
}
html.dark-active .search-input-big {
  background: var(--d-surface-3) !important; color: var(--d-text-strong) !important;
  border-color: var(--d-border-2) !important;
}

.search-results-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.search-result-card-link { text-decoration: none; color: inherit; display: block; }
.search-result-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(60,100,60,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
}
.search-result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(60,100,60,0.08);
}
.src-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.src-name { font-size: 15px; font-weight: 600; color: #3d5a40; margin-bottom: 4px; }
.src-meta { font-size: 12px; color: #6b8e6f; }
.src-foot {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid rgba(60,100,60,0.06);
  display: flex; justify-content: space-between;
  font-size: 12px; color: #8aa68d;
}

/* Карточка участника */
.member-hero {
  display: flex; justify-content: space-between; gap: 24px;
  flex-wrap: wrap; align-items: center;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 24px 30px;
  margin-bottom: 24px;
  border: 1px solid rgba(60,100,60,0.06);
}
.member-hero-right { display: flex; gap: 12px; flex-wrap: wrap; }
.stat-card-mini {
  background: #eaf5eb; border-radius: 12px;
  padding: 12px 18px; text-align: center;
  min-width: 100px;
}
.stat-num-mini { font-size: 22px; font-weight: 600; color: #3d5a40; }
.stat-label-mini { font-size: 11px; color: #6b8e6f; }

.member-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.member-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 20px 22px;
  border: 1px solid rgba(60,100,60,0.06);
}
.member-block h3 { font-size: 14px; color: #6b8e6f; margin-bottom: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.info-line { font-size: 14px; color: #3d5a40; margin: 8px 0; line-height: 1.5; }
.info-label { color: #6b8e6f; margin-right: 6px; }

/* Цепочка наставников вверх (спонсорская / рекрутёрская ветка) */
.uplink-chain { display: flex; flex-direction: column; gap: 2px; }
.uplink-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 7px 10px; border-radius: 8px; text-decoration: none;
  transition: background 0.15s; position: relative;
}
.uplink-row:hover { background: var(--accent-soft, #f3f8f3); text-decoration: none; }
.uplink-arrow {
  color: var(--accent-light, #6ea676); font-weight: 700; flex: 0 0 auto;
  font-size: 13px; width: 14px; text-align: center;
}
.uplink-name { font-weight: 600; color: var(--accent-text, #3d5a40); flex: 0 0 auto; }
.uplink-meta { font-size: 12px; color: #8aa68d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Лёгкая «лесенка»: каждый следующий уровень чуть правее */
.uplink-chain .uplink-row:nth-child(n+2) { margin-left: 6px; }
.uplink-chain .uplink-row:nth-child(n+3) { margin-left: 12px; }
.uplink-chain .uplink-row:nth-child(n+4) { margin-left: 18px; }
.uplink-chain .uplink-row:nth-child(n+5) { margin-left: 24px; }

/* Доход */
.income-hero {
  background: linear-gradient(135deg, #eef5ee, #d4e8d6);
  border-radius: 20px;
  padding: 32px 32px;
  margin-bottom: 24px;
  text-align: center;
  border: 1px solid #b8d4ba;
}
.income-hero-label { color: #5a7a5d; font-size: 14px; }
.income-hero-amount {
  font-size: 48px; font-weight: 600;
  color: #2d5a32; margin: 6px 0 8px;
}
.income-hero-sub { color: #6b8e6f; font-size: 14px; }

.income-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.income-row {
  background: rgba(255,255,255,0.85);
  border-radius: 14px; padding: 16px 22px;
  border: 1px solid rgba(60,100,60,0.08);
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
}
.income-row-done { background: linear-gradient(90deg, #eef5ee, rgba(255,255,255,0.85) 70%); }
.income-row-estimate { background: linear-gradient(90deg, #f0f4f8, rgba(255,255,255,0.85) 70%); }
.income-row-left { display: flex; align-items: center; gap: 14px; }
.income-icon { font-size: 26px; }
.income-title { font-size: 15px; font-weight: 600; color: #3d5a40; }
.income-desc { font-size: 13px; color: #6b8e6f; margin-top: 3px; }
.income-amount {
  font-size: 22px; font-weight: 600;
  color: #4a7a4f; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.next-bonus {
  background: linear-gradient(135deg, #fff8e0, #ffe9b8);
  border-radius: 16px;
  padding: 20px 26px;
  margin-bottom: 20px;
  display: flex; gap: 20px; align-items: center;
  border: 1px solid #f0d090;
}
.next-bonus-emoji { font-size: 40px; }
.next-bonus-label { color: #8a6a20; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.next-bonus-title { font-size: 18px; color: #5a4520; margin: 4px 0; }
.next-bonus-hint  { color: #8a6a20; font-size: 14px; }

.hint-box {
  background: rgba(255,255,255,0.7);
  border-radius: 14px;
  padding: 18px 24px;
  border: 1px solid rgba(60,100,60,0.06);
}
.hint-box h3 { font-size: 14px; color: #6b8e6f; margin-bottom: 8px; font-weight: 600; }
.hint-box ul { padding-left: 22px; color: #6b8e6f; font-size: 13px; line-height: 1.7; }

/* Сервисы команды */
.service-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 26px 28px;
  margin-bottom: 20px;
  border: 1px solid rgba(60,100,60,0.06);
}
.service-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 16px; }
.service-emoji { font-size: 42px; line-height: 1; flex: 0 0 auto; }
.service-card h2 { font-size: 20px; color: #3d5a40; margin-bottom: 4px; }
.service-card .subtitle { font-size: 14px; color: #6b8e6f; }

.link-block {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px;
}
.link-input {
  flex: 1; min-width: 220px;
  padding: 10px 14px;
  background: #f7faf7;
  border: 1px solid #c8dcc9;
  border-radius: 10px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #4a6b4d;
  outline: none;
}
.copy-btn { padding: 10px 16px; font-size: 14px; }

.qr-block {
  display: inline-block;
  padding: 12px;
  background: white;
  border-radius: 12px;
  border: 1px solid rgba(60,100,60,0.10);
  margin-bottom: 10px;
}

.instr {
  margin-top: 10px;
  border-top: 1px solid rgba(60,100,60,0.06);
  padding-top: 12px;
}
.instr summary {
  cursor: pointer;
  color: #4a7a4f; font-weight: 500;
  padding: 6px 0;
}
.instr-body {
  padding: 12px 0;
  color: #3d5a40;
  font-size: 14px; line-height: 1.6;
}
.instr-body h3 { font-size: 14px; margin-top: 12px; margin-bottom: 6px; color: #3d5a40; }
.instr-body h3:first-child { margin-top: 0; }
.instr-body ol { padding-left: 22px; }
.instr-body li { margin: 4px 0; }

.share-tips {
  background: linear-gradient(135deg, #eef5ee, #e0f0e0);
  border-radius: 16px; padding: 20px 24px;
  border: 1px solid #c8e0ca;
}
.share-tips h3 { font-size: 16px; color: #3d5a40; margin-bottom: 10px; }
.share-tips ul { padding-left: 22px; color: #4a6b4d; line-height: 1.7; }

/* Обучение */
.learn-hero {
  display: flex; gap: 24px; flex-wrap: wrap;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 28px 30px;
  margin-bottom: 28px;
  border: 1px solid rgba(60,100,60,0.06);
}
.learn-hero-left { flex: 1; min-width: 260px; }
.learn-hero-right { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.player-rank {
  display: inline-block;
  background: linear-gradient(135deg, #d4e8d6, #a8d4ab);
  color: #2d5a32; padding: 4px 14px;
  border-radius: 12px; font-size: 13px; font-weight: 600;
  margin-bottom: 8px;
}
.player-name { font-size: 24px; font-weight: 600; color: #3d5a40; margin-bottom: 12px; }
.xp-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.xp-value { font-size: 22px; font-weight: 600; color: #4a7a4f; }
.xp-next { font-size: 13px; color: #8aa68d; }
.xp-bar {
  height: 8px; background: #eaf0e9;
  border-radius: 4px; overflow: hidden;
  max-width: 460px;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7ab07c, #4a7a4f);
  transition: width 0.4s ease;
}

.streak-box {
  background: linear-gradient(135deg, #fff4e0, #ffe0b8);
  border-radius: 16px;
  padding: 16px 22px;
  text-align: center;
  min-width: 120px;
}
.streak-num { font-size: 28px; font-weight: 600; color: #c47a20; line-height: 1; }
.streak-label { font-size: 12px; color: #8a6a20; margin-top: 4px; }
.streak-best { font-size: 11px; color: #b08850; margin-top: 4px; }
.rank-pos {
  background: linear-gradient(135deg, #e8d4f0, #c8a8e6);
  color: #553377;
  padding: 14px 22px; border-radius: 16px;
  font-size: 16px; font-weight: 600;
  text-align: center; min-width: 120px;
}

.levels-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.level-card-link { text-decoration: none; color: inherit; display: block; }
.level-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 22px 22px 20px;
  border: 1px solid rgba(60,100,60,0.08);
  border-top: 4px solid var(--lvl-color);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}
.level-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(60,100,60,0.10);
}
.level-card-done::after {
  content: "💚"; position: absolute; top: 14px; right: 14px; font-size: 18px;
}
.level-num { font-size: 11px; color: #8aa68d; text-transform: uppercase; letter-spacing: 0.5px; }
.level-emoji { font-size: 40px; margin: 6px 0 4px; }
.level-title { font-size: 18px; font-weight: 600; color: #3d5a40; margin-bottom: 6px; }
.level-desc { font-size: 13px; color: #6b8e6f; min-height: 36px; line-height: 1.45; }
.level-progress-row {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
}
.level-progress-bar {
  flex: 1; height: 6px; background: #eaf0e9;
  border-radius: 3px; overflow: hidden;
}
.level-progress-bar > div {
  height: 100%; background: var(--lvl-color);
  transition: width 0.4s ease;
}
.level-progress-text { font-size: 12px; color: #6b8e6f; white-space: nowrap; }

.badges-block, .lb-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid rgba(60,100,60,0.06);
}
.badges-block h2, .lb-block h2 {
  font-size: 19px; font-weight: 600; color: #3d5a40; margin-bottom: 16px;
}
.badges-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.badge-card {
  background: linear-gradient(135deg, #fffaf0, #fff4e0);
  border: 1px solid #f0e0c0;
  border-radius: 12px; padding: 14px 12px; text-align: center;
  transition: transform 0.15s;
}
.badge-card:hover { transform: scale(1.03); }
.badge-emoji { font-size: 32px; margin-bottom: 4px; }
.badge-title { font-size: 13px; font-weight: 600; color: #5a4520; }
.badge-desc  { font-size: 11px; color: #8a7050; margin-top: 2px; }
.badge-locked {
  background: #f0f0f0; border-color: #d8d8d8;
  filter: grayscale(0.8); opacity: 0.55;
}

/* Регистрации - топ рекрутеров */
.recruit-list { list-style: none; padding: 0; margin: 0; }
.recruit-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid rgba(60,100,60,0.06); }
.recruit-row:last-child { border-bottom: none; }
.recruit-place { flex: 0 0 36px; font-size: 18px; font-weight: 600; color: #6b8e6f; text-align: center; }
.recruit-name { flex: 1; color: #3d5a40; font-weight: 500; text-decoration: none; }
.recruit-name:hover { color: #4a7a4f; text-decoration: underline; }
.recruit-count { background: #d4e8d6; color: #2d5a32; padding: 3px 10px; border-radius: 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }

.lb-list { list-style: none; padding: 0; margin: 0; }
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(60,100,60,0.06);
}
.lb-row:last-child { border-bottom: none; }
.lb-place {
  flex: 0 0 32px; font-size: 18px; font-weight: 600;
  color: #6b8e6f; text-align: center;
}
.lb-name { flex: 1; color: #3d5a40; font-weight: 500; }
.lb-stats { color: #8aa68d; font-size: 13px; }
.lb-me { background: linear-gradient(90deg, #eaf5eb, transparent 80%); border-radius: 10px; padding-left: 8px; }

/* Уровень - страница */
.lvl-hero {
  background: rgba(255,255,255,0.85);
  border-radius: 20px;
  padding: 28px 30px;
  margin-bottom: 24px;
  border-left: 6px solid var(--lvl-color);
  display: flex; align-items: center; gap: 24px;
}
.lvl-hero-emoji { font-size: 64px; }
.lvl-hero-tag { font-size: 12px; color: #8aa68d; text-transform: uppercase; }
.lvl-hero-title { font-size: 28px; color: #3d5a40; margin: 4px 0 6px; }
.lvl-hero-desc { color: #6b8e6f; font-size: 15px; line-height: 1.5; }

.lessons-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-row {
  background: rgba(255,255,255,0.85);
  border-radius: 14px; padding: 16px 20px;
  border: 1px solid rgba(60,100,60,0.06);
  display: flex; align-items: center; gap: 16px;
  transition: background 0.15s;
}
.lesson-row.lesson-done { background: linear-gradient(90deg, #eaf5eb, rgba(255,255,255,0.85) 70%); }
.lesson-check { font-size: 22px; flex: 0 0 28px; }
.lesson-body { flex: 1; }
.lesson-title { font-size: 16px; font-weight: 600; color: #3d5a40; }
.lesson-desc  { font-size: 13px; color: #6b8e6f; margin-top: 3px; }
.lesson-meta  { font-size: 12px; color: #c47a20; margin-top: 4px; font-weight: 500; }
.lesson-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.lesson-status { color: #4a7a4f; font-size: 14px; font-weight: 500; }
.lesson-complete-btn { padding: 8px 16px; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; right: 24px; bottom: 24px;
  background: white; border-radius: 16px;
  padding: 16px 22px;
  box-shadow: 0 12px 36px rgba(60,100,60,0.20);
  border: 1px solid #c8e0ca;
  min-width: 240px; max-width: 340px;
  animation: slide-in 0.3s ease;
  z-index: 1000;
}
@keyframes slide-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast-xp { font-size: 20px; font-weight: 600; color: #4a7a4f; }
.toast-badges { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.toast-badge {
  background: linear-gradient(135deg, #fff4e0, #ffe9c0);
  padding: 10px 14px; border-radius: 12px;
  font-size: 14px; color: #5a4520; line-height: 1.35;
}
.toast-badge span { color: #8a7050; font-size: 12px; }

/* Дерево команды */
.tree-controls {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.view-toggle {
  display: inline-flex; background: #eaf0e9;
  border-radius: 10px; padding: 3px; gap: 2px;
}
.view-btn {
  background: transparent; border: none;
  padding: 8px 16px; border-radius: 8px;
  color: #5a7a5d; font: inherit; font-size: 14px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.view-btn:hover { background: rgba(255,255,255,0.5); }
.view-btn.active {
  background: white; color: #3d5a40;
  box-shadow: 0 2px 6px rgba(60,100,60,0.08);
}

.tree-visual {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid rgba(60,100,60,0.06);
  position: relative;   /* якорь для кнопок зума */
}
.visual-breadcrumb {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px;
  font-size: 14px; color: #6b8e6f;
}
.visual-breadcrumb a { color: #3d7a45; text-decoration: none; font-weight: 500; }
.visual-breadcrumb a:hover { text-decoration: underline; }
.bc-sep { color: #b0c8b3; }
.bc-current { color: #3d5a40; font-weight: 600; }
.visual-canvas-wrap {
  width: 100%; overflow-x: auto; overflow-y: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
#visual-svg { display: block; }

/* Кнопки зума карты — закреплены в углу панели, не уезжают со скроллом */
.zoom-controls {
  position: absolute; top: 16px; right: 16px; z-index: 8;
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--accent-border, #d4e1d6);
  border-radius: 12px; padding: 4px 6px;
  box-shadow: 0 4px 14px rgba(60,100,60,0.14);
}
.zoom-controls button {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 18px;
  color: var(--accent-text, #3d5a40); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.zoom-controls button:hover { background: var(--accent-soft, #f3f8f3); }
#zoom-label { font-size: 12px; color: #6b8e6f; min-width: 38px; text-align: center; }

.node-svg:hover rect:first-of-type {
  filter: brightness(0.96);
}

/* Тёмная тема для карты дерева */
html.dark-active .tree-visual {
  background: var(--d-surface) !important;
  border-color: var(--d-border) !important;
}
html.dark-active .visual-canvas-wrap { background: transparent; }
html.dark-active .zoom-controls {
  background: var(--d-surface-2); border-color: var(--d-border-2);
}
html.dark-active .zoom-controls button { color: var(--d-text); }
html.dark-active .zoom-controls button:hover { background: var(--d-surface-3); }
html.dark-active .visual-breadcrumb a { color: #7fc98a; }
html.dark-active .bc-current { color: var(--d-text-strong); }
.node-svg:hover rect:first-of-type {
  filter: brightness(0.96);
}

.filter-btn {
  background: white;
  border: 1px solid #c8dcc9;
  color: #5a7a5d;
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit; font-size: 14px;
  cursor: pointer; transition: all 0.15s;
}
.filter-btn:hover { background: #f0f7f1; }
.filter-btn.active {
  background: #fdf6e8;
  border-color: #e6cf94;
  color: #8a6a20;
}

.tree-search-block {
  position: relative; flex: 1; min-width: 240px;
}
.tree-search-block input {
  width: 100%; padding: 14px 18px;
  border: 1px solid #c8dcc9; border-radius: 14px;
  font: inherit; font-size: 15px;
  background: rgba(255,255,255,0.85);
  color: #2d3e2f; outline: none;
}
.tree-search-block input:focus { border-color: #4a7a4f; }

.search-results {
  position: absolute; top: 54px; left: 0; right: 0;
  background: white; border-radius: 14px;
  box-shadow: 0 8px 28px rgba(60,100,60,0.16);
  max-height: 420px; overflow-y: auto;
  display: none; z-index: 10;
}
.search-results.open { display: block; }
.search-item {
  padding: 12px 18px; cursor: pointer;
  border-bottom: 1px solid rgba(60,100,60,0.06);
  display: flex; align-items: center;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #f0f7f1; }
.search-name { color: #3d5a40; font-size: 15px; }
.search-meta { font-size: 12px; color: #6b8e6f; margin-top: 2px; }
.search-empty { padding: 20px; text-align: center; color: #8aa68d; }

.tree-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 20px 24px;
  border: 1px solid rgba(60,100,60,0.06);
}

.tree-list, .tree-children {
  list-style: none; padding: 0; margin: 0;
}
.tree-children {
  margin-left: 28px;
  border-left: 1px dashed rgba(60,100,60,0.15);
  padding-left: 12px;
  display: none;
}
.tree-node.expanded > .tree-children { display: block; }

.node-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  transition: background 0.15s;
}
.node-row.expandable { cursor: pointer; }
.node-row.expandable:hover { background: #f0f7f1; }
.node-row.highlight { background: #d4e8d6; animation: pulse 0.6s ease; }
@keyframes pulse {
  0% { transform: scale(0.98); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}
.node-root { background: rgba(74, 122, 79, 0.08); }

.node-toggle {
  flex: 0 0 18px; font-size: 11px;
  color: #6b8e6f; user-select: none;
}
.node-info { flex: 1; min-width: 0; }
.node-name { color: #2d3e2f; font-size: 15px; }
.node-rank {
  background: #eaf0e9; color: #5a7a5d;
  padding: 2px 8px; border-radius: 8px;
  font-size: 11px; margin-left: 4px;
  font-weight: 500; letter-spacing: 0.2px;
}
/* doTERRA-цвета рангов */
.node-rank[data-rank="Консультант"]              { background: #c8a8e6; color: #fff; }
.node-rank[data-rank="Менеджер"]                 { background: #a47fd4; color: #fff; }
.node-rank[data-rank="Директор"]                 { background: #6a4ca8; color: #fff; }
.node-rank[data-rank="Экзекьютив"]               { background: #2e7a3d; color: #fff; }
.node-rank[data-rank="Элит"]                     { background: #e8d63a; color: #4a4400; }
.node-rank[data-rank="Премьер"]                  { background: #d6478e; color: #fff; }
.node-rank[data-rank="Серебро"]                  { background: #b0b0b0; color: #fff; }
.node-rank[data-rank="Золото"]                   { background: #e89a3c; color: #fff; }
.node-rank[data-rank="Платина"]                  { background: #1a1a1a; color: #fff; }
.node-rank[data-rank="Бриллиант"]                { background: #6dcfd4; color: #1a3d40; }
.node-rank[data-rank="Голубой Бриллиант"]        { background: #3a4ec6; color: #fff; }
.node-rank[data-rank="Президентский Бриллиант"]  { background: #5b32a3; color: #fff; }
.node-meta { font-size: 12px; color: #6b8e6f; margin-top: 2px; }
.node-row.is-recruit {
  background: linear-gradient(90deg, #fff8e8, transparent 80%);
  border-radius: 8px;
}
.my-recruit-star { font-size: 13px; }

/* Кто остыл - сворачиваемые блоки */
details.cool-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 0;
  margin-bottom: 14px;
  border: 1px solid rgba(60,100,60,0.06);
  overflow: hidden;
}
summary.cool-summary {
  list-style: none !important;
  list-style-type: none !important;
  cursor: pointer;
  padding: 20px 28px;
  display: flex !important;
  align-items: center;
  gap: 14px;
  user-select: none;
  transition: background 0.15s;
}
summary.cool-summary::-webkit-details-marker { display: none !important; }
summary.cool-summary::marker { content: "" !important; }
details.cool-block > summary.cool-summary:hover { background: rgba(60,100,60,0.04); }
details.cool-block > summary > .cool-h {
  font-size: 18px; font-weight: 600; color: #3d5a40;
  flex: 1;
}
details.cool-block > summary > .cool-count {
  background: #eaf0e9; color: #5a7a5d;
  padding: 3px 12px; border-radius: 12px;
  font-size: 13px; font-weight: 600;
}
details.cool-block > summary > .cool-arrow {
  color: #8aa68d; font-size: 14px;
  transition: transform 0.2s ease;
}
details.cool-block[open] > summary > .cool-arrow { transform: rotate(180deg); }
details.cool-block > *:not(summary) {
  padding-left: 28px; padding-right: 28px;
}
details.cool-block > *:last-child { padding-bottom: 22px; }
details.cool-block .subtitle { font-size: 14px; color: #6b8e6f; }

.cool-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.cool-card {
  background: white;
  border-radius: 12px; padding: 14px 16px;
  border: 1px solid rgba(60,100,60,0.08);
}
.cool-card-hot   { border-left: 3px solid #c66; }
.cool-card-warm  { border-left: 3px solid #d99655; }
.cool-card-cold  { border-left: 3px solid #b0c8b3; }
.cool-head {
  display: flex; justify-content: space-between; gap: 10px;
  margin-bottom: 6px;
}
.cool-name { font-size: 15px; font-weight: 600; color: #3d5a40; }
.cool-meta { font-size: 12px; color: #6b8e6f; }
.cool-days {
  background: #eaf0e9; color: #5a7a5d;
  padding: 2px 8px; border-radius: 8px;
  font-size: 12px; white-space: nowrap;
}
.cool-prev { font-size: 13px; color: #4a6b4d; margin-bottom: 6px; }
.cool-contacts a {
  margin-right: 12px; font-size: 13px; font-weight: 500;
  color: #3d7a45;
}

/* Новые участники */
.new-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.new-header .subtitle { color: #6b8e6f; font-size: 15px; }

.new-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.new-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(60,100,60,0.08);
}
.new-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.new-name { font-size: 17px; font-weight: 600; color: #3d5a40; margin-bottom: 2px; }
.new-meta { font-size: 13px; color: #6b8e6f; }
.new-pv {
  background: #d4e8d6; color: #2d5a32;
  padding: 4px 10px; border-radius: 10px;
  font-weight: 600; font-size: 13px; white-space: nowrap;
}
.new-contacts, .new-sponsor {
  font-size: 14px; color: #4a6b4d; margin-top: 6px;
}
.new-contacts a { margin: 0 6px; color: #3d7a45; font-weight: 500; }
.new-contacts-label, .new-sponsor-label {
  color: #6b8e6f; margin-right: 6px;
}

a.range-btn { text-decoration: none; }
a.range-btn:hover { text-decoration: none; }

/* Сила Трёх */
.p3-status {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.status-card {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px;
  border: 1px solid rgba(60,100,60,0.06);
  text-align: center;
}
.status-card.status-done { background: #d4e8d6; border-color: #a8c8aa; }
.status-emoji { font-size: 40px; margin-bottom: 8px; }
.status-label { color: #6b8e6f; font-size: 13px; margin-bottom: 6px; }
.status-value { font-size: 22px; font-weight: 600; color: #3d5a40; margin-bottom: 4px; }
.status-bonus { color: #6b8e6f; font-size: 13px; }

.p3-block {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: 18px;
  padding: 24px 28px;
  margin-bottom: 20px;
  border: 1px solid rgba(60,100,60,0.06);
}
.p3-block h2 { font-size: 19px; font-weight: 600; color: #3d5a40; margin-bottom: 8px; }
.p3-block .subtitle { font-size: 14px; color: #6b8e6f; }

.p3-list { list-style: none; padding: 0; margin: 0; }
.p3-list li {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid rgba(60,100,60,0.06);
  font-size: 15px;
}
.p3-list li:last-child { border-bottom: none; }
.p3-emoji { font-size: 18px; flex: 0 0 24px; }
.p3-name { flex: 1; color: #2d3e2f; }
.p3-pv { color: #6b8e6f; font-variant-numeric: tabular-nums; }

.p3-cta { text-align: center; }
.p3-cta h2 { margin-bottom: 8px; }

@media (max-width: 600px) {
  .status-card { padding: 18px; }
  .p3-block { padding: 18px 20px; }
}

/* Markdown в ответах ассистента */
.msg-bubble h2 { font-size: 18px; font-weight: 600; margin: 12px 0 6px; color: #3d5a40; }
.msg-bubble h3 { font-size: 16px; font-weight: 600; margin: 10px 0 4px; color: #3d5a40; }
.msg-bubble h4 { font-size: 15px; font-weight: 600; margin: 8px 0 4px; color: #3d5a40; }
.msg-bubble h2:first-child, .msg-bubble h3:first-child, .msg-bubble h4:first-child { margin-top: 0; }
.msg-bubble b, .msg-bubble strong { font-weight: 600; }
.msg-bubble ul, .msg-bubble ol { margin: 8px 0; padding-left: 22px; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble code {
  background: rgba(60,100,60,0.08);
  padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 0.92em;
}
.msg-bubble pre {
  background: rgba(60,100,60,0.08);
  padding: 12px 14px; border-radius: 8px;
  margin: 8px 0; overflow-x: auto;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-bubble a { color: #3d7a45; text-decoration: underline; }
.msg-user .msg-bubble a { color: #d4e8d6; }

.tile-link {
  text-decoration: none; color: inherit; display: block;
}

@media (max-width: 600px) {
  .chat-wrap { padding: 0 8px; }
  .msg-bubble { max-width: 88%; font-size: 14px; padding: 12px 14px; }
}

/* === Переключатель валюты === */
.cur-switcher { position: relative; display: inline-block; }
.cur-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; background: rgba(255,255,255,0.9);
  border: 1px solid #d4e1d6; border-radius: 10px;
  color: #3d5a40; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: all 0.15s;
}
.cur-btn:hover { background: #f3f8f3; border-color: #6ea676; }
.cur-flag { font-size: 16px; line-height: 1; }
.cur-code { letter-spacing: 0.4px; }
.cur-arrow { opacity: 0.5; font-size: 10px; margin-left: 2px; }
.cur-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: white; border: 1px solid #e0eae2; border-radius: 10px;
  box-shadow: 0 8px 20px rgba(60,100,60,0.12);
  z-index: 100; min-width: 130px; padding: 4px;
}
.cur-opt {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 12px; background: none; border: none; cursor: pointer;
  color: #3d5a40; font-size: 14px; border-radius: 6px;
  text-align: left;
}
.cur-opt:hover { background: #f3f8f3; }
.cur-opt-active { background: #eaf3eb; font-weight: 600; }
.cur-check { margin-left: auto; color: #3d7a48; }

/* === Онбординг-тур === */
.tour-overlay {
  position: fixed; inset: 0; background: rgba(20, 40, 25, 0.55);
  z-index: 9000; backdrop-filter: blur(2px);
}
.tour-highlight {
  position: absolute; z-index: 9100;
  border: 3px solid #6ea676; border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(20,40,25,0.55), 0 0 28px rgba(110,166,118,0.7);
  background: transparent; pointer-events: none;
  transition: all 0.3s ease;
  animation: tourPulse 1.8s ease-in-out infinite;
}
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(20,40,25,0.55), 0 0 28px rgba(110,166,118,0.5); }
  50% { box-shadow: 0 0 0 9999px rgba(20,40,25,0.55), 0 0 36px rgba(110,166,118,0.9); }
}
.tour-card {
  position: absolute; z-index: 9200; width: 340px;
  background: white; border-radius: 14px; padding: 20px 22px;
  box-shadow: 0 18px 50px rgba(20,40,25,0.35);
  font-family: inherit;
}
.tour-skip {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  font-size: 24px; color: #b5b5b5; cursor: pointer; line-height: 1;
  width: 28px; height: 28px; border-radius: 50%;
}
.tour-skip:hover { background: #f5f5f5; color: #c94d4d; }
.tour-title { font-size: 17px; font-weight: 700; color: #3d5a40; margin-bottom: 8px; padding-right: 30px; }
.tour-text { color: #4a6b4d; font-size: 14px; line-height: 1.5; margin-bottom: 16px; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-prev, .tour-next {
  background: #4a7a4f; color: white; border: none; border-radius: 8px;
  padding: 8px 16px; font-weight: 600; font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.tour-prev { background: #d4e1d6; color: #3d5a40; }
.tour-prev:hover:not([disabled]) { background: #c0d5c4; }
.tour-prev[disabled] { opacity: 0.4; cursor: not-allowed; }
.tour-next:hover { background: #3d6842; }
.tour-count { font-size: 12px; color: #8aa68d; }

@media (max-width: 540px) {
  .tour-card { width: calc(100vw - 24px); left: 12px !important; right: 12px; }
}
