/* ============================================================
   ППБ CRM — frontend
   Все CSS-переменные (--bg/--t1/--ac/--r/--fd и т.д.) теперь
   объявлены в design-tokens.css как алиасы на семантические токены.
   Подключение: design-tokens.css → style.css (см. index.html).
   При создании новых правил используй ТОЛЬКО семантические токены:
     var(--text-primary), var(--bg-surface), var(--action-primary),
     var(--status-success), var(--radius-md), var(--shadow-card)
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  height: 100%;
}
body {
  font-family: var(--fb);
  background: var(--bg);
  color: var(--t1);
  height: 100%;
  min-height: 100vh;
  /* Глобально предотвращаем горизонтальный scroll — любой случайно
     широкий элемент (toolbar / kanban) не должен двигать весь viewport.
     overflow-x: hidden только на body (НЕ на html — это ломает grid). */
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse 600px 400px at 50% 0%, var(--brand-glow), transparent 70%),
    var(--bg-base);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
/* Брендовая полоса 4px сверху карточки в primary-цвете (sapphire blue
   #2178cb — Bitrix-стиль). Раньше тут был жёлтый ППБ — отказались. */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--brand-primary);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  min-height: 48px;
}
.login-logo img {
  max-height: 48px;
  max-width: 220px;
  object-fit: contain;
}
/* Fallback: если lo go.png не загружен — рендерим текст с данными
   из data-app-name (см. branding.js) */
.login-logo:not(:has(img)) {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  letter-spacing: 0.04em;
}
.login-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
  line-height: var(--line-height-sm);
}

/* ============================================================
   FORMS / BUTTONS / INPUTS (общие)
   ============================================================ */
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-sm);
}

/* ─── Input (default = md = 36px height) ────────────────────── */
.input {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  height: var(--size-control-md);
  padding: 0 var(--padding-control-md);
  width: 100%;
  margin-bottom: 12px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.input::placeholder { color: var(--text-disabled); }
.input:hover { border-color: var(--text-disabled); }
.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--bg-disabled);
}
/* iOS zoom prevention: 16px текста гарантирует что Safari не зумнёт
   при фокусе на input. Десктоп остаётся 14px (компактнее). */
@media (max-width: 768px) {
  .input { font-size: 16px; height: var(--size-control-lg); }     /* 44px touch target */
  .select, .dept-filter { font-size: 16px; height: var(--size-control-lg); }
  .btn { height: var(--size-control-lg); font-size: 15px; }        /* 44px */
  .btn.sm { height: var(--size-control-md); }                       /* 36px остаётся для sm */
  .icon-btn { width: 40px; height: 40px; }

  /* Topbar — компактнее на мобиле */
  .topbar { gap: 6px; flex-wrap: wrap; }
  .topbar .view-toggle { order: 99; flex-basis: 100%; }            /* view-toggle в свою строку */
  .page-title { font-size: var(--font-size-lg); }
  .page-title-icon svg { width: 20px; height: 20px; }

  /* Главные контентные area — убираем лишний padding */
  .main { padding: 16px 12px; }

  /* Toolbar — на мобиле только search видим, остальные фильтры скрыты
     (доступ через ⋯-меню при необходимости). Search/select 'Все' filter
     дают почти весь функционал. Большой выпадающий список фильтров на 320px
     был неюзабельным. */
  .users-toolbar, .deals-toolbar {
    padding: 8px 10px;
    gap: 6px;
  }
  .users-toolbar > .input,
  .deals-toolbar > #deals-search {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
  }
  /* Скрываем тяжёлые фильтры на мобиле — оставляем только search и reset */
  .deals-toolbar .deals-filter,
  .deals-toolbar .deals-filter-amount,
  .deals-toolbar .deals-filter-archive,
  .deals-toolbar .deals-toolbar-summary,
  .users-toolbar .dept-filter {
    display: none;
  }
  /* Customer-list — счётчик пагинации показываем под таблицей */
  #customers-count { display: block; margin: 8px 0 0 !important; }

  /* ============================================================
   * Таблицы на мобиле — превращаются в стек карточек.
   * Каждая строка таблицы = карта с парой ключевых полей.
   * Скрываем th и второстепенные td.
   * ============================================================ */
  .users-table-wrap,
  .deals-list-wrap {
    border: none;
    box-shadow: none;
    background: transparent;
    border-radius: 0;
    max-height: none;
    overflow: visible;
  }
  .users-table thead,
  .deals-list-table thead { display: none; }

  .users-table, .deals-list-table {
    display: block;
    width: 100%;
  }
  .users-table tbody, .deals-list-table tbody { display: block; width: 100%; }

  .users-table tr.row,
  .deals-list-table tr.deals-list-row {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-xs);
  }
  .users-table tr.row:hover td,
  .deals-list-table tr.deals-list-row:hover td {
    background: transparent;
  }

  .users-table tr.row td,
  .deals-list-table tr.deals-list-row td {
    display: block;
    padding: 2px 0;
    border: none;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
  }
  /* Первая колонка (имя/название) — крупнее, чёрным */
  .users-table tr.row td:first-child,
  .deals-list-table tr.deals-list-row td:first-child {
    font-size: var(--font-size-base);
    color: var(--text-primary);
    font-weight: var(--font-weight-medium);
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
    max-width: 100%;
  }
  /* Сумма (в deals-list) — крупнее, выделяется */
  .deals-list-table tr.deals-list-row td.num:first-of-type {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    text-align: left;
  }

  /* Kanban-колонки на мобиле — почти на весь экран */
  .crm-col { min-width: 88vw; max-width: 88vw; }

  /* Cmd+K на мобиле — full-width */
  .cmdk-panel { max-width: 100%; margin: 0 8px; }
  .cmdk-backdrop { padding: 60px 8px 8px; }

  /* Deal modal — компактнее на мобиле */
  .dc-chevrons {
    padding: 8px 10px;
    gap: 1px;
  }
  .deal-chevron { min-width: 80px; padding: 6px 4px 6px 14px; font-size: 10px; }
  .deal-chevron-label { font-size: 10px; }
  .dc-header { padding: 8px 12px; min-height: 48px; }
  .dc-header-title { font-size: var(--font-size-base); }
  .dc-left, .dc-right { padding: 12px 14px; }

  /* New deal modal на мобиле — full-screen */
  .modal-backdrop { padding: 0; }
  .modal {
    max-width: 100vw !important;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
  .modal-header { padding: 12px 16px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* ============================================================
   * Поповеры (Workday, Уведомления, Меню профиля) на мобиле
   * становятся BOTTOM SHEET — слайдят снизу на всю ширину.
   * Раньше: position: fixed + style.left = rect.right (с desktop
   * rail слева) → на мобиле уходили за правый край экрана.
   * ============================================================ */
  .workday-panel,
  .notif-center,
  .menu-popup {
    /* Принудительно прижимаем к низу + растягиваем на всю ширину */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .35);
    max-height: 70vh;
    overflow-y: auto;
    /* Учитываем safe-area для iPhone home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* Slide-up анимация */
    animation: sheet-slide-up 220ms ease-out;
  }
  .menu-popup { padding: 8px 8px env(safe-area-inset-bottom, 8px) 8px; }
  .menu-item { padding: 14px 16px; font-size: 15px; }

  @keyframes sheet-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* Bottom rail должен оставаться поверх контента и учитывать safe area */
  .app.active .rail {
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
  }
}

/* ─── Button (default = md = 36px = primary action) ─────────── */
.btn {
  background: var(--action-primary);
  border: 1px solid var(--action-primary);
  border-radius: var(--radius-md);
  color: var(--action-on-primary);
  cursor: pointer;
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  height: var(--size-control-md);
  padding: 0 var(--padding-control-lg);
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--action-primary-hover);
  border-color: var(--action-primary-hover);
}
.btn:active:not(:disabled) { background: var(--action-primary-active); }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Secondary — нейтральная кнопка (отмена, второстепенная) */
.btn.secondary {
  background: var(--action-secondary);
  color: var(--action-on-secondary);
  border-color: var(--action-secondary-border);
}
.btn.secondary:hover:not(:disabled) {
  background: var(--action-secondary-hover);
  border-color: var(--border-strong);
}

/* Brand — жёлтая кнопка, для брендовых моментов и зон где она безопасна
   (на dark surface или в hero блоке). На обычной форме НЕ используем. */
.btn.brand {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border-color: var(--brand-primary);
  font-weight: var(--font-weight-semibold);
}
.btn.brand:hover:not(:disabled) {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  box-shadow: var(--shadow-cta);
}

/* Status variants — кнопки действий с предупреждением о последствиях */
.btn.danger {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border-color: var(--status-danger-border);
}
.btn.danger:hover:not(:disabled) {
  background: var(--status-danger);
  color: #fff;
  border-color: var(--status-danger);
}
.btn.success {
  background: var(--status-success-bg);
  color: var(--status-success);
  border-color: var(--status-success-border);
}
.btn.success:hover:not(:disabled) {
  background: var(--status-success);
  color: #fff;
  border-color: var(--status-success);
}

/* Ghost — текстовая кнопка без фона */
.btn.ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: transparent;
}
.btn.ghost:hover:not(:disabled) { background: var(--action-ghost-hover); }

/* Размеры sm/lg */
.btn.sm {
  height: var(--size-control-sm);
  padding: 0 var(--padding-control-md);
  font-size: var(--font-size-sm);
  width: auto;
}
.btn.lg {
  height: var(--size-control-lg);
  padding: 0 24px;
  font-size: var(--font-size-md);
}

.error {
  background: var(--rdbg);
  border: 1px solid rgba(227,30,36,.3);
  border-radius: 8px;
  color: var(--rd);
  font-size: 12px;
  padding: 9px 12px;
  margin-bottom: 10px;
}

/* ============================================================
   APP LAYOUT — Slack style
   Rail (64px) | Second Panel (280px, optional) | Main (flex)
   ============================================================ */
.app {
  display: none;
  min-height: 100vh;
}
.app.active {
  display: grid;
  grid-template-rows: 100vh;
  /* По умолчанию rail узкий, second-panel скрыта */
  grid-template-columns: var(--rail-w) 1fr;
}
/* Когда есть вторая панель (Чат) */
.app.active.has-second-panel {
  grid-template-columns: var(--rail-w) var(--second-panel-w) 1fr;
}
/* Когда rail развёрнут (широкий с лейблами) */
.app.active.rail-expanded {
  grid-template-columns: var(--rail-expanded-w) 1fr;
}

/* HOVER-EXPAND: на desktop sidebar расширяется когда курсор над .rail.
   Используем CSS-only через :hover на родительском .app.
   Mobile/touch — отключаем (см. @media max-width: 768px ниже). */
@media (hover: hover) and (min-width: 769px) {
  .app.active:has(.rail:hover) {
    grid-template-columns: var(--rail-expanded-w) 1fr;
  }
  .app.active.has-second-panel:has(.rail:hover) {
    grid-template-columns: var(--rail-expanded-w) var(--second-panel-w) 1fr;
  }
  /* Внутри rail переключаемся в expanded-режим — показываем lables + logo-text */
  .app.active .rail:hover {
    align-items: stretch;
    padding: 12px 10px;
  }
  .app.active .rail:hover .rail-logo {
    width: auto;
    height: 44px;
    padding: 0 8px;
    justify-content: flex-start;
    align-self: stretch;
    gap: 10px;
    overflow: hidden;
  }
  /* В expanded mode (hover) — переключаем картинки:
     mark прячем, full (широкий с текстом) показываем по натуральной ширине. */
  .app.active .rail:hover .rail-logo-mark {
    width: auto;
    height: 40px;
    flex-shrink: 0;
  }
  .app.active .rail:hover .rail-logo-mark .rail-logo-img-mark {
    display: none;
  }
  .app.active .rail:hover .rail-logo-mark .rail-logo-img-full {
    display: block;
    width: auto;
    height: 100%;
    max-width: 100%;
  }
  /* CSS-текст «ППБ CRM» рядом скрываем — он уже есть внутри картинки. */
  .app.active .rail:hover .rail-logo-text {
    display: none;
  }
  .app.active .rail:hover .rail-modules,
  .app.active .rail:hover .rail-bottom {
    align-items: stretch;
  }
  .app.active .rail:hover .rail-icon {
    width: 100%;
    justify-content: flex-start;
    padding: 0 10px;
    gap: 12px;
  }
  .app.active .rail:hover .rail-icon-label {
    display: inline;
    font-size: 13px;
    font-weight: 500;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app.active .rail:hover .rail-bottom-btn {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    padding: 0 10px;
    gap: 12px;
  }
  .app.active .rail:hover .rail-bottom-btn .rail-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
    margin: 0;
  }
  /* Плавный transition grid-template-columns */
  .app.active { transition: grid-template-columns 200ms ease; }
}
.app.active.rail-expanded.has-second-panel {
  grid-template-columns: var(--rail-expanded-w) var(--second-panel-w) 1fr;
}

/* ─── Rail (узкая панель модулей) — Bitrix-style dark navy ─── */
.rail {
  background: var(--rail-bg);
  border-right: 1px solid var(--rail-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 4px;
  color: var(--rail-text);
}

/* Rail logo — настоящее изображение бренд-марки ППБ (брендовые блоки).
   В collapsed виде — квадрат 40x40 с изображением, в expanded — лого + текст. */
.rail-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.rail-logo-mark {
  display: block;
  line-height: 1;
  width: 100%;
  height: 100%;
}
.rail-logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Default (collapsed rail): показываем квадратную mark-иконку, прячем wide. */
.rail-logo-mark .rail-logo-img-mark { display: block; }
.rail-logo-mark .rail-logo-img-full { display: none; }
.rail-logo-text { display: none; }

.rail-modules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--rail-divider);
  width: 100%;
  align-items: center;
}

.rail-spacer {
  flex: 1;
}

.rail-bottom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--rail-divider);
  width: 100%;
  align-items: center;
}

.rail-icon {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rail-text);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.rail-icon:hover {
  background: var(--rail-bg-hover);
  color: var(--rail-text-active);
}
.rail-icon:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
/* Active state — Bitrix-style: cyan-тинт фон + белая иконка + cyan
   индикатор слева 3px. На тёмном navy фоне cyan-тинт читается отлично. */
.rail-icon.active {
  background: var(--rail-active-bg);
  color: var(--rail-text-active);
  box-shadow: inset 3px 0 0 0 var(--brand-primary);
}
.rail-icon.active:hover {
  background: var(--rail-active-bg-hover);
}

.rail-icon-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}
.rail-icon-emoji .rail-svg-icon { display: block; }
/* page-title-icon — слот для SVG-иконки рядом с h1 page-title */
.page-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  color: var(--text-secondary);
  flex-shrink: 0;
  vertical-align: middle;
}
.page-title {
  display: inline-flex !important;
  align-items: center;
  gap: 0;
}
/* .btn содержит SVG-icon → выровнять с текстом */
.btn svg { flex-shrink: 0; }
.icon-btn svg { display: block; }

/* ─── Развёрнутый rail (когда rail-expanded) ──────────────── */
/* В развёрнутом виде иконки превращаются в полные пункты с текстом */
.rail-toggle {
  width: 44px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--rail-divider);
  color: var(--rail-text);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 8px;
  transition: background .15s, color .15s, border-color .15s;
}
.rail-toggle:hover {
  background: var(--rail-bg-hover);
  color: var(--rail-text-active);
  border-color: rgba(255, 255, 255, .18);
}

.rail-icon-label {
  display: none;
}

.app.active.rail-expanded .rail {
  align-items: stretch;
  padding: 12px 10px;
}
.app.active.rail-expanded .rail-logo {
  width: auto;
  height: 44px;
  padding: 0 14px;
  justify-content: flex-start;
  align-self: stretch;
  gap: 10px;
  font-size: 15px;
  letter-spacing: 0.06em;
}
/* В rail-expanded (toggle-режим, не hover) — переключаем картинки на full. */
.app.active.rail-expanded .rail-logo-mark {
  width: auto;
  height: 40px;
  flex-shrink: 0;
}
.app.active.rail-expanded .rail-logo-mark .rail-logo-img-mark {
  display: none;
}
.app.active.rail-expanded .rail-logo-mark .rail-logo-img-full {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
}
.app.active.rail-expanded .rail-logo-text {
  display: none;
}
.app.active.rail-expanded .rail-modules,
.app.active.rail-expanded .rail-bottom {
  align-items: stretch;
}
.app.active.rail-expanded .rail-icon {
  width: 100%;
  justify-content: flex-start;
  padding: 0 12px;
  gap: 12px;
  font-size: 18px;
}
.app.active.rail-expanded .rail-icon-label {
  display: inline;
  font-size: 13px;
  font-weight: 500;
  color: inherit;
}
.app.active.rail-expanded .rail-toggle {
  align-self: stretch;
  width: auto;
}
/* В развёрнутом — нижние кнопки выглядят как обычные пункты,
   аватарка слева как иконка, имя — справа */
.app.active.rail-expanded .rail-bottom-btn {
  width: 100%;
  height: 44px;
  justify-content: flex-start;
  padding: 0 12px;
  gap: 12px;
}
.app.active.rail-expanded .rail-bottom-btn .rail-avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
  margin: 0;
}

.rail-icon-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--rd);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ac);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s;
}
.rail-avatar:hover { transform: scale(1.05); }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─── Second Panel (для Чата) ──────────────────────────────── */
.second-panel {
  background: var(--bg2);
  border-right: 1px solid var(--b1);
  width: var(--second-panel-w);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.second-panel-header {
  padding: 14px;
  border-bottom: 1px solid var(--b1);
}

.second-panel-body {
  flex: 1;
  overflow-y: auto;
}

/* ─── Main (основная область) ─────────────────────────────── */
.main {
  padding: 20px 24px;
  overflow-y: auto;
}

/* ============================================================
   COMMON UI (топбары, страницы, таблицы)
   ============================================================ */
/* =============================================================
 * TOPBAR / PAGE HEADER — единый паттерн на всех страницах
 * (Сделки, Клиенты, Сотрудники, Задачи, Дашборд, Workday, etc)
 *
 * Высота 56px, divider снизу, page-title h1 22px Roboto Condensed.
 * Actions справа (кнопка «+», экспорт, фильтры — что нужно странице).
 * ============================================================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -20px -24px 20px;        /* вытягиваем за main padding для full-bleed */
  padding: 14px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  min-height: 56px;
  flex-shrink: 0;
}
.page-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
/* h1.page-title (используется на Задачах/Сделках) — те же стили */
h1.page-title { font-family: var(--font-family-heading); }
/* На мобиле и узких экранах padding меньше */
@media (max-width: 768px) {
  .topbar {
    margin: -16px -16px 16px;
    padding: 12px 16px;
    min-height: 52px;
  }
  .page-title {
    font-size: var(--font-size-lg);
  }
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--brand-primary);
}
.icon-btn:active { background: var(--bg-active); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--t3);
}
.empty-state .icon { font-size: 36px; margin-bottom: 10px; opacity: .5; }
.empty-state .text { font-size: 13px; }

/* Toolbar для списков */
/* =============================================================
 * Users/Customers toolbar — flat, без heavy обёртки
 * ============================================================= */
.users-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.users-toolbar .input { margin: 0; max-width: 320px; flex: 1 1 240px; min-width: 200px; }

/* dept-filter (используется в Customers + Employees + Org) — унифицирую с .select */
.dept-filter {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  height: var(--size-control-md);
  padding: 0 28px 0 var(--padding-control-md);
  cursor: pointer;
  min-width: 150px;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235e6470' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.dept-filter:hover { border-color: var(--text-disabled); }
.dept-filter:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* =============================================================
 * Users/Customers table — единый паттерн (синхронен с deals-list-table)
 * ============================================================= */
.users-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: auto;
  box-shadow: var(--shadow-card);
  max-height: calc(100vh - 280px);
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}
.users-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-base);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.users-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
  line-height: var(--line-height-base);
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr.row {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.users-table tr.row:hover td { background: var(--bg-surface-hover); }
.users-table tr.row:focus-within td { background: var(--bg-surface-active); }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-cell .name {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.user-cell .username {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.role-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-badge.owner { background: var(--ambg); color: var(--am); }
.role-badge.admin { background: var(--acbg); color: var(--ac2); }
.role-badge.user { background: var(--bg3); color: var(--t3); }

/* Type-badges (Физ/Юр/Архив) — мягкие чипы рядом с именем клиента */
.type-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
}
.type-badge.individual { background: var(--status-success-bg); color: var(--status-success); }
.type-badge.company    { background: var(--status-info-bg);    color: var(--status-info); }
.type-badge.archived   { background: var(--status-neutral-bg); color: var(--status-neutral); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  /* Плоское затемнение вместо backdrop-filter: blur() — blur пересчитывается
     браузером на каждом кадре и тормозит ВСЕ модалки (см. #133). */
  background: rgba(15, 17, 24, 0.62);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--b1);
}
.modal-header h2 {
  font-family: var(--fd);
  font-size: 17px;
  font-weight: 700;
  color: var(--t1);
}
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--b1);
  justify-content: flex-end;
}
.form-group { margin-bottom: 14px; }

