/* ============================================================
   ППБ 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; }
body {
  font-family: var(--fb);
  background: var(--bg);
  color: var(--t1);
  min-height: 100vh;
  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;
}
/* Брендовая жёлтая полоска сверху — единственное место в Login где
   жёлтый встречается как заметный элемент. */
.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-sm);
  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; }
}

/* ─── Button (default = md = 36px = primary action) ─────────── */
.btn {
  background: var(--action-primary);
  border: 1px solid var(--action-primary);
  border-radius: var(--radius-sm);
  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;
}
.app.active.rail-expanded.has-second-panel {
  grid-template-columns: var(--rail-expanded-w) var(--second-panel-w) 1fr;
}

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

/* Rail logo chip — жёлтый бренд-марк ППБ. В collapsed виде квадрат с буквой,
   в expanded — превращается в строку «П  ППБ CRM». Жёлтый здесь работает
   как бренд-маркер (не как CTA, см. design-tokens.css). */
.rail-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  color: var(--brand-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-heading);
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  margin-bottom: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.rail-logo-mark { display: block; line-height: 1; }
.rail-logo-text { display: none; }

.rail-modules {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-top: 1px solid var(--b1);
  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(--b1);
  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(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.rail-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.rail-icon:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
/* Active state — жёлтый indicator слева, лёгкий жёлтый фон.
   Это бренд-маркер: жёлтый «маркер прочитанного места» в навигации. */
.rail-icon.active {
  background: rgba(255, 199, 0, .12);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 0 var(--brand-primary);
}
.rail-icon.active:hover {
  background: rgba(255, 199, 0, .18);
}

.rail-icon-emoji {
  display: block;
  line-height: 1;
}

/* ─── Развёрнутый rail (когда rail-expanded) ──────────────── */
/* В развёрнутом виде иконки превращаются в полные пункты с текстом */
.rail-toggle {
  width: 44px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--b1);
  color: var(--t3);
  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(--bg3);
  color: var(--t1);
  border-color: var(--b2);
}

.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;
}
.app.active.rail-expanded .rail-logo-mark {
  font-size: 20px;
  width: 24px;
  flex-shrink: 0;
}
.app.active.rail-expanded .rail-logo-text {
  display: inline;
  font-weight: 800;
}
.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: 24px 32px;
  overflow-y: auto;
}

/* ============================================================
   COMMON UI (топбары, страницы, таблицы)
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.page-title {
  font-family: var(--fd);
  font-size: 20px;
  font-weight: 700;
  color: var(--t1);
  flex: 1;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  color: var(--t2);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.icon-btn:hover { background: var(--bg4); color: var(--ac2); }

.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-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.users-toolbar .input { margin: 0; max-width: 300px; }

.dept-filter {
  background: var(--bg3);
  border: 1px solid var(--b2);
  border-radius: 8px;
  color: var(--t1);
  font-family: var(--fb);
  font-size: 13px;
  padding: 9px 12px;
  cursor: pointer;
  min-width: 180px;
}

/* Таблица (Сотрудники / Клиенты) */
.users-table-wrap {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--rl);
  overflow: hidden;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
}
.users-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--b1);
  color: var(--t2);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tr.row { cursor: pointer; transition: background .12s; }
.users-table tr.row:hover td { background: var(--bg3); }

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-cell .name { color: var(--t1); font-weight: 600; }
.user-cell .username { font-size: 11px; color: var(--t3); }

