/* ================================================================
   CRM sidebar — общий для CRM, Трекера и TikTok Ads.
   Чёрная колонна: все разделы видны сразу, сгруппированы.
   .crm-sidebar--pinned = развёрнуто (по умолчанию); без него — рейка иконок.
   ================================================================ */

/* --- Layout shell --- */
.crm-public-layout {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  min-height: 100dvh;
}

.crm-public-main {
  flex: 1;
  min-width: 0;
}

/* --- Sidebar root --- */
.crm-sidebar {
  --sb-w: 64px;
  --sb-w-open: 248px;
  --sb-bg: #1a1a1a;
  --sb-active: #303030;
  --sb-field: #2b2b2b;
  --sb-line: rgba(255, 255, 255, .08);
  --sb-text: #e3e3e3;
  --sb-muted: #8f8f8f;
  --sb-icon: #b5b5b5;
  --sb-radius: 8px;
  --sb-ease: cubic-bezier(.22, 1, .36, 1);
  --sb-font: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;

  position: sticky;
  top: 0;
  z-index: 40;
  height: 100vh;
  height: 100dvh;
  align-self: flex-start;
  flex-shrink: 0;
  width: var(--sb-w);
  background: var(--sb-bg);
  color: var(--sb-text);
  font-family: var(--sb-font);
  transition: width .2s var(--sb-ease);
}

.crm-sidebar--pinned {
  width: var(--sb-w-open);
}

/* Контент лежит «листом» на чёрной раме: скруглённые углы у края меню. */
.crm-sidebar::before,
.crm-sidebar::after {
  content: "";
  position: absolute;
  left: 100%;
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.crm-sidebar::before {
  top: 0;
  background: radial-gradient(circle at 100% 100%, transparent 11.5px, var(--sb-bg) 12px);
}

.crm-sidebar::after {
  bottom: 0;
  background: radial-gradient(circle at 100% 0, transparent 11.5px, var(--sb-bg) 12px);
}

.crm-sidebar__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* --- SVG icon base --- */
.crm-sidebar__svg {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: currentColor;
}

.crm-sidebar__svg--stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --- Brand --- */
.crm-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 10px;
}

.crm-sidebar__brand-link {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: -4px;
  padding: 4px;
  border-radius: 10px;
  color: #fff;
  text-decoration: none;
  transition: background-color .15s ease;
}

.crm-sidebar__brand-link:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.crm-sidebar__brand-link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .7);
  outline-offset: 0;
}

.crm-sidebar__brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  object-fit: contain;
}

.crm-sidebar__brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.crm-sidebar__brand-text {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.crm-sidebar__brand-sub {
  overflow: hidden;
  color: var(--sb-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* --- Search --- */
.crm-sidebar__search {
  position: relative;
  margin: 2px 12px 10px;
}

.crm-sidebar__search[hidden] {
  display: none;
}

.crm-sidebar__search-input {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  padding: 0 30px 0 32px;
  border: 1px solid transparent;
  border-radius: var(--sb-radius);
  background: var(--sb-field);
  color: #fff;
  font: 500 13px/1 var(--sb-font);
  outline: none;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.crm-sidebar__search-input::placeholder {
  color: var(--sb-muted);
  opacity: 1;
}

.crm-sidebar__search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.crm-sidebar__search-input:hover {
  background: #333;
}

/* main.css задаёт всем полям фиолетовый фокус через !important; в чёрном меню — нейтральный. */
.crm-sidebar .crm-sidebar__search-input:focus {
  border-color: rgba(255, 255, 255, .3) !important;
  background: #111;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .07) !important;
}

.crm-sidebar__search-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  color: var(--sb-muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.crm-sidebar__search-icon .crm-sidebar__svg {
  width: 14px;
  height: 14px;
}

.crm-sidebar .crm-sidebar__search-key {
  position: absolute;
  top: 50%;
  right: 7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 5px;
  background: transparent;
  box-shadow: none;
  color: var(--sb-muted);
  font: 600 11px/16px var(--sb-font);
  text-align: center;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .15s ease;
}

.crm-sidebar__search-input:focus ~ .crm-sidebar__search-key,
.crm-sidebar__search-input:not(:placeholder-shown) ~ .crm-sidebar__search-key {
  opacity: 0;
}

/* --- Nav area --- */
.crm-sidebar__nav {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 8px 20px;
  overscroll-behavior: contain;
  /* Нижний край растворяется — видно, что список прокручивается дальше. */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 20px), transparent);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .16) transparent;
}

.crm-sidebar__nav::-webkit-scrollbar {
  width: 6px;
}

.crm-sidebar__nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
}

.crm-sidebar__group {
  margin: 0;
  padding: 0;
}

.crm-sidebar__group + .crm-sidebar__group {
  margin-top: 12px;
}

/* Группа без заголовка (ИИ-помощник над разделами): отделена тонкой линией. */
.crm-sidebar__group--top {
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--sb-line);
}