/* Departments inline editor */
.dept-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dept-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 10px;
}
.dept-row .name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--t1);
}
.dept-row .count {
  font-size: 11px;
  color: var(--t3);
  background: var(--bg2);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ============================================================
   SIDE PANEL (Bitrix-style для клиента)
   ============================================================ */
/* Customer card — modal (центрированное окно с backdrop), не slider */
/* =============================================================
 * Side panel (modal-стайл — для Customer card, Tasks и т.п.)
 * ============================================================= */
.side-panel {
  position: fixed;
  inset: 0;
  /* Плоское затемнение вместо backdrop-filter: blur() — blur тормозит (см. #133). */
  background: rgba(15, 17, 24, 0.62);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.side-panel.open {
  opacity: 1;
  pointer-events: auto;
}
.side-panel-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform .18s ease;
}
.side-panel.open .side-panel-content {
  transform: scale(1) translateY(0);
}
.side-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.side-panel-header h2 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  margin: 0;
}
.side-panel-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
}
.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  overscroll-behavior: contain;
}
.side-panel-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-base);
  flex-shrink: 0;
}
.side-panel-footer .btn { width: auto; }
.cp-textarea {
  resize: vertical;
  font-family: var(--font-family-body);
  min-height: 100px;
  height: auto;
  padding: 8px 12px;
  line-height: var(--line-height-base);
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* На мобиле rail-expanded не действует — всегда horizontal tab bar.
     Container ОБЯЗАТЕЛЬНО должен иметь явную высоту, иначе 1fr не работает
     и нижний rail уходит за viewport. Используем 100dvh (dynamic — учитывает
     показ/скрытие address-bar на мобильных браузерах). */
  .app.active,
  .app.active.has-second-panel,
  .app.active.rail-expanded,
  .app.active.rail-expanded.has-second-panel {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 60px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  /* Контентная зона (.main и т.д.) скроллится внутри 1fr-строки */
  .app.active > :first-child,
  .app.active > .main,
  .app.active > #page-content {
    min-height: 0;
    overflow-y: auto;
  }
  
  .rail-toggle { display: none; }
  
  .rail {
    grid-row: 2;
    grid-column: 1;
    flex-direction: row;
    padding: 0 12px;
    border-right: none;
    border-top: 1px solid var(--rail-border);
  }
  .rail-logo { display: none; }
  .rail-modules {
    flex-direction: row;
    border-top: none;
    padding: 0;
    flex: 1;
    justify-content: space-around;
  }
  .rail-spacer { display: none; }
  .rail-bottom {
    flex-direction: row;
    border-top: none;
    padding: 0;
    width: auto;
  }
  .rail-icon { width: 44px; height: 44px; font-size: 20px; }
  .rail-icon.active { box-shadow: 0 -3px 0 0 var(--brand-primary) inset; }
  /* Скрываем модули с mobile=false из bottom-nav (доступны из avatar-меню) */
  .rail-modules .rail-icon[data-mobile="0"] { display: none; }
  /* Скрываем theme-toggle на мобиле — он в avatar-меню */
  .rail-bottom #theme-toggle { display: none; }
  /* Компактнее padding между группами rail */
  .rail { gap: 0; }
  .rail-modules { gap: 2px; }
  .rail-bottom { gap: 2px; }
  
  .main { padding: 16px; grid-row: 1; position: relative; }
  /* Добавляем правый padding под плавающую search-кнопку (40px + 12px gap) */
  .main > .topbar:first-child { padding-right: 56px; }
  
  /* Вторая панель на мобиле во всю ширину поверх main */
  .second-panel {
    grid-row: 1;
    width: 100%;
  }
  
  /* Customer modal — на мобиле во весь экран */
  .side-panel { padding: 0; }
  .side-panel-content {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
  
  /* Скрываем колонки Отдел и Телефон в таблицах на маленьких экранах */
  .users-table th:nth-child(4),
  .users-table td:nth-child(4),
  .users-table th:nth-child(5),
  .users-table td:nth-child(5) { display: none; }
}

/* ============================================================
   CHAT MODULE — стили чата, мерженные с Suite дизайн-токенами
   ============================================================ */

/* Alias-переменные — чат использует --bg-0/--text-1/--accent,
   мапим их на Suite переменные --bg/--t1/--ac */
:root {
  --bg-0: var(--bg);
  --bg-1: var(--bg2);
  --bg-2: var(--bg3);
  --bg-3: var(--bg4);
  --border: var(--b1);
  --text-1: var(--t1);
  --text-2: var(--t2);
  --text-3: var(--t3);
  --accent: var(--ac2);
  --accent-2: var(--ac);
  --success: var(--gn);
  --danger: var(--rd);
  --warn: var(--am);
}

/* Buttons чата */
.btn-primary {
  background: var(--ac); border: none; border-radius: 10px; color: white;
  cursor: pointer; font-family: var(--fb); font-size: 14px; font-weight: 600; padding: 11px 20px;
}
.btn-primary:hover { background: var(--ac2); }
.btn-secondary {
  background: var(--bg3); color: var(--t1); border: 1px solid var(--b2);
  border-radius: 10px; padding: 11px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: var(--bg4); }
.btn-danger {
  background: var(--rd); color: white; border: none; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 7px 14px !important; font-size: 12px !important; min-width: 0 !important; }
.btn-icon {
  background: var(--bg3); border: 1px solid var(--b2); color: var(--t1);
  border-radius: 10px; padding: 0 14px; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg4); }

.form-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--b2); border-radius: 10px;
  color: var(--t1); padding: 10px 14px; font-size: 14px; outline: none; font-family: var(--fb);
}
.form-input:focus { border-color: var(--ac); }
.form-input:disabled { opacity: 0.6; }

.form-hint { font-size: 11px; color: var(--t3); margin-top: 4px; }

.login-error {
  background: var(--rdbg); border: 1px solid rgba(227,30,36,.3); color: var(--rd);
  padding: 10px; border-radius: 8px; font-size: 13px;
}
.login-success {
  background: var(--gnbg); border: 1px solid rgba(63,216,142,.3); color: var(--gn);
  padding: 10px; border-radius: 8px; font-size: 13px;
}

.modal-wide { max-width: 640px !important; }

.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio {
  display: flex; align-items: flex-start; gap: 10px; padding: 8px;
  border-radius: 8px; cursor: pointer;
}
.radio:hover { background: var(--bg3); }
.radio input { margin-top: 2px; }
.radio-option {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  background: var(--bg3); border: 1px solid var(--b1); border-radius: 10px; cursor: pointer;
}
.radio-option:hover { border-color: var(--ac); }
.radio-option input { margin-top: 2px; }
.radio-title { font-weight: 600; font-size: 14px; }
.radio-hint { font-size: 12px; color: var(--t3); margin-top: 2px; }

/* Chat shell — основной контейнер чата внутри main */
#chat-shell {
  flex-direction: column;
  height: 100%;
  background: var(--bg);
  margin: -24px -32px;
}

/* Chat sidebar внутри second-panel */
#chat-sidebar { height: 100%; display: flex; flex-direction: column; }

.icon-btn-inline {
  background: transparent; border: none; color: var(--t3);
  cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px;
}
.icon-btn-inline:hover { background: var(--bg3); color: var(--t1); }

/* =============================================================
 * CHAT — sidebar (каналы, DM, search) + chat-view + messages
 * ============================================================= */
.sidebar-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-default);
  position: relative;
  background: var(--bg-surface);
}
.search-input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 32px;
  font-size: var(--font-size-sm);
  outline: none;
  font-family: var(--font-family-body);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.search-results {
  position: absolute;
  left: 14px; right: 14px;
  top: calc(100% - 1px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: var(--z-popover);
  box-shadow: var(--shadow-popover);
}
.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-surface-hover); }
.search-result-channel {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--font-weight-medium);
  margin-bottom: 2px;
}
.search-result-text {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}
.search-results .empty,
.search-results .loading {
  padding: 16px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-align: center;
}
.search-highlight {
  background: rgba(33, 120, 203, .25);
  padding: 0 2px;
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}

.sidebar-section {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-section:last-child { border-bottom: none; }
.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 6px;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: var(--font-weight-semibold);
}
.channels-list { display: flex; flex-direction: column; }
.channel-item {
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.channel-item:hover { background: var(--bg-hover); }
/* Active: жёлтый indicator слева (3px) + лёгкий жёлтый bg — паттерн как rail */
.channel-item.active {
  background: rgba(33, 120, 203, .12);
  box-shadow: inset 3px 0 0 0 var(--brand-primary);
}
:root[data-theme="dark"] .channel-item.active {
  background: rgba(33, 120, 203, .14);
}
.channel-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
}
.channel-item.active .channel-icon { color: var(--text-primary); }
.channel-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}
.channel-item.active .channel-name {
  color: var(--text-primary);
  font-weight: var(--font-weight-medium);
}
.channel-unread {
  background: var(--status-danger);
  color: #fff;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  padding: 0 6px;
  height: 18px;
  border-radius: var(--radius-pill);
  min-width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.channel-avatar {
  width: 24px; height: 24px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.channel-mute-icon { font-size: 11px; opacity: 0.6; margin-right: 4px; }
.channel-item.muted .channel-name { opacity: 0.65; }
.channel-item.muted.active .channel-name { opacity: 1; }

/* Chat view */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.chat-empty-icon { font-size: 48px; opacity: 0.5; }
.chat-view { display: flex; flex-direction: column; height: 100%; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
  min-height: 56px;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info.clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background var(--transition-fast);
}
.chat-header-info.clickable:hover { background: var(--bg-surface-hover); }
.chat-title {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-md);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.online-count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.online-count::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--status-success);
}

/* Pinned bar — закреплённое сообщение сверху чата */
.pinned-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(33, 120, 203, .10);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.pinned-bar:hover { background: rgba(33, 120, 203, .18); }
.pinned-icon {
  color: var(--brand-on-primary);
  font-size: 14px;
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-primary);
  border-radius: var(--radius-sm);
}
.pinned-content {
  flex: 1;
  min-width: 0;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-content .pinned-author {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-right: 6px;
}
.pinned-nav {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.pinned-nav:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: var(--bg-base);
}
.messages-loading {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-size: var(--font-size-sm);
}
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  position: relative;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.message:hover {
  background: var(--bg-surface-hover);
}
.message-edit-input, .message textarea, .message input {
  -webkit-user-select: text !important;
  user-select: text !important;
  -webkit-touch-callout: default !important;
}
/* #207 — разрешить выделять и копировать текст сообщения мышью (на десктопе).
   Само .message имеет user-select:none (чтобы клики не выделяли); для текста —
   разрешаем. На мобиле НЕ трогаем: там работает long-press меню с «Копировать»
   (иначе нативное выделение конфликтует с кастомным меню). */
@media (min-width: 601px) {
  .message .message-text,
  .message .message-text * {
    -webkit-user-select: text !important;
    user-select: text !important;
    cursor: text;
  }
}
.message.grouped { padding-top: 0; margin-top: -4px; }
.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  overflow: hidden;
  text-transform: uppercase;
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message.grouped .message-avatar { visibility: hidden; height: 0; }
.message-body { flex: 1; min-width: 0; }
.message-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.message-author {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 0 2px;
  margin: 0 -2px;
  transition: background var(--transition-fast);
}
.message-author:hover { background: var(--bg-active); }
.message-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.message-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
}
.message-day-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.message-day-divider::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border-default);
  z-index: 0;
}
.message-day-divider span {
  background: var(--bg-base);
  padding: 0 12px;
  position: relative;
  z-index: 1;
  font-weight: var(--font-weight-medium);
}

/* Composer */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
}
.message-input {
  flex: 1;
  min-width: 0;
  /* Фон чуть светлее composer-context. На dark theme composer = bg-surface,
     input = bg-surface-hover (заметно светлее, чёрный → серый как просили). */
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 14px;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  resize: none;
  max-height: 200px;
  outline: none;
  font-family: var(--font-family-body);
  min-height: 36px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.message-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
/* iOS zoom prevention */
@media (max-width: 768px) {
  .message-input { font-size: 16px; }
}
.composer-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.composer-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.composer-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.composer-btn:hover { color: var(--ac2); }
.send-btn {
  background: var(--ac); color: white; border: none; border-radius: 10px;
  width: 40px; height: 40px; font-size: 16px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.send-btn:hover { background: var(--ac2); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Reply preview */
.reply-preview {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg2); border-top: 1px solid var(--b1);
}
.reply-preview-bar { width: 3px; height: 36px; background: var(--ac); border-radius: 2px; flex-shrink: 0; }
.reply-preview-info { flex: 1; min-width: 0; font-size: 13px; }
.reply-preview-author { font-weight: 600; color: var(--ac2); }
.reply-preview-text { color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; margin-top: 2px; }

.message-reply-quote {
  display: flex; gap: 8px; padding: 6px 10px;
  background: var(--acbg); border-left: 3px solid var(--ac);
  border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 12px;
}
.message-reply-quote:hover { background: var(--acb); }
.message-reply-quote .author { font-weight: 600; color: var(--ac2); }
.message-reply-quote .preview { color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mentions */
.mention { color: var(--ac2); background: var(--acbg); padding: 0 4px; border-radius: 4px; font-weight: 500; cursor: pointer; }
.mention.self { background: var(--acb); font-weight: 600; }
.mentions-popup {
  position: absolute; background: var(--bg2); border: 1px solid var(--b1);
  border-radius: 10px; max-height: 240px; overflow-y: auto; z-index: 80;
  box-shadow: var(--shadow); min-width: 240px;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: pointer; border-bottom: 1px solid var(--b1);
}
.mention-item:last-child { border-bottom: none; }
.mention-item:hover, .mention-item.active { background: var(--bg3); }
.mention-item .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0; overflow: hidden;
}
.mention-item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.mention-item .info { flex: 1; min-width: 0; }
.mention-item .name { font-size: 13px; font-weight: 500; }
.mention-item .username { font-size: 11px; color: var(--t3); }

/* Reactions */
.reactions-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--b1); border-radius: 12px;
  padding: 2px 8px; font-size: 12px; cursor: pointer;
}
.reaction-chip:hover { background: var(--bg4); }
.reaction-chip.mine { background: var(--acbg); border-color: var(--ac); }
.reaction-chip .count { font-size: 11px; font-weight: 600; color: var(--t2); }
.reaction-chip.mine .count { color: var(--ac2); }

/* Edited / Deleted */
.edited-mark { font-size: 11px; color: var(--t3); margin-left: 6px; font-style: italic; }
.message-deleted { color: var(--t3); font-style: italic; font-size: 13px; }
.message-deleted-show-original { color: var(--ac2); cursor: pointer; font-size: 11px; margin-left: 6px; text-decoration: underline; }

/* Edit inline — переписано на новые семантические токены.
   Раньше bg3 + ac1 (alias на старые) на dark theme = почти чёрный фон
   с фиолетово-чёрным border'ом → invisible textarea. */
.message-edit-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: var(--font-size-base);
  font-family: var(--font-family-body);
  line-height: var(--line-height-base);
  resize: vertical;
  outline: none;
  min-height: 60px;
  box-shadow: var(--shadow-focus);
}
.message-edit-input:focus { border-color: var(--brand-primary); }
.message-edit-actions {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  align-items: center;
}
.message-edit-actions a {
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-hover);
  transition: background var(--transition-fast);
}
.message-edit-actions a:hover { background: var(--bg-active); text-decoration: none; }

/* Typing indicator */
.typing-indicator { font-size: 12px; color: var(--ac2); font-style: italic; }
.typing-dots::after {
  content: ''; display: inline-block;
  animation: typing-dots 1.2s steps(4) infinite;
  width: 18px; text-align: left;
}
@keyframes typing-dots {
  0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } 100% { content: ''; }
}

/* Message actions (hover ⋯) */
.message-actions {
  position: absolute; top: 6px; right: 8px; display: none;
  background: var(--bg2); border: 1px solid var(--b1); border-radius: 8px; padding: 2px;
}
.message:hover .message-actions { display: flex; }
.message-actions button {
  background: transparent; border: none; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; color: var(--t2); font-size: 14px;
}
.message-actions button:hover { background: var(--bg3); color: var(--t1); }
@media (max-width: 600px) { .message-actions { display: none !important; } }

/* Emoji picker */
.emoji-picker {
  position: fixed; background: var(--bg2); border: 1px solid var(--b1);
  border-radius: 12px; padding: 6px; display: flex; gap: 2px;
  box-shadow: var(--shadow); z-index: 1100;
}
.emoji-btn {
  background: transparent; border: none; font-size: 22px;
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
}
.emoji-btn:hover { background: var(--bg3); }

/* Message context menu */
.message-menu {
  position: fixed; background: var(--bg2); border: 1px solid var(--b1);
  border-radius: 10px; padding: 4px; min-width: 180px;
  z-index: 1100; box-shadow: var(--shadow);
}
.msg-menu-item {
  display: block; width: 100%; background: transparent; border: none;
  text-align: left; padding: 8px 12px; border-radius: 6px;
  font-size: 14px; color: var(--t1); cursor: pointer;
}
.msg-menu-item:hover { background: var(--bg3); }
.msg-menu-item.danger { color: var(--rd); }

/* Attachment preview */
.attachment-preview {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg2); border-top: 1px solid var(--b1);
}
.attachment-preview-thumb {
  width: 48px; height: 48px; border-radius: 8px; background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 22px; overflow: hidden;
}
.attachment-preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-preview-info { flex: 1; min-width: 0; font-size: 13px; }
.attachment-preview-info .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-preview-info .size { font-size: 11px; color: var(--t3); margin-top: 2px; }

/* Message media */
.message-image {
  max-width: 360px; max-height: 360px; border-radius: 12px;
  margin-top: 4px; cursor: pointer; display: block; background: var(--bg3);
}
.message-video { max-width: 360px; max-height: 360px; border-radius: 12px; margin-top: 4px; display: block; background: black; }
.message-audio { margin-top: 4px; max-width: 360px; }
.message-audio audio { width: 100%; height: 36px; }
.message-doc {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  margin-top: 4px; background: var(--bg2); border: 1px solid var(--b1);
  border-radius: 12px; text-decoration: none; color: inherit;
  max-width: 360px; cursor: pointer;
}
.message-doc:hover { background: var(--bg3); }
.message-doc-icon {
  width: 40px; height: 40px; background: var(--ac); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
}
.message-doc-info { min-width: 0; flex: 1; }
.message-doc-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-doc-size { font-size: 11px; color: var(--t3); margin-top: 2px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-close, .lightbox-download {
  position: absolute; top: 20px; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(255,255,255,0.1);
  color: white; border: none; font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.lightbox-close { right: 20px; }
.lightbox-download { right: 76px; font-size: 20px; }

/* Users management items */
.users-mgmt-list { display: flex; flex-direction: column; gap: 8px; }
.users-mgmt-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--bg3); border: 1px solid var(--b1);
  border-radius: 10px; gap: 12px;
}
.users-mgmt-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.users-mgmt-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0; overflow: hidden;
}
.users-mgmt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.users-mgmt-name { font-weight: 600; font-size: 14px; }
.users-mgmt-meta { font-size: 12px; color: var(--t3); margin-top: 2px; }
.users-mgmt-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.users-mgmt-actions .btn { white-space: nowrap; }

/* User card */
.user-card-header {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 16px; margin-bottom: 4px;
  border-bottom: 1px solid var(--b1);
}
.user-card-avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; flex-shrink: 0; overflow: hidden;
}
.user-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-card-name { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.user-card-meta { font-size: 13px; color: var(--t3); }
.user-card-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.user-card-actions .btn { width: 100%; padding: 10px 16px; font-size: 14px; font-weight: 500; }

/* Channel members add list */
.channel-members-add-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 240px; overflow-y: auto;
}
.channel-members-add-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg3); border: 1px solid var(--b1); border-radius: 8px;
}
.channel-members-add-item .btn { min-width: 110px; flex-shrink: 0; }

/* Auto-add toggle */
.channel-auto-add-toggle {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: var(--bg3); border: 1px solid var(--b1); border-radius: 10px;
  margin-bottom: 16px; cursor: pointer;
}
.channel-auto-add-toggle:hover { background: var(--bg4); }
.channel-auto-add-toggle input[type="checkbox"] {
  width: 18px; height: 18px; margin: 2px 0 0 0; flex-shrink: 0; accent-color: var(--ac);
}
.toggle-title { font-size: 14px; font-weight: 500; color: var(--t1); }
.toggle-hint { font-size: 12px; color: var(--t3); margin-top: 4px; }

/* History entries */
.history-entry {
  padding: 10px 12px; background: var(--bg3); border: 1px solid var(--b1);
  border-radius: 10px; margin-bottom: 8px;
}
.history-entry .action { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.history-entry .action.edit { color: var(--ac2); }
.history-entry .action.delete { color: var(--rd); }
.history-entry .meta { font-size: 11px; color: var(--t3); margin-bottom: 6px; }
.history-entry .text { font-size: 13px; color: var(--t1); white-space: pre-wrap; word-break: break-word; }
.history-current {
  padding: 10px 12px; background: var(--acbg); border: 1px solid var(--ac);
  border-radius: 10px; margin-bottom: 16px;
}

/* Credentials box */
.credentials-box {
  background: var(--bg3); border: 1px solid var(--b1); border-radius: 8px;
  padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; white-space: pre-wrap; word-break: break-all; user-select: text;
}

/* Profile avatar */
.profile-avatar-section { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 24px; }
.profile-avatar-wrapper { position: relative; width: 100px; height: 100px; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 600; overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-camera {
  position: absolute; bottom: 0; right: 0; width: 32px; height: 32px;
  border-radius: 50%; background: var(--ac); color: white;
  border: 2px solid var(--bg2); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-link {
  background: transparent; border: none; color: var(--rd);
  font-size: 12px; cursor: pointer; padding: 4px 8px; text-decoration: underline;
}

/* Generic avatar */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px !important; height: 32px !important; font-size: 12px !important; }

/* Mobile */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: inline-flex; }
  #chat-shell { margin: 0; }
}

/* Modal user-created — поверх остальных модалок */
#modal-user-created { z-index: 200; }
/* ============================================================
   EMPLOYEE CARD (модалка сотрудника)
   ============================================================ */

.employee-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--b1);
}

.employee-card-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ac);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.employee-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.employee-card-subtitle {
  font-size: 13px;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.employee-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--b1);
}

/* === Личный график работы в карточке сотрудника === */
.employee-card-schedule {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--b1);
}
.sched-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.sched-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--t2);
}
.sched-month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sched-month-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  text-transform: capitalize;
  min-width: 140px;
  text-align: center;
}
.sched-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 8px;
}
.sched-templates {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.sched-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.sched-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--t3);
  padding: 4px 0;
  text-transform: uppercase;
}
.sched-cell {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 6px;
  padding: 6px 4px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.1s;
  font-variant-numeric: tabular-nums;
}
.sched-cell:hover { background: var(--bg4); }
.sched-cell.sched-empty {
  background: transparent;
  border: 1px dashed var(--b1);
  opacity: 0.3;
  cursor: default;
}
.sched-cell.is-work {
  background: var(--brand-glow, rgba(33, 120, 203, 0.18));
  border-color: var(--brand-primary);
}
.sched-cell.is-today { box-shadow: 0 0 0 2px var(--gn) inset; }
.sched-cell-num { font-size: 13px; font-weight: 600; color: var(--t1); }
.sched-cell-time { font-size: 9px; color: var(--brand-primary); margin-top: 2px; }
.sched-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

/* === Tabs на странице Сотрудники === */
.emp-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--b1);
  margin: 0 0 16px 0;
}
.emp-tab {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--t2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.emp-tab:hover { color: var(--t1); }
.emp-tab.active { color: var(--ac); border-bottom-color: var(--ac); }

.perf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.perf-table-wrap {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  overflow: hidden;
}
.perf-table th.perf-sortable {
  cursor: pointer;
  user-select: none;
}
.perf-table th.perf-sortable:hover { background: var(--bg3); }
.perf-table th.perf-sortable.active { color: var(--ac); }
.perf-row { cursor: pointer; }
.perf-row:hover { background: var(--bg3); }

/* === KPI блок в карточке сотрудника + страница «Эффективность» === */
.employee-card-kpi {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--b1);
}
.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.kpi-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--t2);
}
.kpi-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.kpi-chip {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--b1);
  background: transparent;
  color: var(--t2);
  transition: all 0.15s;
}
.kpi-chip:hover { background: var(--bg3); color: var(--t1); }
.kpi-chip.active { background: var(--ac); color: #fff; border-color: var(--ac); }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpi-card {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
  min-height: 72px;
}
.kpi-card.skeleton { background: var(--bg3); opacity: 0.4; animation: kpi-skel 1.2s ease-in-out infinite alternate; }
@keyframes kpi-skel { from { opacity: 0.3 } to { opacity: 0.6 } }
.kpi-num {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--t1);
}
.kpi-lbl {
  font-size: 11px;
  color: var(--t2);
  margin-top: 4px;
  line-height: 1.3;
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.employee-card-actions .btn {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}


/* === SMALL FIXES PATCH === */

.rail-bottom .rail-bottom-btn {
  align-items: center;
}
.rail-bottom .rail-bottom-btn .rail-icon-emoji,
.rail-bottom .rail-bottom-btn .rail-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app.active.rail-expanded .rail-bottom .rail-bottom-btn {
  padding: 0 12px;
  gap: 12px;
  justify-content: flex-start;
}
.app.active.rail-expanded .rail-bottom .rail-bottom-btn .rail-icon-emoji {
  width: 28px;
  height: 28px;
  font-size: 18px;
}
.app.active.rail-expanded .rail-bottom .rail-bottom-btn .rail-avatar {
  width: 28px;
  height: 28px;
  font-size: 11px;
  margin: 0;
}

.chat-view {
  min-height: 0;
}
#chat-shell .composer {
  flex-shrink: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* === END SMALL FIXES PATCH === */

/* === COMPOSER BOTTOM ALIGNMENT === */
.main:has(#chat-shell[style*="display: flex"]),
.main:has(#chat-shell[style*="display:flex"]) {
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
}
#chat-shell {
  flex: 1;
  min-height: 0;
}


/* === READ RECEIPTS (галочки доставки/прочтения) === */
.msg-ticks {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  vertical-align: middle;
  user-select: none;
  letter-spacing: -1px;
}
.msg-ticks.pending { color: var(--t3); opacity: 0.7; }
.msg-ticks.sent { color: var(--t3); }
.msg-ticks.delivered { color: var(--t2); }
.msg-ticks.read { color: var(--ac); font-weight: 600; }
.msg-ticks.group-read { cursor: pointer; padding: 0 4px; border-radius: 4px; }
.msg-ticks.group-read:hover { background: rgba(56, 189, 248, 0.12); }
.msg-ticks .readers-count {
  display: inline-block;
  margin-left: 2px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ac);
}
.readers-row:hover { background: var(--bg3); }
.readers-avatar { width: 32px; height: 32px; flex-shrink: 0; }