.user-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;
}
.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-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 6px;
  vertical-align: middle;
}
.type-badge.individual { background: var(--gnbg); color: var(--gn); }
.type-badge.company    { background: var(--tlbg); color: var(--tl); }
.type-badge.archived   { background: var(--rdbg); color: var(--rd); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8,10,28,0.78);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 16px;
  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 {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 90;
  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(--bg2);
  border: 1px solid var(--b1);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  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: 18px 22px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.side-panel-header h2 {
  font-family: var(--fd);
  font-size: 17px;
  font-weight: 700;
  color: var(--t1);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}
.side-panel-meta {
  font-size: 11px;
  color: var(--t3);
  margin-top: 4px;
}
.side-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
  overscroll-behavior: contain;
}
.side-panel-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--b1);
  flex-shrink: 0;
}
.cp-textarea {
  resize: vertical;
  font-family: var(--fb);
  min-height: 100px;
  line-height: 1.5;
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
  /* На мобиле rail-expanded не действует — всегда horizontal tab 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;
  }
  
  .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(--b1);
  }
  .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: 40px; height: 40px; font-size: 20px; }
  .rail-icon.active { box-shadow: 0 -3px 0 0 var(--ac) inset; }
  
  .main { padding: 16px; grid-row: 1; }
  
  /* Вторая панель на мобиле во всю ширину поверх 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); }

.sidebar-search { padding: 12px 14px; border-bottom: 1px solid var(--b1); position: relative; }
.search-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--b2); color: var(--t1);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; outline: none; font-family: var(--fb);
}
.search-input:focus { border-color: var(--ac); }

.search-results {
  position: absolute; left: 14px; right: 14px; top: calc(100% - 1px);
  background: var(--bg2); border: 1px solid var(--b1); border-radius: 10px;
  margin-top: 4px; max-height: 60vh; overflow-y: auto; z-index: 50; box-shadow: var(--shadow);
}
.search-result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--b1); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg3); }
.search-result-channel { font-size: 11px; color: var(--t3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.search-result-text { font-size: 13px; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 11px; color: var(--t3); margin-top: 2px; }
.search-results .empty, .search-results .loading { padding: 14px; font-size: 13px; color: var(--t3); text-align: center; }
.search-highlight { background: var(--acbg); padding: 0 2px; border-radius: 2px; color: var(--ac2); }

.sidebar-section { padding: 10px 0; border-bottom: 1px solid var(--b1); }
.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: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--t3); font-weight: 600;
}
.channels-list { display: flex; flex-direction: column; }
.channel-item {
  padding: 8px 14px; display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: background 0.1s;
}
.channel-item:hover { background: var(--bg3); }
.channel-item.active { background: var(--acbg); }
.channel-icon {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; color: var(--t2);
}
.channel-item.active .channel-icon { color: var(--ac2); }
.channel-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.channel-unread {
  background: var(--ac); color: white; font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center; flex-shrink: 0;
}
.channel-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0; overflow: hidden;
}
.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.7; }
.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(--t3); gap: 12px;
}
.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: 14px 20px;
  border-bottom: 1px solid var(--b1); background: var(--bg2); flex-shrink: 0;
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info.clickable {
  cursor: pointer; border-radius: 8px; padding: 4px 8px; margin: -4px -8px;
}
.chat-header-info.clickable:hover { background: var(--bg3); }
.chat-title { font-weight: 600; font-size: 16px; color: var(--t1); }
.chat-subtitle { font-size: 12px; color: var(--t3); }
.chat-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.online-count {
  font-size: 12px; color: var(--t3); display: flex; align-items: center;
  gap: 6px; white-space: nowrap;
}
.online-count::before {
  content: ''; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--gn);
}

/* Pinned bar */
.pinned-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--acbg); border-bottom: 1px solid var(--b1); cursor: pointer; flex-shrink: 0;
}
.pinned-bar:hover { background: var(--acb); }
.pinned-icon { color: var(--ac2); font-size: 14px; }
.pinned-content {
  flex: 1; min-width: 0; font-size: 13px; color: var(--t2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pinned-content .pinned-author { font-weight: 600; color: var(--t1); margin-right: 6px; }
.pinned-nav { background: transparent; border: none; color: var(--t2); font-size: 18px; cursor: pointer; padding: 0 4px; }

/* Messages */
.messages-container { flex: 1; overflow-y: auto; padding: 16px 20px; background: var(--bg); }
.messages-loading { text-align: center; color: var(--t3); padding: 20px; font-size: 13px; }
.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;
}
.message-edit-input, .message textarea, .message input {
  -webkit-user-select: text !important; user-select: text !important;
  -webkit-touch-callout: default !important;
}
.message.grouped { padding-top: 0; margin-top: -4px; }
.message-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ac); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0; overflow: hidden;
}
.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: 600; font-size: 14px; color: var(--t1);
  cursor: pointer; border-radius: 4px; padding: 0 2px; margin: 0 -2px;
}
.message-author:hover { background: var(--acbg); }
.message-time { font-size: 11px; color: var(--t3); }
.message-text { white-space: pre-wrap; word-break: break-word; color: var(--t1); font-size: 14px; }
.message-day-divider { text-align: center; margin: 16px 0; position: relative; font-size: 12px; color: var(--t3); }
.message-day-divider::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--b1); z-index: 0;
}
.message-day-divider span { background: var(--bg); padding: 0 12px; position: relative; z-index: 1; }