/* Заголовок группы прилипает, пока её пункты на экране. */
.crm-sidebar__group-label {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 6px 8px 4px;
  background: var(--sb-bg);
  color: var(--sb-muted);
  font: 600 12px/16px var(--sb-font);
  letter-spacing: 0;
  text-transform: none;
}

/* Пометка раздела в разработке («скоро») рядом с названием группы. */
/* Логотип рекламной площадки у названия группы (TikTok Ads, Meta Ads) — те же, что у кампаний. */
.crm-sidebar__group-logo {
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* Логотип TikTok — чёрный знак: на тёмном меню делаем его цвета подписи группы. */
.crm-sidebar__group-logo--tiktok {
  filter: invert(1);
  opacity: .62;
}

.crm-sidebar__group-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .1);
  color: var(--sb-text);
  font: 600 11px/16px var(--sb-font);
  vertical-align: top;
}

/* Пометка подписки у «Тарифов»: пробный период, скорый конец, долг. */
.crm-sidebar__plans-note {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .1);
  color: var(--sb-text);
  font: 600 11px/16px var(--sb-font);
  vertical-align: 1px;
}
.crm-sidebar__plans-note--info   { background: rgba(34, 211, 238, .14); color: #a5f3fc; }
.crm-sidebar__plans-note--warn   { background: rgba(253, 186, 116, .16); color: #fed7aa; }
.crm-sidebar__plans-note--danger { background: rgba(248, 113, 113, .18); color: #fecaca; }
/* В свёрнутом меню подписи не видно: о долге напоминает точка на иконке. */
.crm-sidebar__link--alert .crm-sidebar__icon { position: relative; }
.crm-sidebar__link--alert .crm-sidebar__icon::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f87171;
  box-shadow: 0 0 0 2px var(--sb-bg, #1f1f1f);
}

.crm-sidebar__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.crm-sidebar__sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--sb-line);
  list-style: none;
}

.crm-sidebar--filtering .crm-sidebar__sep {
  display: none;
}

.crm-sidebar__empty {
  margin: 4px 8px;
  color: var(--sb-muted);
  font-size: 12px;
  line-height: 1.45;
}

.crm-sidebar__empty[hidden],
.crm-sidebar [data-crm-sidebar-item][hidden],
.crm-sidebar [data-crm-sidebar-group][hidden] {
  display: none;
}

/* --- Nav link --- */
.crm-sidebar__link {
  --accent: #b5b5b5;
  --accent-r: 181, 181, 181;

  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 30px;
  margin: 0;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--sb-radius);
  background: transparent;
  color: var(--sb-text);
  font: 500 13px/20px var(--sb-font);
  letter-spacing: 0;
  text-align: start;
  text-decoration: none;
  text-transform: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color .15s ease, background-color .15s ease;
}

.crm-sidebar__link:hover,
.crm-sidebar__link:focus-visible {
  color: #fff;
}

/* Без JS (нет «бегунка») — обычная подсветка строки. */
.crm-sidebar:not(.crm-sidebar--glide) .crm-sidebar__link:hover {
  background: rgba(255, 255, 255, .07);
}

.crm-sidebar__link:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .72);
  outline-offset: -2px;
}

.crm-sidebar__link--active {
  background: var(--sb-active);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 0 rgba(0, 0, 0, .45);
  color: #fff;
  font-weight: 600;
}