.message-status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
  height: 14px;
  line-height: 1;
}
.message-status .msg-ticks {
  margin-left: 0;
}

/* === END READ RECEIPTS === */








/* ============================================================
   CHAT BUBBLES v2 - own right, others left, fit content
   ============================================================ */

/* Сбрасываем старое .message-body flex:1 для DM-облачек */
.messages-list .message {
  display: flex !important;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 4px;
  padding: 6px 8px;
  max-width: 100%;
  position: relative;
}

/* === ЧУЖИЕ - слева === */
.messages-list .message.other {
  flex-direction: row;
  justify-content: flex-start;
}
.messages-list .message.other .message-avatar {
  order: 1;
  flex-shrink: 0;
}
.messages-list .message.other .message-body {
  order: 2;
  flex: 0 1 auto !important;
  /* ЧУЖИЕ — нейтральный серый пузырь, тёмный текст. На обеих темах
     bg-subtle отличается от .messages-list canvas. */
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px 16px 16px 4px;
  padding: 8px 12px;
  width: fit-content !important;
  max-width: min(420px, calc(100% - 60px)) !important;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* === СВОИ - справа === */
.messages-list .message.own {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.messages-list .message.own .message-avatar {
  display: none;
}
.messages-list .message.own .message-body {
  flex: 0 1 auto !important;
  /* СВОИ — БРЕНДОВЫЙ ЯНТАРЬ (Telegram-style "мои сообщения").
     Авто-контраст: в light жёлтый+чёрный, в dark янтарь+чёрный — оба читаемы. */
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border-radius: 16px 16px 4px 16px;
  padding: 8px 12px;
  width: fit-content !important;
  max-width: min(420px, calc(100% - 20px)) !important;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  position: relative;
  margin-left: auto;
}
/* Все дочерние элементы своего сообщения наследуют контрастный текст
   к янтарному фону. Перекрывает специфичные правила .message-text,
   .message-author, .message-meta, .message-time, и т.д. */
.messages-list .message.own .message-body,
.messages-list .message.own .message-body * {
  color: var(--brand-on-primary) !important;
}
/* #207 — НО кнопка ⋯ сидит на белом кружке, а не на синем облачке: правило
   выше (.message.own .message-body *) красило её точки в белое → невидимо.
   Возвращаем контрастный --t1 с большей специфичностью (0,4,1 > 0,4,0). */
.messages-list .message.own .message-body .message-actions button,
.messages-list .message.other .message-body .message-actions button {
  color: var(--t1) !important;
}
/* Время / edited-mark — приглушённый чёрный (контрастирует с янтарным,
   но не такой яркий как основной текст). */
.messages-list .message.own .message-time,
.messages-list .message.own .edited-mark,
.messages-list .message.own .message-meta {
  color: rgba(15, 17, 24, 0.65) !important;
}
/* Replied-quote / reply-preview внутри своего пузыря — тоже на тёмное */
.messages-list .message.own .message-reply,
.messages-list .message.own .message-reply *,
.messages-list .message.own .reply-author,
.messages-list .message.own .reply-text {
  color: rgba(15, 17, 24, 0.78) !important;
  background: rgba(15, 17, 24, 0.08) !important;
}

/* Author + time + grouped */
.messages-list .message.own .message-meta .message-author,
.messages-list .message.own .message-meta {
  display: none;
}
.messages-list .message.other .message-meta {
  margin-bottom: 2px;
  font-size: 12px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.messages-list .message.other .message-meta .message-author {
  font-weight: 600;
  color: var(--ac2);
  background: transparent;
  padding: 0;
  margin: 0;
}
.messages-list .message.other .message-meta .message-author:hover {
  background: transparent;
  text-decoration: underline;
}
.messages-list .message .message-meta .message-time {
  font-size: 11px;
  color: var(--t3);
}
.messages-list .message.other.grouped .message-avatar {
  visibility: hidden;
}
.messages-list .message.grouped .message-meta {
  display: none;
}

/* Text and content */
.messages-list .message-body .message-text {
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.35;
  font-size: 14px;
}
.messages-list .message.own .message-text {
  color: white;
}
.messages-list .message.other .message-text {
  color: var(--t1);
}

.messages-list .message.own .edited-mark {
  color: rgba(255,255,255,0.7);
}

/* Reply-quote inside bubble */
.messages-list .message-body .message-reply-quote {
  border-left: 3px solid var(--ac);
  padding: 4px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}
.messages-list .message.own .message-reply-quote {
  border-left-color: white;
  background: rgba(255,255,255,0.18);
}
.messages-list .message.own .message-reply-quote .author {
  color: white;
  font-weight: 600;
  font-size: 12px;
}
.messages-list .message.own .message-reply-quote .preview {
  color: rgba(255,255,255,0.9);
  font-size: 12px;
}
.messages-list .message.other .message-reply-quote .author {
  color: var(--ac2);
  font-weight: 600;
  font-size: 12px;
}
.messages-list .message.other .message-reply-quote .preview {
  color: var(--t2);
  font-size: 12px;
}

/* Reactions */
.messages-list .message-body .reactions-bar {
  margin-top: 4px;
  gap: 4px;
  flex-wrap: wrap;
}

/* Media - compact sizes */
.messages-list .message-body .message-image {
  max-width: 280px !important;
  max-height: 360px !important;
  width: auto;
  height: auto;
  border-radius: 12px;
  margin-top: 4px;
  cursor: pointer;
  display: block;
  object-fit: cover;
}
.messages-list .message-body .message-video {
  max-width: 280px !important;
  max-height: 360px !important;
  border-radius: 12px;
  margin-top: 4px;
  display: block;
}
.messages-list .message-body .message-audio {
  margin-top: 4px;
  max-width: 280px;
}

/* Documents */
.messages-list .message-body .message-doc {
  margin-top: 4px;
  background: rgba(0,0,0,0.08);
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  min-width: 180px;
  cursor: pointer;
}
.messages-list .message.own .message-body .message-doc {
  background: rgba(255,255,255,0.18);
}
.messages-list .message.own .message-doc-icon {
  background: rgba(255,255,255,0.25);
}
.messages-list .message.own .message-doc-name {
  color: white;
}
.messages-list .message.own .message-doc-size {
  color: rgba(255,255,255,0.7);
}
.messages-list .message-body .message-doc-icon {
  width: 32px;
  height: 32px;
  font-size: 16px;
}

/* Status (time + ticks) */
.messages-list .message-body .message-status {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.85;
  line-height: 1;
}
.messages-list .message.own .message-status {
  color: rgba(255,255,255,0.85);
}
.messages-list .message.other .message-status {
  color: var(--t3);
}
.messages-list .message-body .message-time-inline {
  font-size: 11px;
}

/* Ticks on own messages */
.messages-list .message.own .msg-ticks {
  color: rgba(255,255,255,0.85);
}
.messages-list .message.own .msg-ticks.read {
  color: #7dd9ff;
  font-weight: 700;
}

/* Mentions */
.messages-list .message.own .mention {
  color: #b8d4ff;
  background: rgba(255,255,255,0.15);
}

/* Message actions (...) - small button at TOP-LEFT corner of bubble */




@media (max-width: 600px) {
  
}

/* Day divider override */
.messages-list .message-day-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
}
.messages-list .message-day-divider span {
  background: var(--bg3);
  color: var(--t2);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  position: relative;
  z-index: 1;
}

/* Mobile sizes */
@media (max-width: 600px) {
  .messages-list .message.own .message-body,
  .messages-list .message.other .message-body {
    max-width: min(82%, 320px) !important;
  }
  .messages-list .message-body .message-image,
  .messages-list .message-body .message-video {
    max-width: 240px !important;
    max-height: 300px !important;
  }
}

/* END BUBBLES v2 */

/* Actions position: own bubble is on the right side, so actions go to bubble's top-left.
   Other bubble is on left side, so actions also go to bubble's top-left.
   We position actions relative to .message but offset by avatar+gap. */



/* For own messages: actions go to top-right corner of bubble (= near right edge of message) */





/* Own: button on LEFT of bubble (inward toward chat center) */

/* Other: button on RIGHT of bubble (inward toward chat center) */




/* Own message: order so actions are BEFORE body (i.e., to LEFT of bubble visually,
   since own is row-reverse, "before" becomes right side. So order=3 makes it left). */

/* Other message: actions go AFTER body (right side of bubble) */





/* ============================================================
   BULLETPROOF CHAT LAYOUT
   Composer absolutely positioned at bottom, messages fill space above.
   ============================================================ */

/* Main контейнер - relative for absolute children */
.app .main {
  height: 100vh !important;
  max-height: 100vh !important;
  overflow: hidden !important;
  position: relative !important;
  padding: 0 !important;
}

/* Chat shell takes full main */
#chat-shell {
  position: absolute !important;
  inset: 0 !important;
  margin: 0 !important;
  display: flex;  /* без !important чтобы inline display:none мог скрыть */
  flex-direction: column !important;
  overflow: hidden !important;
  background: var(--bg);
}
/* Когда chat-shell скрыт через inline style="display:none" - принудительно скрываем */
#chat-shell[style*="display: none"],
#chat-shell[style*="display:none"] {
  display: none !important;
}

/* Chat view fills shell */
.chat-view {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* Header fixed at top */
.chat-view > .chat-header {
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* Pinned bar (if visible) below header */
.chat-view > .pinned-bar {
  flex-shrink: 0;
}

/* Messages container takes remaining space */
.chat-view > #messages-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}

/* Reply preview + attachment preview between messages and composer */
.chat-view > #reply-preview,
.chat-view > #attachment-preview {
  flex-shrink: 0;
}

/* Composer always at bottom */
.chat-view > .composer {
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Empty state takes full shell */
#chat-empty {
  position: absolute !important;
  inset: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

/* For non-chat pages: restore main padding via page-content */
.app .main #page-content {
  height: 100%;
  overflow-y: auto;
  padding: 24px 32px;
  box-sizing: border-box;
}

/* When chat is NOT shown (chat-shell hidden), page-content is visible */


/* === ACTIONS INSIDE BUBBLE - corner overlap === */
/* .message-actions теперь внутри .message-body. .message-body имеет position:relative.
   Кнопка перекрывает угол облачка. */
.messages-list .message-body .message-actions {
  position: absolute !important;
  top: -8px !important;
  width: 24px !important;
  height: 24px !important;
  background: var(--bg2) !important;
  border: 1px solid var(--b1) !important;
  border-radius: 50% !important;
  padding: 0 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
  z-index: 5 !important;
}
.messages-list .message:hover .message-body .message-actions {
  display: flex !important;
}

/* OWN (right bubble): action на TOP-LEFT углу (направлено к центру чата) */
.messages-list .message.own .message-body .message-actions {
  left: -8px !important;
  right: auto !important;
}

/* OTHER (left bubble): action на TOP-RIGHT углу (направлено к центру чата) */
.messages-list .message.other .message-body .message-actions {
  right: -8px !important;
  left: auto !important;
}

.messages-list .message-body .message-actions button {
  background: transparent !important;
  border: none !important;
  cursor: pointer !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  border-radius: 50% !important;
  /* #207 — было var(--t2): в светлой теме «три точки» сливались с белым кружком.
     --t1 контрастен в обеих темах (тёмный на свету, светлый в тёмной). */
  color: var(--t1) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.messages-list .message-body .message-actions button:hover {
  background: var(--bg3) !important;
  color: var(--t1) !important;
}

@media (max-width: 600px) {
  .messages-list .message-body .message-actions { display: none !important; }
}


/* === COMPOSER BREATHING SPACE === */
.chat-view > .composer {
  margin-bottom: 10px !important;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0)) !important;
}


/* === MOBILE CHAT FIX === */
@media (max-width: 768px) {
  /* На мобиле main занимает первый grid-row, rail - второй (60px) */
  .app.active .main {
    height: auto !important;
    grid-row: 1 !important;
    overflow: hidden !important;
    position: relative !important;
  }
  
  /* chat-shell внутри mobile main - абсолютное на всю площадь */
  .app.active .main #chat-shell {
    position: absolute !important;
    inset: 0 !important;
    margin: 0 !important;
  }
  
  /* На мобиле когда second-panel показана - она занимает первый row */
  .app.active.has-second-panel .second-panel {
    grid-row: 1 !important;
    width: 100% !important;
    height: auto !important;
  }
  
  /* Когда second-panel показана и есть выбранный чат - chat-view должен быть видим
     поверх sidebar (на мобиле sidebar и chat-view не отображаются одновременно) */
}


/* Pinned bar unpin button */
.pinned-bar #pinned-unpin {
  font-size: 22px;
  line-height: 1;
  padding: 0 8px;
  color: var(--rd);
}
.pinned-bar #pinned-unpin:hover {
  color: var(--rd);
  background: var(--rdbg);
  border-radius: 6px;
}




/* ============================================================
   DEALS KANBAN - ELC-style visual
   ============================================================ */

/* Канбан-доска: горизонтальный flex */
/* =============================================================
 * KANBAN — редизайн (см. components.css для разделяемых паттернов)
 *
 * Депт-rhythm:
 *   canvas (серый) → column (прозрачный + thin top stripe stage_color) →
 *   card (белая + shadow-xs)
 *
 * Карточка читается как «лист бумаги» приподнятый над колонкой.
 * Stage color визуально дан через 2px stripe сверху колонки (а не через
 * заливку counter'a — это шумно).
 * ============================================================= */
.crm-kanban-wrap {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  min-height: 420px;
  /* Перфоманс: горизонтальный скролл по канбану раньше сильно лагал
     (особенно на странице роботов). Причина — каждая колонка/карточка
     имеет transition + :hover, и при скролле курсор проходит над всеми
     по очереди → каскад recompute style + repaint. contain даёт изоляцию
     рендеринга, overscroll-behavior отсекает scroll-chain в родителя. */
  overscroll-behavior-x: contain;
}
/* Skeleton-board — loading-state до прихода данных */
.deals-skeleton-board {
  display: flex;
  gap: 12px;
  padding-bottom: 12px;
  min-height: 420px;
}
.deals-skeleton-col {
  flex: 0 0 264px;
  min-width: 264px;
}

/* Колонка — прозрачная группа */
.crm-col {
  min-width: 264px;
  max-width: 280px;
  flex: 0 0 auto;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  padding-top: 0;
  /* Изоляция рендеринга — браузер не пересчитывает layout соседних
     колонок при изменениях внутри этой. Критично для горизонтального
     скролла по канбану с 6+ колонками. */
  contain: layout style;
  /* Вложенный scroll внутри .rob-list / .crm-col-body не пробрасывается
     на родителя — убирает «дёргание» при достижении конца верт. скролла. */
  overscroll-behavior: contain;
}

/* Заголовок колонки — толстая цветная полоса сверху (как у Bitrix24).
   Раньше 2px — выглядела как линия; стало 5px — полноценная stage-полоса. */
.crm-col-header {
  padding: 12px 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  border-top: 5px solid var(--stage-color, var(--border-strong));
  border-radius: 3px 3px 0 0;
  margin-top: 0;
  padding-top: 14px;
}
.crm-col-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
/* dot теперь скрыт (stage color в top stripe). Оставлен в DOM для совместимости. */
.crm-stage-dot {
  display: none;
}
.crm-stage-icon {
  font-size: 12px;
  color: var(--text-muted);
}
.crm-col-name {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  color: var(--text-primary) !important; /* override inline color из старого JS */
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* Counter — нейтральный chip без шума */
.crm-col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-pill);
  background: var(--bg-active) !important;     /* override inline */
  color: var(--text-secondary) !important;
  border: none !important;
  flex-shrink: 0;
}

/* Сумма по колонке */
.crm-col-sum {
  padding: 0 4px 10px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
  border-bottom: none;
}

/* Тело колонки (карточки) */
.crm-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 2px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  border-radius: var(--radius-md);
}
.crm-col-body.drag-over {
  background: rgba(33, 120, 203, 0.10);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}
.crm-col-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-disabled);
  font-size: var(--font-size-xs);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-base);
}

/* Карточка сделки — белый «лист» приподнятый над колонкой */
.crm-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  cursor: grab;
  /* Transition только при наведении мыши, а не на ВСЕХ карточках одновременно
     во время скролла. На touch-устройствах hover не срабатывает — это
     дополнительно режет лишние repaint'ы. Раньше 4 свойства transition
     на каждой карточке + :hover при прохождении курсора через скролл
     давали каскад reflow. */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  position: relative;
  /* contain даёт изоляцию рендеринга — каждая карточка живёт в своём
     слое. Браузер не пересчитывает layout/paint соседних карточек при
     hover или анимации одной. */
  contain: layout style;
}
.crm-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}
.crm-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--brand-primary);
}
.crm-card:active { cursor: grabbing; }
.crm-card.dragging {
  opacity: 0.5;
  transform: rotate(1.5deg);
  box-shadow: var(--shadow-card-hover);
}
/* Stale indicator — вертикальная полоска слева вместо inline-warning */
.crm-card[data-stale="warm"]::before,
.crm-card[data-stale="cold"]::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  pointer-events: none;  /* не перехватывать click — карточка должна открываться */
}
.crm-card[data-stale="warm"]::before { background: var(--status-warning); }
.crm-card[data-stale="cold"]::before { background: var(--status-danger); }

.crm-card-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  line-height: var(--line-height-base);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.crm-card-customer {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  min-width: 0;
}
.crm-card-customer > :last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.crm-card-customer-icon {
  font-size: var(--font-size-sm);
  opacity: 0.6;
  flex-shrink: 0;
}

/* Amount — главный визуальный сигнал в карточке */
.crm-card-amount {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-top: 2px;
  letter-spacing: -0.01em;
}

.crm-card-notes {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: var(--line-height-sm);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.crm-card-row {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
/* Inline-edit assigned-name — клик меняет ответственного без открытия модалки */
.crm-card-assigned {
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 2px 4px;
  margin: 0 -4px;
  transition: background var(--transition-fast);
}
.crm-card-assigned:hover {
  background: rgba(33, 120, 203, .14);
}
.crm-card-assigned:hover .crm-card-icon { color: var(--brand-on-primary); }
.menu-item-current { background: rgba(33, 120, 203, .10); }
.crm-card-row > :last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-card-icon {
  font-size: var(--font-size-sm);
  opacity: 0.6;
  flex-shrink: 0;
}

.crm-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.crm-card-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.crm-card-stale {
  font-size: var(--font-size-xs);
  color: var(--status-danger);
  font-weight: var(--font-weight-semibold);
}

/* Mobile - колонки уже */
@media (max-width: 768px) {
  .crm-col {
    min-width: 84vw;
    max-width: 84vw;
  }
}

/* END DEALS KANBAN ELC-STYLE */

/* Pipeline tabs — border-bottom indicator паттерн (как .tabs в components.css) */
.deals-pipeline-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
  align-items: stretch;
}
.deals-pipeline-tab {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  margin-bottom: -1px;
}
.deals-pipeline-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.deals-pipeline-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand-primary);
  background: transparent;
}
.deals-pipeline-tab:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}
.deals-board {
  width: 100%;
}


/* ============================================================
   DEALS TOOLBAR + LIST VIEW
   ============================================================ */

/* Toolbar */
/* =============================================================
 * Deals toolbar (search + filters + view-toggle)
 * Flat refresh — без тяжёлой обёртки-карточки.
 * ============================================================= */
.deals-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}
.deals-toolbar .input,
.deals-toolbar .select {
  margin: 0;
}
.deals-search {
  flex: 1 1 240px;
  min-width: 200px;
}
.deals-filter {
  flex: 0 1 160px;
  min-width: 130px;
}
.deals-filter-amount {
  flex: 0 1 110px;
  min-width: 90px;
}
.deals-toolbar-summary {
  margin-left: auto;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
  padding-left: 8px;
}

/* View toggle (Канбан / Список) — segmented control */
.view-toggle {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}
.vt-btn {
  height: 28px;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family-body);
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.vt-btn:hover { color: var(--text-primary); }
.vt-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.vt-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* =============================================================
 * Deals list (табличный вид)
 * Sticky header, плотные строки, мягкий hover, focus-glow.
 * ============================================================= */
.deals-list-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: auto;
  box-shadow: var(--shadow-card);
  max-height: calc(100vh - 280px);
}
.deals-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
  table-layout: auto;
}
.deals-list-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-base);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.deals-list-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.deals-list-table th.sortable:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.deals-list-table th.num,
.deals-list-table td.num {
  text-align: right;
}
.deals-list-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
  line-height: var(--line-height-base);
}
.deals-list-table tr:last-child td { border-bottom: none; }
.deals-list-table tr.deals-list-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.deals-list-table tr.deals-list-row:hover td {
  background: var(--bg-surface-hover);
}
.deals-list-table tr.deals-list-row:focus-within td {
  background: var(--bg-surface-active);
}
.deals-list-table tr.deals-list-row td strong {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}
/* Truncate длинного title в первой колонке */
.deals-list-table td:first-child {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Stage chip — мягкий badge с stage_color */
.deals-list-stage {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  line-height: 1;
}
.sort-icon {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.4;
}
.sort-icon.active {
  opacity: 1;
  color: var(--text-primary);
  color: var(--ac2);
}

@media (max-width: 768px) {
  .deals-toolbar { padding: 8px; }
  .deals-search { flex: 1 1 100%; min-width: 0; }
  .deals-filter, .deals-filter-amount { flex: 1 1 calc(50% - 4px); }
  .deals-toolbar-summary { margin-left: 0; flex: 1 1 100%; }
  
  /* На мобильном таблица скроллится горизонтально */
  .deals-list-wrap { overflow-x: auto; }
  .deals-list-table { min-width: 600px; }
}
/* END DEALS TOOLBAR + LIST VIEW */


/* ============================================================
   DEAL CARD MODAL (full-screen Bitrix-style)
   ============================================================ */

.deal-modal-backdrop {
  position: fixed;
  inset: 0;
  /* Раньше был backdrop-filter: blur(2px) — это перфоманс-убийца при скролле
     внутри модалки: браузер пересчитывает блюр на каждом кадре прокрутки.
     Заменили на чуть более тёмный плоский фон — тот же визуальный эффект
     «затемнения», но без лагов. */
  background: rgba(15, 17, 24, 0.62);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.deal-modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1140px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-modal);
}