/* Composer */
.composer {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--b1); background: var(--bg2); flex-shrink: 0;
}
.message-input {
  flex: 1; min-width: 0; background: var(--bg3); border: 1px solid var(--b2);
  border-radius: 10px; color: var(--t1); padding: 10px 14px;
  font-size: 16px; resize: none; max-height: 200px; outline: none; font-family: var(--fb);
}
.message-input:focus { border-color: var(--ac); }
.composer-btn {
  background: transparent; border: none; color: var(--t2);
  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;
}
.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 */
.message-edit-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--ac);
  border-radius: 8px; color: var(--t1); padding: 6px 10px;
  font-size: 14px; font-family: inherit; resize: none; outline: none; min-height: 32px;
}
.message-edit-actions { display: flex; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--t3); }
.message-edit-actions a { color: var(--ac2); cursor: pointer; text-decoration: underline; }

/* 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-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; }

.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;
  background: var(--bg3);
  color: var(--t1);
  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;
  background: var(--ac);
  color: white;
  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;
}

/* 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;
  color: var(--t2) !important;
  font-size: 14px !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 */
.crm-kanban-wrap {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  min-height: 420px;
}

/* Колонка */
.crm-col {
  min-width: 240px;
  max-width: 260px;
  flex: 0 0 auto;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--rl);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

/* Заголовок колонки */
.crm-col-header {
  padding: 11px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.crm-col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}
.crm-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.crm-stage-icon {
  font-size: 12px;
}
.crm-col-name {
  font-weight: 700;
  font-size: 12px;
}
.crm-col-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border: 1px solid;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Сумма по колонке */
.crm-col-sum {
  padding: 0 12px 8px;
  font-size: 11px;
  color: var(--t3);
  border-bottom: 1px solid var(--b1);
  font-weight: 500;
}

/* Тело колонки (карточки) */
.crm-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 100px;
  transition: background .15s;
}
.crm-col-body.drag-over {
  background: var(--acbg);
}
.crm-col-empty {
  text-align: center;
  padding: 20px 0;
  color: var(--t3);
  font-size: 11px;
  flex: 1;
}

/* Карточка сделки */
.crm-card {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  transition: border-color .15s, opacity .15s, transform .15s;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.crm-card:hover {
  border-color: var(--b2);
}
.crm-card:active {
  cursor: grabbing;
}
.crm-card.dragging {
  opacity: 0.45;
  transform: rotate(1deg);
}

.crm-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--t1);
  line-height: 1.45;
  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: 11px;
  color: var(--t2);
}
.crm-card-customer-icon {
  font-size: 11px;
  opacity: 0.7;
}

.crm-card-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--ac2);
  margin-top: 2px;
}

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

.crm-card-row {
  font-size: 11px;
  color: var(--t2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.crm-card-icon {
  font-size: 11px;
  opacity: 0.7;
}

.crm-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--b1);
}
.crm-card-date {
  font-size: 10px;
  color: var(--t3);
}
.crm-card-stale {
  font-size: 9px;
  color: var(--rd);
  font-weight: 600;
}

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

/* END DEALS KANBAN ELC-STYLE */