/* Наведение на активный пункт: его подложка уступает «бегунку», чтобы пункт
   подсветился так же, как остальные, а свечение не выглядывало из-под него. */
.crm-sidebar--glide .crm-sidebar__link--active:hover {
  background: transparent;
  box-shadow: none;
}

.crm-sidebar__link--disabled {
  cursor: not-allowed;
  opacity: .38;
  pointer-events: none;
}

.crm-sidebar__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--sb-icon);
  transition: color .18s ease, transform .35s var(--sb-ease);
}

.crm-sidebar__icon svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.crm-sidebar__link:hover .crm-sidebar__icon,
.crm-sidebar__link:focus-visible .crm-sidebar__icon {
  color: var(--accent);
  transform: scale(1.14);
}

.crm-sidebar__link--active .crm-sidebar__icon {
  color: var(--accent);
}

.crm-sidebar__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Оптическое выравнивание: иконки, которые занимают меньше своего квадрата
   (замер bbox, 2026-10-29), подтягиваются до общего визуального размера. */
.crm-sidebar__link--tt-integrations .crm-sidebar__icon svg { transform: scale(1.25); }
.crm-sidebar__link--messenger .crm-sidebar__icon svg,
.crm-sidebar__link--logs .crm-sidebar__icon svg { transform: scale(1.11); }
.crm-sidebar__link--tt-jobs .crm-sidebar__icon svg,
.crm-sidebar__link--tt-rules .crm-sidebar__icon svg { transform: scale(1.1); }
.crm-sidebar__link--feedback .crm-sidebar__icon svg { transform: scale(1.09); }
.crm-sidebar__link--stats .crm-sidebar__icon svg,
.crm-sidebar__link--pipelines .crm-sidebar__icon svg,
.crm-sidebar__link--tt-costs .crm-sidebar__icon svg { transform: scale(1.06); }
/* Палочка рисуется мельче соседей (13,3 px против 15–16) — выравниваем оптически. */
.crm-sidebar__link--assistant .crm-sidebar__icon svg { transform: scale(1.15); }
.crm-sidebar .crm-sidebar__theme-btn svg { transform: scale(1.14); }

/* --- Hover «бегунок»: одна подсветка скользит между пунктами
       и перетекает в цвет раздела под курсором. --- */
@property --glider-color {
  syntax: "<color>";
  inherits: true;
  initial-value: rgb(181, 181, 181);
}

.crm-sidebar__glider {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 0;
  height: 0;
  border-radius: var(--sb-radius);
  background: rgba(255, 255, 255, .07);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--glider-color) 24%, transparent),
    color-mix(in srgb, var(--glider-color) 7%, transparent) 60%,
    rgba(255, 255, 255, .045));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--glider-color) 22%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(var(--glider-x, 0px), var(--glider-y, 0px), 0);
  transition: transform .34s var(--sb-ease),
              width .34s var(--sb-ease),
              height .34s var(--sb-ease),
              --glider-color .34s linear,
              opacity .18s ease;
}

.crm-sidebar__glider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 3px;
  height: 14px;
  margin-top: -7px;
  border-radius: 0 3px 3px 0;
  background: var(--glider-color);
  box-shadow: 0 0 12px 1px var(--glider-color);
}

.crm-sidebar__glider.is-visible {
  opacity: 1;
}

.crm-sidebar__glider.is-snapping {
  transition: opacity .18s ease;
}