.deal-modal-loading {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-base);
}

/* Header */
.deal-modal-header {
  display: flex;
  align-items: flex-start;
  padding: 16px 22px;
  border-bottom: 1px solid var(--b1);
  gap: 12px;
}
.deal-modal-title {
  flex: 1;
  min-width: 0;
}
.deal-modal-title h2 {
  font-family: var(--fd);
  font-size: 18px;
  font-weight: 700;
  color: var(--t1);
  margin: 0;
  line-height: 1.3;
}
.deal-modal-subtitle {
  font-size: 12px;
  color: var(--t3);
  margin-top: 4px;
}
.deal-modal-close {
  flex-shrink: 0;
}

/* Stage strip */
.deal-stage-strip {
  display: flex;
  gap: 4px;
  padding: 10px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--b1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.deal-stage-chip {
  flex-shrink: 0;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--fb);
  transition: all .15s;
  position: relative;
}
.deal-stage-chip:hover {
  background: var(--bg4);
  color: var(--t1);
}
.deal-stage-chip.past {
  background: var(--bg4);
  color: var(--t3);
  opacity: 0.7;
}
.deal-stage-chip.current {
  background: var(--stage-color, var(--ac));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.deal-stage-chip.success {
  border-color: rgba(63,216,142,0.4);
}
.deal-stage-chip.success.current {
  background: var(--gn);
  color: white;
}
.deal-stage-chip.lost {
  border-color: rgba(227,30,36,0.4);
}
.deal-stage-chip.lost.current {
  background: var(--rd);
  color: white;
}

/* Tabs */
.deal-tabs {
  display: flex;
  gap: 4px;
  padding: 0 22px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.deal-tab {
  background: transparent;
  border: none;
  color: var(--t2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  font-family: var(--fb);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.deal-tab:hover { color: var(--t1); }
.deal-tab.active {
  color: var(--ac2);
  border-bottom-color: var(--ac);
}
.deal-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Body */
.deal-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--bg);
}

/* Section */
.deal-section {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 12px;
  margin-bottom: 14px;
  overflow: hidden;
}
.deal-section-title {
  padding: 12px 18px;
  font-size: 11px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
}
.deal-section-body {
  padding: 14px 18px;
}

/* Field row - label слева, value справа */
.deal-field-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--b1);
}
.deal-field-row:last-child {
  border-bottom: none;
}
.deal-field-label {
  font-size: 12px;
  color: var(--t3);
  font-weight: 500;
}
.deal-field-value .input {
  margin: 0;
  font-size: 13px;
  padding: 7px 10px;
}
.deal-field-value textarea.input {
  padding: 8px 10px;
  font-family: var(--fb);
  resize: vertical;
}
.deal-field-readonly {
  font-size: 13px;
  color: var(--t1);
}

/* Footer */
.deal-modal-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--b1);
  background: var(--bg2);
}

/* Mobile */
@media (max-width: 768px) {
  .deal-modal-backdrop { padding: 0; }
  .deal-modal-content {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    height: 100vh;
  }
  .deal-field-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .deal-stage-strip { padding: 8px 14px; }
  .deal-modal-header,
  .deal-tabs,
  .deal-modal-body,
  .deal-modal-footer { padding-left: 14px; padding-right: 14px; }
}
/* END DEAL CARD MODAL */


/* ============================================================
   DEAL CARD v2
   ============================================================ */

.deal-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8,10,28,0.78);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
}
.deal-modal-content {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 14px;
  width: 100%;
  max-width: 1280px;
  max-height: 94vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.deal-modal-loading {
  padding: 60px 20px; text-align: center; color: var(--t3); font-size: 14px;
}

/* ============================================================
 * Deal-card modal — глубокий редизайн
 * ============================================================ */
.dc-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  flex-shrink: 0;
  min-height: 52px;
}
.dc-header-back {
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: 18px; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.dc-header-back:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
/* На desktop back-кнопка избыточна (есть ✕ справа). Скрываем на >= 768px. */
@media (min-width: 768px) {
  .dc-header-back { display: none; }
}
.dc-header-title-wrap { flex: 1; min-width: 0; }
.dc-header-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary); margin: 0; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dc-header-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Chevrons strip — стадии воронки */
.dc-chevrons {
  display: flex;
  padding: 10px 16px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.deal-chevron {
  flex: 1 1 0;
  min-width: 120px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: 10px 8px 10px 22px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-family-body);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.deal-chevron:first-child {
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
  border-radius: var(--radius-xs) 0 0 var(--radius-xs);
  padding-left: 12px;
}
.deal-chevron:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.deal-chevron:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.deal-chevron.past {
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.deal-chevron.current {
  background: var(--chevron-color, var(--text-primary));
  color: #fff;
  border-color: transparent;
  font-weight: var(--font-weight-semibold);
}
.deal-chevron.success.current {
  background: var(--status-success);
  color: #fff;
}
.deal-chevron.lost.current {
  background: var(--status-danger);
  color: #fff;
}
.deal-chevron:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  z-index: 1;
}
.deal-chevron-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: var(--font-size-sm);
  line-height: 1.2;
}

/* Main tabs (Общие / Товары) — underline-indicator паттерн */
.dc-tabs {
  display: flex; gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  background: var(--bg-surface);
  align-items: stretch;
}
.dc-tab {
  display: inline-flex; align-items: center;
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  padding: 0 16px;
  height: 40px;
  cursor: pointer;
  font-family: var(--font-family-body);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.dc-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.dc-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: var(--font-weight-semibold);
}
.dc-tab.disabled { opacity: 0.4; cursor: not-allowed; }
.dc-tab:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}

/* Body — двухколоночный.
   Левая 500px (~40%) — «о сделке», сводка, кастомные поля, оплата, заказ.
   Правая 1fr (~60%) — вкладки: WhatsApp, Товары, История, Дела.
   Пропорции под Bitrix24-стиль. */
.dc-body {
  flex: 1;
  overflow: hidden;
  display: grid;
  grid-template-columns: 500px 1fr;
  gap: 0;
  background: var(--bg-base);
}
.dc-left {
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding: 16px 20px 20px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
}
.dc-right {
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding: 16px 20px 20px;
  background: var(--bg-surface);
  /* Flex column — чтобы .dc-lifeline-body-whatsapp с height:100% мог
     забрать всю оставшуюся после табов высоту, а композер прибился ко дну. */
  display: flex;
  flex-direction: column;
}
.dc-right > .dc-lifeline-body-whatsapp,
.dc-right > .dc-lifeline-body-tasks,
.dc-right > .dc-lifeline-body-comments,
.dc-right > .dc-lifeline-body-history {
  flex: 1 1 auto;
  min-height: 0;
}

/* Section — плоская группа (без bg/border/radius переутомления).
   Только UPPERCASE label сверху + плотный список полей под. */
.dc-section {
  background: transparent;
  border: none;
  border-radius: 0;
  margin-bottom: 4px;
  overflow: visible;
  padding-top: 12px;
}
.dc-section + .dc-section {
  border-top: 1px solid var(--border-subtle);
  padding-top: 16px;
  margin-top: 12px;
}
.dc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 8px;
  background: transparent;
  border-bottom: none;
  gap: 8px;
}
.dc-section-toggle {
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-family-body);
  padding: 0;
}
.dc-section-toggle:hover { color: var(--text-primary); }
.dc-section-caret {
  transition: transform var(--transition-fast);
  font-size: 10px;
  opacity: .7;
}
.dc-section.collapsed .dc-section-caret {
  transform: rotate(-90deg);
}
.dc-section.collapsed .dc-section-body {
  display: none;
}
.dc-section-actions {
  display: flex; gap: 4px;
}
.dc-section-link {
  background: transparent; border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  cursor: pointer;
  padding: 2px 6px;
  font-family: var(--font-family-body);
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.dc-section-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.dc-section-body {
  padding: 0;
}

/* Row — label 140 | value 1fr. Без border-bottom (не «table») */
.dc-row {
  display: grid;
  /* Левая колонка 500px (~40%) — label-колонка может быть 130px без давления
     на инпуты (поле ввода ~330px). */
  grid-template-columns: 130px 1fr;
  gap: 12px;
  padding: 4px 0;
  align-items: start;
  border-bottom: none;
}
.dc-row + .dc-row { padding-top: 6px; }
.dc-row.dc-row-readonly { padding: 4px 0; }
.dc-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: var(--font-weight-medium);
  padding-top: 8px;
  line-height: var(--line-height-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}
.dc-label-req {
  color: var(--rd);
  font-weight: 700;
  margin-left: 2px;
}
.dc-row-error {
  animation: dc-row-error-flash 0.6s ease-in-out 0s 4 alternate;
}
@keyframes dc-row-error-flash {
  from { background: transparent; }
  to   { background: rgba(239, 68, 68, 0.16); }
}
/* Required-fields modal rows */
.rf-row { margin-bottom: 12px; }
.rf-row .rf-label {
  display: block;
  font-size: 12px;
  color: var(--t2);
  font-weight: 600;
  margin-bottom: 4px;
}
.rf-row .input { width: 100%; }
.dc-field-gear {
  background: transparent;
  border: none;
  color: var(--t3);
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  border-radius: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.dc-row:hover .dc-field-gear { opacity: 0.8; }
.dc-field-gear:hover {
  opacity: 1 !important;
  background: var(--bg3);
  color: var(--brand-primary);
}
.dc-field-hint {
  font-size: 11px;
  color: var(--t3);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.4;
}

/* === Popover настройки поля (Битрикс-стиль) === */
.dc-fc-pop {
  position: fixed;
  inset: 0;
  z-index: 9999;
}
.dc-fc-pop-card {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dc-fc-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
}
.dc-fc-pop-body { padding: 14px; display: flex; flex-direction: column; }
.dc-fc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--t1);
  flex-wrap: wrap;
}
.dc-fc-row input[type="checkbox"] { cursor: pointer; width: 16px; height: 16px; accent-color: var(--brand-primary); }
.dc-fc-stage-sel {
  flex: 1 1 100%;
  margin: 4px 0 0 24px;
  padding: 6px 8px;
  font-size: 12px;
  min-height: 90px;
}
/* Field-config popover — карточка со скроллом тела + sticky footer.
   Раньше без max-height карточка уезжала ниже viewport, кнопки
   Сохранить/Отменить было не видно. */
.dc-fc-pop-card {
  background: var(--bg-elevated, var(--bg2));
  border: 1px solid var(--bd, var(--b1));
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  overflow: hidden;  /* скруглённые углы поверх внутренних блоков */
}
.dc-fc-pop-head {
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bd, var(--b1));
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
}
.dc-fc-pop-body {
  flex: 1 1 auto;
  overflow-y: auto;       /* ← скролл когда контента много */
  padding: 16px 20px;
  min-height: 0;          /* критично для flex-скролла */
}
.dc-fc-pop-foot {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--bd, var(--b1));
  display: flex;
  gap: 10px;
  background: var(--bg-elevated, var(--bg2));  /* всегда видна, не прозрачная */
}
.dc-fc-pop-foot .btn { flex: 1; }
.dc-fc-close {
  background: transparent;
  border: none;
  color: var(--t3);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

/* Список этапов чекбоксами (мультивыбор кликом). Заменил <select multiple>. */
.dc-fc-stage-list {
  margin: 6px 0 0 24px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--bd, var(--b1));
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.dc-fc-stage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--t1);
  cursor: pointer;
  transition: background .1s;
}
.dc-fc-stage-item:hover { background: var(--bg-surface-hover, var(--bg3)); }
.dc-fc-stage-item input[type="checkbox"] {
  cursor: pointer;
  width: 15px; height: 15px;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}
.dc-fc-stage-item input:disabled + span { opacity: .5; }
.dc-fc-hint-small {
  font-size: 11px;
  color: var(--t3);
  margin: 4px 0 0 24px;
  font-style: italic;
}
#dc-fc-hint-text {
  margin: 6px 0 0 24px;
  font-size: 12px;
  width: calc(100% - 24px);
}
.dc-fc-pop-foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--b1);
  background: var(--bg3);
}
.dc-fc-close {
  background: transparent;
  border: none;
  color: var(--t3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.dc-fc-close:hover { background: var(--bg4); color: var(--t1); }
.dc-value {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  min-width: 0;
}
.dc-value .input,
.dc-value .select {
  margin: 0;
}
.dc-value textarea.input {
  height: auto;
  min-height: 64px;
  padding: 8px 12px;
  font-family: var(--font-family-body);
  resize: vertical;
}
.dc-row-readonly .dc-value {
  padding: 8px 0;
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

/* Customer card — flat (без отдельного inset-bg) */
.dc-customer-card {
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 0;
}
/* «Сменить клиента» — collapsible details */
.dc-customer-change {
  margin-top: 6px;
}
.dc-customer-change > summary {
  cursor: pointer;
  list-style: none;
  outline: none;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  padding: 4px 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
/* Скрываем нативный disclosure-маркер во ВСЕХ браузерах */
.dc-customer-change > summary::-webkit-details-marker { display: none; }
.dc-customer-change > summary::marker { content: ''; display: none; }
/* Наш собственный caret — SVG-стрелка, повторяет анимацию open/closed */
.dc-customer-change > summary::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke='%235e6470' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='3,2 7,5 3,8'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.dc-customer-change[open] > summary::before {
  transform: rotate(90deg);
}
.dc-customer-change > summary:hover { color: var(--text-primary); }
.dc-customer-change > summary:focus-visible {
  box-shadow: var(--shadow-focus);
}
.dc-customer-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}
.dc-customer-info { flex: 1; min-width: 0; }
.dc-customer-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dc-customer-phone {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 1px;
}
.dc-customer-actions {
  display: flex; gap: 4px;
}
.dc-customer-iconbtn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  text-decoration: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.dc-customer-iconbtn:hover {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.dc-amount-row {
  display: flex; gap: 8px; align-items: center;
}
.dc-amount-input { flex: 1; }
.dc-amount-row .btn { flex-shrink: 0; width: auto; }

/* Lifeline tabs — underline indicator паттерн (как .tabs) */
.dc-lifeline-tabs {
  display: flex;
  gap: 0;
  margin: -16px -20px 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  position: sticky;
  top: -16px;
  z-index: 1;
  align-items: stretch;
}
.dc-lifeline-tab {
  display: inline-flex; align-items: center;
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: 0 12px;
  height: 36px;
  cursor: pointer;
  font-family: var(--font-family-body);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.dc-lifeline-tab:hover {
  color: var(--text-primary);
}
.dc-lifeline-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--brand-primary);
}
.dc-lifeline-tab.disabled { opacity: 0.4; cursor: not-allowed; }
.dc-lifeline-tab:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}

.dc-lifeline-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  padding: 32px 14px;
  font-style: normal;
  line-height: var(--line-height-sm);
}
.dc-lifeline-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.dc-lifeline-item:last-child { border-bottom: none; }
.dc-lifeline-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-pill);
  background: var(--bg-active);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
}
.dc-lifeline-content { flex: 1; min-width: 0; }
.dc-lifeline-title {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-sm);
}
.dc-lifeline-title strong {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
}
.dc-lifeline-meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.dc-footer {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-base);
  flex-shrink: 0;
}

.dc-pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.dc-pick-row:hover { background: var(--bg3); }
.dc-pick-row input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
}
.dc-pick-row span { flex: 1; }
.dc-pick-badge {
  font-size: 9px;
  background: var(--acbg);
  color: var(--ac2);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

@media (max-width: 900px) {
  .dc-body {
    grid-template-columns: 1fr;
  }
  .dc-right {
    border-right: none;
    border-top: 1px solid var(--b1);
  }
  .dc-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .dc-label {
    padding-top: 0;
    padding-bottom: 2px;
  }
  .deal-modal-backdrop { padding: 0; }
  .deal-modal-content {
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
}
/* END DEAL CARD v2 */


/* ============================================================
   SELECT DROPDOWN ARROWS — custom caret for all selects
   ============================================================ */
select.input,
select.dept-filter,
select.deals-filter {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 4.5L6 7.5L9 4.5' stroke='%23a4a8c8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 32px !important;
  cursor: pointer;
}

/* Light theme — стрелка темнее */
:root[data-theme="light"] select.input,
:root[data-theme="light"] select.dept-filter,
:root[data-theme="light"] select.deals-filter {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 4.5L6 7.5L9 4.5' stroke='%234a4f72' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}

select.input:focus,
select.dept-filter:focus,
select.deals-filter:focus {
  outline: none;
  border-color: var(--ac);
}

/* На случай если select без класса input */
.dc-value select,
.deal-field-value select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
/* END SELECT ARROWS */


/* ============================================================
   ACTIVITY LOG in deal card right column
   ============================================================ */
.dc-lifeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--b1);
}
.dc-lifeline-title-text {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--t3);
}
.dc-bulk-btn {
  background: var(--rd);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--fb);
}
.dc-bulk-btn:hover { opacity: 0.85; }

.dc-act-item {
  display: flex;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--b1);
  align-items: flex-start;
  position: relative;
}
.dc-act-item:last-child { border-bottom: none; }
.dc-act-item:hover { background: var(--bg3); margin: 0 -8px; padding: 9px 8px; border-radius: 6px; }
.dc-act-item:hover .dc-act-del { opacity: 1; }

.dc-act-check {
  width: 14px; height: 14px;
  margin-top: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.dc-act-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--acbg);
  color: var(--ac2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.dc-act-content { flex: 1; min-width: 0; }
.dc-act-title {
  font-size: 12px;
  color: var(--t1);
  line-height: 1.4;
  word-break: break-word;
}
.dc-act-label {
  color: var(--t3);
  font-weight: 500;
}
.dc-act-old {
  color: var(--t3);
  text-decoration: line-through;
  opacity: 0.7;
}
.dc-act-wa-text {
  display: block;
  margin-top: 4px;
  padding: 6px 10px;
  background: rgba(34, 197, 94, 0.08);
  border-left: 3px solid var(--gn, #22c55e);
  border-radius: 4px;
  color: var(--t1);
  font-size: 12px;
  line-height: 1.4;
  word-wrap: break-word;
}
.dc-act-arrow {
  color: var(--t3);
  margin: 0 2px;
}
.dc-act-meta {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}
.dc-act-del {
  background: transparent;
  border: none;
  color: var(--rd);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s, background .15s;
  border-radius: 4px;
  flex-shrink: 0;
}
.dc-act-del:hover {
  background: var(--rdbg);
}
/* END ACTIVITY LOG */


/* ============================================================
   AMOUNT INPUT WIDTH FIX
   ============================================================ */
.dc-amount-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}
.dc-amount-input {
  flex: 1 1 auto !important;
  min-width: 180px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  padding: 8px 12px !important;
}
.dc-amount-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}
/* END AMOUNT INPUT FIX */


/* ============================================================
   CASHIER HINT under amount field
   ============================================================ */
.dc-amount-hint {
  font-size: 11px;
  color: var(--t3);
  margin-top: 4px;
}
.dc-amount-hint strong {
  color: var(--t2);
  font-weight: 600;
}
.dc-amount-hint-warn {
  color: var(--am);
}
/* END CASHIER HINT */


/* ============================================================
   FIELD PICKER (combined: show/hide + delete + create)
   ============================================================ */
.dc-pick-hint {
  font-size: 12px;
  color: var(--t3);
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 6px;
  line-height: 1.5;
}
.dc-pick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dc-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}
.dc-pick-row:hover {
  background: var(--bg3);
  border-color: var(--b1);
}
.dc-pick-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.dc-pick-name {
  flex: 1;
  min-width: 0;
  color: var(--t1);
}
.dc-pick-badge {
  font-size: 9px;
  background: var(--acbg);
  color: var(--ac2);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  flex-shrink: 0;
}
.dc-pick-badge-std {
  background: var(--bg4);
  color: var(--t3);
}
.dc-pick-del {
  background: transparent;
  border: none;
  color: var(--rd);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 16px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity .15s, background .15s;
}
.dc-pick-row:hover .dc-pick-del {
  opacity: 1;
}
.dc-pick-del:hover {
  background: var(--rdbg);
}
/* END FIELD PICKER */


/* ============================================================
   ACCEPT PAYMENT BUTTON (compact icon-style)
   ============================================================ */
.dc-pay-btn {
  flex: 0 0 auto;
  background: var(--ac);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--fb);
  cursor: pointer;
  white-space: nowrap;
  height: 30px;
  line-height: 1;
  transition: opacity .15s, background .15s;
}
.dc-pay-btn:hover:not(:disabled) {
  opacity: 0.9;
}
.dc-pay-btn:disabled {
  background: var(--bg4);
  color: var(--t3);
  cursor: not-allowed;
}

/* ============================================================
   ARCHIVE BUTTON (tiny text link, hard to hit by mistake)
   ============================================================ */
.dc-archive-link {
  background: transparent;
  border: none;
  color: var(--t3);
  font-size: 10px;
  font-family: var(--fb);
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  opacity: 0.55;
  transition: color .15s, opacity .15s;
}
.dc-archive-link:hover {
  color: var(--rd);
  opacity: 1;
}
/* END BUTTON FIXES */


/* ============================================================
   PIPELINE SETTINGS MODAL
   ============================================================ */
.ps-toolbar {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--b1);
}
.ps-empty {
  text-align: center;
  color: var(--t3);
  font-size: 13px;
  padding: 30px 14px;
  font-style: italic;
}
.ps-pipelines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ps-pipeline {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 10px 12px;
}
.ps-pipeline-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.ps-pipeline-name {
  flex: 1;
  margin: 0 !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}