/* Pipeline tabs */
.deals-pipeline-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--b1);
}
.deals-pipeline-tab {
  background: transparent;
  border: none;
  color: var(--t2);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--fb);
}
.deals-pipeline-tab:hover { background: var(--bg3); color: var(--t1); }
.deals-pipeline-tab.active {
  background: var(--acbg);
  color: var(--ac2);
}
.deals-board {
  width: 100%;
}


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

/* Toolbar */
.deals-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--rl);
}
.deals-toolbar .input {
  margin: 0;
  font-size: 13px;
  padding: 7px 10px;
}
.deals-search {
  flex: 1 1 220px;
  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: 12px;
  color: var(--t3);
  white-space: nowrap;
  padding-left: 8px;
}

/* View toggle (Канбан / Список) */
.view-toggle {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--b2);
  border-radius: var(--r);
  overflow: hidden;
}
.vt-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--fb);
  border: none;
  background: transparent;
  color: var(--t2);
  cursor: pointer;
  transition: all .15s;
}
.vt-btn:hover { color: var(--t1); }
.vt-btn.active {
  background: var(--ac);
  color: white;
}

/* List view */
.deals-list-wrap {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: var(--rl);
  overflow: auto;
}
.deals-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.deals-list-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
  white-space: nowrap;
}
.deals-list-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.deals-list-table th.sortable:hover {
  background: var(--bg4);
  color: var(--t1);
}
.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(--b1);
  color: var(--t2);
  vertical-align: middle;
}
.deals-list-table tr:last-child td { border-bottom: none; }
.deals-list-table tr.deals-list-row {
  cursor: pointer;
  transition: background .1s;
}
.deals-list-table tr.deals-list-row:hover td {
  background: var(--bg3);
}
.deals-list-table tr.deals-list-row td strong {
  color: var(--t1);
  font-weight: 600;
}
.deals-list-stage {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.sort-icon {
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.4;
}
.sort-icon.active {
  opacity: 1;
  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;
  background: rgba(8,10,28,0.78);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.deal-modal-content {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  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;
}

/* 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;
}

.dc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.dc-header-back {
  background: transparent; border: none; color: var(--t2);
  font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.dc-header-back:hover { background: var(--bg3); color: var(--t1); }
.dc-header-title-wrap { flex: 1; min-width: 0; }
.dc-header-title {
  font-family: var(--fd); font-size: 18px; font-weight: 700;
  color: var(--t1); margin: 0; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dc-header-meta {
  font-size: 11px; color: var(--t3); margin-top: 2px;
}

.dc-chevrons {
  display: flex;
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--b1);
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.deal-chevron {
  flex: 1 1 0;
  min-width: 100px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  color: var(--t2);
  font-size: 11px;
  font-weight: 600;
  padding: 9px 6px 9px 18px;
  cursor: pointer;
  font-family: var(--fb);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  transition: background .12s, color .12s;
}
.deal-chevron:first-child {
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
  border-radius: 4px 0 0 4px;
}
.deal-chevron:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%);
  border-radius: 0 4px 4px 0;
}
.deal-chevron:hover {
  background: var(--bg4);
  color: var(--t1);
}
.deal-chevron.past {
  background: var(--bg4);
  color: var(--t3);
}
.deal-chevron.current {
  background: var(--chevron-color, var(--ac));
  color: white;
  border-color: var(--chevron-color, var(--ac));
  font-weight: 700;
}
.deal-chevron.success.current {
  background: var(--gn);
  color: white;
}
.deal-chevron.lost.current {
  background: var(--rd);
  color: white;
}
.deal-chevron-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

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

.dc-body {
  flex: 1;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  background: var(--bg);
}
.dc-left {
  overflow-y: auto;
  padding: 14px 18px;
  border-right: 1px solid var(--b1);
}
.dc-right {
  overflow-y: auto;
  padding: 14px 18px;
  background: var(--bg2);
}

.dc-section {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.dc-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--b1);
  gap: 8px;
}
.dc-section-toggle {
  background: transparent; border: none;
  color: var(--t2);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--fb);
  padding: 0;
}
.dc-section-toggle:hover { color: var(--t1); }
.dc-section-caret {
  transition: transform .15s;
  font-size: 10px;
}
.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(--ac2);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  font-family: var(--fb);
  border-radius: 4px;
}
.dc-section-link:hover {
  background: var(--acbg);
  color: var(--ac);
}
.dc-section-body {
  padding: 8px 14px;
}

.dc-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 6px 0;
  align-items: start;
  border-bottom: 1px solid var(--b1);
}
.dc-row:last-child { border-bottom: none; }
.dc-row.dc-row-readonly { padding: 4px 0; }
.dc-label {
  font-size: 12px;
  color: var(--t3);
  font-weight: 500;
  padding-top: 8px;
}
.dc-value {
  font-size: 13px;
  color: var(--t1);
}
.dc-value .input {
  margin: 0;
  font-size: 13px;
  padding: 6px 10px;
}
.dc-value textarea.input {
  font-family: var(--fb);
  resize: vertical;
}
.dc-row-readonly .dc-value {
  padding: 8px 0;
  font-size: 12px;
  color: var(--t2);
}

.dc-customer-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 8px 10px;
}
.dc-customer-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ac);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.dc-customer-info { flex: 1; min-width: 0; }
.dc-customer-name {
  font-weight: 600; font-size: 13px;
  color: var(--t1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dc-customer-phone {
  font-size: 11px; color: var(--t3); margin-top: 1px;
}
.dc-customer-actions {
  display: flex; gap: 4px;
}
.dc-customer-iconbtn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg4);
  border: 1px solid var(--b1);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  text-decoration: none;
  color: var(--t1);
  transition: all .15s;
}
.dc-customer-iconbtn:hover {
  background: var(--ac);
  color: white;
  border-color: var(--ac);
}

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

.dc-lifeline-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--b1);
}
.dc-lifeline-tab {
  background: transparent; border: none;
  color: var(--t2);
  font-size: 12px; font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--fb);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.dc-lifeline-tab.active {
  color: var(--ac2);
  border-bottom-color: var(--ac);
}
.dc-lifeline-tab.disabled { opacity: 0.4; cursor: not-allowed; }

.dc-lifeline-empty {
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  padding: 30px 14px;
  font-style: italic;
}
.dc-lifeline-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--b1);
}
.dc-lifeline-item:last-child { border-bottom: none; }
.dc-lifeline-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--acbg);
  color: var(--ac2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.dc-lifeline-content { flex: 1; min-width: 0; }
.dc-lifeline-title {
  font-size: 12px;
  color: var(--t2);
  line-height: 1.4;
}
.dc-lifeline-title strong { color: var(--t1); font-weight: 600; }
.dc-lifeline-meta {
  font-size: 11px;
  color: var(--t3);
  margin-top: 2px;
}

.dc-footer {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--b1);
  background: var(--bg2);
  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-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: #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;
}
.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;
}
.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-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tasks-new-btn {
  align-self: flex-start;
}
.tasks-empty {
  padding: 14px;
  text-align: center;
  color: var(--t3);
  font-size: 12px;
  font-style: italic;
}
.tasks-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.tasks-group summary {
  cursor: pointer;
  list-style: none;
  outline: none;
}
.tasks-group summary::-webkit-details-marker { display: none; }
.tasks-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 0;
}
.tasks-group-overdue {
  color: var(--rd);
}
.task-row {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.task-row.task-overdue {
  border-color: var(--rd);
  background: rgba(227, 30, 36, 0.04);
}
.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: 6px;
}
.task-icon {
  font-size: 14px;
}
.task-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  color: var(--t1);
}
.task-del {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 18px;
  color: var(--t3);
  padding: 0 4px;
  line-height: 1;
}
.task-del:hover { color: var(--rd); }
.task-desc {
  font-size: 12px;
  color: var(--t2);
  white-space: pre-wrap;
}
.task-meta {
  display: flex;
  gap: 4px;
  font-size: 11px;
  color: var(--t3);
}
.task-time { font-weight: 500; }
.task-result {
  font-size: 12px;
  color: var(--t2);
  background: var(--bg3);
  padding: 4px 8px;
  border-radius: 6px;
  font-style: italic;
}
.task-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.task-btn {
  background: var(--bg3);
  border: 1px solid var(--b1);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--fb);
  color: var(--t1);
}
.task-btn-complete:hover {
  background: var(--gnbg);
  border-color: var(--gn);
}
.task-btn-skip:hover {
  background: var(--bg4);
}
/* 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: 4px;
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.task-type-opt input { cursor: pointer; }
.task-type-opt:has(input:checked) {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
}
/* 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;
}
@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);
}
.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 {
  display: inline-flex;
  border: 1px solid var(--b1);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.vt-toggle .vt-btn {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--t2);
  font-family: var(--fb);
  font-weight: 500;
}
.vt-toggle .vt-btn.active {
  background: var(--ac);
  color: #fff;
}
.vt-toggle .vt-btn:hover:not(.active) {
  background: var(--bg3);
  color: var(--t1);
}
.tasks-filter {
  margin: 0 !important;
  padding: 6px 10px !important;
  font-size: 12px !important;
  width: auto !important;
  min-width: 140px;
}
.tasks-show-completed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--t2);
  margin-left: auto;
}
.tasks-show-completed input {
  cursor: pointer;
}
.tasks-page-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.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 {
  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);
}
/* 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;
}
.notif-bell-btn:hover {
  background: var(--bg3);
}
.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-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-btn-start {
  background: var(--gn);
  color: #fff;
  border-color: var(--gn);
}
.workday-btn-start:hover { background: var(--gn); filter: brightness(1.08); }
.workday-btn-pause {
  background: var(--am);
  color: #fff;
  border-color: var(--am);
}
.workday-btn-pause:hover { filter: brightness(1.08); }
.workday-btn-resume {
  background: var(--gn);
  color: #fff;
  border-color: var(--gn);
}
.workday-btn-resume:hover { filter: brightness(1.08); }
.workday-btn-end {
  background: var(--rd);
  color: #fff;
  border-color: var(--rd);
}
.workday-btn-end:hover { 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 */
.dash-filters {
  padding: 12px 14px;
  border-bottom: 1px solid var(--b1);
  background: var(--bg2);
}
.dash-period-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.dash-period-tab {
  background: transparent;
  border: 1px solid var(--b1);
  padding: 5px 12px;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  border-radius: 8px;
}
.dash-period-tab:hover { background: var(--bg3); }
.dash-period-tab.active {
  background: var(--ac);
  color: #fff;
  border-color: var(--ac);
}
.dash-period-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.dash-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dash-flabel {
  font-size: 12px;
  color: var(--t2);
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.dash-card {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-left: 4px solid var(--ac);
  border-radius: 10px;
  padding: 14px 16px;
}
.dash-card-open { border-left-color: #1976d2; }
.dash-card-won  { border-left-color: var(--gn); }
.dash-card-lost { border-left-color: var(--rd); }
.dash-card-conv { border-left-color: var(--ac); }
.dash-card-label {
  font-size: 11px;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.dash-card-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--t1);
  font-variant-numeric: tabular-nums;
}
.dash-card-sub {
  font-size: 11px;
  color: var(--t2);
  margin-top: 4px;
}

.dash-block {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.dash-block-title {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--t1);
  border-bottom: 1px solid var(--b1);
  background: var(--bg3);
}
.dash-funnel {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.dash-funnel-label {
  width: 160px;
  font-size: 12px;
  color: var(--t1);
  flex-shrink: 0;
}
.dash-funnel-bar-wrap {
  flex: 1;
  height: 18px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
}
.dash-funnel-bar {
  height: 100%;
  transition: width .25s;
}
.dash-funnel-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  min-width: 130px;
  justify-content: flex-end;
}
.dash-funnel-count {
  color: var(--t1);
  font-weight: 700;
}
.dash-funnel-sum {
  color: var(--t3);
}

.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;
}
.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;
  grid-template-columns: 1fr 90px 110px 80px 110px 28px;
  gap: 8px;
  align-items: center;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
}
.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;
}
.tpl-help-table td {
  padding: 4px 8px;
  vertical-align: top;
}
.tpl-help-table td:first-child {
  width: 200px;
}
.tpl-help-table code {
  background: var(--bg2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--ac);
}
/* 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
   Эталон: Сделки. Все страницы должны выглядеть единообразно.
   ===================================================================== */