/* --- Per-section accent colours --- */
.crm-sidebar__link--messenger       { --accent: #22d3ee; --accent-r: 34, 211, 238; }
.crm-sidebar__link--pipelines       { --accent: #60a5fa; --accent-r: 96, 165, 250; }
.crm-sidebar__link--automation      { --accent: #fbbf24; --accent-r: 251, 191, 36; }
.crm-sidebar__link--macros          { --accent: #c4b5fd; --accent-r: 196, 181, 253; }
.crm-sidebar__link--bots            { --accent: #38bdf8; --accent-r: 56, 189, 248; }
.crm-sidebar__link--posting         { --accent: #a78bfa; --accent-r: 167, 139, 250; }
.crm-sidebar__link--assistant       { --accent: #c084fc; --accent-r: 192, 132, 252; }
.crm-sidebar__link--onboarding      { --accent: #4ade80; --accent-r: 74, 222, 128; }
.crm-sidebar__link--campaigns       { --accent: #f59e0b; --accent-r: 245, 158, 11; }
.crm-sidebar__link--offers          { --accent: #38bdf8; --accent-r: 56, 189, 248; }
.crm-sidebar__link--landings        { --accent: #22d3ee; --accent-r: 34, 211, 238; }
.crm-sidebar__link--domains         { --accent: #60a5fa; --accent-r: 96, 165, 250; }
.crm-sidebar__link--pixels          { --accent: #e879f9; --accent-r: 232, 121, 249; }
.crm-sidebar__link--affiliates      { --accent: #fb923c; --accent-r: 251, 146, 60; }
.crm-sidebar__link--stats           { --accent: #34d399; --accent-r: 52, 211, 153; }
.crm-sidebar__link--clicks          { --accent: #f472b6; --accent-r: 244, 114, 182; }
.crm-sidebar__link--orders          { --accent: #a3e635; --accent-r: 163, 230, 53; }
.crm-sidebar__link--logs            { --accent: #94a3b8; --accent-r: 148, 163, 184; }
.crm-sidebar__link--tt-overview, .crm-sidebar__link--meta-overview, .crm-sidebar__link--google-overview { --accent: #25f4ee; --accent-r: 37, 244, 238; }
.crm-sidebar__link--tt-accounts, .crm-sidebar__link--meta-accounts, .crm-sidebar__link--google-accounts { --accent: #38bdf8; --accent-r: 56, 189, 248; }
.crm-sidebar__link--tt-campaigns, .crm-sidebar__link--meta-campaigns, .crm-sidebar__link--google-campaigns { --accent: #fb7185; --accent-r: 251, 113, 133; }
/* «Автоправила» — фиолетовый «автоматики», «Каталоги» — зелёный «товаров»: рядом с оранжевыми «Креативами»
   жёлтые оттенки сливались. Пункты Meta и Google — тех же цветов, что у TikTok: меню не меняется при смене площадки. */
.crm-sidebar__link--tt-rules, .crm-sidebar__link--meta-rules, .crm-sidebar__link--google-rules { --accent: #a78bfa; --accent-r: 167, 139, 250; }
.crm-sidebar__link--tt-launch, .crm-sidebar__link--meta-launch, .crm-sidebar__link--google-launch { --accent: #f472b6; --accent-r: 244, 114, 182; }
.crm-sidebar__link--tt-library, .crm-sidebar__link--meta-library, .crm-sidebar__link--google-library { --accent: #f59e0b; --accent-r: 245, 158, 11; }
.crm-sidebar__link--tt-templates    { --accent: #c084fc; --accent-r: 192, 132, 252; }
.crm-sidebar__link--tt-catalogs, .crm-sidebar__link--meta-catalogs { --accent: #4ade80; --accent-r: 74, 222, 128; }
.crm-sidebar__link--tt-jobs         { --accent: #a78bfa; --accent-r: 167, 139, 250; }
.crm-sidebar__link--tt-costs        { --accent: #4ade80; --accent-r: 74, 222, 128; }
.crm-sidebar__link--tt-integrations { --accent: #2dd4bf; --accent-r: 45, 212, 191; }
.crm-sidebar__link--tt-mail         { --accent: #93c5fd; --accent-r: 147, 197, 253; }
.crm-sidebar__link--tt-team         { --accent: #4ade80; --accent-r: 74, 222, 128; }
.crm-sidebar__link--tt-settings     { --accent: #f87171; --accent-r: 248, 113, 113; }
.crm-sidebar__link--managers        { --accent: #f472b6; --accent-r: 244, 114, 182; }
.crm-sidebar__link--admin-groups    { --accent: #e879f9; --accent-r: 232, 121, 249; }
.crm-sidebar__link--departments     { --accent: #a78bfa; --accent-r: 167, 139, 250; }
.crm-sidebar__link--roles           { --accent: #fbbf24; --accent-r: 251, 191, 36; }
.crm-sidebar__link--plans           { --accent: #fdba74; --accent-r: 253, 186, 116; }
.crm-sidebar__link--feedback        { --accent: #22d3ee; --accent-r: 34, 211, 238; }
/* «Партнёры» (витрина сервисов со скидками): розовый, но не «Сотрудники». */
.crm-sidebar__link--partners        { --accent: #fb7185; --accent-r: 251, 113, 133; }
/* Финансы: лайм — «деньги», но не изумруд «Статистики» прямо над ним. */
.crm-sidebar__link--finance         { --accent: #a3e635; --accent-r: 163, 230, 53; }
/* «Команда» (пункт группы внизу меню): свой цвет вместо нейтрального серого. */
.crm-sidebar__link--team            { --accent: #818cf8; --accent-r: 129, 140, 248; }
.crm-sidebar__toggle                { --accent: #94a3b8; --accent-r: 148, 163, 184; }

/* --- Footer --- */
.crm-sidebar__footer {
  /* Опора для бегунка подвала: его координаты считаются от подвала. */
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 8px 10px;
  border-top: 1px solid var(--sb-line);
}

.crm-sidebar__user-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  margin-top: 6px;
  padding: 6px 0 0 6px;
  border-top: 1px solid var(--sb-line);
}

.crm-sidebar__user {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crm-sidebar__user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  background: #7ee2a8;
  color: #0b3b22;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.crm-sidebar__user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.crm-sidebar__user-name {
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.crm-sidebar__user-email {
  overflow: hidden;
  color: var(--sb-muted);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.crm-sidebar .crm-sidebar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  flex-shrink: 0;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: var(--sb-radius);
  background: transparent;
  color: var(--sb-icon);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.crm-sidebar .crm-sidebar__icon-btn svg {
  width: 16px;
  height: 16px;
  opacity: 1;
}

.crm-sidebar .crm-sidebar__icon-btn:hover,
.crm-sidebar .crm-sidebar__icon-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.crm-sidebar .crm-sidebar__icon-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .72);
  outline-offset: -2px;
}

.crm-sidebar .crm-sidebar__logout:hover {
  background: rgba(248, 113, 113, .14);
  color: #fca5a5;
}

.crm-sidebar__logout-form {
  display: flex;
  margin: 0;
}

/* Меню темы привязано к строке пользователя и открывается вверх на её ширину. */
.crm-sidebar .crm-sidebar__user-row .crm-theme-widget {
  position: static;
}

.crm-sidebar .crm-sidebar__user-row .crm-theme-menu {
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 0;
}

.crm-sidebar__toggle .crm-sidebar__icon {
  transition: color .18s ease, transform .35s var(--sb-ease);
}

/* --- Desktop: свёрнутая рейка иконок --- */
@media (min-width: 769px) {
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__nav {
    scrollbar-width: none;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__nav::-webkit-scrollbar {
    display: none;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__brand {
    justify-content: center;
    padding: 14px 0 10px;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__brand-link {
    flex: 0 0 auto;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__brand-copy,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__search,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__empty,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__user-text,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__user-row .crm-theme-widget,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__logout-form {
    display: none;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__label,
  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__group-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__group + .crm-sidebar__group {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--sb-line);
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__sep {
    margin-inline: 12px;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__link {
    justify-content: center;
    gap: 0;
    min-height: 34px;
    padding: 7px 0;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__user-row {
    justify-content: center;
    padding-left: 0;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__user {
    flex: 0 0 auto;
  }

  .crm-sidebar:not(.crm-sidebar--pinned) .crm-sidebar__toggle .crm-sidebar__icon {
    transform: scaleX(-1);
  }
}

/* --- Mobile shell --- */
.crm-mobile-header,
.crm-sidebar-backdrop,
.crm-sidebar__mobile-close {
  display: none;
}

.crm-sidebar-backdrop[hidden] {
  display: none !important;
}

.crm-mobile-header {
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 1040;
  align-items: center;
  gap: 10px;
  padding: env(safe-area-inset-top, 0px) 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: #1a1a1a;
  color: #e3e3e3;
}

.crm-mobile-menu-btn,
.crm-sidebar__mobile-close {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #2b2b2b;
  color: #fff;
  cursor: pointer;
}

.crm-mobile-menu-btn {
  display: inline-flex;
}

.crm-mobile-menu-btn .crm-sidebar__svg,
.crm-sidebar__mobile-close .crm-sidebar__svg {
  width: 20px;
  height: 20px;
}

.crm-mobile-menu-btn:hover,
.crm-sidebar__mobile-close:hover {
  background: #383838;
}

.crm-mobile-menu-btn:focus-visible,
.crm-sidebar__mobile-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .8);
  outline-offset: 2px;
}

.crm-mobile-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-family: Manrope, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.crm-mobile-brand:hover {
  color: #fff;
}

.crm-mobile-brand img {
  display: block;
  width: 30px;
  height: 30px;
}

.crm-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1045;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  :root {
    --crm-mobile-header-height: calc(60px + env(safe-area-inset-top, 0px));
  }

  .crm-public-layout {
    display: block;
    min-height: calc(100dvh - var(--crm-mobile-header-height));
  }

  .crm-mobile-header {
    display: flex;
    height: var(--crm-mobile-header-height);
  }

  .crm-public-main {
    min-height: calc(100dvh - var(--crm-mobile-header-height));
  }

  .crm-sidebar,
  .crm-sidebar.crm-sidebar--pinned {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    width: min(300px, calc(100vw - 32px));
    height: 100dvh;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    transition: transform .24s var(--sb-ease);
    will-change: transform;
  }

  .crm-sidebar::before,
  .crm-sidebar::after,
  .crm-sidebar__toggle,
  .crm-sidebar .crm-sidebar__search-key {
    display: none;
  }

  .crm-sidebar:focus {
    outline: none;
  }

  .crm-sidebar__brand {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .crm-sidebar__mobile-close {
    display: inline-flex;
  }

  .crm-sidebar__link {
    min-height: 40px;
    font-size: 14px;
  }

  .crm-sidebar__search-input {
    height: 40px;
    font-size: 16px;
  }

  .crm-sidebar__footer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  body.crm-sidebar-mobile-open,
  body.tt-sidebar-open {
    overflow: hidden;
  }

  body.crm-sidebar-mobile-open .crm-sidebar,
  body.tt-sidebar-open .crm-sidebar {
    box-shadow: 18px 0 48px rgba(0, 0, 0, .45);
    transform: translateX(0);
  }

  body.crm-sidebar-mobile-open .crm-sidebar-backdrop:not([hidden]) {
    display: block;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .crm-sidebar,
  .crm-sidebar__link,
  .crm-sidebar__icon,
  .crm-sidebar__glider,
  .crm-sidebar__search-input {
    transition-duration: .01ms;
  }

  .crm-sidebar__link:hover .crm-sidebar__icon,
  .crm-sidebar__link:focus-visible .crm-sidebar__icon {
    transform: none;
  }
}

/* Меню темы в палитре сайдбара: тёмная плашка, нейтральная подсветка строки,
   у выбранной темы — галочка (вместо светлого меню с фиолетовым пунктом). */
.crm-sidebar .crm-theme-menu {
  padding: 6px;
  border: 1px solid var(--sb-line);
  border-radius: 12px;
  background: #242424;
  color: var(--sb-text);
  box-shadow: 0 16px 36px -8px rgba(0, 0, 0, .6);
}

.crm-sidebar .crm-theme-menu__title {
  padding: 6px 10px 8px;
  color: var(--sb-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.crm-sidebar .crm-theme-option {
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--sb-radius);
  color: var(--sb-text);
  font-size: 13px;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}

.crm-sidebar .crm-theme-option:hover {
  background: var(--sb-active);
  color: #fff;
}

.crm-sidebar .crm-theme-option:focus-visible {
  outline: 2px solid #4b9bff;
  outline-offset: -2px;
  background: var(--sb-active);
}

.crm-sidebar .crm-theme-option[aria-checked="true"] {
  color: #fff;
  font-weight: 650;
}

.crm-sidebar .crm-theme-option .crm-theme-check {
  display: inline-grid;
  margin-left: auto;
  opacity: 1;
}

.crm-sidebar .crm-theme-check svg {
  width: 16px;
  height: 16px;
  color: #fff;
}