.ps-pipeline-save,
.ps-pipeline-del,
.ps-stage-save,
.ps-stage-del {
  background: var(--bg4);
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.ps-pipeline-save:hover,
.ps-stage-save:hover {
  background: var(--gnbg);
  border-color: var(--gn);
}
.ps-pipeline-del:hover,
.ps-stage-del:hover {
  background: var(--rdbg);
  border-color: var(--rd);
}
.ps-stages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ps-stage-row {
  display: grid;
  grid-template-columns: 22px 12px 1fr 110px 110px 32px 32px;
  gap: 8px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 6px 8px;
}
.ps-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.ps-stage-name,
.ps-stage-color,
.ps-stage-type {
  margin: 0 !important;
  font-size: 12px !important;
  padding: 5px 8px !important;
}
.ps-add-stage {
  background: transparent;
  border: 1px dashed var(--b2);
  border-radius: 8px;
  color: var(--t3);
  font-size: 12px;
  padding: 8px;
  cursor: pointer;
  margin-top: 4px;
  font-family: var(--fb);
  transition: color .15s, border-color .15s;
}
.ps-add-stage:hover {
  color: var(--ac2);
  border-color: var(--ac);
}
@media (max-width: 700px) {
  .ps-stage-row {
    grid-template-columns: 12px 1fr 32px 32px;
    grid-template-rows: auto auto;
  }
  .ps-stage-color, .ps-stage-type {
    grid-column: 1 / -1;
  }
}
/* END PIPELINE SETTINGS */


/* DEALS TOPBAR COMPACT */
/* Topbar — keep view-toggle visible and shrink action buttons */
#deals-page .topbar,
.module-page .topbar:has(#deals-new-btn) {
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 8px;
}

/* View toggle — never shrink */
#deals-view-toggle {
  flex-shrink: 0;
  display: inline-flex;
  border: 1px solid var(--b1);
  border-radius: 8px;
  overflow: hidden;
}
#deals-view-toggle .vt-btn {
  background: transparent;
  border: 0;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--t2);
  font-family: var(--fb);
  transition: background .15s, color .15s;
}
#deals-view-toggle .vt-btn.active {
  background: var(--ac);
  color: var(--text-on-dark, #fff);
}
#deals-view-toggle .vt-btn:not(.active):hover {
  background: var(--bg3);
  color: var(--t1);
}

/* Settings button — compact */
#deals-settings-btn {
  flex-shrink: 0;
  padding: 4px 8px !important;
  font-size: 14px !important;
  min-width: 32px;
}

/* + Сделка button — make compact */
#deals-new-btn {
  flex-shrink: 0;
  padding: 5px 12px !important;
  font-size: 13px !important;
  height: auto !important;
  min-height: 0 !important;
}

/* Toolbar — Сбросить button compact */
#deals-filter-reset {
  flex-shrink: 0;
  padding: 5px 12px !important;
  font-size: 12px !important;
  height: auto !important;
  min-height: 0 !important;
}

/* Mobile — wrap nicely */
@media (max-width: 700px) {
  #deals-page .topbar {
    gap: 6px;
  }
  #deals-page .page-title {
    flex: 1 1 100%;
    margin-bottom: 4px;
  }
  #deals-view-toggle .vt-btn {
    padding: 4px 10px;
    font-size: 11px;
  }
  #deals-new-btn {
    padding: 4px 10px !important;
    font-size: 12px !important;
  }
}
/* END DEALS TOPBAR COMPACT */


/* DEALS BTN WIDTH FIX */
/* Override .btn width:100% for compact buttons in deals toolbar/topbar */
#deals-new-btn,
#deals-filter-reset {
  width: auto !important;
  flex: 0 0 auto !important;
}
/* END DEALS BTN WIDTH FIX */


/* DEAL PAYMENTS */
.dc-row-full { grid-column: 1 / -1; }
.pay-summary {
  background: var(--bg3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.pay-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 2px 0;
  color: var(--t2);
}
.pay-summary-row strong {
  color: var(--t1);
  font-weight: 600;
}
.pay-summary-remaining {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--b1);
  font-weight: 600;
}
.pay-progress {
  height: 6px;
  background: var(--bg2);
  border-radius: 3px;
  margin: 8px 0;
  overflow: hidden;
}
.pay-progress-bar {
  height: 100%;
  transition: width .3s ease;
  border-radius: 3px;
}

/* Явный баннер «что делать с деньгами» — крупно, цветом по смыслу.
   due (доплатить) — синий, refund (вернуть) — оранжевый, paid — зелёный. */
.pay-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.pay-banner-label { font-size: 13px; font-weight: 600; }
.pay-banner-amount { font-size: 19px; font-weight: 800; letter-spacing: -0.5px; }
.pay-banner-due {
  background: rgba(33, 120, 203, 0.12);
  border-color: var(--brand-primary, #2178cb);
  color: var(--brand-primary, #2178cb);
}
.pay-banner-refund {
  background: rgba(255, 152, 0, 0.12);
  border-color: var(--status-warning, #ff9800);
  color: var(--status-warning, #ff9800);
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.pay-banner-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pay-refund-btn {
  width: 100%;
  background: var(--status-warning, #ff9800);
  border-color: var(--status-warning, #ff9800);
  color: #fff;
  font-weight: 600;
}
.pay-refund-btn:hover { filter: brightness(0.94); }
.pay-row-refund {
  border-color: rgba(255, 152, 0, 0.45);
  background: rgba(255, 152, 0, 0.06);
}
.pay-row-refund .pay-amount { color: var(--status-warning, #ff9800); }
.pay-banner-paid {
  background: rgba(22, 163, 74, 0.12);
  border-color: var(--status-success, #16a34a);
  color: var(--status-success, #16a34a);
  justify-content: center;
}
.pay-banner-paid .pay-banner-label { font-size: 14px; }

.pay-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pay-row {
  display: grid;
  grid-template-columns: 24px 1fr 90px 1fr 70px 18px 28px;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  font-size: 12px;
  color: var(--t1);
}
.pay-icon { font-size: 14px; text-align: center; }
.pay-amount { font-weight: 600; }
.pay-method { color: var(--t2); font-size: 11px; }
.pay-by { color: var(--t2); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pay-date { color: var(--t3); font-size: 11px; }
.pay-note { font-size: 12px; cursor: help; }
.pay-del {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.5;
  transition: opacity .15s;
  padding: 2px 4px;
}
.pay-del:hover { opacity: 1; }
.pay-empty {
  padding: 14px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  font-style: italic;
}
.pay-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.pay-form-label {
  font-size: 12px;
  color: var(--t2);
  font-weight: 500;
}
.pay-form-warn {
  font-size: 11px;
  color: var(--am);
  margin-top: 2px;
}
.pay-method-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.pay-method-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.pay-method-opt input { cursor: pointer; }
.pay-method-opt:has(input:checked) {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
}
@media (max-width: 600px) {
  .pay-row {
    grid-template-columns: 20px 1fr 18px 28px;
    grid-template-rows: auto auto;
    row-gap: 2px;
  }
  .pay-method, .pay-by, .pay-date {
    grid-column: 2 / 5;
    font-size: 10px;
  }
}
/* END DEAL PAYMENTS */


/* DEAL CARD COMPACT FOOTER */
.dc-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--b1);
}
.dc-footer .btn,
.dc-footer #dp-save,
.dc-footer [data-close] {
  width: auto !important;
  flex: 0 0 auto !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  height: auto !important;
  min-height: 0 !important;
}
.dc-footer .btn.secondary {
  background: var(--bg3);
  color: var(--t1);
}
.dc-footer .btn.secondary:hover {
  background: var(--bg4);
}
.dc-archive-link {
  background: transparent;
  border: 0;
  color: var(--t3);
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  padding: 4px 6px;
}
.dc-archive-link:hover { color: var(--rd); }

/* Payment modal — Принять button compact */
#pay-form-submit {
  width: auto !important;
  flex: 0 0 auto !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  height: auto !important;
  min-height: 0 !important;
}
/* END DEAL CARD COMPACT FOOTER */


/* PAYMENT MODAL BUTTONS COMPACT */
/* Buttons inside Add Payment modal — kill width:100% from base .btn */
.modal-backdrop .modal [data-close].btn,
.modal-backdrop .modal [data-close].btn.btn-sm,
#pay-form-submit {
  width: auto !important;
  flex: 0 0 auto !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  height: auto !important;
  min-height: 0 !important;
}
/* END PAYMENT MODAL BUTTONS COMPACT */


/* PIPELINE PAYMENT ACTION */
.ps-payment-action {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 12px;
}
.ps-pa-title {
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 6px;
}
.ps-pa-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  color: var(--t1);
}
.ps-pa-opt input[type="radio"] {
  cursor: pointer;
  flex-shrink: 0;
}
.ps-pa-opt-row {
  flex-wrap: wrap;
}
.ps-pa-opt-row .input {
  margin: 0 !important;
  padding: 4px 8px !important;
  font-size: 11px !important;
  flex: 0 1 auto;
  min-width: 120px;
}
/* Auto-save индикатор «✓ сохранено» рядом с селектами. Fade-out через 1.5s. */
.ps-pa-saved {
  font-size: 11px;
  color: var(--status-success);
  font-weight: 500;
  opacity: 0;
  transition: opacity .25s ease;
  min-width: 90px;
}
.ps-pa-saved.flash {
  opacity: 1;
}
.ps-pa-save-route {
  background: var(--bg4);
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  padding: 3px 7px;
  font-size: 11px;
}
.ps-pa-save-route:hover {
  background: var(--gnbg);
  border-color: var(--gn);
}
/* END PIPELINE PAYMENT ACTION */


/* PIPELINE ACCORDION */
.ps-pipeline-toggle {
  background: var(--bg4);
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  color: var(--t2);
  transition: background .15s;
}
.ps-pipeline-toggle:hover {
  background: var(--bg3);
  color: var(--t1);
}
.ps-pipeline-chevron {
  font-size: 9px;
  display: inline-block;
  transition: transform .15s;
}
.ps-pipeline-count {
  background: var(--bg2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--t2);
  font-weight: 600;
}
.ps-stages {
  flex-direction: column;
  gap: 6px;
}
/* END PIPELINE ACCORDION */


/* DEALS PIPELINE SELECT */
.deals-pipeline-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--b1);
}
.deals-pipeline-select-label {
  font-size: 12px;
  color: var(--t2);
  font-weight: 500;
  flex-shrink: 0;
}
.deals-pipeline-select {
  min-width: 200px;
  max-width: 320px;
  margin: 0 !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
  font-weight: 600;
}
@media (max-width: 600px) {
  .deals-pipeline-tabs {
    padding: 6px 8px;
  }
  .deals-pipeline-select {
    flex: 1;
    min-width: 0;
    max-width: none;
  }
}
/* END DEALS PIPELINE SELECT */


/* TASKS UI */
.dc-lifeline-tab {
  cursor: pointer;
}
.dc-lifeline-tab.disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.dc-lifeline-body-tasks {
  padding: 8px;
}
/* =============================================================
 * Tasks — единый паттерн с deal-секциями
 * ============================================================= */
.tasks-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tasks-new-btn {
  align-self: flex-start;
  width: auto;
}
.tasks-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-style: normal;
  line-height: var(--line-height-sm);
}
.tasks-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.tasks-group summary {
  cursor: pointer;
  list-style: none;
  outline: none;
  padding: 4px 0;
  border-radius: var(--radius-sm);
}
.tasks-group summary:focus-visible {
  box-shadow: var(--shadow-focus);
}
.tasks-group summary::-webkit-details-marker { display: none; }
.tasks-group-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
}
.tasks-group-overdue {
  color: var(--status-danger);
}
.task-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.task-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.task-row.task-overdue {
  border-color: var(--status-danger-border);
  background: var(--bg-surface);
}
.task-row.task-overdue::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--status-danger);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  pointer-events: none;
}
.task-row.task-completed,
.task-row.task-skipped {
  opacity: 0.6;
}
.task-row.task-completed .task-title,
.task-row.task-skipped .task-title {
  text-decoration: line-through;
}
.task-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.task-title {
  flex: 1;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: var(--line-height-base);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-del {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 4px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.task-del:hover { color: var(--status-danger); background: var(--status-danger-bg); }
.task-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: var(--line-height-sm);
}
.task-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.task-time { font-weight: var(--font-weight-medium); color: var(--text-secondary); }
.task-who-co {
  color: var(--brand-primary);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(33, 120, 203, 0.12);
}
.task-result {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  background: var(--bg-base);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-strong);
  font-style: normal;
  line-height: var(--line-height-sm);
}
.task-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.task-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  height: 24px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  font-family: var(--font-family-body);
  color: var(--text-secondary);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.task-btn-complete:hover {
  background: var(--status-success-bg);
  border-color: var(--status-success-border);
  color: var(--status-success);
}
.task-btn-skip:hover {
  background: var(--bg-hover);
}
/* Task form modal */
.task-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.task-form-row-dt {
  flex-direction: row;
  gap: 10px;
}
.task-form-label {
  font-size: 12px;
  color: var(--t2);
  font-weight: 500;
}
.task-type-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.task-type-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.task-type-opt:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.task-type-opt input { cursor: pointer; }
.task-type-opt:has(input:checked) {
  background: var(--action-primary);
  color: var(--action-on-primary);
  border-color: var(--action-primary);
}
/* END TASKS UI */


/* KANBAN CARD BADGES + SOURCE */
.crm-card-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
}
.crm-card-header .crm-card-title {
  flex: 1;
  margin-bottom: 0;
}
.crm-card-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}
.crm-card-badge-active {
  background: var(--ac);
}
.crm-card-badge-overdue {
  background: var(--rd);
  animation: badge-pulse 2s infinite;
}
/* На hover карточки сделки появляется .deal-card-ping-btn (position:absolute,
   top:6px right:6px, 26×26). Без сдвига он перекрывает badge с числом дел.
   Сдвигаем badge влево на ширину bell+gap, плавно. */
.crm-card:hover .crm-card-badge {
  margin-right: 32px;
  transition: margin-right 0.15s;
}
.crm-card .crm-card-badge {
  transition: margin-right 0.15s;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 30, 36, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(227, 30, 36, 0); }
}

.crm-card-source {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--bg4);
  color: var(--t2);
}
/* #206 — исходная воронка под названием (когда сделку перенесли) */
.crm-card-origin {
  font-size: 11px;
  color: var(--t3);
  margin: -2px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-card-source.src-whatsapp  { background: #25d366; color: #fff; }
.crm-card-source.src-instagram { background: #e1306c; color: #fff; }
.crm-card-source.src-tiktok    { background: #000;    color: #fff; }
.crm-card-source.src-call      { background: #1976d2; color: #fff; }
.crm-card-source.src-site      { background: #6168c4; color: #fff; }
.crm-card-source.src-referral  { background: #ffcc00; color: #333; }
.crm-card-source.src-dealer    { background: #ff9800; color: #fff; }
.crm-card-source.src-other     { background: #9896b0; color: #fff; }
/* END KANBAN CARD BADGES + SOURCE */


/* TRANSFER BTN */
#dp-transfer-pipeline {
  font-size: 13px !important;
  padding: 4px 8px !important;
}
/* END TRANSFER BTN */


/* FIELD OPTIONS EDITOR */
.dc-act-toolbar {
  padding: 4px 8px 0;
  min-height: 24px;
}
.dc-act-bulk-btn {
  background: var(--rd);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--fb);
  font-weight: 600;
}
.dc-act-bulk-btn:hover {
  opacity: 0.85;
}

.dc-pick-edit-opts {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity .15s;
}
.dc-pick-edit-opts:hover {
  opacity: 1;
}

.opt-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.opt-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.opt-input {
  flex: 1;
  margin: 0 !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}
.opt-del {
  background: transparent;
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--t3);
  padding: 2px 8px;
  line-height: 1;
  flex-shrink: 0;
}
.opt-del:hover {
  background: var(--rdbg);
  color: var(--rd);
  border-color: var(--rd);
}
/* END FIELD OPTIONS EDITOR */


/* TASKS PAGE */
.tasks-toolbar {
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--b1);
}
.tasks-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* vt-toggle — segmented control (как .view-toggle). Согласовано визуально. */
.vt-toggle {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}
.vt-toggle .vt-btn {
  background: transparent;
  border: 0;
  height: 28px;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-family-body);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.vt-toggle .vt-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.vt-toggle .vt-btn:hover:not(.active) {
  color: var(--text-primary);
}
.vt-toggle .vt-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.tasks-filter {
  margin: 0 !important;
  min-width: 150px;
}
.tasks-show-completed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  color: var(--text-secondary);
  margin-left: auto;
}
.tasks-show-completed input {
  cursor: pointer;
}
.tasks-page-list {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.tasks-flat {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-deal-link {
  font-size: 11px;
  color: var(--ac);
  cursor: pointer;
  margin: 2px 0;
}
.task-deal-link:hover {
  text-decoration: underline;
}
/* END TASKS PAGE */


/* IN-APP NOTIFICATIONS */
.notif-toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  max-width: 380px;
  pointer-events: none;
}
.notif-toast {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-left: 4px solid var(--ac);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity .25s, transform .25s;
  pointer-events: auto;
  position: relative;
  min-width: 280px;
}
.notif-toast-show {
  opacity: 1;
  transform: translateX(0);
}
.notif-toast-hide {
  opacity: 0;
  transform: translateX(20%);
}
.notif-toast-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--t1);
  margin-bottom: 4px;
  padding-right: 24px;
}
.notif-toast-body {
  font-size: 12px;
  color: var(--t2);
}
.notif-toast-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--t3);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}
.notif-toast-close:hover {
  color: var(--t1);
}
.notif-toast-task_assigned,
.notif-toast-task_reassigned {
  border-left-color: var(--ac);
}
.notif-toast-task_reminder {
  border-left-color: #ff9800;
}
.notif-toast-task_overdue,
.notif-toast-task_overdue_supervisor {
  border-left-color: var(--rd);
}
.notif-toast-deal_assigned,
.notif-toast-deal_reassigned {
  border-left-color: #1976d2;
}
@media (max-width: 600px) {
  .notif-toast-container {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  .notif-toast {
    min-width: 0;
  }
}
/* END IN-APP NOTIFICATIONS */


/* GRACE & TASK DUE */
.task-row.task-due {
  border-color: #ff9800;
  background: rgba(255, 152, 0, 0.05);
}
.task-row.task-due .task-time {
  color: #ff9800;
  font-weight: 600;
}

.ps-grace-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ps-grace-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.ps-grace-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}
.ps-grace-label {
  flex: 1;
  font-size: 13px;
  color: var(--t1);
}
.ps-grace-suffix {
  font-size: 11px;
  color: var(--t3);
}
.ps-grace-save {
  background: var(--bg4);
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
}
.ps-grace-save:hover {
  background: var(--gnbg);
  border-color: var(--gn);
}

/* 2-колоночный режим: лейбл | reminder | grace | save */
.ps-grace-header {
  display: grid;
  grid-template-columns: 130px 1fr 1fr 36px;
  gap: 10px;
  align-items: center;
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--b1);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--t3);
}
.ps-grace-col-title { text-align: left; }
.ps-grace-row-2col {
  display: grid;
  grid-template-columns: 130px 1fr 1fr 36px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--b1);
}
.ps-grace-row-2col:last-child { border-bottom: none; }
.ps-grace-label-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ps-grace-input-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ps-grace-input-cell input.ps-grace-input {
  width: 70px;
  margin: 0;
  padding: 5px 8px;
  font-size: 12px;
}
@media (max-width: 600px) {
  .ps-grace-header { display: none; }
  .ps-grace-row-2col {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
/* END GRACE & TASK DUE */


/* COMMENTS UI */
.dc-lifeline-body-comments {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cmt-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--b1);
}
.cmt-form textarea {
  margin: 0 !important;
  padding: 8px 10px !important;
}
.cmt-form-actions {
  display: flex;
  justify-content: flex-end;
}
.cmt-empty {
  padding: 16px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  font-style: italic;
}
.cmt-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cmt-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.cmt-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
}
.cmt-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.cmt-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.cmt-body {
  flex: 1;
  min-width: 0;
}
.cmt-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 2px;
}
.cmt-author {
  font-weight: 700;
  color: var(--t1);
}
.cmt-time {
  color: var(--t3);
}
.cmt-edited {
  color: var(--t3);
  font-style: italic;
  font-size: 10px;
}
.cmt-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .15s;
}
.cmt-row:hover .cmt-actions {
  opacity: 1;
}
.cmt-action-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--t3);
  padding: 0 4px;
  line-height: 1;
}
.cmt-action-btn:hover {
  color: var(--t1);
}
.cmt-action-del:hover {
  color: var(--rd);
}
.cmt-text {
  font-size: 13px;
  color: var(--t1);
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
/* END COMMENTS UI */


/* MENTION AUTOCOMPLETE */
.cmt-input-wrap {
  position: relative;
}
.cmt-mention-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-width: 320px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  overflow: hidden;
  z-index: 1000;
  opacity: 1;
  backdrop-filter: none;
}
.cmt-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t1);
}
.cmt-mention-item:hover,
.cmt-mention-item.active {
  background: var(--ac);
  color: #fff;
}
.cmt-mention-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--t1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.cmt-mention-item.active .cmt-mention-avatar {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.cmt-mention-name {
  flex: 1;
}
.cmt-mention {
  background: rgba(97, 104, 196, 0.15);
  color: var(--ac);
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 4px;
}
/* END MENTION AUTOCOMPLETE */


/* NOTIFICATION CENTER */
.notif-bell-btn {
  position: relative;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 18px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
/* Hover/active use rail-цвета — иначе на тёмно-синем navy рейле
   светлый --bg3 даёт «засвет» (бледно-кремовый блик).
   .notif-bell-btn.active — когда попап уведомлений открыт. */
.notif-bell-btn:hover {
  background: var(--rail-bg-hover);
  color: var(--rail-text-active);
}
.notif-bell-btn.active {
  background: var(--rail-active-bg);
  color: var(--rail-text-active);
  box-shadow: inset 3px 0 0 0 var(--brand-primary);
}
.notif-bell-icon {
  line-height: 1;
}
.notif-bell-badge {
  position: absolute;
  top: 4px;
  left: 26px;
  background: var(--rd);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notif-center {
  position: fixed;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  background-color: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.35);
  z-index: 9998;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.notif-center-head {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--b1);
  background: var(--bg2);
}
.notif-center-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--t1);
  flex: 1;
}
.notif-center-clear {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  color: var(--ac);
  padding: 4px 8px;
}
.notif-center-clear:hover {
  text-decoration: underline;
}
.notif-center-list {
  overflow-y: auto;
  flex: 1;
}
.notif-center-empty {
  padding: 24px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  font-style: italic;
}
.notif-item {
  position: relative;
  padding: 10px 14px 10px 28px;
  border-bottom: 1px solid var(--b1);
  cursor: pointer;
  display: flex;
  gap: 8px;
}
.notif-item:hover {
  background: var(--bg2);
}
.notif-item:last-child {
  border-bottom: 0;
}
.notif-item-dot {
  position: absolute;
  left: 10px;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ac);
}
.notif-item-unread .notif-item-title {
  font-weight: 700;
}
.notif-item-body {
  flex: 1;
  min-width: 0;
}
.notif-item-title {
  font-size: 13px;
  color: var(--t1);
  margin-bottom: 2px;
}
.notif-item-text {
  font-size: 12px;
  color: var(--t2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-item-time {
  font-size: 10px;
  color: var(--t3);
  margin-top: 4px;
}
/* Missed-call entries — red accent stripe on the unread dot side */
.notif-item-missed {
  border-left: 3px solid var(--rd);
  padding-left: 25px; /* compensate for the stripe so dot stays aligned */
}
.notif-item-missed .notif-item-dot {
  background: var(--rd);
}
/* END NOTIFICATION CENTER */


/* WORKDAY */
.workday-btn .rail-icon-label {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.workday-panel {
  position: fixed;
  width: 280px;
  background-color: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.35);
  z-index: 9998;
  overflow: hidden;
}
.workday-panel-head {
  padding: 12px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--t1);
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
}
.workday-panel-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.workday-status {
  font-size: 14px;
  font-weight: 700;
}
.workday-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.workday-paused-total {
  font-size: 11px;
  color: var(--t3);
}
.workday-ended-note {
  font-size: 12px;
  color: var(--t3);
  font-style: italic;
  padding: 6px 0;
}
.workday-actions {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.workday-mobile-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 14px 12px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px dashed var(--b1);
}
.workday-mobile-block-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 2px;
  opacity: 0.85;
}
.workday-mobile-block-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--t1);
}
.workday-mobile-block-text {
  font-size: 12px;
  color: var(--t3);
  line-height: 1.35;
}
.workday-action-btn {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--b1);
  background: var(--bg3);
  color: var(--t1);
  text-align: center;
}
.workday-action-btn:hover {
  background: var(--bg4);
}
.workday-action-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}
/* Workday action кнопки — solid Bitrix-style. Высокая specificity
   (.workday-panel .workday-action-btn.workday-btn-*) и !important чтобы не
   ловить случайных override от .btn / .btn.danger / focus стейтов. */