/* TOPBAR — единая шапка страницы */
.topbar {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 16px 22px !important;
  gap: 14px !important;
  min-height: 64px !important;
  box-sizing: border-box !important;
}

/* Заголовок страницы — крупный 24px */
.topbar .page-title,
.topbar h1,
.topbar h2 {
  font-size: 24px !important;
  font-weight: 700 !important;
  margin: 0 !important;
  color: var(--t1) !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
}

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

/* SEARCH INPUT в topbar — компактный 36px высота */
.topbar input.input,
.topbar .input,
.topbar input[type="search"],
.topbar input[type="text"] {
  height: 36px !important;
  padding: 0 12px !important;
  font-size: 13px !important;
  width: 260px !important;
  margin: 0 !important;
  border-radius: 8px !important;
  box-sizing: border-box !important;
  line-height: 36px !important;
}

/* SELECT в topbar */
.topbar select.input,
.topbar select {
  height: 36px !important;
  padding: 0 28px 0 12px !important;
  font-size: 13px !important;
  margin: 0 !important;
  border-radius: 8px !important;
}

/* КНОПКИ в topbar — единая высота 36px, no-wrap */
.topbar .btn,
.topbar .btn-primary,
.topbar .btn-secondary,
.topbar .btn-danger,
.topbar button.icon-btn {
  height: 36px !important;
  padding: 0 14px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  border-radius: 8px !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;
}