.workday-panel .workday-action-btn.workday-btn-start,
.workday-panel .workday-action-btn.workday-btn-resume {
  background: var(--status-success) !important;
  color: #ffffff !important;
  border-color: var(--status-success) !important;
}
.workday-panel .workday-action-btn.workday-btn-start:hover,
.workday-panel .workday-action-btn.workday-btn-resume:hover {
  background: var(--status-success) !important;
  filter: brightness(1.08);
}
.workday-panel .workday-action-btn.workday-btn-pause {
  background: var(--status-warning) !important;
  color: #ffffff !important;
  border-color: var(--status-warning) !important;
}
.workday-panel .workday-action-btn.workday-btn-pause:hover {
  background: var(--status-warning) !important;
  filter: brightness(1.08);
}
.workday-panel .workday-action-btn.workday-btn-end {
  background: var(--status-danger) !important;
  color: #ffffff !important;
  border-color: var(--status-danger) !important;
}
.workday-panel .workday-action-btn.workday-btn-end:hover {
  background: var(--status-danger) !important;
  filter: brightness(1.08);
}
/* END WORKDAY */


/* WORK SCHEDULE */
.ps-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ps-sched-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 12px;
}
.ps-sched-day {
  width: 32px;
  font-weight: 600;
  color: var(--t1);
}
.ps-sched-workday {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--t2);
  min-width: 80px;
}
.ps-sched-workday input {
  margin: 0;
}
.ps-sched-save {
  background: var(--bg4);
  border: 1px solid var(--b1);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
}
.ps-sched-save:hover {
  background: var(--gnbg);
  border-color: var(--gn);
}
.ps-sched-settings-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--b1);
}
.ps-sched-set-label {
  font-size: 12px;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: 4px;
}
/* END WORK SCHEDULE */


/* OVERTIME DIALOGS */
.workday-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.workday-dialog {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.workday-dialog-head {
  padding: 14px 18px;
  font-weight: 700;
  font-size: 14px;
  color: var(--t1);
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
}
.workday-dialog-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
}
.workday-dialog-label {
  font-size: 12px;
  color: var(--t2);
  margin-bottom: 4px;
}
.workday-dialog-body .input {
  margin: 0;
  font-size: 13px;
}
.workday-dialog-actions {
  padding: 12px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--b1);
  background: var(--bg3);
}
.workday-btn-overtime {
  background: var(--bg4);
  color: var(--t1);
  border-color: var(--b1);
  margin-top: 4px;
}
.workday-btn-overtime:hover {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
}
.workday-overtime-approved {
  font-size: 11px;
  color: var(--gn);
  font-weight: 600;
  padding: 4px 0;
}
.ot-review-meta {
  font-size: 14px;
  color: var(--t1);
  margin-bottom: 6px;
}
.ot-review-note {
  font-size: 12px;
  color: var(--t2);
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: 8px;
  margin-bottom: 6px;
}
/* END OVERTIME DIALOGS */


/* TOAST ACTIONS */
.notif-toast-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.notif-toast-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--b1);
  background: var(--bg3);
  color: var(--t1);
}
.notif-toast-btn:hover {
  background: var(--bg4);
}
.notif-toast-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.notif-toast-btn-approve {
  background: var(--gn);
  color: #fff;
  border-color: var(--gn);
}
.notif-toast-btn-reject {
  background: var(--rd);
  color: #fff;
  border-color: var(--rd);
}
/* END TOAST ACTIONS */


/* WORKTIME */
.wt-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 14px 0;
  border-bottom: 1px solid var(--b1);
}
.wt-tab {
  background: transparent;
  border: 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--t2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.wt-tab:hover { color: var(--t1); }
.wt-tab.active {
  color: var(--ac);
  border-bottom-color: var(--ac);
  font-weight: 600;
}
.wt-body { padding: 14px; }
.wt-live-header {
  font-size: 12px;
  color: var(--t3);
  margin-bottom: 10px;
}
.wt-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.wt-summary-item {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  font-size: 12px;
  color: var(--t1);
  display: flex;
  align-items: center;
  gap: 6px;
}
.wt-summary-num {
  font-size: 14px;
  font-weight: 700;
}
.wt-summary-item.wt-working { border-color: var(--gn); }
.wt-summary-item.wt-paused  { border-color: var(--am); }
.wt-summary-item.wt-late    { border-color: var(--rd); }
.wt-summary-item.wt-ended   { border-color: var(--t3); }

.wt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wt-row {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--b1);
  border-radius: 10px;
  background: var(--bg2);
}
.wt-row.wt-working  { border-left: 4px solid var(--gn); }
.wt-row.wt-paused   { border-left: 4px solid var(--am); }
.wt-row.wt-late     { border-left: 4px solid var(--rd); }
.wt-row.wt-noshow   { border-left: 4px solid var(--rd); background: rgba(255,82,82,0.05); }
.wt-row.wt-ended    { border-left: 4px solid var(--t3); }
.wt-row.wt-off      { border-left: 4px solid var(--t3); opacity: 0.7; }
.wt-row.wt-notstarted { border-left: 4px solid var(--t3); opacity: 0.85; }

.wt-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.wt-avatar-img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.wt-avatar-fallback {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--ac); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.wt-row-body { flex: 1; min-width: 0; }
.wt-row-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.wt-name { font-weight: 600; font-size: 13px; color: var(--t1); }
.wt-role {
  font-size: 10px; color: var(--t3); text-transform: uppercase; letter-spacing: .5px;
  background: var(--bg3); padding: 1px 6px; border-radius: 4px;
}
.wt-late-badge {
  font-size: 10px; color: var(--rd); font-weight: 600;
  background: rgba(255,82,82,0.1); padding: 2px 6px; border-radius: 4px;
}
.wt-row-detail {
  display: flex; align-items: center; gap: 8px; font-size: 11px;
}
.wt-status-pill {
  padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.wt-status-pill.wt-working  { background: rgba(76,175,80,0.15); color: var(--gn); }
.wt-status-pill.wt-paused   { background: rgba(255,152,0,0.15); color: var(--am); }
.wt-status-pill.wt-late     { background: rgba(255,82,82,0.15); color: var(--rd); }
.wt-status-pill.wt-noshow   { background: rgba(255,82,82,0.25); color: var(--rd); }
.wt-status-pill.wt-ended    { background: var(--bg3); color: var(--t2); }
.wt-status-pill.wt-off      { background: var(--bg3); color: var(--t3); }
.wt-status-pill.wt-notstarted { background: var(--bg3); color: var(--t3); }
.wt-detail-text { color: var(--t2); }

.wt-report-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--b1);
}
.wt-ctrl-label { font-size: 12px; color: var(--t2); }
.wt-report-table {
  width: 100%; border-collapse: collapse; margin-top: 4px;
}
.wt-report-table th {
  text-align: left; padding: 8px; font-size: 11px;
  color: var(--t3); text-transform: uppercase;
  border-bottom: 1px solid var(--b1);
  font-weight: 600;
}
.wt-report-table td {
  padding: 6px 8px; font-size: 13px; color: var(--t1);
  border-bottom: 1px solid var(--b1);
}
.wt-report-day-row td { padding-top: 2px; padding-bottom: 2px; }
.wt-report-meta { padding: 8px; font-size: 11px; color: var(--t3); }
/* END WORKTIME */


/* ORG STRUCTURE */
.org-modal {
  max-width: 820px;
  width: 95%;
  max-height: 85vh;
}
.org-modal .modal-body {
  padding: 0;
  overflow-y: auto;
}

.org-tree {
  padding: 8px 16px 4px;
}

.org-node {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 4px 0;
}

.org-caret {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--t2);
  width: 24px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.org-caret:hover { background: var(--bg3); color: var(--t1); }
.org-caret-empty { cursor: default; color: var(--t3); opacity: 0.4; }
.org-caret-empty:hover { background: transparent; }

.org-node-card {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--b1);
  border-radius: 10px;
  background: var(--bg2);
  transition: border-color 0.15s, background 0.15s;
  min-height: 52px;
}
.org-node-card:hover {
  background: var(--bg3);
  border-color: var(--b2);
}

.org-node-main { min-width: 0; }
.org-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--t1);
  line-height: 1.2;
}
.org-desc {
  font-size: 11px;
  color: var(--t3);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-mgr {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 220px;
}
.org-mgr-empty {
  font-size: 11px;
  color: var(--t3);
  font-style: italic;
  padding: 4px 0;
}
.org-mgr-avatar {
  flex-shrink: 0;
}
.org-mgr-avatar-img,
.org-mgr-avatar-fb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.org-mgr-avatar-img { object-fit: cover; }
.org-mgr-avatar-fb {
  background: var(--ac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.org-mgr-info { min-width: 0; }
.org-mgr-name {
  font-size: 12px;
  color: var(--t1);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.org-mgr-pos {
  font-size: 10px;
  color: var(--t3);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.org-count-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 5px 10px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 14px;
  flex-shrink: 0;
}
.org-count-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.org-count-lbl {
  font-size: 10px;
  color: var(--t3);
  text-transform: lowercase;
}

.org-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.org-act-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--t2);
  transition: background 0.15s, color 0.15s;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.org-act-btn:hover {
  background: var(--bg4);
  color: var(--t1);
}
.org-act-btn.org-act-del:hover {
  background: rgba(255, 82, 82, 0.12);
  color: var(--rd);
}

.org-children {
  margin-left: 24px;
  padding-left: 12px;
  border-left: 2px dashed var(--b1);
  margin-top: 2px;
  margin-bottom: 2px;
}

.org-footer {
  padding: 14px 16px 18px;
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--b1);
  margin-top: 8px;
  background: var(--bg2);
}

.org-empty {
  padding: 50px 30px;
  text-align: center;
}
.org-empty-icon {
  font-size: 48px;
  opacity: 0.5;
  margin-bottom: 12px;
}
.org-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 6px;
}
.org-empty-sub {
  font-size: 13px;
  color: var(--t3);
}

/* Edit dialog */
.org-edit-modal {
  max-width: 500px;
}
.org-edit-modal .modal-body {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.org-form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.org-form-field .field-label {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0;
  font-weight: 600;
}
.org-form-field .input {
  margin: 0;
}

/* Responsive — narrow columns on small screens */
@media (max-width: 720px) {
  .org-node-card {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main count"
      "mgr  actions";
    gap: 8px;
  }
  .org-node-main { grid-area: main; }
  .org-count-badge { grid-area: count; }
  .org-mgr { grid-area: mgr; max-width: 100%; }
  .org-actions { grid-area: actions; }
}
/* END ORG STRUCTURE */


/* Generic close button for modals */
.btn-icon-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--t3);
  padding: 4px 10px;
  border-radius: 8px;
}
.btn-icon-close:hover {
  color: var(--t1);
  background: var(--bg3);
}

/* Org modal — extra width */
.org-modal {
  max-width: 720px !important;
}

/* Slight tweak: org-tree breathing room */
.modal-body > .org-tree {
  padding: 12px 18px;
}
.org-tree .org-node {
  padding: 8px 6px;
}


/* DASHBOARD */
/* =============================================================
 * Dashboard — KPI карты + блоки графиков
 * ============================================================= */
.dash-filters {
  padding: 14px 16px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-period-tabs {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  align-self: flex-start;
}
.dash-period-tab {
  height: 28px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: var(--font-family-body);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.dash-period-tab:hover { color: var(--text-primary); }
.dash-period-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.dash-period-tab:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.dash-period-custom {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dash-flabel {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-top: 3px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.dash-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}
.dash-card-open    { border-top-color: var(--status-info); }
.dash-card-won     { border-top-color: var(--status-success); }
.dash-card-lost    { border-top-color: var(--status-danger); }
.dash-card-conv    { border-top-color: var(--brand-primary); }
.dash-card-avg     { border-top-color: var(--text-secondary); }
.dash-card-revenue { border-top-color: var(--status-success); }
.dash-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--text-muted);
}
.dash-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.dash-card-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
}
.dash-card-val {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.dash-card-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
 * Top managers — leaderboard with medals + progress bars
 * ============================================================ */
.dash-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 0;
}
.dash-tm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.dash-tm-row:last-child { border-bottom: none; }
.dash-tm-row-top {
  background: linear-gradient(90deg, rgba(255,199,0,.06), transparent 60%);
}
.dash-tm-medal {
  font-size: 22px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.dash-tm-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}
.dash-tm-avatar,
.dash-tm-avatar-fb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
}
.dash-tm-avatar-fb {
  background: var(--bg-active);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
  text-transform: uppercase;
}
.dash-tm-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-tm-name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-tm-bar {
  height: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.dash-tm-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  transition: width 300ms ease;
}
.dash-tm-stats {
  text-align: right;
  flex-shrink: 0;
}
.dash-tm-sum {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.dash-tm-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .dash-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dash-card { padding: 12px; }
  .dash-card-val { font-size: var(--font-size-xl); }
  .dash-tm-bar { display: none; }
  .dash-tm-stats { text-align: right; }
  /* Dashboard filters — компактнее */
  .dash-filters { padding: 8px 0; gap: 6px; }
  .dash-period-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    margin: 0 -12px;
    padding: 0 12px 4px;
  }
  .dash-period-tab { flex-shrink: 0; }
  .dash-filter-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .dash-filter-row .input,
  .dash-filter-row select { width: 100% !important; }
  .dash-flabel { font-size: var(--font-size-xs); }
  /* Stale-row компактнее */
  .dash-stale-row { padding: 10px 12px; gap: 10px; }
  .dash-stale-amount { font-size: var(--font-size-xs); }
  /* Leaderboard на мобиле */
  .dash-tm-row { padding: 10px 12px; gap: 8px; }
  .dash-tm-medal { font-size: 18px; width: 22px; }
  .dash-tm-avatar, .dash-tm-avatar-fb { width: 32px; height: 32px; }
}

/* ============================================================
 * Stale deals widget — застрявшие сделки
 * ============================================================ */
.dash-stale-list {
  display: flex;
  flex-direction: column;
}
.dash-stale-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.dash-stale-row:last-child { border-bottom: none; }
.dash-stale-row:hover { background: var(--bg-surface-hover); }
.dash-stale-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--status-warning-bg);
  color: var(--status-warning);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.dash-stale-badge.warm {
  background: var(--status-warning-bg);
  color: var(--status-warning);
}
.dash-stale-badge.cold {
  background: var(--status-danger-bg);
  color: var(--status-danger);
}
.dash-stale-info {
  flex: 1;
  min-width: 0;
}
.dash-stale-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-stale-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-stale-amount {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.dash-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* ─── Birthday widget (dashboard) ─── */
.dash-birthday-block {
  padding-bottom: 8px;
}
.dash-bd-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
}
.dash-bd-row.dash-bd-today {
  background: linear-gradient(90deg, rgba(33, 120, 203, 0.10), rgba(33, 120, 203, 0));
  border-left: 3px solid var(--brand-primary);
  padding-left: 13px;
}
.dash-bd-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.bd-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.bd-avatar-letters { line-height: 1; }
.dash-bd-info { flex: 1; min-width: 0; }
.dash-bd-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-bd-when {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dash-bd-today .dash-bd-when {
  color: var(--brand-primary);
  font-weight: 500;
}
.dash-bd-divider {
  padding: 6px 16px 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* ─── Birthdays banner (Сотрудники page) ─── */
.users-bd-section {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.users-bd-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.users-bd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.users-bd-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--bg-surface-hover);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.users-bd-card:hover { background: var(--bg-hover); }
.users-bd-card.is-today {
  background: linear-gradient(135deg, rgba(33, 120, 203, 0.14), rgba(33, 120, 203, 0.04));
  border: 1px solid var(--brand-primary);
}
.users-bd-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}
.users-bd-info { flex: 1; min-width: 0; }
.users-bd-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.users-bd-when {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.users-bd-date {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
}
.users-bd-card.is-today .users-bd-date,
.users-bd-card.is-today .users-bd-days {
  color: var(--brand-primary);
  font-weight: 600;
}
.dash-block-title {
  padding: 12px 16px;
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
}
.dash-funnel {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dash-funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.dash-funnel-row:last-child { border-bottom: none; }
.dash-funnel-row:hover { background: var(--bg-surface-hover); }
.dash-funnel-label {
  width: 180px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-funnel-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.dash-funnel-bar {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 300ms ease;
  min-width: 2px;
}
.dash-funnel-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: var(--font-size-xs);
  min-width: 110px;
}
.dash-funnel-count {
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
  font-variant-numeric: tabular-nums;
}
.dash-funnel-sum {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .dash-funnel-label { width: 110px; font-size: var(--font-size-xs); }
  .dash-funnel-meta { min-width: 80px; }
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
}
.dash-table th {
  text-align: left;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  border-bottom: 1px solid var(--b1);
}
.dash-table td {
  padding: 8px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--b1);
}
.dash-table tr:last-child td { border-bottom: 0; }
.dash-tm-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-tm-avatar, .dash-tm-avatar-fb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dash-tm-avatar { object-fit: cover; }
.dash-tm-avatar-fb {
  background: var(--ac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* Dashboard — sources breakdown */
.dash-sources-table .dash-num { text-align: right; white-space: nowrap; }
.dash-src-row { transition: background .12s; }
.dash-src-row:hover { background: var(--bg); }
.dash-src-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 4px;
}
.dash-src-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--b2);
}
.dash-src-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.dash-src-bar-fill {
  height: 100%;
  transition: width .3s ease;
}
.dash-src-won-hint {
  font-size: 10px;
  color: var(--t3);
  font-weight: 400;
  margin-top: 2px;
}

.dash-overdue-list {
  padding: 6px 0;
  max-height: 360px;
  overflow-y: auto;
}
.dash-overdue-row {
  display: flex;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--b1);
}
.dash-overdue-row:hover { background: var(--bg3); }
.dash-overdue-row:last-child { border-bottom: 0; }
.dash-od-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 26px;
}
.dash-od-body { flex: 1; min-width: 0; }
.dash-od-title {
  font-size: 13px;
  color: var(--t1);
  font-weight: 600;
  margin-bottom: 2px;
}
.dash-od-meta {
  font-size: 11px;
  color: var(--t3);
}
/* END DASHBOARD */


/* STAGE DEALS MODAL */
.stage-deals-summary {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--t2);
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
}
.stage-deals-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
}
.stage-deals-tbl-wrap {
  max-height: 60vh;
  overflow-y: auto;
}
.stage-deals-table {
  width: 100%;
  border-collapse: collapse;
}
.stage-deals-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--b1);
  background: var(--bg2);
  position: sticky;
  top: 0;
}
.stage-deals-table td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--b1);
}
.stage-deals-row {
  cursor: pointer;
}
.stage-deals-row:hover {
  background: var(--bg3);
}
/* END STAGE DEALS MODAL */


/* STAGES DND */
.ps-stage-row[draggable="true"] {
  cursor: default;
}
.ps-stage-handle {
  cursor: grab;
  color: var(--t3);
  font-size: 14px;
  user-select: none;
  text-align: center;
  line-height: 1;
}
.ps-stage-handle:hover {
  color: var(--t1);
}
.ps-stage-row.ps-dragging {
  opacity: 0.4;
}
.ps-stage-row.ps-drop-before {
  border-top: 2px solid var(--ac);
}
.ps-stage-row.ps-drop-after {
  border-bottom: 2px solid var(--ac);
}
/* END STAGES DND */


/* COMMENT ATTACHMENTS */
.cmt-pending-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0;
}
.cmt-pending-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 14px;
  font-size: 11px;
  color: var(--t1);
  max-width: 280px;
}
.cmt-pending-icon { font-size: 13px; }
.cmt-pending-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmt-pending-size { color: var(--t3); font-size: 10px; }
.cmt-pending-remove {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--t3);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 50%;
}
.cmt-pending-remove:hover { color: var(--rd); }

.cmt-attachments {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cmt-attach-img {
  display: inline-block;
  max-width: 240px;
  max-height: 160px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--b1);
}
.cmt-attach-img img {
  display: block;
  max-width: 240px;
  max-height: 160px;
  object-fit: cover;
}
.cmt-attach-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 8px;
  font-size: 12px;
  color: var(--t1);
  text-decoration: none;
  max-width: 320px;
}
.cmt-attach-file:hover {
  background: var(--bg4);
}
.cmt-attach-icon { font-size: 16px; }
.cmt-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmt-attach-size { color: var(--t3); font-size: 11px; }
/* END COMMENT ATTACHMENTS */


/* Fix gap between 📎 and Send button */
.cmt-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
}


/* REQUIRED ON STAGES */
.cf-stages-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 2px;
}
.cf-pipe-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--b1);
  border-radius: 10px;
  background: var(--bg2);
}
.cf-pipe-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--ac);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--b1);
}
.cf-stages-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.cf-stage-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--b1);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--t1);
  background: var(--bg3);
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.cf-stage-chip:hover {
  background: var(--bg4);
  border-color: var(--b2);
}
.cf-stage-chip input[type=checkbox] {
  margin: 0;
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: var(--ac);
}
.cf-stage-chip span {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.cf-stage-chip:has(input:checked) {
  border-color: var(--ac);
  background: color-mix(in srgb, var(--ac) 12%, var(--bg2));
  color: var(--ac);
  font-weight: 600;
}
@media (max-width: 540px) {
  .cf-stages-row { grid-template-columns: 1fr; }
}
/* END REQUIRED ON STAGES */


/* PRODUCTS LIST */
.pr-list {
  padding: 16px 18px;
  overflow-y: auto;
}

/* === Клиенты: мультивыбор + «Показать ещё» === */
.cust-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  /* Solid bg2 + 2px брендовая рамка + тень — чтобы при sticky-режиме
     над прокручиваемой таблицей не было «просвечивания» через шапку. */
  background: var(--bg2);
  border: 2px solid var(--brand-primary);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.cust-bulk-info { font-size: 13px; color: var(--text-primary); flex: 1; }
.cust-bulk-info b { color: var(--brand-primary); font-weight: 700; }
.cust-bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cust-cb-cell { width: 36px; text-align: center; padding: 0 4px; }
.cust-row-cb, #cust-header-cb {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}
.cust-table tr.is-selected {
  background: var(--brand-glow, rgba(33, 120, 203, .08)) !important;
}
.customers-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0 24px;
}
.customers-loadmore {
  display: flex;
  justify-content: center;
  width: 100%;
}
.customers-loadmore .btn {
  min-width: 260px;
}
.customers-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}
.cust-page-indicator {
  padding: 0 12px;
  color: var(--t2);
  white-space: nowrap;
}
#cust-page-jump {
  width: 60px;
  margin-left: 12px;
  padding: 6px 8px;
  text-align: center;
}

/* Мультивыбор: bulk-bar над таблицей с действиями */
.pr-bulk-bar {
  position: sticky;
  top: -1px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--brand-glow, rgba(33, 120, 203, .14));
  border: 1px solid var(--brand-primary);
  border-radius: 8px;
}
.pr-bulk-count {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}
.pr-bulk-count strong {
  color: var(--brand-primary);
  font-weight: 700;
}
.pr-row-selected {
  background: var(--brand-glow, rgba(33, 120, 203, .08)) !important;
}
.pr-check, #pr-check-all {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}
.pr-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  overflow: hidden;
}
.pr-table thead {
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
}
.pr-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--t3);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.pr-table td {
  padding: 10px 14px;
  border-top: 1px solid var(--b1);
  font-size: 13px;
  vertical-align: middle;
}
.pr-row {
  transition: background 0.12s;
}
.pr-row:hover {
  background: var(--bg3);
}
.pr-row-archived {
  opacity: 0.55;
}
.pr-sku {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: var(--t2);
}
.pr-name {
  font-weight: 500;
  color: var(--t1);
  line-height: 1.3;
}
.pr-desc {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}
.pr-price {
  font-weight: 600;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.pr-arch-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg4);
  font-size: 10px;
  color: var(--t3);
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.topbar-actions {
  display: flex;
  align-items: center;
}
/* END PRODUCTS LIST */


/* Fix gap between row action buttons */
.pr-table td button + button {
  margin-left: 6px;
}


.pr-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.pr-row-actions .btn-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


/* DEAL PRODUCTS */
.dp-products-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dp-line {
  display: grid;
  /* После удаления столбца «скидка»: товар(1fr) | qty | price | sum | × */
  grid-template-columns: minmax(0, 1fr) 70px 80px 90px 24px;
  gap: 6px;
  align-items: center;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
}
.dp-line-name { min-width: 0; }
.dp-line-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dp-line:hover {
  background: var(--bg3);
}
.dp-line-name-text {
  font-weight: 500;
  color: var(--t1);
  line-height: 1.3;
}
.dp-line-sku {
  font-size: 11px;
  color: var(--t3);
  font-family: ui-monospace, monospace;
  margin-top: 2px;
}
.dp-line-arch {
  color: var(--t3);
  font-size: 11px;
  font-weight: 400;
}
.dp-line-qty,
.dp-line-price,
.dp-line-discount {
  color: var(--t2);
  text-align: right;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  transition: background 0.1s;
}
.dp-line-qty:hover,
.dp-line-price:hover,
.dp-line-discount:hover {
  background: var(--bg4);
  color: var(--t1);
}
.dp-line-discount-zero {
  color: var(--t3);
  font-size: 11px;
}
.dp-line-discount {
  color: var(--rd);
  font-weight: 500;
}
.dp-line-discount-zero {
  color: var(--t3);
  font-size: 11px;
  font-weight: normal;
}
.dp-line-sum {
  text-align: right;
  font-weight: 700;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.dp-line-del {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 20px;
  color: var(--t3);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}
.dp-line-del:hover {
  background: rgba(255,82,82,0.12);
  color: var(--rd);
}
.dp-inline-input {
  width: 100%;
  border: 1px solid var(--ac);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 13px;
  background: var(--bg2);
  color: var(--t1);
  text-align: right;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.dp-products-total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 6px;
  border-top: 1px solid var(--b1);
}
.dp-products-total-label {
  font-size: 13px;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.dp-products-total-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}

/* Add product dialog */
.dp-add-results {
  margin-top: 10px;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dp-add-item {
  padding: 10px 12px;
  border: 1px solid var(--b1);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg2);
  transition: background 0.12s, border-color 0.12s;
}
.dp-add-item:hover {
  background: var(--bg3);
  border-color: var(--ac);
}
.dp-add-item-name {
  font-weight: 500;
  color: var(--t1);
  font-size: 13px;
}
.dp-add-item-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--t3);
}
.dp-add-item-sku {
  font-family: ui-monospace, monospace;
}
.dp-add-item-price {
  font-weight: 600;
  color: var(--t2);
}

@media (max-width: 700px) {
  .dp-line {
    grid-template-columns: 1fr 70px 90px 70px 90px 24px;
    font-size: 12px;
  }
}
/* END DEAL PRODUCTS */


/* TEMPLATES LIST */
.tpl-list {
  padding: 16px 18px;
  overflow-y: auto;
}
.tpl-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  overflow: hidden;
}
.tpl-table thead {
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
}
.tpl-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--t3);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.tpl-table td {
  padding: 12px 14px;
  border-top: 1px solid var(--b1);
  font-size: 13px;
  vertical-align: middle;
}
.tpl-row:hover {
  background: var(--bg3);
}
.tpl-name {
  font-weight: 600;
  color: var(--t1);
  line-height: 1.3;
}
.tpl-desc {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}
.tpl-file {
  color: var(--t2);
  font-size: 13px;
}
.tpl-file-size {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}
.tpl-date {
  color: var(--t3);
  font-size: 12px;
}
.tpl-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}
.tpl-row-actions .btn-icon {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tpl-help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}
.tpl-help-table td {
  padding: 6px 8px;
  vertical-align: middle;
  border-bottom: 1px solid var(--b1);
}
.tpl-help-table tr:last-child td { border-bottom: none; }
.tpl-help-table td:first-child {
  width: 240px;
  white-space: nowrap;
}
.tpl-help-table td:last-child {
  color: var(--t2);
}
/* Чипы переменных в справке шаблонов — читаемы в обеих темах.
   ВАЖНО: НЕ использовать var(--ac) как цвет текста — в dark теме он
   намеренно тёмный (#2b2e36) для legacy background:var(--ac). Берём
   яркий CTA-цвет --action-primary. */
.tpl-help-modal code {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--b1);
  padding: 1px 7px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--action-primary);
  white-space: nowrap;
}
/* END TEMPLATES LIST */


/* DEAL DOCUMENTS */
.dd-docs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dd-doc-line {
  display: grid;
  grid-template-columns: 32px 1fr 28px 28px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--b1);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg2);
}
.dd-doc-line:hover {
  background: var(--bg3);
}
.dd-doc-icon {
  font-size: 20px;
  text-align: center;
}
.dd-doc-name {
  font-weight: 500;
  color: var(--t1);
  line-height: 1.3;
  word-break: break-word;
}
.dd-doc-meta {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}
.dd-doc-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  color: var(--t3);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  padding: 0;
  line-height: 1;
}
.dd-doc-btn:hover {
  background: var(--bg4);
  color: var(--t1);
}
.dd-doc-btn[data-action="delete"]:hover {
  background: rgba(255,82,82,0.12);
  color: var(--rd);
}

/* Template picker in generate dialog */
.dd-tpl-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
}
.dd-tpl-item {
  padding: 12px 14px;
  border: 1px solid var(--b1);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg2);
  transition: background 0.12s, border-color 0.12s;
}
.dd-tpl-item:hover {
  background: var(--bg3);
  border-color: var(--ac);
}
.dd-tpl-item-name {
  font-weight: 600;
  color: var(--t1);
  font-size: 13px;
}
.dd-tpl-item-desc {
  font-size: 11px;
  color: var(--t3);
  margin-top: 4px;
}
/* END DEAL DOCUMENTS */


/* PROFILE SIGNATURE */
.profile-signature-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  padding: 0;
  background: transparent;
  border: none;
}
.profile-signature-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
}
.profile-signature-wrapper {
  width: 140px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px dashed var(--b1);
  border-radius: 6px;
}
.profile-signature {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-signature img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.profile-signature.empty::before {
  content: 'Нет подписи';
  color: var(--t3);
  font-size: 12px;
}
.profile-signature-actions {
  display: flex;
  gap: 12px;
}
.profile-signature-hint {
  font-size: 11px;
  color: var(--t3);
  text-align: center;
  max-width: 300px;
  line-height: 1.4;
}
/* END PROFILE SIGNATURE */


/* =====================================================================
   UNIFIED BUTTONS & INPUTS
   ---------------------------------------------------------------------
   Привязка обеих систем (.btn + .btn-primary) к единым размерам и стилю.
   Цель: одинаковая высота, padding, font-size, border-radius везде.
   Старые селекторы не удаляем — они продолжают работать.
   ===================================================================== */

/* --- MEDIUM (по умолчанию для .btn и .btn-primary/.btn-secondary/.btn-danger) --- */
.btn,
.btn-primary,
.btn-secondary,
.btn-danger {
  font-family: var(--fb);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  height: 38px;
  line-height: 1;
  box-sizing: border-box;
  transition: background .15s, opacity .15s, border-color .15s;
}

/* --- DANGER: единый стиль (белый текст на красном фоне) --- */
.btn.danger,
.btn-danger {
  background: var(--rd);
  color: white;
  border: none;
}
.btn.danger:hover,
.btn-danger:hover {
  opacity: 0.85;
  background: var(--rd);
  color: white;
}

/* --- SMALL: .btn.sm и .btn-sm — одинаковые --- */
.btn.sm,
.btn-sm,
.btn.btn-sm {
  font-size: 12px !important;
  padding: 6px 12px !important;
  height: 30px !important;
  min-width: 0 !important;
  width: auto !important;
}

/* --- LARGE (на будущее, для CTA в логине и т.п.) --- */
.btn.lg,
.btn-lg {
  font-size: 15px;
  padding: 13px 24px;
  height: 46px;
}

/* --- ICON-BUTTONS — выровнять высоту с .btn (38px) --- */
.btn-icon {
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  font-size: 15px;
}

/* --- INPUTS --- */
.input {
  font-size: 14px;
  padding: 9px 12px;
  height: 38px;
  border-radius: 10px;
  box-sizing: border-box;
  line-height: 1.2;
}

/* --- INPUT SIZES --- */
.input.input-sm,
.input-sm {
  font-size: 12px;
  padding: 5px 10px;
  height: 30px;
}
.input.input-lg,
.input-lg {
  font-size: 15px;
  padding: 12px 14px;
  height: 46px;
}

/* --- TEXTAREA с классом .input — не фиксировать высоту --- */
textarea.input {
  height: auto;
  min-height: 38px;
  padding: 9px 12px;
}

/* --- SELECT с классом .input --- */
select.input {
  height: 38px;
  padding: 0 32px 0 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23999' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* --- ICON-BTN (тот что в шапке диалогов) — оставить компактным --- */
.icon-btn {
  height: 32px;
  min-width: 32px;
}

/* END UNIFIED BUTTONS & INPUTS */


/* =====================================================================
   UNIFIED TOPBAR & FILTERS — refresh на новых токенах
   Эталон: Сделки. Все страницы должны выглядеть единообразно.
   ===================================================================== */

/* TOPBAR — единая шапка страницы (full-bleed, divider снизу) */
.topbar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 14px 24px !important;
  gap: 12px !important;
  min-height: 56px !important;
  margin: -20px -24px 20px !important;
  background: var(--bg-surface) !important;
  border-bottom: 1px solid var(--border-default) !important;
  box-sizing: border-box !important;
}

/* Заголовок страницы — Roboto Condensed 22px */
.topbar .page-title,
.topbar h1,
.topbar h2 {
  font-family: var(--font-family-heading) !important;
  font-size: var(--font-size-xl) !important;
  font-weight: var(--font-weight-bold) !important;
  margin: 0 !important;
  color: var(--text-primary) !important;
  line-height: 1.2 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  flex: 1 !important;
  min-width: 0 !important;
}

/* Группа действий справа */
.topbar-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
}

/* SEARCH INPUT в topbar — 36px height на семантических токенах */
.topbar input.input,
.topbar .input,
.topbar input[type="search"],
.topbar input[type="text"] {
  height: var(--size-control-md) !important;
  padding: 0 var(--padding-control-md) !important;
  font-size: var(--font-size-base) !important;
  width: 280px !important;
  max-width: 100% !important;
  margin: 0 !important;
  border-radius: var(--radius-md) !important;
  box-sizing: border-box !important;
  line-height: var(--size-control-md) !important;
}

/* SELECT в topbar */
.topbar select.input,
.topbar select {
  height: var(--size-control-md) !important;
  padding: 0 28px 0 var(--padding-control-md) !important;
  font-size: var(--font-size-base) !important;
  margin: 0 !important;
  border-radius: var(--radius-md) !important;
}

/* КНОПКИ в topbar — height 36px, auto-width */
.topbar .btn,
.topbar .btn-primary,
.topbar .btn-secondary,
.topbar .btn-danger,
.topbar button.icon-btn {
  height: var(--size-control-md) !important;
  padding: 0 var(--padding-control-lg) !important;
  font-size: var(--font-size-base) !important;
  font-weight: var(--font-weight-medium) !important;
  border-radius: var(--radius-md) !important;
  white-space: nowrap !important;
  width: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}
.topbar button.icon-btn {
  padding: 0 !important;
  width: var(--size-control-md) !important;
}

@media (max-width: 768px) {
  .topbar {
    margin: -16px -16px 16px !important;
    padding: 12px 16px !important;
    min-height: 52px !important;
  }
  .topbar .page-title,
  .topbar h1,
  .topbar h2 {
    font-size: var(--font-size-lg) !important;
  }
  .topbar input.input,
  .topbar input[type="search"] {
    width: 100% !important;
  }
}

/* Кнопки .sm в topbar — оставляем 36px (не делать ещё меньше) */
.topbar .btn.sm,
.topbar .btn-sm,
.topbar .btn.btn-sm {
  height: 36px !important;
  padding: 0 14px !important;
  font-size: 13px !important;
}

/* Icon-only buttons (шестерёнка и т.п.) — квадратные 36×36 */
.topbar .icon-btn,
.topbar button[title]:not(.btn) {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  min-width: 36px !important;
}

/* DEALS-SPECIFIC: шестерёнка настроек должна быть 36×36, не выпадать */
.deals-settings-btn,
button.deals-settings,
.topbar .deals-settings-btn {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  font-size: 16px !important;
}

/* FILTERS BAR (вторая строка под topbar — поиск + фильтры в сделках) */
.deals-filters,
.filters-bar,
.tasks-filters {
  padding: 10px 22px !important;
  gap: 10px !important;
}

.deals-filters .input,
.filters-bar .input,
.tasks-filters .input {
  height: 36px !important;
  padding: 0 12px !important;
  font-size: 13px !important;
  margin: 0 !important;
  border-radius: 8px !important;
  line-height: 36px !important;
}

.deals-filters select,
.filters-bar select,
.tasks-filters select {
  height: 36px !important;
  padding: 0 28px 0 12px !important;
  font-size: 13px !important;
}

/* END UNIFIED TOPBAR & FILTERS */


/* INTEGRATIONS PAGE */
/* =============================================================
 * Integrations / Settings — единый паттерн с .tabs из components.css
 * ============================================================= */
.integrations-page {
  padding: 0;
  max-width: 900px;
}
.integrations-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
  align-items: stretch;
}
.int-tab {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 0;
  height: 40px;
  padding: 0 16px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.int-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}
.int-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: var(--font-weight-semibold);
}
.int-tab:focus-visible {
  outline: none;
  background: var(--bg-surface-hover);
  box-shadow: inset 0 0 0 2px var(--brand-primary);
}
.int-tab-soon {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  background: var(--bg-active);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  margin-left: 6px;
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.integrations-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.int-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.int-card h3 {
  margin: 0 0 14px;
  font-family: var(--font-family-heading);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

/* Deal sources table */
.src-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-base);
}
.src-table th, .src-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.src-table th {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-base);
}
.src-row-archived { opacity: 0.55; }
.src-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}
.src-slug code {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  background: var(--bg-base);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
}
.src-actions { white-space: nowrap; text-align: right; }
.src-actions .btn-link {
  font-size: var(--font-size-sm);
  padding: 4px 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.src-actions .btn-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.src-badge-active, .src-badge-archived {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-pill);
  line-height: 1;
}
.src-badge-active {
  background: var(--status-success-bg);
  color: var(--status-success);
}
.src-badge-archived {
  background: var(--status-neutral-bg);
  color: var(--status-neutral);
}
.int-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin-bottom: 18px;
}
.int-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: currentColor;
}
.int-status-ok {
  background: var(--status-success-bg);
  color: var(--status-success);
}
.int-status-off {
  background: var(--status-neutral-bg);
  color: var(--status-neutral);
}
.int-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.int-result {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.5;
}
.int-result-loading {
  background: var(--bg3);
  color: var(--t2);
}
.int-result-ok {
  background: rgba(63, 216, 142, 0.12);
  color: var(--gn);
}
.int-result-error {
  background: var(--rdbg);
  color: var(--rd);
}
/* END INTEGRATIONS PAGE */


/* CHECKBOX LABEL */
.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--t1);
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
}
.form-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--ac);
  margin: 0;
}
.form-checkbox-label input[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}




/* PING DIALOG */
.ping-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ping-result-btn {
  padding: 12px 10px;
  border: 1px solid var(--b1);
  background: var(--bg3);
  color: var(--t1);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.ping-result-btn:hover {
  background: var(--bg4);
}
.ping-result-btn.active {
  /* Раньше: слабый фон rgba(0.12) + текст var(--ac) (тёмно-синий) —
     на dark-теме и фон и текст тёмные → не видно что выбрано.
     Теперь: насыщенная заливка brand-primary + белый текст. */
  background: var(--brand-primary, #2178cb);
  border-color: var(--brand-primary, #2178cb);
  color: #fff;
  font-weight: 600;
}
/* Ping button on kanban deal card */
.deal-card-ping-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.15s, background 0.12s;
  z-index: 2;
}
.crm-card:hover .deal-card-ping-btn {
  opacity: 1;
}
.deal-card-ping-btn:hover {
  background: var(--ac);
  color: white;
  border-color: var(--ac);
}
.crm-card {
  position: relative;
}


/* PING TIME PRESETS */
.ping-time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ping-time-btn {
  padding: 6px 10px;
  border: 1px solid var(--b1);
  background: var(--bg3);
  color: var(--t2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.ping-time-btn:hover {
  background: var(--bg4);
}
.ping-time-btn.active {
  background: var(--brand-primary, #2178cb);
  border-color: var(--brand-primary, #2178cb);
  color: #fff;
  font-weight: 600;
}


/* =====================================================================
   CUSTOMER PANEL TABS + WHATSAPP
   ===================================================================== */

/* Customer panel becomes flex column so tabs/body/footer stack */
#side-panel-customer {
  display: flex;
  flex-direction: column;
}

/* Tabs row */
.cp-tabs {
  display: flex;
  border-bottom: 1px solid var(--b1);
  background: var(--bg2);
  flex-shrink: 0;
}
.cp-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.cp-tab:hover { color: var(--t1); }
.cp-tab.active {
  color: var(--ac);
  border-bottom-color: var(--ac);
}

/* Panes are flex-column 1 to fill remaining height */
.cp-tab-pane {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.cp-tab-pane-profile {
  /* uses existing .side-panel-body — already scrollable */
  overflow-y: auto;
}
.cp-tab-pane-whatsapp {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Status bar inside WhatsApp pane */
.cp-wa-status {
  display: none;
  padding: 8px 14px;
  font-size: 12px;
  background: var(--bg3);
  color: var(--t2);
  border-bottom: 1px solid var(--b1);
}
.cp-wa-status-error {
  background: var(--rdbg);
  color: var(--rd);
}

/* Messages area */
.cp-wa-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}
.cp-wa-loading,
.cp-wa-empty {
  text-align: center;
  color: var(--t3);
  font-size: 13px;
  padding: 24px 16px;
}
.cp-wa-day {
  align-self: center;
  font-size: 11px;
  color: var(--t3);
  background: var(--bg3);
  padding: 3px 10px;
  border-radius: 10px;
  margin: 8px 0 4px;
}

/* Message bubbles */
.cp-wa-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.cp-wa-msg-in {
  align-self: flex-start;
  background: var(--bg2);
  color: var(--t1);
  border-bottom-left-radius: 4px;
}
.cp-wa-msg-out {
  align-self: flex-end;
  background: rgba(110, 120, 255, 0.18);
  color: var(--t1);
  border-bottom-right-radius: 4px;
}
.cp-wa-msg-text {
  /* text content */
}
.cp-wa-msg-meta {
  font-size: 10px;
  color: var(--t3);
  margin-top: 2px;
  text-align: right;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.cp-wa-msg-in .cp-wa-msg-meta {
  text-align: left;
  justify-content: flex-start;
}
.cp-wa-status-icon {
  font-size: 11px;
}
.cp-wa-status-icon.cp-wa-status-read {
  color: var(--ac);
}

/* Composer */
.cp-wa-composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--b1);
  background: var(--bg2);
  flex-shrink: 0;
}
.cp-wa-input {
  flex: 1;
  margin: 0 !important;
  resize: none;
  min-height: 36px;
  max-height: 100px;
}
.cp-wa-send {
  align-self: flex-end;
}
/* END CUSTOMER PANEL WHATSAPP */


/* DEAL CARD WHATSAPP */
.dc-lifeline-body-whatsapp {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.dc-wa-status {
  padding: 8px 14px;
  font-size: 12px;
  background: var(--bg3);
  color: var(--t2);
  border-bottom: 1px solid var(--b1);
}
.dc-wa-status-error {
  background: var(--rdbg);
  color: var(--rd);
}
.dc-wa-messages {
  flex: 1 1 auto;
  min-height: 200px;
  /* Раньше был max-height: 460px — из-за него под композером оставался
     пустой void даже когда сообщений было много. Снимаем и даём flex:1
     растянуть до композера. Высоту контролит родитель .dc-right. */
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}
.dc-wa-composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--b1);
  background: var(--bg2);
  flex-shrink: 0;
}

/* Message bubbles — переиспользуем стиль */
.cp-wa-loading,
.cp-wa-empty {
  text-align: center;
  color: var(--t3);
  font-size: 13px;
  padding: 24px 16px;
  line-height: 1.5;
}
.cp-wa-day {
  align-self: center;
  font-size: 11px;
  color: var(--t3);
  background: var(--bg3);
  padding: 3px 10px;
  border-radius: 10px;
  margin: 8px 0 4px;
}
.cp-wa-msg {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.cp-wa-msg-in {
  align-self: flex-start;
  background: var(--bg2);
  color: var(--t1);
  border-bottom-left-radius: 4px;
}
.cp-wa-msg-out {
  align-self: flex-end;
  background: rgba(110, 120, 255, 0.18);
  color: var(--t1);
  border-bottom-right-radius: 4px;
}
.cp-wa-msg-author {
  font-size: 10px;
  color: var(--t3);
  margin-bottom: 2px;
}
.cp-wa-msg-meta {
  font-size: 10px;
  color: var(--t3);
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.cp-wa-msg-in .cp-wa-msg-meta {
  justify-content: flex-start;
}
.cp-wa-status-icon { font-size: 11px; }
.cp-wa-status-icon.cp-wa-status-read { color: var(--ac); }

.cp-wa-input {
  flex: 1;
  margin: 0 !important;
  resize: none;
  min-height: 36px;
  max-height: 100px;
}
.cp-wa-send {
  align-self: flex-end;
}
/* END DEAL CARD WHATSAPP */


/* WA COMPOSER ICONS */
.dc-wa-composer-wrap {
  border-top: 1px solid var(--b1);
  background: var(--bg2);
  flex-shrink: 0;
}
.dc-wa-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}
.dc-wa-iconbtn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  color: var(--t2);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  padding: 0;
}
.dc-wa-iconbtn:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--t1);
}
.dc-wa-send-btn {
  background: var(--brand-primary, var(--ac));
  color: var(--brand-on-primary, #fff);
}
.dc-wa-send-btn:hover:not(:disabled) {
  background: var(--brand-primary, var(--ac));
  filter: brightness(1.1);
  color: var(--brand-on-primary, #fff);
}
.dc-wa-send-btn:disabled {
  background: var(--bg3);
  color: var(--t3);
  cursor: not-allowed;
  opacity: 0.55;
}
/* SVG иконка внутри тоже наследует цвет — fix чтобы не пропадала на любой теме */
.dc-wa-send-btn svg { stroke: currentColor; fill: currentColor; }

/* Attached preview above composer */
.dc-wa-attached {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border-top: 1px solid var(--b1);
  font-size: 13px;
}
.dc-wa-attached-uploading {
  color: var(--t3);
  font-style: italic;
}
.dc-wa-attached-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.dc-wa-attached-info {
  flex: 1;
  min-width: 0;
}
.dc-wa-attached-name {
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dc-wa-attached-size {
  font-size: 11px;
  color: var(--t3);
}
.dc-wa-attached-remove {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--t3);
  font-size: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dc-wa-attached-remove:hover {
  background: var(--bg4);
  color: var(--t1);
}

/* Media in bubbles */
.cp-wa-msg-image-link {
  display: block;
}
.cp-wa-msg-image {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}
.cp-wa-msg-video,
.cp-wa-msg-audio {
  max-width: 100%;
  border-radius: 8px;
}
.cp-wa-msg-file {
  display: inline-block;
  padding: 8px 12px;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  text-decoration: none;
  color: var(--t1);
  font-size: 13px;
  margin-bottom: 4px;
}
.cp-wa-msg-file:hover {
  background: rgba(0,0,0,0.1);
}
/* END WA COMPOSER ICONS */


/* CALL RECORDING AUDIO IN ACTIVITY */
.dc-act-audio {
  margin-top: 6px;
}
.dc-act-audio audio {
  width: 100%;
  height: 28px;
  outline: none;
}

/* ============================================================
   PROFILE QUICK ACTIONS — внутри модала Профиль
   ============================================================ */
.profile-qa-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.profile-qa-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .12s ease;
}
.profile-qa-btn:hover {
  background: var(--surface-2, rgba(0,0,0,.03));
}
.profile-qa-icon {
  flex: 0 0 auto;
  font-size: 16px;
  width: 22px;
  text-align: center;
}
.profile-qa-modules-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 16px 0 8px;
  font-weight: 600;
}
.profile-qa-modules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.profile-qa-mod {
  padding: 10px 12px;
  background: var(--surface-2, rgba(0,0,0,.03));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.profile-qa-mod:active {
  background: var(--surface-3, rgba(0,0,0,.06));
}

/* ============================================================
   SIP CLIENT (WebRTC dialer — bottom-bar + overlay)
   ============================================================ */
.sip-bar {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-popover, 0 4px 12px rgba(0,0,0,.15));
  z-index: 9000;
  transition: background .15s;
}
.sip-bar:hover { background: var(--bg-surface-hover, var(--bg2)); }
.sip-bar-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 auto;
}
.sip-bar-ready    .sip-bar-dot { background: var(--status-success); }
.sip-bar-calling  .sip-bar-dot { background: var(--status-warning); animation: sip-pulse 1s infinite; }
.sip-bar-ringing  .sip-bar-dot { background: var(--brand-primary);  animation: sip-pulse .6s infinite; }
.sip-bar-in-call  .sip-bar-dot { background: var(--status-success); }
.sip-bar-error    .sip-bar-dot { background: var(--status-danger); }
.sip-bar-connecting .sip-bar-dot { background: var(--text-muted); animation: sip-pulse 1.2s infinite; }

@keyframes sip-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(1.4); }
}