/* Кнопки .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-page {
  padding: 20px 22px;
  max-width: 800px;
}
.integrations-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--b1);
  margin-bottom: 18px;
}
.int-tab {
  background: transparent;
  border: 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.int-tab:hover { color: var(--t1); }
.int-tab.active {
  color: var(--ac);
  border-bottom-color: var(--ac);
}
.int-tab-soon {
  display: inline-block;
  font-size: 10px;
  background: var(--bg3);
  color: var(--t3);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 500;
}
.integrations-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.int-card {
  background: var(--bg2);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 18px;
}
.int-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
}

/* Deal sources table */
.src-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.src-table th, .src-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--b1);
}
.src-table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--t3);
}
.src-row-archived { opacity: 0.5; }
.src-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--b2);
  vertical-align: middle;
}
.src-slug code {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--t2);
}
.src-actions { white-space: nowrap; text-align: right; }
.src-actions .btn-link { font-size: 12px; padding: 2px 8px; }
.src-badge-active, .src-badge-archived {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.src-badge-active {
  background: rgba(63, 216, 142, 0.12);
  color: #3fd88e;
}
.src-badge-archived {
  background: var(--bg3);
  color: var(--t3);
}
.int-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 18px;
}
.int-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.int-status-ok {
  background: rgba(63, 216, 142, 0.12);
  color: var(--gn);
}
.int-status-off {
  background: var(--bg3);
  color: var(--t3);
}
.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 {
  background: rgba(110, 120, 255, 0.12);
  border-color: var(--ac);
  color: var(--ac);
}
/* 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: rgba(110, 120, 255, 0.12);
  border-color: var(--ac);
  color: var(--ac);
}


/* =====================================================================
   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;
  min-height: 200px;
  max-height: 460px;
  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(--ac);
  color: white;
}
.dc-wa-send-btn:hover:not(:disabled) {
  background: var(--ac);
  filter: brightness(1.1);
  color: white;
}
.dc-wa-send-btn:disabled {
  background: var(--bg3);
  color: var(--t3);
  cursor: not-allowed;
}

/* 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;
}