.sip-bar-timer {
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  margin-left: 4px;
}
.sip-bar-hangup {
  background: var(--status-danger-bg, rgba(220,38,38,.12));
  color: var(--status-danger);
  border: 0;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sip-bar-hangup:hover {
  background: var(--status-danger);
  color: #fff;
}

/* Overlay (dialer card) */
.sip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sip-overlay-card {
  background: var(--bg-elevated);
  border-radius: 16px;
  padding: 32px 40px;
  min-width: 320px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 16px 64px rgba(0,0,0,.4);
}
.sip-overlay-state {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.sip-overlay-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.sip-overlay-phone {
  font-size: 14px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}
.sip-overlay-timer {
  font-size: 28px;
  font-weight: 300;
  color: var(--status-success);
  font-variant-numeric: tabular-nums;
  margin-bottom: 24px;
}
.sip-overlay-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.sip-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.sip-btn:hover { background: var(--bg-surface-hover, var(--bg2)); }
.sip-btn-active {
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  border-color: var(--brand-primary);
}
.sip-btn-hangup-overlay {
  background: var(--status-danger);
  color: #fff;
  border-color: var(--status-danger);
}
.sip-btn-hangup-overlay:hover { background: #b91c1c; color: #fff; }
.sip-btn-answer {
  background: var(--status-success);
  color: #fff;
  border-color: var(--status-success);
}

/* ─── DTMF pad — открывается над кнопками при клике на dialpad ─── */
.sip-dtmf-pad {
  margin: 14px 0 18px;
  padding: 12px;
  background: var(--bg-surface-hover, rgba(255,255,255,.04));
  border-radius: 12px;
}
.sip-dtmf-display-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.sip-dtmf-display {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-family-mono, ui-monospace, monospace);
  color: var(--text-primary, #f5f5f7);
  min-height: 24px;
  letter-spacing: 2px;
}
/* «×» рядом с дисплеем — очистить визуально (тоны уже отправлены) */
.sip-dtmf-clear {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--bd, rgba(255,255,255,.12));
  background: transparent;
  color: var(--text-muted, rgba(255,255,255,.5));
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.sip-dtmf-clear:hover {
  background: var(--bg-surface-hover, rgba(255,255,255,.08));
  color: var(--text-primary, #f5f5f7);
}
.sip-dtmf-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sip-dtmf-key {
  height: 48px;
  border: 1px solid var(--bd, rgba(255,255,255,.12));
  border-radius: 10px;
  background: var(--bg-surface, #1f2024);
  color: var(--text-primary, #f5f5f7);
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-family-base);
  cursor: pointer;
  transition: background .12s, transform .08s;
}
.sip-dtmf-key:hover { background: var(--bg-surface-hover, rgba(255,255,255,.08)); }
.sip-dtmf-key:active { transform: scale(.94); }

@media (max-width: 768px) {
  .sip-bar { bottom: 80px; right: 10px; padding: 6px 12px; font-size: 12px; }
  .sip-overlay-card { padding: 24px; min-width: 280px; }
  .sip-btn { width: 48px; height: 48px; }
}

/* ============================================================
   WHATSAPP INSTANCES (в Интеграциях)
   ============================================================ */
.wa-inst-list-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.wa-inst-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wa-inst-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 8px);
  padding: 14px;
  background: var(--bg-elevated);
}
.wa-inst-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.wa-inst-title {
  font-size: 14px;
}
.wa-inst-row {
  display: flex;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
  align-items: baseline;
}
.wa-inst-label {
  color: var(--text-muted);
  flex: 0 0 100px;
  font-size: 12px;
}
.wa-inst-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

@media (max-width: 768px) {
  .wa-inst-label {
    flex: 0 0 80px;
    font-size: 11px;
  }
  .wa-inst-actions {
    gap: 4px;
  }
  .wa-inst-actions .btn {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* ============================================================
   SIGNATURE WARNING (в модале «Сгенерировать документ»)
   ============================================================ */
.dd-sig-warn {
  background: rgba(245, 158, 11, .10);
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: var(--radius-md, 8px);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-primary);
}
.dd-sig-warn-head {
  font-weight: 600;
  color: var(--status-warning);
  margin-bottom: 4px;
}
.dd-sig-warn-body {
  color: var(--text-secondary);
  font-size: 12px;
}
.dd-sig-warn-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   DASHBOARD STORAGE WIDGET
   ============================================================ */
.dash-storage {
  display: block;
  padding: 0;  /* inner padding в head/bars/list — единообразие с другими dash-block */
}
.dash-storage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
  flex-wrap: wrap;
  gap: 8px;
}
.dash-storage-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.dash-storage-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
}
.dash-storage-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-storage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
}
.dash-storage-bar-label strong {
  color: var(--text-primary);
}
.dash-storage-bar {
  height: 8px;
  background: var(--surface-2, rgba(0,0,0,.06));
  border-radius: 999px;
  overflow: hidden;
}
.dash-storage-bar-fill {
  height: 100%;
  transition: width .3s ease;
}
.dash-storage-warn {
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: var(--radius-md, 8px);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--status-warning);
  margin: 0 16px 12px;
}
.dash-storage-list {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border-subtle);
}
.dash-storage-list-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.dash-storage-row {
  display: grid;
  /* Лейбл резиновый, остальные колонки фиксированной ширины — чтобы цифры,
     размеры и иконка корзины выстраивались в одну вертикальную линию */
  grid-template-columns: 1fr 90px 80px 28px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-subtle);
}
.dash-storage-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dash-storage-size {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.dash-storage-cleanup-spacer {
  display: block;
  width: 28px;
  height: 28px;
}
.dash-storage-cleanup-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm, 6px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.dash-storage-cleanup-btn svg {
  stroke: currentColor;
  fill: none;
  width: 14px;
  height: 14px;
}
.dash-storage-cleanup-btn:hover {
  background: rgba(220, 38, 38, .12);
  color: var(--status-danger);
}
.dash-storage-cleanup-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.dash-storage-row:last-child {
  border-bottom: 0;
}
.dash-storage-icon {
  font-size: 14px;
}
.dash-storage-label {
  color: var(--text-primary);
}
.dash-storage-count {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.dash-storage-size {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  min-width: 70px;
  text-align: right;
}

@media (max-width: 768px) {
  .dash-storage-row {
    grid-template-columns: 20px 1fr auto;
    grid-template-areas:
      "icon label size"
      ".    count count";
    gap: 4px 8px;
  }
  .dash-storage-icon { grid-area: icon; }
  .dash-storage-label { grid-area: label; }
  .dash-storage-count { grid-area: count; font-size: 10px; }
  .dash-storage-size { grid-area: size; }
}

/* ============================================================
   DEAL ORDER WIDGET (внутри карточки сделки)
   ============================================================ */
.dp-order-widget {
  font-size: 13px;
}
.dp-order-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.dp-order-warn {
  color: var(--status-warning);
  font-size: 12px;
  font-weight: 600;
}
.dp-order-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

/* ─── Order widget v2: items как карточки (вместо широкой table) ─── */
.dp-order-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.dp-order-item-card {
  background: var(--bg-surface-hover);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
}
.dp-order-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.dp-order-item-name {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dp-order-item-stock {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dp-order-item-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px 12px;
}
.dp-order-item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  font-size: 11px;
}
.dp-order-item-key {
  color: var(--text-muted);
}
.dp-order-item-val {
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.dp-order-item-val.val-shipped { color: var(--status-success); font-weight: 600; }
.dp-order-item-val.val-return  { color: var(--status-warning); font-weight: 600; }
.dp-order-item-val.val-cancel  { color: var(--status-danger); font-weight: 600; }
.dp-order-item-val.rem-done    { color: var(--status-success); font-weight: 600; }
.dp-order-item-val.rem-low     { color: var(--status-danger); font-weight: 600; }

/* Баннер «к возврату за отменённый товар» — сумма сделки не меняется,
   возврат показывается отдельно. */
.dp-cancel-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 152, 0, 0.12);
  border: 1px solid var(--status-warning, #ff9800);
  color: var(--status-warning, #ff9800);
}
.dp-cancel-banner-label { font-size: 13px; font-weight: 600; }
.dp-cancel-banner-amount { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }

/* ─── Old table style — оставлено для модалок «Отгрузить» / «Возврат» ─── */
.dp-order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 10px 0;
}
.dp-order-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.dp-order-table th.num,
.dp-order-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dp-order-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.dp-order-table tbody tr:last-child td { border-bottom: none; }
.dp-order-table .val-shipped { color: var(--status-success); font-weight: 600; }
.dp-order-table .val-return  { color: var(--status-warning); font-weight: 600; }
.dp-order-table .rem-done    { color: var(--status-success); font-weight: 600; }
.dp-order-table .rem-low     { color: var(--status-danger); font-weight: 600; }
.dp-order-table .rem-ok      { color: var(--text-primary); }

.dp-order-progress {
  margin: 10px 0 6px;
}
.dp-order-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.dp-order-progress-label strong { color: var(--text-primary); }
.dp-order-progress-pct {
  font-weight: 600;
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums;
}
.dp-order-progress-bar {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.dp-order-progress-fill {
  height: 100%;
  background: var(--status-success);
  border-radius: 3px;
  transition: width .3s ease;
}

.dp-order-docs {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
}
.dp-order-docs-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}
.dp-order-doc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-surface-hover);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.dp-order-doc-row.is-return {
  background: rgba(217, 149, 0, .08);
  border-left: 3px solid var(--status-warning);
}
.dp-order-doc-row.is-ship {
  border-left: 3px solid var(--status-success);
}
.dp-order-doc-head {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  margin-bottom: 2px;
}
.dp-order-doc-icon { font-size: 13px; }
.dp-order-doc-num { font-weight: 600; color: var(--text-primary); }
.dp-order-doc-date { color: var(--text-muted); }
.dp-order-doc-user { color: var(--text-muted); }
.dp-order-doc-items {
  grid-column: 1;
  color: var(--text-secondary);
  font-size: 11px;
}
.dp-order-doc-total {
  grid-column: 2;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: end;
}
.dp-order-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface-2, rgba(0,0,0,.03));
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
}
.dp-order-item-name {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dp-order-item-qty {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dp-order-item-avail {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
}
.dp-order-avail-ok {
  background: rgba(34, 197, 94, .12);
  color: var(--status-success);
}
.dp-order-avail-low {
  background: rgba(220, 38, 38, .12);
  color: var(--status-danger);
}
.dp-order-avail-warn {
  background: rgba(245, 158, 11, .14);
  color: var(--status-warning);
}
.dp-order-avail-shipped {
  background: var(--surface-2, rgba(0,0,0,.04));
  color: var(--text-muted);
}
.dp-order-timeline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface-2, rgba(0,0,0,.02));
  border-radius: var(--radius-sm, 4px);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.dp-order-tl-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-primary);
  margin-right: 6px;
  vertical-align: middle;
}
.dp-order-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}
/* Кнопки в виджете «Заказ» растягиваются на свою колонку — одинаковая
   ширина независимо от длины текста. На очень узком — 1 колонка. */
.dp-order-actions .btn {
  width: 100%;
}
@media (max-width: 420px) {
  .dp-order-actions {
    grid-template-columns: 1fr;
  }
}
.dp-order-invoice {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 0;
}

@media (max-width: 768px) {
  .dp-order-item {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name avail"
      "qty  qty";
    gap: 4px 8px;
  }
  .dp-order-item-name  { grid-area: name; }
  .dp-order-item-qty   { grid-area: qty; }
  .dp-order-item-avail { grid-area: avail; }
}

/* ============================================================
   WAREHOUSE MODULE
   ============================================================ */

/* Tabs */
.wh-tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  margin: 0 -24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wh-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.wh-tab:hover {
  color: var(--text-primary);
}
.wh-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}
.wh-tab svg {
  flex: 0 0 auto;
}

/* Toolbar */
.wh-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.wh-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.wh-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand-primary);
}

/* Stock table cell helpers */
.wh-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}
.wh-avail {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2, rgba(0,0,0,.04));
  color: var(--text-primary);
}
.wh-avail-low {
  background: rgba(220, 38, 38, .12);
  color: var(--status-danger);
}
.wh-avail-warn {
  background: rgba(245, 158, 11, .14);
  color: var(--status-warning);
}

/* Product card modal */
.wh-pc-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.wh-pc-stat {
  padding: 12px 14px;
  background: var(--surface-2, rgba(0,0,0,.03));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
}
.wh-pc-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.wh-pc-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.wh-pc-history {
  max-height: 360px;
  overflow-y: auto;
  margin: 0 -4px;
}
.wh-pc-mov {
  display: grid;
  grid-template-columns: 140px 1fr 80px 80px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}
.wh-pc-mov:last-child {
  border-bottom: 0;
}
.wh-pc-mov-when {
  font-size: 12px;
  color: var(--text-muted);
}
.wh-pc-mov-type {
  color: var(--text-secondary);
}
.wh-pc-mov-delta {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.wh-pc-mov-after {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* New document modal — item rows */
.wh-doc-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.wh-doc-item-row .input {
  margin: 0;
}
.wh-doc-item-row .icon-btn {
  flex: 0 0 auto;
}

/* Daily report tab — компактная таблица в духе Excel */
.wh-daily-table {
  font-size: 13px;
}
.wh-daily-table th,
.wh-daily-table td {
  padding: 8px 10px;
}
.wh-daily-table th.num,
.wh-daily-table td.num {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.wh-daily-table tbody tr:hover {
  background: var(--surface-2, rgba(0,0,0,.02));
}
.wh-daily-table tfoot td {
  background: var(--surface-2, rgba(0,0,0,.05));
}

@media (max-width: 768px) {
  .wh-daily-table { font-size: 11px; }
  .wh-daily-table th,
  .wh-daily-table td { padding: 6px 4px; }
}

/* Inventory tab */
.wh-inv-intro {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(96, 165, 250, .08);
  border: 1px solid rgba(96, 165, 250, .25);
  border-radius: var(--radius-md, 8px);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.wh-inv-intro code {
  background: var(--surface-2, rgba(0,0,0,.05));
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
}
.wh-inv-input {
  background: var(--surface-2, rgba(33, 120, 203, .06));
  border-color: rgba(33, 120, 203, .3) !important;
}
.wh-inv-input:focus {
  border-color: var(--brand-primary) !important;
  background: var(--bg-elevated);
}
.wh-inv-bottom {
  position: sticky;
  bottom: 0;
  margin: 16px -24px -24px;
  padding: 12px 24px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  box-shadow: 0 -4px 12px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  z-index: 10;
}
.wh-inv-summary {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 0 0 auto;
}
.wh-inv-summary strong {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.wh-inv-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 300px;
}

/* Mobile adaptation */
@media (max-width: 768px) {
  .wh-inv-bottom {
    margin: 12px -16px -16px;
    padding: 10px 16px;
  }
  .wh-tabs {
    padding: 0 16px;
    margin: 0 -16px 12px;
  }
  .wh-tab {
    padding: 10px 12px;
    font-size: 12px;
  }
  .wh-pc-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .wh-pc-stat {
    padding: 8px 10px;
  }
  .wh-pc-stat-val {
    font-size: 16px;
  }
  .wh-pc-mov {
    grid-template-columns: 1fr 70px 70px;
    grid-template-areas:
      "when when when"
      "type delta after";
    gap: 4px 8px;
  }
  .wh-pc-mov-when { grid-area: when; }
  .wh-pc-mov-type { grid-area: type; }
  .wh-pc-mov-delta { grid-area: delta; }
  .wh-pc-mov-after { grid-area: after; }

  .wh-doc-item-row {
    gap: 6px;
  }
  .wh-doc-item-row .input.wh-item-product {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }
  .wh-doc-item-row .input.wh-item-qty,
  .wh-doc-item-row .input.wh-item-price {
    flex: 1 1 calc(50% - 24px) !important;
    width: auto !important;
  }
}

/* === Сделки: bulk-bar в list view + чекбоксы === */
.deals-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 2px solid var(--brand-primary);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.deals-bulk-info { font-size: 13px; color: var(--text-primary); flex: 1; }
.deals-bulk-info b { color: var(--brand-primary); font-weight: 700; }
.deals-bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.deals-list-cb-cell { width: 36px; text-align: center; padding: 0 4px; }
.deals-list-cb, #deals-list-header-cb {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-primary);
}
.deals-list-row.is-selected {
  background: var(--brand-glow, rgba(33, 120, 203, .08)) !important;
}

/* === DAILY REPORT (admin dashboard) === */
.daily-section { margin-bottom: 20px; }
.daily-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--t);
  background: var(--brand-primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
}
.daily-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px;
  background: var(--bg2);
  border-radius: 0 0 8px 8px;
  border: 1px solid var(--bd);
  border-top: none;
}
.daily-stat {
  background: var(--bg3);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  transition: background .15s;
}
.daily-stat-edit:hover { background: var(--bg4, var(--bg2)); }
.daily-stat-label { font-size: 11px; color: var(--t3); text-transform: uppercase; letter-spacing: .03em; }
.daily-stat-val { font-size: 22px; font-weight: 700; color: var(--t); margin-top: 4px; }
.daily-table-wrap {
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-top: none;
  border-radius: 0 0 8px 8px;
  overflow-x: auto;
}
.daily-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.daily-table th, .daily-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle, var(--bd));
}
.daily-table th { background: var(--bg3); color: var(--t2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.daily-table td.num, .daily-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.daily-table-total { background: var(--bg3); font-weight: 700; }
.daily-table-total td { color: var(--t); }

@media (max-width: 768px) {
  .daily-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.dept-row select.dept-kind-sel {
  background: var(--bg3);
  border: 1px solid var(--bd);
  color: var(--t2);
}

/* Список сотрудников в форме отдела */
.dept-user-row:hover { background: var(--bg2); }
.dept-user-row input[type="checkbox"] { accent-color: var(--brand-primary); cursor: pointer; }

/* === Numeric stepper [ − ] N [ + ] для дневного отчёта === */
.num-stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--bd);
  border-radius: 6px;
  padding: 2px;
}
.num-stepper-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--t2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: background .1s, color .1s;
  user-select: none;
}
.num-stepper-btn:hover:not(:disabled) { background: var(--brand-primary); color: #fff; }
.num-stepper-btn:disabled { opacity: .35; cursor: not-allowed; }
.num-stepper-val {
  min-width: 32px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--t);
  padding: 0 4px;
  cursor: pointer;
}
.num-stepper-val:hover { color: var(--brand-primary); }
.num-stepper.saving { border-color: var(--am, #ff9800); }
.num-stepper.saved { border-color: #4caf50; }
.num-stepper.error { border-color: #f44336; }
