/* ===== Namo Space Styles ===== */
/*
  Система переменных — 3 темы:
    (default)      = dark  — тёмный уголь
    body.theme-light = светлая
    body.theme-soft  = мягкая (бумажно-серая, sand)

  Переменные покрывают ВСЁ:
    --bg            фон страницы
    --bg-2          фон карточки / sidebar
    --bg-3          фон поднятый (канбан-колонка, ai-sidebar)
    --bg-4          фон инпута
    --bg-5          hover-подсветка ячеек, строк

    --border        основная граница
    --border-2      более тёмная / акцентная граница

    --text          основной текст
    --text-2        вторичный (подписи, meta)
    --text-3        третичный (placeholder, dim)

    --primary       акцент (indigo)
    --primary-glow  полупрозрачный акцент

    --success / --danger / --warning / --info  — семантика

    --shadow-*      тени
    --radius-*      радиусы
*/

/* ================================================================
   ПЕРЕМЕННЫЕ — ТЁМНАЯ ТЕМА (default)
   ================================================================ */
:root {
  /* Brand */
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-glow:  rgba(99, 102, 241, 0.18);
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #3b82f6;

  /* Backgrounds */
  --bg:   #1a1b23;
  --bg-2: #22232e;
  --bg-3: #1e1f2a;
  --bg-4: #171821;
  --bg-5: rgba(255,255,255,0.035);

  /* Borders */
  --border:   #2e3048;
  --border-2: #3d3f5a;

  /* Text */
  --text:   #eeeef2;
  --text-2: #8b8fa8;
  --text-3: #5c6080;

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 4px  rgba(0,0,0,.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.45);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.55);

  /* Transition */
  --transition: 0.15s ease;
}

/* ================================================================
   СВЕТЛАЯ ТЕМА
   ================================================================ */
body.theme-light {
  --primary:      #5b5bd6;
  --primary-dark: #4945c4;
  --primary-glow: rgba(91,91,214,0.12);
  --success:      #059669;

  --bg:   #f2f3f8;
  --bg-2: #ffffff;
  --bg-3: #e8eaf2;
  --bg-4: #ffffff;
  --bg-5: rgba(0,0,0,0.025);

  --border:   #dde0ed;
  --border-2: #c5c9de;

  --text:   #1c1e2e;
  --text-2: #3d4060;
  --text-3: #5a5f80;

  --shadow-sm: 0 1px 4px  rgba(0,0,0,.07);
  --shadow-md: 0 3px 12px rgba(0,0,0,.09);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.12);
  --shadow-xl: 0 16px 50px rgba(0,0,0,.15);

  color-scheme: light;
}

/* ================================================================
   РОЗОВАЯ ТЕМА (blossom / pink)
   ================================================================ */
body.theme-pink {
  --primary:      #d946a8;
  --primary-dark: #be2d90;
  --primary-glow: rgba(217,70,168,0.13);
  --success:      #059669;

  --bg:   #fdf2f8;
  --bg-2: #ffffff;
  --bg-3: #fce7f3;
  --bg-4: #ffffff;
  --bg-5: rgba(217,70,168,0.04);

  --border:   #fbcfe8;
  --border-2: #f9a8d4;

  --text:   #1e0a17;
  --text-2: #6b2a52;
  --text-3: #9d5a7c;

  --shadow-sm: 0 1px 4px  rgba(217,70,168,.07);
  --shadow-md: 0 3px 12px rgba(217,70,168,.10);
  --shadow-lg: 0 8px 28px rgba(217,70,168,.13);
  --shadow-xl: 0 16px 50px rgba(0,0,0,.15);

  color-scheme: light;
}

/* ================================================================
   МЯТНАЯ ТЕМА (mint / teal)
   ================================================================ */
body.theme-mint {
  --primary:      #0d9488;
  --primary-dark: #0f766e;
  --primary-glow: rgba(13,148,136,0.13);
  --success:      #059669;

  --bg:   #f0fdf9;
  --bg-2: #ffffff;
  --bg-3: #ccfbf1;
  --bg-4: #ffffff;
  --bg-5: rgba(13,148,136,0.04);

  --border:   #99f6e4;
  --border-2: #5eead4;

  --text:   #042f2e;
  --text-2: #115e59;
  --text-3: #4d9e96;

  --shadow-sm: 0 1px 4px  rgba(13,148,136,.07);
  --shadow-md: 0 3px 12px rgba(13,148,136,.10);
  --shadow-lg: 0 8px 28px rgba(13,148,136,.13);
  --shadow-xl: 0 16px 50px rgba(0,0,0,.15);

  color-scheme: light;
}

/* ================================================================
   МЯГКАЯ ТЕМА (sand / paper)
   ================================================================ */
body.theme-soft {
  --primary:      #7c6f52;
  --primary-dark: #5f5238;
  --primary-glow: rgba(124,111,82,0.14);
  --success:      #4a7c59;

  --bg:   #f0ece4;
  --bg-2: #faf7f2;
  --bg-3: #e8e2d8;
  --bg-4: #faf7f2;
  --bg-5: rgba(0,0,0,0.025);

  --border:   #d8d0c0;
  --border-2: #bfb49e;

  --text:   #2c2416;
  --text-2: #5a4e38;
  --text-3: #8a7a62;

  --shadow-sm: 0 1px 4px  rgba(0,0,0,.07);
  --shadow-md: 0 3px 12px rgba(0,0,0,.09);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.12);
  --shadow-xl: 0 16px 50px rgba(0,0,0,.15);

  color-scheme: light;
}

/* ================================================================
   BASE RESET
   ================================================================ */
* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ================================================================
   LOGIN
   ================================================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

body.theme-light #login-screen,
body.theme-soft  #login-screen,
body.theme-pink  #login-screen,
body.theme-mint  #login-screen {
  background: var(--bg-3);
}

.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 400px;
  box-shadow: var(--shadow-xl);
}

.login-logo { text-align:center; margin-bottom:8px; display:flex; justify-content:center; }

.login-title {
  font-size: 28px; font-weight: 700; text-align: center;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 4px; letter-spacing: -0.3px;
}

.login-subtitle { text-align: center; color: var(--text-2); font-size: 14px; margin-bottom: 32px; }

/* ================================================================
   MAIN LAYOUT
   ================================================================ */
#main-app { display: flex; min-height: 100vh; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  width: 240px; min-width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 50; transition: transform 0.3s ease;
}

body.theme-light .sidebar { box-shadow: 2px 0 16px rgba(0,0,0,.06); }
body.theme-soft  .sidebar { box-shadow: 2px 0 12px rgba(0,0,0,.06); }
body.theme-pink  .sidebar { box-shadow: 2px 0 16px rgba(217,70,168,.08); }
body.theme-mint  .sidebar { box-shadow: 2px 0 14px rgba(13,148,136,.08); }

.sidebar-logo {
  padding: 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #4338ca, #312e81);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
}

.sidebar-logo-text {
  font-size: 20px; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }

.nav-section-title {
  font-size: 10.5px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 14px 20px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; cursor: pointer;
  border-radius: var(--radius-md); margin: 1px 8px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: all var(--transition);
  text-decoration: none; position: relative;
}

.nav-item:hover { background: var(--bg-5); color: var(--text); }

.nav-item.active { background: var(--primary-glow); color: var(--primary); }

.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; background: var(--primary); border-radius: 0 3px 3px 0;
}

.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.nav-badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 10px; min-width: 20px; text-align: center;
}

.sidebar-user {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}

.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-2); }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content { flex: 1; margin-left: 240px; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  height: 60px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 40;
}

body:not(.theme-light):not(.theme-soft):not(.theme-pink):not(.theme-mint) .topbar {
  background: rgba(26,27,35,.9);
  backdrop-filter: blur(12px);
}

body.theme-light .topbar { background: rgba(242,243,248,.96); backdrop-filter: blur(10px); }
body.theme-soft  .topbar { background: rgba(240,236,228,.96); backdrop-filter: blur(10px); }
body.theme-pink  .topbar { background: rgba(253,242,248,.96); backdrop-filter: blur(10px); }
body.theme-mint  .topbar { background: rgba(240,253,249,.96); backdrop-filter: blur(10px); }

.topbar-title { font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -0.2px; color: var(--text); }

/* ================================================================
   PAGE CONTENT
   ================================================================ */
.page-content { flex: 1; padding: 24px; overflow-y: auto; overflow-x: hidden; background: var(--bg); }
.page-content.deals-page { overflow-x: auto; overflow-y: hidden; display: flex; flex-direction: column; }
#kanban-board-container { flex: 1; overflow-x: auto; overflow-y: hidden; min-height: 0; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  color: var(--text);
}

.card-hover { transition: border-color var(--transition), box-shadow var(--transition); }
.card-hover:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }

body.theme-light .card,
body.theme-soft  .card,
body.theme-pink  .card,
body.theme-mint  .card { box-shadow: var(--shadow-sm); }

/* ================================================================
   STATS GRID
   ================================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
  color: var(--text);
}
.stat-card::before { display: none; }
.stat-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); }

.stat-icon {
  font-size: 20px; margin-bottom: 12px;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-glow);
}

.stat-value { font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; color: var(--text); }
.stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 5px; }

body.theme-light .stat-card,
body.theme-soft  .stat-card,
body.theme-pink  .stat-card,
body.theme-mint  .stat-card { box-shadow: var(--shadow-sm); }

/* ================================================================
   KANBAN
   ================================================================ */
.kanban-board { display: flex; gap: 14px; padding: 0 4px 16px 4px; height: 100%; min-height: 500px; }

.kanban-column {
  min-width: 280px; max-width: 280px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  height: fit-content; max-height: calc(100vh - 220px);
}

.kanban-column-header {
  padding: 13px 16px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-3); z-index: 1;
}

.stage-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.column-name { font-size: 12.5px; font-weight: 600; flex: 1; letter-spacing: 0.01em; color: var(--text); }

.column-count {
  background: var(--bg-5); color: var(--text-2);
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-xl);
}

.kanban-cards { flex: 1; padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

.deal-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 13px;
  cursor: pointer; transition: all var(--transition); position: relative;
  color: var(--text);
}

.deal-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.deal-card-title { font-size: 13px; font-weight: 600; margin-bottom: 6px; line-height: 1.35; color: var(--text); }
.deal-card-contact { font-size: 12px; color: var(--text-2); margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.deal-card-budget { font-size: 14px; font-weight: 700; color: var(--success); margin-bottom: 8px; }

.deal-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }

.tag {
  background: var(--primary-glow); color: var(--primary);
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-xl);
  border: 1px solid var(--primary-glow);
}
.tag.red    { background: rgba(239,68,68,.13);   color: #fca5a5; border-color: rgba(239,68,68,.2); }
.tag.green  { background: rgba(16,185,129,.13);  color: #6ee7b7; border-color: rgba(16,185,129,.2); }
.tag.yellow { background: rgba(245,158,11,.13);  color: #fcd34d; border-color: rgba(245,158,11,.2); }

body.theme-light .tag, body.theme-soft .tag,
body.theme-pink  .tag, body.theme-mint  .tag { color: var(--primary-dark); }
body.theme-light .tag.red    { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
body.theme-light .tag.green  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
body.theme-light .tag.yellow { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
body.theme-soft  .tag.red    { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
body.theme-soft  .tag.green  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
body.theme-soft  .tag.yellow { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
body.theme-pink  .tag.red    { background: #fee2e2; color: #9f1239; border-color: #fca5a5; }
body.theme-pink  .tag.green  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
body.theme-pink  .tag.yellow { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
body.theme-mint  .tag.red    { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
body.theme-mint  .tag.green  { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
body.theme-mint  .tag.yellow { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

.deal-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}

.priority-badge {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: var(--radius-sm);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.priority-critical { background: rgba(239,68,68,.18); color: #fca5a5; }
.priority-high     { background: rgba(245,158,11,.18); color: #fcd34d; }
.priority-medium   { background: rgba(99,102,241,.18); color: #a5b4fc; }
.priority-low      { background: rgba(107,114,128,.18); color: #9ca3af; }

body.theme-light .priority-critical, body.theme-soft .priority-critical,
body.theme-pink  .priority-critical, body.theme-mint  .priority-critical { color: #b91c1c; background: #fee2e2; }
body.theme-light .priority-high,     body.theme-soft .priority-high,
body.theme-pink  .priority-high,     body.theme-mint  .priority-high     { color: #92400e; background: #fef3c7; }
body.theme-light .priority-medium,   body.theme-soft .priority-medium,
body.theme-pink  .priority-medium,   body.theme-mint  .priority-medium   { color: var(--primary-dark); background: var(--primary-glow); }
body.theme-light .priority-low,      body.theme-soft .priority-low,
body.theme-pink  .priority-low,      body.theme-mint  .priority-low      { color: var(--text-2); background: var(--bg-3); }

.assignee-chip { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-2); }
.assignee-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-4); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 9px 13px;
  color: var(--text); font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-input::placeholder { color: var(--text-3); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: var(--bg-2); color: var(--text); }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 17px; border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap; text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white; box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-primary:hover { opacity: .92; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text);
}
.btn-secondary:hover { background: var(--bg-3); }

.btn-danger  { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }
.btn-danger:hover  { background: rgba(239,68,68,.25); }
.btn-success { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }
.btn-success:hover { background: rgba(16,185,129,.25); }

.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-5); color: var(--text); }

body.theme-light .btn-danger, body.theme-soft .btn-danger,
body.theme-pink  .btn-danger, body.theme-mint  .btn-danger  { color: #b91c1c; }
body.theme-light .btn-success, body.theme-soft .btn-success,
body.theme-pink  .btn-success, body.theme-mint  .btn-success { color: #065f46; }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(5px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn .15s ease;
}
body.theme-light .modal-overlay,
body.theme-soft  .modal-overlay { background: rgba(0,0,0,.4); }

@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:translateY(0) } }

.modal {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 600px; max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp .2s ease; box-shadow: var(--shadow-xl);
  color: var(--text);
}

.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-sm { max-width: 420px; }

.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title  { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); }
.modal-body   { padding: 22px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 15px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

.close-btn {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: transparent; border: none; color: var(--text-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: all var(--transition);
}
.close-btn:hover { background: var(--bg-5); color: var(--text); }

/* ================================================================
   TABLES
   ================================================================ */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; color: var(--text); }
thead tr { border-bottom: 1px solid var(--border); }
th {
  text-align: left; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 16px; background: var(--bg-3);
}
td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--bg-5); }

/* ================================================================
   AI CHAT
   ================================================================ */
.ai-container {
  display: flex; height: calc(100vh - 100px); gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  overflow: hidden; background: var(--bg-2);
}
.ai-sidebar {
  width: 260px; min-width: 260px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: var(--bg-3);
}
.ai-chat { flex: 1; display: flex; flex-direction: column; }
.ai-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.ai-message { display: flex; gap: 12px; max-width: 85%; animation: slideUp .2s ease; }
.ai-message.user      { align-self: flex-end; flex-direction: row-reverse; }
.ai-message.assistant { align-self: flex-start; }

.message-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.ai-message.user .message-avatar      { background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.ai-message.assistant .message-avatar { background: var(--bg-3); border: 1px solid var(--border-2); }

.message-bubble {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 11px 15px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  color: var(--text);
}
.ai-message.user .message-bubble { background: var(--primary-glow); border-color: var(--primary-glow); }
.message-bubble strong { color: var(--primary); }
.message-bubble code { background: var(--bg-5); padding: 2px 6px; border-radius: var(--radius-sm); font-size: 12px; }

.ai-input-area { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; }
.ai-input {
  flex: 1; background: var(--bg-4); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 9px 13px;
  color: var(--text); font-size: 14px; outline: none; resize: none;
  max-height: 120px; font-family: inherit; transition: border-color var(--transition); line-height: 1.5;
}
.ai-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.quick-actions { padding: 14px; border-bottom: 1px solid var(--border); }
.quick-btn {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px 12px;
  color: var(--text-2); font-size: 12px; cursor: pointer; margin-bottom: 5px;
  transition: all var(--transition);
}
.quick-btn:hover { background: var(--bg-5); color: var(--text); border-color: var(--border-2); }
.quick-btn.quick-btn-action { border-color: var(--primary-glow); color: var(--primary); }
.quick-btn.quick-btn-action:hover { background: var(--primary-glow); }

/* ================================================================
   PIPELINE STAGES EDITOR
   ================================================================ */
.stage-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 8px;
  transition: border-color var(--transition);
}
.stage-item:hover { border-color: var(--border-2); }
.stage-drag-handle { color: var(--text-3); cursor: grab; font-size: 14px; }
.stage-color-dot { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }

/* ================================================================
   AUTOMATION
   ================================================================ */
.automation-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 15px; margin-bottom: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.automation-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.automation-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.automation-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.automation-status.active   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.automation-status.inactive { background: var(--text-3); }
.flow-arrow { display: flex; align-items: center; gap: 8px; padding: 4px 0; color: var(--text-3); font-size: 12px; }
.flow-block {
  background: var(--bg-5); border: 1px dashed var(--border-2);
  border-radius: var(--radius-md); padding: 10px 14px; font-size: 13px;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}

/* ================================================================
   SEARCH
   ================================================================ */
.search-input {
  background: var(--bg-4); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 8px 14px 8px 36px;
  color: var(--text); font-size: 14px; outline: none; width: 260px;
  transition: border-color var(--transition), width var(--transition);
}
.search-input:focus { border-color: var(--primary); width: 320px; box-shadow: 0 0 0 3px var(--primary-glow); }
.search-wrapper { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; }

/* ================================================================
   TOAST
   ================================================================ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 13px 17px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; min-width: 280px;
  box-shadow: var(--shadow-lg); animation: slideUp .3s ease;
  color: var(--text);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }

/* ================================================================
   LOADING
   ================================================================ */
.loading-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 200; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }
.spinner { width: 38px; height: 38px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-icon  { font-size: 44px; margin-bottom: 16px; opacity: .55; display: flex; justify-content: center; }
.empty-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-text  { font-size: 13.5px; max-width: 320px; margin: 0 auto; line-height: 1.5; }

/* Пустая колонка канбан */
.kanban-col-empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 8px; opacity: .7;
  border: 2px dashed var(--border-2); border-radius: var(--radius-md);
  margin: 8px 4px;
  transition: opacity .2s, border-color .2s;
}
.kanban-col-empty:hover { opacity: 1; border-color: var(--primary); }

/* ================================================================
   PIPELINE TABS
   ================================================================ */
.pipeline-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-3); border-radius: var(--radius-md); border: 1px solid var(--border); flex-wrap: wrap;
}
.pipeline-tab {
  padding: 7px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); border: none; background: transparent; color: var(--text-2);
}
.pipeline-tab.active { background: linear-gradient(135deg, var(--primary), #8b5cf6); color: white; box-shadow: 0 2px 8px var(--primary-glow); }
.pipeline-tab:hover:not(.active) { background: var(--bg-5); color: var(--text); }

/* ================================================================
   BADGES
   ================================================================ */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-xl); }
.badge-purple { background: rgba(139,92,246,.18); color: #c4b5fd; }
.badge-green  { background: rgba(16,185,129,.18);  color: #6ee7b7; }
.badge-red    { background: rgba(239,68,68,.18);   color: #fca5a5; }
.badge-yellow { background: rgba(245,158,11,.18);  color: #fcd34d; }
.badge-gray   { background: var(--bg-5);            color: var(--text-2); border: 1px solid var(--border); }

body.theme-light .badge-purple, body.theme-soft .badge-purple { background: #ede9fe; color: #5b21b6; }
body.theme-light .badge-green,  body.theme-soft .badge-green  { background: #d1fae5; color: #065f46; }
body.theme-light .badge-red,    body.theme-soft .badge-red    { background: #fee2e2; color: #b91c1c; }
body.theme-light .badge-yellow, body.theme-soft .badge-yellow { background: #fef3c7; color: #92400e; }
body.theme-light .badge-gray,   body.theme-soft .badge-gray   { background: var(--bg-3); color: var(--text-2); border-color: var(--border); }

/* ================================================================
   ACTIVITY FEED
   ================================================================ */
.activity-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); }
.activity-icon {
  width: 28px; height: 28px; border-radius: 50%; background: var(--primary-glow);
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.activity-content { flex: 1; }
.activity-text  { margin-bottom: 2px; color: var(--text); }
.activity-time  { font-size: 11px; color: var(--text-3); }

/* ================================================================
   DEAL DETAIL
   ================================================================ */
.deal-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; }
@media (max-width: 900px) { .deal-detail-grid { grid-template-columns: 1fr; } }

.deal-detail-grid .card           { padding: 14px 16px; border-radius: var(--radius-md); }
.deal-detail-grid .form-group     { margin-bottom: 6px; }
.deal-detail-grid .form-label     { font-size: 11px; font-weight: 600; color: var(--text-3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
.deal-detail-grid .form-input,
.deal-detail-grid .form-select    { padding: 5px 10px; font-size: 13px; border-radius: var(--radius-sm); height: 32px; }
.deal-detail-grid textarea.form-input { height: auto; min-height: 56px; padding: 6px 10px; }
.deal-detail-grid .grid-2         { gap: 8px; margin-bottom: 6px; }
.deal-detail-grid .card > h4      { font-size: 13px; margin-bottom: 10px; }
.deal-detail-grid .form-group button.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.deal-detail-grid #edit-tags      { height: 32px; }
.deal-detail-grid #comm-messages  { max-height: 220px; }
.deal-detail-grid #comm-messages + div .form-select,
.deal-detail-grid #comm-messages + div .form-input { height: 32px; padding: 5px 10px; font-size: 12px; }

/* ================================================================
   INLINE FIELD EDITING (deal modal)
   ================================================================ */
.dfield-row:hover .dfield-val { background: var(--primary-glow); border-radius: var(--radius-xs); }
.dfield-val { transition: background .12s; line-height: 1.4; }
.dfield-row:hover { background: var(--bg-5); }
.dsection > div:first-child:hover { opacity: .8; }
.dfi { width: 100% !important; flex: 1 !important; min-width: 0 !important; }
.dfi-save-btn   { flex-shrink: 0 !important; transition: background .12s; }
.dfi-save-btn:hover   { background: var(--primary-dark) !important; }
.dfi-cancel-btn { flex-shrink: 0 !important; }
.dfi-cancel-btn:hover { background: var(--bg-3) !important; color: var(--text) !important; }
.dfield-row .dfield-val::after { content: ' ✎'; opacity: 0; font-size: 9px; color: var(--primary); transition: opacity .12s; }
.dfield-row:hover .dfield-val::after { opacity: .6; }

/* ================================================================
   DEAL MODAL — clean redesign (theme-aware, no hardcoded colors)
   ================================================================ */

/* Header --------------------------------------------------------- */
.dm-header {
  padding: 14px 18px !important;
  gap: 12px !important;
  align-items: flex-start !important;
  border-bottom: 1px solid var(--border);
}
.dm-title {
  font-size: 17px; font-weight: 700; line-height: 1.3;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px; border-radius: var(--radius-sm);
  width: 100%; color: var(--text);
  transition: border-color .12s, background .12s;
}
.dm-title:hover  { background: var(--bg-5); }
.dm-title:focus  { border-color: var(--primary); background: var(--bg-4); outline: none; }

/* Unified header dropdowns — all look identical */
.dm-meta-row { display: flex; align-items: center; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.dm-select {
  font-size: 12px; height: 28px; padding: 0 24px 0 9px; width: auto;
  background: var(--bg-4); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .12s;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238b8fa8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.dm-select:hover  { border-color: var(--border-2); }
.dm-select:focus  { border-color: var(--primary); outline: none; }

/* Header action buttons — quiet icon group + one primary + danger */
.dm-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.dm-btn-primary {
  font-size: 12px; font-weight: 600; padding: 6px 13px;
  background: var(--primary); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s;
}
.dm-btn-primary:hover { background: var(--primary-dark); }
.dm-icon-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-2);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; transition: all .12s;
}
.dm-icon-btn:hover        { background: var(--bg-5); color: var(--text); border-color: var(--border); }
.dm-icon-btn.danger:hover { background: rgba(239,68,68,.12); color: var(--danger); border-color: transparent; }

/* Body grid ------------------------------------------------------ */
/* Layout: 2 equal columns (left = details + fields | right = communications) + full-width history/tasks strip */
.deal-modal-body {
  gap: 0;
  display: grid;
  grid-template-columns: var(--dm-col-left-fr, 1fr) var(--dm-col-right-fr, 1fr);
  grid-template-rows: minmax(120px, 1fr) var(--dm-bottom-h, 170px);
  height: calc(90vh - 82px);
  overflow: hidden;
  position: relative;
}
/* Вертикальный разделитель колонок — тянуть влево/вправо */
.dm-col-resize {
  position: absolute; top: 0; bottom: var(--dm-bottom-h, 170px);
  width: 9px; margin-left: -4px; cursor: col-resize; z-index: 7;
  display: flex; align-items: center; justify-content: center;
}
.dm-col-resize::after { content: ''; width: 4px; height: 46px; border-radius: 4px; background: var(--border); transition: background .12s; }
.dm-col-resize:hover::after { background: var(--primary); }
.deal-modal-body.dm-bottom-empty .dm-col-resize { bottom: var(--dm-bottom-empty-h, 46px); }
/* When the bottom strip is empty (all its blocks dragged out) it collapses to a slim drop hint */
.deal-modal-body.dm-bottom-empty { grid-template-rows: 1fr var(--dm-bottom-empty-h, 46px); }
/* Left column holds details, then fields — stacked vertically */
.dm-col-left    { overflow-y: auto; padding: 14px 18px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
/* Right column = chat, spans full height of the left column, equal width.
   overflow:hidden (not auto) so the inner message list scrolls, and the .dsection
   truly fills the column height — keeping the composer pinned to the bottom. */
.dm-col-right   { overflow: hidden; padding: 14px 16px; background: var(--bg); display: flex; flex-direction: column; gap: 14px; }
/* Only the CHAT (comms) section fills the right column so the composer sits at the bottom.
   Other sections dragged into the right column stay auto-height cards (no overlap). */
.dm-col-right > .dsection { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; }
.dm-col-right > #dsec-comms { flex: 1 1 auto; }
/* The comms section body carries an inline style="display:block" from the builder,
   so we use !important to turn it into a flex column that fills the height.
   :not([style*="none"]) keeps the collapse (display:none) behaviour working. */
.dm-col-right > #dsec-comms > [id^="dsec-body-"]:not([style*="none"]) { flex: 1 1 auto; display: flex !important; flex-direction: column; min-height: 0; overflow: hidden; }
/* Full-width strip along the bottom (History / Tasks tabbed) — FIXED height so it doesn't jump between tabs */
.dm-bottom {
  grid-column: 1/-1; border-top: 1px solid var(--border);
  height: 100%; padding: 12px 18px;
  background: var(--bg-2);
  overflow: hidden;
  position: relative;
  display: flex; flex-direction: column; gap: 12px;
}
/* Resize grip pinned to the top edge of the bottom strip — drag to grow/shrink */
.dm-bottom-resize {
  position: absolute; top: -7px; left: 0; right: 0; height: 15px;
  cursor: ns-resize; z-index: 20; display: flex; align-items: center; justify-content: center;
}
.dm-bottom-resize::after { content: ''; width: 60px; height: 5px; border-radius: 4px; background: var(--border); transition: background .12s; }
.dm-bottom-resize:hover::after { background: var(--primary); }
.dm-bottom-resize.dl-resizing::after { background: var(--primary); }
/* Drop hint shown when a block is being dragged over the bottom strip / when it's empty */
.dm-bottom.dl-dropzone { outline: 2px dashed var(--primary); outline-offset: -6px; background: var(--primary-glow); }
.dm-bottom-empty-hint {
  display: none; align-items: center; justify-content: center; gap: 8px;
  color: var(--text-3); font-size: 12px; font-weight: 600; height: 100%;
  border: 1.5px dashed var(--border); border-radius: 10px;
}
.deal-modal-body.dm-bottom-empty .dm-bottom-empty-hint { display: flex; }
/* legacy bottom-col helpers kept as harmless no-ops for any stray markup */
.dm-bottom-col { min-width: 0; flex: 1 1 auto; min-height: 0; }
/* Tabbed section fills the strip; tabs stay pinned, only the active pane scrolls */
.dm-bottom-tabbed { height: 100%; display: flex; flex-direction: column; min-height: 0; }

/* Bottom tabbed panel: History <-> Tasks toggle acting like a filter */
.dm-bottom-tabs { gap: 6px; padding-bottom: 2px; flex: 0 0 auto; }
.dm-bottom-tab {
  background: transparent; border: 1px solid transparent; cursor: pointer;
  color: var(--text-3); font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 7px; transition: all .12s;
  display: inline-flex; align-items: center; gap: 6px;
}
.dm-bottom-tab:hover { color: var(--text); background: var(--bg-3); }
.dm-bottom-tab.active {
  color: var(--text); background: var(--bg-3);
  border-color: var(--border);
}
.dm-bottom-tab i { font-size: 12px; }
/* Active pane fills remaining height and scrolls internally; hidden pane doesn't affect height */
.dm-bottom-pane { padding-top: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.dm-bottom-pane[style*="none"] { flex: 0; }

/* Section header — quiet, uniform (no rainbow colors) */
.dm-sec-head {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0 8px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.dm-sec-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-2); cursor: pointer; user-select: none;
  flex: 1; display: flex; align-items: center; gap: 7px;
}
.dm-sec-title i { color: var(--primary); font-size: 11px; width: 13px; text-align: center; }
.dm-sec-caret  { color: var(--text-3); font-size: 10px; cursor: pointer; user-select: none; }
.dm-sec-tool   { background: transparent; border: none; color: var(--text-3); font-size: 11px; cursor: pointer; padding: 3px 5px; border-radius: var(--radius-xs); transition: color .12s, background .12s; }
.dm-sec-tool:hover { color: var(--primary); background: var(--bg-5); }

/* Field rows — no duplicate icons, aligned values, breathing room */
.dm-field {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  min-height: 32px;
}
.dm-field:last-child { border-bottom: none; }
.dm-field-label {
  width: 116px; flex-shrink: 0; font-size: 11.5px; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-field-val {
  flex: 1; font-size: 12.5px; color: var(--text);
  padding: 4px 7px; border-radius: var(--radius-xs); cursor: pointer;
  min-height: 24px; word-break: break-word; transition: background .12s;
  display: flex; align-items: center; gap: 4px;
}
.dm-field-val:hover { background: var(--primary-glow); }
.dm-field-val .dm-add { color: var(--text-3); font-size: 10.5px; }
.dm-field-act {
  flex-shrink: 0; width: 26px; height: 24px; border: none; border-radius: var(--radius-xs);
  color: #fff; font-size: 11px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .12s;
}
.dm-field-act:hover { opacity: .82; }

/* Communications ------------------------------------------------- */
/* Message list grows to fill all free space so the composer is pinned to the bottom */
.dm-msg-list { flex: 1 1 auto; min-height: 120px; max-height: none; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
/* Keep the scroll anchor / channel row / composer at their natural size at the bottom */
#comm-msg-scroll-anchor { flex: 0 0 auto; }
.dm-msg-row  { display: flex; flex-direction: column; }
.dm-msg-row.out { align-items: flex-end; }
.dm-msg-row.in  { align-items: flex-start; }
.dm-bubble {
  max-width: 86%; border-radius: var(--radius-md); padding: 7px 11px; font-size: 12px; line-height: 1.4;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
}
.dm-msg-row.out .dm-bubble { background: var(--primary-glow); border-color: transparent; }
.dm-bubble-meta { font-size: 9.5px; color: var(--text-2); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.dm-empty { text-align: center; color: var(--text-3); font-size: 11.5px; padding: 16px; }

/* Channel quick-action buttons row */
.dm-chan-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; flex: 0 0 auto; align-items: center; }
.dm-chan-btn {
  font-size: 11.5px; padding: 5px 11px; border: none; border-radius: var(--radius-sm);
  color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-weight: 500;
  transition: opacity .12s;
}
.dm-chan-btn:hover { opacity: .85; }
.dm-chan-btn.ghost { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.dm-chan-btn.ghost:hover { background: var(--bg-5); color: var(--text); opacity: 1; }

/* Круглые иконки-кнопки мессенджеров в карточке сделки */
.dm-chan-circle {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; position: relative; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}
.dm-chan-circle:hover { transform: translateY(-2px) scale(1.06); box-shadow: 0 5px 14px rgba(0,0,0,0.28); filter: brightness(1.08); }
.dm-chan-circle:active { transform: translateY(0) scale(0.97); }
.dm-chan-circle.active-sel { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 3px rgba(99,102,241,0.4); }
.dm-chan-circle.ghost { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); box-shadow: none; }
.dm-chan-circle.ghost:hover { background: var(--bg-5); color: var(--text); }
/* всплывающая подсказка канала */
.dm-chan-circle .dm-chan-tip {
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; font-size: 11px; font-weight: 500; padding: 3px 8px;
  border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s;
  z-index: 20;
}
.dm-chan-circle:hover .dm-chan-tip { opacity: 1; }

/* Message composer — pinned to the bottom of the communications column.
   flex-wrap lets the channel select take a full row on narrow columns so its
   label (e.g. "WABA 995593299175") is never truncated mid-character. */
.dm-composer { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; flex-wrap: wrap; }
.dm-composer .dm-select {
  height: 32px; min-width: 150px; max-width: 100%;
  flex: 1 1 150px;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.dm-composer .form-input { flex: 2 1 160px; min-width: 120px; font-size: 12px; height: 32px; padding: 0 10px; }
.dm-send-btn, .dm-tpl-btn {
  height: 32px; padding: 0 11px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; transition: background .12s;
}
.dm-send-btn { background: var(--primary); color: #fff; }
.dm-send-btn:hover { background: var(--primary-dark); }
.dm-tpl-btn { background: var(--bg-3); color: var(--text-2); border: 1px solid var(--border); }
.dm-tpl-btn:hover { background: var(--bg-5); color: var(--text); }

/* Details key-value list */
.dm-detail { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.dm-detail:last-child { border-bottom: none; }
.dm-detail-k { color: var(--text-2); font-size: 11px; flex-shrink: 0; }
.dm-detail-v { font-size: 11.5px; text-align: right; color: var(--text); }

/* History filter tabs — quiet segmented control */
.dm-hist-filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.dm-hist-tab {
  font-size: 10.5px; padding: 3px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  cursor: pointer; white-space: nowrap; transition: all .12s;
}
.dm-hist-tab:hover  { border-color: var(--border-2); color: var(--text); }
.dm-hist-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dm-hist-list { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; }
.dm-hist-item { font-size: 11.5px; color: var(--text-2); padding: 6px 4px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-start; }
.dm-hist-item:last-child { border-bottom: none; }
.dm-hist-item .dm-hist-ico { flex-shrink: 0; font-size: 12px; }
.dm-hist-item .dm-hist-body { flex: 1; min-width: 0; }
.dm-hist-item .dm-hist-txt  { color: var(--text); word-break: break-word; line-height: 1.4; }
.dm-hist-item .dm-hist-time { color: var(--text-3); font-size: 10px; margin-top: 2px; }
.dm-note-row { margin-top: 10px; display: flex; gap: 6px; }

/* Automation buttons */
.dm-auto-wrap { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.dm-auto-btn { border: none; color: #fff; padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; font-weight: 500; transition: opacity .15s; }
.dm-auto-btn:hover { opacity: .82; }

/* ================================================================
   TYPING INDICATOR
   ================================================================ */
.typing-dots { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.typing-dot  { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: typingBounce 1.2s ease infinite; }
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%,80%,100% { transform:translateY(0) } 40% { transform:translateY(-6px) } }

/* ================================================================
   GLOBAL SEARCH MODAL
   ================================================================ */
#global-search-modal .modal { border-color: var(--border-2); box-shadow: var(--shadow-xl); }
#global-search-input:focus   { outline: none; box-shadow: none; }

/* ================================================================
   THEME PICKER UI
   ================================================================ */
.theme-picker-btn {
  position: fixed; bottom: 20px; right: 20px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; box-shadow: var(--shadow-md); z-index: 100;
  transition: transform .2s, box-shadow .2s;
}
.theme-picker-btn:hover { transform: scale(1.1); box-shadow: var(--shadow-lg); }

.theme-picker-panel {
  position: fixed; bottom: 72px; right: 14px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 10px;
  z-index: 200; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 4px; min-width: 160px;
}

.theme-option {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-md);
  cursor: pointer; font-size: 13px; color: var(--text);
  border: 1px solid transparent; transition: background var(--transition), border-color var(--transition);
}
.theme-option:hover  { background: var(--bg-3); }
.theme-option.active { border-color: var(--primary); background: var(--primary-glow); }

.theme-dot { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; border: 2px solid rgba(255,255,255,.12); }
body.theme-light .theme-dot,
body.theme-soft  .theme-dot,
body.theme-pink  .theme-dot,
body.theme-mint  .theme-dot { border-color: rgba(0,0,0,.1); }

/* ================================================================
   FLOW BUILDER
   ================================================================ */
#fb-root { height: calc(100vh - 120px); }
#fb-canvas-wrap { background: var(--bg-3); touch-action: none; }
/* Mobile-only Flow Builder buttons: hidden on desktop, shown in mobile media query */
.fb-mobile-only  { display: none !important; }
.fb-palette-only { display: none !important; }
/* Desktop-only Flow Builder buttons: shown on desktop, hidden on mobile */
.fb-desktop-only { display: inline-flex !important; align-items: center; }
/* fb-mobile-show / fb-desktop-show for hint text */
.fb-mobile-show  { display: none; }
.fb-desktop-show { display: inline; }
#fb-canvas-wrap:active { cursor: grabbing; }
#fb-canvas-wrap::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--border-2) 1px, transparent 1px);
  background-size: 28px 28px; pointer-events: none; opacity: .35;
}
.fb-node:hover { border-color: var(--primary) !important; }
.fb-node-selected { border-color: #6366f1 !important; box-shadow: 0 0 0 3px rgba(99,102,241,0.3) !important; }
.fb-port-out:hover, .fb-port-yes:hover, .fb-port-no:hover { transform: translateY(-50%) scale(1.4) !important; border-color: var(--primary) !important; }
.fb-palette-item:active { opacity: .7; transform: scale(.97); }
#fb-name:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }
#fb-props::-webkit-scrollbar { width: 4px; }
#fb-props::-webkit-scrollbar-track { background: transparent; }
#fb-props::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ================================================================
   OVERDUE DEAL CARDS
   ================================================================ */
.deal-card.overdue { border-color: rgba(239,68,68,.4); }
.deal-card.overdue::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger); margin: 8px;
  box-shadow: 0 0 6px var(--danger);
}

/* ================================================================
   VIEW SETTINGS TABLE
   ================================================================ */
#view-settings-modal tbody tr:nth-child(even) { background: var(--bg-5); }
#view-settings-modal tbody tr:hover { background: var(--primary-glow); }

/* ================================================================
   INLINE STYLE OVERRIDES — light, soft, pink & mint themes
   Перекрывают жёстко зашитые тёмные цвета в app.js
   ================================================================ */

/* --- Тёмные фоны в модалках / чатах --- */
body.theme-light .modal [style*="background:#111827"],
body.theme-light .modal [style*="background: #111827"],
body.theme-light .modal [style*="background:#1f2937"],
body.theme-light .modal [style*="background: #1f2937"],
body.theme-light .modal [style*="background:#0f1623"],
body.theme-light .modal [style*="background:#06090f"],
body.theme-light .modal [style*="background:#0d1117"],
body.theme-light .modal [style*="background:#171821"],
body.theme-light [style*="background:#111827"],
body.theme-light [style*="background:#1f2937"],
body.theme-light [style*="background:#0d1117"],
body.theme-light [style*="background:#171821"],
body.theme-soft  .modal [style*="background:#111827"],
body.theme-soft  .modal [style*="background: #111827"],
body.theme-soft  .modal [style*="background:#1f2937"],
body.theme-soft  .modal [style*="background: #1f2937"],
body.theme-soft  .modal [style*="background:#0f1623"],
body.theme-soft  .modal [style*="background:#06090f"],
body.theme-soft  .modal [style*="background:#0d1117"],
body.theme-soft  .modal [style*="background:#171821"],
body.theme-soft  [style*="background:#111827"],
body.theme-soft  [style*="background:#1f2937"],
body.theme-soft  [style*="background:#0d1117"],
body.theme-soft  [style*="background:#171821"],
body.theme-pink  .modal [style*="background:#111827"],
body.theme-pink  .modal [style*="background: #111827"],
body.theme-pink  .modal [style*="background:#1f2937"],
body.theme-pink  .modal [style*="background: #1f2937"],
body.theme-pink  .modal [style*="background:#0f1623"],
body.theme-pink  .modal [style*="background:#06090f"],
body.theme-pink  .modal [style*="background:#0d1117"],
body.theme-pink  .modal [style*="background:#171821"],
body.theme-pink  [style*="background:#111827"],
body.theme-pink  [style*="background:#1f2937"],
body.theme-pink  [style*="background:#0d1117"],
body.theme-pink  [style*="background:#171821"],
body.theme-mint  .modal [style*="background:#111827"],
body.theme-mint  .modal [style*="background: #111827"],
body.theme-mint  .modal [style*="background:#1f2937"],
body.theme-mint  .modal [style*="background: #1f2937"],
body.theme-mint  .modal [style*="background:#0f1623"],
body.theme-mint  .modal [style*="background:#06090f"],
body.theme-mint  .modal [style*="background:#0d1117"],
body.theme-mint  .modal [style*="background:#171821"],
body.theme-mint  [style*="background:#111827"],
body.theme-mint  [style*="background:#1f2937"],
body.theme-mint  [style*="background:#0d1117"],
body.theme-mint  [style*="background:#171821"] {
  background: var(--bg-3) !important;
  color: var(--text) !important;
}

/* Чат-пузыри */
body.theme-light [style*="background:#312e81"],
body.theme-soft  [style*="background:#312e81"],
body.theme-pink  [style*="background:#312e81"],
body.theme-mint  [style*="background:#312e81"] { background: var(--primary-glow) !important; color: var(--text) !important; }
body.theme-light [style*="background:#1c3a2e"],
body.theme-soft  [style*="background:#1c3a2e"],
body.theme-pink  [style*="background:#1c3a2e"],
body.theme-mint  [style*="background:#1c3a2e"] { background: #d1fae5 !important; color: #065f46 !important; }
body.theme-light [style*="background:#1a2535"],
body.theme-soft  [style*="background:#1a2535"],
body.theme-pink  [style*="background:#1a2535"],
body.theme-mint  [style*="background:#1a2535"] { background: var(--bg-3) !important; color: var(--text) !important; }

/* --- Серые тексты --- */
body.theme-light [style*="color:#9ca3af"],
body.theme-light [style*="color:#6b7280"]:not(.fg-arrow),
body.theme-light [style*="color:#4b5563"],
body.theme-soft  [style*="color:#9ca3af"],
body.theme-soft  [style*="color:#6b7280"]:not(.fg-arrow),
body.theme-soft  [style*="color:#4b5563"],
body.theme-pink  [style*="color:#9ca3af"],
body.theme-pink  [style*="color:#6b7280"]:not(.fg-arrow),
body.theme-pink  [style*="color:#4b5563"],
body.theme-mint  [style*="color:#9ca3af"],
body.theme-mint  [style*="color:#6b7280"]:not(.fg-arrow),
body.theme-mint  [style*="color:#4b5563"] { color: var(--text-2) !important; }

body.theme-light [style*="color:var(--text-muted)"],
body.theme-soft  [style*="color:var(--text-muted)"],
body.theme-pink  [style*="color:var(--text-muted)"],
body.theme-mint  [style*="color:var(--text-muted)"] { color: var(--text-2) !important; }
body.theme-light [style*="color:var(--text-dim)"],
body.theme-soft  [style*="color:var(--text-dim)"],
body.theme-pink  [style*="color:var(--text-dim)"],
body.theme-mint  [style*="color:var(--text-dim)"]   { color: var(--text-3) !important; }

/* Email textarea */
body.theme-light #sem-body,
body.theme-soft  #sem-body,
body.theme-pink  #sem-body,
body.theme-mint  #sem-body { background: var(--bg-4) !important; color: var(--text) !important; }

/* Email textarea dark default */
#sem-body { color: var(--text); background: var(--bg-2); }

/* --- Форс базового цвета на всех контейнерах --- */
body,
.page-content,
.main-content,
.card,
.modal,
.sidebar,
.topbar,
.kanban-column,
.deal-card,
.stat-card,
.automation-card,
.stage-item,
.flow-block,
.toast,
.message-bubble,
.ai-container,
.activity-item {
  color: var(--text);
}

/* Muted utility */
.text-muted, .muted, small, .caption { color: var(--text-2); }
.text-dim { color: var(--text-3); }

/* ================================================================
   UTILS
   ================================================================ */
/* ── utility (замена Tailwind CDN — только используемые классы) ── */
.flex            { display: flex; }
.inline-flex     { display: inline-flex; }
.block           { display: block; }
.inline-block    { display: inline-block; }
.hidden          { display: none; }
.grid            { display: grid; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.items-end       { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.flex-wrap       { flex-wrap: wrap; }
.flex-col        { flex-direction: column; }
.flex-1          { flex: 1 1 0%; }
.flex-shrink-0   { flex-shrink: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; } .gap-10 { gap: 40px; }
.w-full          { width: 100%; }
.w-auto          { width: auto; }
.h-full          { height: 100%; }
.h-screen        { height: 100vh; }
.min-w-0         { min-width: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.truncate        { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap; }
.relative        { position: relative; }
.absolute        { position: absolute; }
.fixed           { position: fixed; }
.sticky          { position: sticky; }
.inset-0         { top: 0; right: 0; bottom: 0; left: 0; }
.z-10            { z-index: 10; }
.z-50            { z-index: 50; }
.cursor-pointer  { cursor: pointer; }
.cursor-default  { cursor: default; }
.select-none     { user-select: none; }
.pointer-events-none { pointer-events: none; }
.opacity-0       { opacity: 0; }
.opacity-50      { opacity: 0.5; }
.opacity-100     { opacity: 1; }
.font-medium     { font-weight: 500; }
.font-semibold   { font-weight: 600; }
.font-bold       { font-weight: 700; }
.uppercase       { text-transform: uppercase; }
.capitalize      { text-transform: capitalize; }
.underline       { text-decoration: underline; }
.text-left       { text-align: left; }
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.space-x-2 > * + * { margin-left: 8px; }
.space-y-2 > * + * { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mb-4  { margin-bottom: 16px; }
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 11px; }
.font-bold { font-weight: 700; }
.truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3    { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ================================================================
   MOBILE UTILITIES — touch-friendly global improvements
   ================================================================ */
/* Bigger tap targets for buttons and inputs on touch devices */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 40px; }
  .form-input, .form-select, .form-textarea { min-height: 44px; font-size: 16px; }
  .sidebar-item { min-height: 44px; }
  .dropdown-item { min-height: 40px; }
  select { font-size: 16px; }
}

/* ================================================================
   SIDEBAR OVERLAY (mobile)
   ================================================================ */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 49; backdrop-filter: blur(2px); }
.sidebar-overlay.visible { display: block; }

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */
@media (max-width: 768px) {
  body { overflow: hidden; } /* main-content handles scroll */
  .sidebar { transform: translateX(-100%); z-index: 50; width: 260px; min-width: 260px; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 28px rgba(0,0,0,.55); }
  .main-content { margin-left: 0; overflow-y: auto; height: 100dvh; }
  .page-content { overflow-y: visible; min-height: 0; }

  /* ═══════════════════════════════════════════════════════════════
     МАСШТАБ ПОД МОБИЛКУ — фикс "уезжающей" ширины + читаемость.
     Причина жалобы "маштаб не адаптирован": inline-стили с
     фиксированной шириной (width:NNNpx, min-width) в контенте тянут
     страницу шире экрана, браузер уменьшает всю вёрстку.
     ═══════════════════════════════════════════════════════════════ */
  /* Любой прямой потомок контента не шире экрана */
  .page-content > *,
  .page-content > * > * { max-width: 100% !important; }
  /* Сбрасываем жёсткие inline min-width, кроме скроллируемых зон */
  .page-content [style*="min-width"]:not(.kanban-column):not(.pipeline-tab) {
    min-width: 0 !important;
  }
  /* Карточки/панели контента — во всю ширину, без inline-фикса */
  .page-content .card,
  .page-content .panel { width: auto !important; max-width: 100% !important; }
  /* Композер сообщений и поля не переполняют */
  .dm-composer, .dm-composer .form-input,
  .form-group, .form-row { min-width: 0 !important; max-width: 100% !important; }
  /* Разрешаем горизонтальный скролл ТОЛЬКО там, где он задуман */
  .kanban-board, .table-container, #fb-canvas-wrap,
  .pipeline-tabs, .projects-scroll { max-width: 100% !important; }
  .topbar { padding: 0 12px; height: 54px; gap: 8px; }
  .topbar-title { font-size: 15px; }
  #mob-menu-btn { display: flex !important; }
  .page-content { padding: 12px; }

  /* Читаемость на телефоне: крупнее базовый текст, кнопки, элементы списков */
  .card, .panel { font-size: 14px; }
  .btn { min-height: 42px; font-size: 14px; }
  .btn-sm { min-height: 38px; font-size: 13px; padding: 6px 12px; }
  .nav-item { min-height: 46px; font-size: 15px; }
  .deal-card { padding: 12px; }
  .deal-card-title { font-size: 14px; }
  .stat-label { font-size: 12px; }
  label, .form-label { font-size: 13px; }

  .stats-grid { grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 16px; }
  .stat-value { font-size: 21px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 10px; }
  .login-card { width: 100%; max-width: 360px; padding: 28px 20px; }

  /* ═══════════════════════════════════════════════════════════════
     КАНБАН (воронки/сделки) НА МОБИЛКЕ — компактный масштаб.
     Колонки уже, виден край следующей (подсказка что можно свайпать),
     карточки/шрифты меньше, чтобы всё влезало.
     ═══════════════════════════════════════════════════════════════ */
  .kanban-board { gap: 8px; padding: 0 2px 12px 2px; min-height: 0; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .kanban-column {
    min-width: 46vw !important; max-width: 46vw !important;
    width: 46vw !important; flex-shrink: 0 !important;
    scroll-snap-align: start;
    max-height: calc(100dvh - 190px) !important;
  }
  .kanban-column-header { padding: 9px 11px !important; gap: 6px; }
  .column-name { font-size: 12px; }
  .column-count { font-size: 10px; padding: 1px 6px; }
  .kanban-cards { padding: 7px !important; gap: 6px !important; }
  /* Карточка сделки в канбане — компактнее (общий deal-card ниже переопределяем) */
  .kanban-column .deal-card { padding: 8px 9px !important; }
  .kanban-column .deal-card-title { font-size: 11.5px !important; line-height: 1.25; }
  .kanban-column .deal-card * { font-size: 10px; }
  .kanban-column .deal-card .deal-card-title { font-size: 11.5px !important; }
  /* Кнопка "+ сделка" внутри колонки не должна быть 42px-гигантом */
  .kanban-column .btn { min-height: 32px !important; font-size: 11px !important; padding: 4px 7px !important; }
  /* Кнопка «переместить» на карточке — видимый tap-target для мобилки */
  .deal-card-move-btn {
    position: absolute; top: 6px; right: 6px;
    width: 30px; height: 30px; display: none;
    align-items: center; justify-content: center;
    background: var(--bg-4); border: 1px solid var(--border);
    border-radius: 7px; color: var(--text-2); font-size: 13px;
    z-index: 3; cursor: pointer;
  }

  .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 560px; }
  th, td { padding: 9px 10px; font-size: 13px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0; max-height: 92vh; animation: slideUpMobile .25s ease; }
  .modal-sm, .modal-lg, .modal-xl { max-width: 100%; }
  .modal-header { padding: 16px 20px; }
  .modal-body   { padding: 16px 20px; overflow-y: auto; }
  .modal-footer { padding: 12px 20px; }
  @keyframes slideUpMobile { from { transform:translateY(100%); opacity:0 } to { transform:translateY(0); opacity:1 } }

  /* Карточка сделки — стек вместо двух колонок */
  .deal-detail-grid { grid-template-columns: 1fr; gap: 10px; }
  /* Поля сделки — полная ширина, удобный tap-target */
  .deal-detail-grid .form-input,
  .deal-detail-grid .form-select,
  .deal-detail-grid .form-textarea { font-size: 16px; padding: 10px 13px; } /* 16px предотвращает zoom на iOS */
  .deal-field-row { flex-direction: column; gap: 4px; }
  .deal-field-label { min-width: unset; font-size: 11px; }

  .ai-container { flex-direction: column; height: auto; border-radius: var(--radius-lg); }
  .ai-sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  .ai-messages { max-height: 45vh; }
  .search-input { width: 100%; }
  .search-input:focus { width: 100%; }
  .toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { min-width: unset; width: 100%; }
  .theme-picker-btn { bottom: 16px; right: 16px; }
  .theme-picker-panel { bottom: 66px; right: 10px; }
  #topbar-search-btn { display: none !important; }
  .pipeline-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pipeline-tab { flex-shrink: 0; }
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; min-width: 100px; }
  .sidebar-user { padding: 12px; }

  /* Flow Builder на мобиле */
  #fb-palette { display: none !important; }
  #fb-props   { width: 100% !important; min-width: unset !important; border-left: none !important; border-top: 1px solid var(--border) !important; max-height: 40vh !important; overflow-y: auto !important; display: none !important; }
  #fb-root    { height: calc(100vh - 54px); flex-direction: column !important; }
  #fb-canvas-wrap { min-height: 0; flex: 1; touch-action: none; }
  .fb-mobile-hint { display: flex !important; }
  /* Show palette/props toggle buttons on mobile (uses new CSS-only classes) */
  .fb-mobile-only  { display: flex !important; align-items: center; }
  .fb-palette-only { display: flex !important; align-items: center; }
  /* Hide desktop-only buttons (zoom/fit/stats) on mobile to save toolbar space */
  .fb-desktop-only { display: none !important; }
  /* Show mobile hint text, hide desktop hint text */
  .fb-mobile-show  { display: inline !important; }
  .fb-desktop-show { display: none !important; }
  /* Mobile connect hint bar */
  #fb-connect-hint {
    display: none;
    position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
    background: #6366f1; color: #fff; padding: 8px 18px; border-radius: 20px;
    font-size: 12px; z-index: 600; white-space: nowrap; pointer-events: none;
    box-shadow: 0 2px 12px rgba(99,102,241,0.4);
  }
  #fb-connect-hint.active { display: block; }
  /* Keep old class selectors for backward compat */
  .fb-palette-toggle { display: flex !important; }
  .fb-props-toggle   { display: flex !important; }
  /* Toolbar wraps on mobile */
  #fb-toolbar { gap: 4px !important; padding: 5px 8px !important; flex-wrap: wrap; }
  #fb-name { font-size: 12px !important; min-width: 80px !important; max-width: 120px !important; }
  /* fb-node tap target larger */
  .fb-node { min-height: 72px !important; touch-action: none; -webkit-user-select: none; user-select: none; }
  /* Node being dragged — hardware acceleration */
  .fb-node[style*="will-change"] { transform: translateZ(0); }
  .fb-del-btn { width: 28px !important; height: 28px !important; font-size: 14px !important; }
  /* Ports — bigger touch area */
  .fb-port { width: 22px !important; height: 22px !important; }
  .fb-port-out { right: -11px !important; }
  .fb-port-yes { right: -11px !important; }
  .fb-port-no  { right: -11px !important; }

  /* Deal modal — stack columns on mobile */
  .deal-modal-body { grid-template-columns: 1fr !important; height: auto !important; overflow: visible !important; max-height: none !important; }
  .deal-modal-body > div:first-child { border-right: none !important; border-bottom: 1px solid var(--bg-3) !important; max-height: 50vh; overflow-y: auto; }
  .deal-modal-body > div:last-child { max-height: none; }
  /* ── Чат в карточке сделки: чтобы МОЖНО было писать на мобилке ──
     Правая колонка (чат) получает реальную высоту, список сообщений
     скроллится внутри, а поле ввода остаётся видимым и доступным. */
  .dm-col-right {
    overflow: visible !important;
    min-height: 60vh !important;
    padding: 12px 12px !important;
  }
  .dm-col-right > #dsec-comms { min-height: 55vh !important; }
  /* Тело чата: фиксированная область под сообщения со скроллом */
  .dm-col-right > #dsec-comms > [id^="dsec-body-"]:not([style*="none"]) {
    overflow: visible !important; min-height: 0 !important;
  }
  /* Лента сообщений скроллится, не выталкивая поле ввода за экран */
  #full-chat, [id^="fc-messages"], .full-chat-messages {
    max-height: 42vh !important; overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  /* Композер: селектор канала сверху, поле ввода на всю ширину, крупный шрифт */
  #fc-channel-select { width: 100% !important; margin-bottom: 6px; }
  #fc-msg-input {
    width: 100% !important; box-sizing: border-box !important;
    font-size: 16px !important; /* без zoom на iOS */
    min-height: 44px !important; height: auto !important;
  }
  /* Ряд композера — колонкой, чтобы select не сжимал textarea */
  #fc-msg-input, #fc-channel-select { flex: none !important; }
  .dm-col-right [style*="display:flex"][style*="gap:8px"] { flex-direction: column !important; }
  /* Deal fields list — no max-height on mobile */
  .deal-fields-list { max-height: none !important; }
  /* Deal form fields - bigger tap targets */
  .deal-fields-list .form-input,
  .deal-fields-list .form-select,
  .deal-fields-list .form-textarea { font-size: 16px !important; padding: 10px 12px !important; min-height: 44px !important; }

  /* ── Analytics ── */
  .analytics-grid, [class*="analytics"] > div[style*="grid"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Settings ── */
  .settings-layout, [class*="settings"] > div[style*="flex"] {
    flex-direction: column !important;
  }
  .settings-nav { width: 100% !important; min-width: unset !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; display: flex !important; overflow-x: auto !important; }
  .settings-content { padding: 12px !important; }

  /* ── Users page ── */
  .users-header { flex-direction: column !important; gap: 8px !important; }
  .user-card { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
  .user-card-actions { width: 100% !important; justify-content: flex-end !important; }

  /* ── Integrations ── */
  .integrations-grid, [class*="integration"] > div[style*="grid"] {
    grid-template-columns: 1fr !important;
  }
  .integration-card { flex-direction: column !important; gap: 10px !important; }
  .integration-card-actions { width: 100% !important; }

  /* ── Tasks ── */
  .task-row-meta { flex-wrap: wrap !important; gap: 6px !important; }

  /* ── Leads ── */
  .leads-toolbar { flex-wrap: wrap !important; gap: 8px !important; }

  /* ── Tenant settings ── */
  .plan-cards { flex-direction: column !important; }
  .plan-card { width: 100% !important; min-width: unset !important; }

  /* ── Pipeline editor ── */
  .pipeline-editor-layout { flex-direction: column !important; }
  .pipeline-editor-sidebar { width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; }

  /* ── Email / Chats ── */
  .email-layout, .chat-layout, .msg-layout { flex-direction: column !important; height: auto !important; }
  .email-sidebar, .chat-list-col { width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; max-height: 200px !important; overflow-y: auto !important; }
  .email-content, .chat-content { height: auto !important; min-height: 300px !important; }

  /* ── Inline grids → stack on mobile ── */
  /* 2-col grids */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: repeat(2"],
  div[style*="grid-template-columns:repeat(2"] {
    grid-template-columns: 1fr !important;
  }
  /* 3-col grids */
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns:repeat(3"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* 4-col grids */
  div[style*="grid-template-columns: repeat(4"],
  div[style*="grid-template-columns:repeat(4"] {
    grid-template-columns: 1fr 1fr !important;
  }
  /* Mixed grids with fixed px values — go 1col */
  div[style*="grid-template-columns:1fr 280px"],
  div[style*="grid-template-columns: 1fr 280px"],
  div[style*="grid-template-columns:1fr 120px 1fr"],
  div[style*="grid-template-columns: 1fr 120px 1fr"],
  div[style*="grid-template-columns:1fr 80px 1fr"],
  div[style*="grid-template-columns: 1fr 80px 1fr"],
  div[style*="grid-template-columns:140px 1fr"],
  div[style*="grid-template-columns: 140px 1fr"],
  div[style*="grid-template-columns:1fr 80px 120px"],
  div[style*="grid-template-columns: 1fr 80px 120px"],
  div[style*="grid-template-columns:1fr 120px 1fr 28px"],
  div[style*="grid-template-columns: 1fr 120px 1fr 28px"],
  div[style*="grid-template-columns:1fr 80px 1fr 80px"],
  div[style*="grid-template-columns: 1fr 80px 1fr 80px"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Form rows with label+input ── */
  .form-row { flex-direction: column !important; gap: 6px !important; }
  .form-label-col { min-width: unset !important; width: 100% !important; }

  /* ── Inline fixed widths ── */
  div[style*="min-width: 340px"], div[style*="min-width:340px"],
  div[style*="min-width: 300px"], div[style*="min-width:300px"],
  div[style*="width: 340px"],     div[style*="width:340px"] {
    width: 100% !important; min-width: unset !important;
  }

  /* ── Action buttons row ── */
  .btn-row, .action-row { flex-wrap: wrap !important; gap: 8px !important; }
  .btn-row .btn, .action-row .btn { flex: 1 1 auto; min-width: 120px; justify-content: center; }

  /* ── Page header with title + actions ── */
  .page-header { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
  .page-header-actions { width: 100% !important; }
  .page-header-actions .btn { flex: 1; justify-content: center; }

  /* ── Topbar search ── */
  #topbar-search { display: none; }

  /* ── Scrollable horizontal tabs ── */
  .tabs-row, .tab-bar { overflow-x: auto !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch !important; }
  .tab-item, .tab-btn { flex-shrink: 0 !important; }

  /* ── Flex rows → stack on mobile ── */
  .flex.justify-between, [style*="display:flex"][style*="justify-content:space-between"],
  div[style*="display: flex"][style*="justify-content: space-between"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  
  /* ── Kanban board: horizontal scroll (проекты — .kanban-col) ── */
  .kanban-board { overflow-x: auto !important; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch !important; padding-bottom: 12px !important; }
  .kanban-col { min-width: 46vw !important; max-width: 46vw !important; width: 46vw !important; flex-shrink: 0 !important; }
  /* Показываем кнопку перемещения на карточках (тач-дружелюбно) */
  .deal-card-move-btn { display: flex !important; }
  .kanban-column .deal-card { padding-right: 40px !important; }

  /* ── Users / team page: table → cards ── */
  table { display: block !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch !important; }
  table tbody tr { display: block !important; border: 1px solid var(--border) !important; border-radius: var(--radius-md) !important; margin-bottom: 10px !important; padding: 10px !important; }
  table tbody td { display: flex !important; justify-content: space-between !important; border: none !important; padding: 4px 0 !important; font-size: 12px !important; }
  table thead { display: none !important; }

  /* ── Settings / integrations: card grids ── */
  .settings-grid, .integrations-grid { grid-template-columns: 1fr !important; }

  /* ── Integration cards: action buttons row ── */
  .integration-card-actions,
  .card [style*="display:flex"][style*="gap:8px"],
  .card [style*="display: flex"][style*="gap: 8px"] {
    flex-wrap: wrap !important;
    align-items: flex-start !important;
  }
  
  /* ── General: flex rows with buttons should wrap ── */
  [style*="display:flex"][style*="gap:8px"],
  [style*="display: flex"][style*="gap: 8px"] {
    flex-wrap: wrap !important;
  }
  /* Exceptions: keep nowrap for scrollable nav/tabs */
  [style*="overflow-x:auto"],
  [style*="overflow-x: auto"],
  [style*="flex-wrap:nowrap"],
  [style*="flex-wrap: nowrap"],
  #fb-toolbar,
  .pipeline-tabs,
  .kanban-board,
  nav {
    flex-wrap: nowrap !important;
  }
  
  /* ── Category/tab pills: scrollable ── */
  .integration-tabs, 
  [style*="display:flex"][style*="overflow"][style*="auto"],
  [class*="tab"][style*="overflow"] {
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100vw !important;
  }
  
  /* ── Overflow protection: all flex containers in cards ── */
  .card { overflow: hidden !important; }
  .card .flex, .card [style*="display:flex"] {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* ── Inline flex rows with fixed gap → wrap ── */
  div[style*="display:flex"][style*="gap:12px"],
  div[style*="display: flex"][style*="gap: 12px"],
  div[style*="display:flex"][style*="gap:16px"],
  div[style*="display: flex"][style*="gap: 16px"] {
    flex-wrap: wrap !important;
  }
  
  /* ── Fixed-width sidebar-like panels ── */
  div[style*="width:320px"], div[style*="width: 320px"],
  div[style*="width:300px"], div[style*="width: 300px"],
  div[style*="width:360px"], div[style*="width: 360px"],
  div[style*="min-width:280px"], div[style*="min-width: 280px"] {
    width: 100% !important; min-width: unset !important; max-width: 100% !important;
  }

  /* ═══════════════════════════════════════════════════════════════
     TOPBAR: не даём правой группе кнопок уезжать за экран
     ═══════════════════════════════════════════════════════════════ */
  /* Заголовок сжимается и обрезается многоточием, а не вытесняет кнопки */
  .topbar-title {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  /* Правая группа топбара не сжимается ниже своего контента и не переносится */
  .topbar > .flex.items-center {
    flex: 0 0 auto !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    margin-left: auto !important;
  }
  /* Скрываем текст на кнопке действия — оставляем только иконку "+" */
  .topbar-action-btn .topbar-btn-label { display: none !important; }
  .topbar-action-btn { padding: 0 12px !important; min-width: 40px; justify-content: center; }
  /* SIP-бейдж и подсказка поиска не нужны на мобиле — экономим место */
  #sip-status-badge { display: none !important; }
  #search-hint { display: none !important; }
  /* Кнопки топбара компактнее */
  .topbar .btn-ghost.btn-sm { padding: 0 9px !important; }

  /* ═══════════════════════════════════════════════════════════════
     ГЛОБАЛЬНАЯ ЗАЩИТА ОТ ГОРИЗОНТАЛЬНОГО ПЕРЕПОЛНЕНИЯ
     ═══════════════════════════════════════════════════════════════ */
  html, body { max-width: 100vw !important; overflow-x: hidden !important; }
  .main-content { max-width: 100vw !important; overflow-x: hidden !important; }
  .page-content { max-width: 100vw !important; }
  /* Страница сделок скроллит канбан внутри себя, но не тянет всю страницу */
  .page-content.deals-page { overflow-x: hidden !important; }

  /* ═══════════════════════════════════════════════════════════════
     ПРОЕКТЫ: две колонки → вертикальный стек, доска скроллит внутри
     ═══════════════════════════════════════════════════════════════ */
  .projects-layout {
    flex-direction: column !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 10px !important;
  }
  /* Левая панель списка проектов — на всю ширину, невысокая, скролл */
  .projects-layout > div:first-child {
    width: 100% !important;
    flex-shrink: 0 !important;
    max-height: 200px !important;
    border-right: none !important;
    border-radius: 12px !important;
  }
  /* Правая доска — на всю ширину */
  #project-kanban-area {
    width: 100% !important;
    border-radius: 12px !important;
    min-height: 60vh !important;
  }
  /* Заголовок доски проекта: заголовок сверху, кнопки переносятся ниже */
  .proj-board-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }
  .proj-board-actions {
    width: 100% !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .proj-board-actions .btn { flex: 0 1 auto; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card  { padding: 14px; }
  .topbar-title { font-size: 14px; }
  .page-content { padding: 8px; }
  .modal-body   { padding: 12px 14px; }

  /* Канбан на маленьких телефонах: держим 2 этапа на экране */
  .kanban-column, .kanban-col {
    min-width: 47vw !important; max-width: 47vw !important; width: 47vw !important;
  }
  .kanban-column .deal-card { padding: 7px 8px !important; }
  .kanban-column .deal-card-title { font-size: 11px !important; }
  .kanban-column-header { padding: 7px 8px !important; }
  .column-name { font-size: 11px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 200px; min-width: 200px; }
  .main-content { margin-left: 200px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  #fb-palette { display: none !important; }
  #fb-props   { display: none !important; }
  .fb-props-toggle   { display: flex !important; }
  .fb-palette-toggle { display: flex !important; }
  .fb-mobile-only    { display: flex !important; align-items: center; }
  .fb-palette-only   { display: flex !important; align-items: center; }
  /* Tablet grids: 2 cols instead of 3 */
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Notifications Dropdown ───────────────────────────────────────────────── */
.notif-dropdown {
  position: fixed;
  top: 52px;
  right: 12px;
  width: 360px;
  max-width: calc(100vw - 24px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 1200;
  display: none;
  overflow: hidden;
}
.notif-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.notif-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-2);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-3); }
.notif-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.notif-body { flex: 1; min-width: 0; }
.notif-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
}
.notif-time {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 3px;
}

/* ── Задача 4: перетаскивание и ресайз секций карточки сделки ── */
.dsection.dl-dragging { opacity: .45; }
.dsection.dl-dragover { outline: 2px dashed var(--primary); outline-offset: 2px; border-radius: 8px; }
.dm-sec-head { position: relative; }
.dm-sec-drag { cursor: grab; color: var(--text-3); font-size: 11px; margin-right: 4px; opacity: .6; user-select: none; }
.dm-sec-drag:hover { opacity: 1; color: var(--primary); }
.dsection.dl-dragging .dm-sec-drag { cursor: grabbing; }
.dl-resize-handle { height: 9px; cursor: ns-resize; margin-top: 2px; border-radius: 4px; background: transparent; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.dl-resize-handle:hover { background: rgba(99,102,241,0.12); }
.dl-resize-handle::after { content: ''; width: 34px; height: 3px; border-radius: 3px; background: var(--border); }
.dl-resize-handle:hover::after { background: var(--primary); }
/* Fixed-height sections must NOT collapse or overlap siblings in the flex column */
.dsection.dl-fixed-height { flex: 0 0 auto !important; }
.dsection.dl-fixed-height > [id^="dsec-body-"] { overflow-y: auto !important; flex: none !important; }
/* A section dragged into the bottom strip sits as a normal stacked card */
.dm-bottom > .dsection { flex: 0 0 auto; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; overflow: auto; }
.dm-bottom > .dm-bottom-col { flex: 1 1 auto; min-height: 120px; }
/* Нижняя зона: НЕ прокручиваем саму полосу (иначе грип-ресайза уезжает).
   Вместо этого содержимое кладём в горизонтальный ряд с прокруткой,
   а грип остаётся закреплён у верхней кромки. Каждый блок внутри сам скроллится. */
.dm-bottom { overflow: hidden; }
.dm-bottom > .dsection, .dm-bottom > .dm-bottom-col { min-height: 0; max-height: 100%; }

/* ── Пустая колонка left/right: остаётся зоной для возврата блока ──────────
   Без контента колонка схлопывалась и в неё нельзя было перетащить блок. */
.dm-col-left.dm-col-empty, .dm-col-right.dm-col-empty { min-height: 90px; }
.dm-col-left.dm-col-empty::after, .dm-col-right.dm-col-empty::after {
  content: '\f0fe\00a0\00a0Перетащите блок сюда';
  font-family: 'Font Awesome 6 Free', sans-serif; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex: 1 1 auto; min-height: 80px; color: var(--text-3); font-size: 12px;
  border: 1.5px dashed var(--border); border-radius: 10px; padding: 16px;
}
/* Подсветка колонки-приёмника при перетаскивании */
.dl-col-dropzone { outline: 2px dashed var(--primary); outline-offset: -6px; background: var(--primary-glow); border-radius: 8px; }
.dl-reset-btn { font-size: 11px; color: var(--text-3); cursor: pointer; background: none; border: none; padding: 2px 6px; }
.dl-reset-btn:hover { color: var(--primary); }
/* Плейсхолдер вставки — показывает, КУДА встанет блок (никогда не затирает соседей) */
.dl-placeholder {
  min-height: 42px; margin: 2px 0; border-radius: 10px;
  border: 2px dashed var(--primary);
  background: var(--primary-glow);
  flex: 0 0 auto; box-sizing: border-box;
  animation: dlPhPulse 1s ease-in-out infinite;
}
@keyframes dlPhPulse { 0%,100%{opacity:.55} 50%{opacity:1} }
/* Кнопка-замок в активном (заблокированном) состоянии */
.dm-icon-btn.dl-locked-on { color: #f59e0b; background: rgba(245,158,11,.12); }
.dsection.dl-locked .dm-sec-drag { display: none !important; }

/* ── Deal tasks subsections (Активные / Выполненные) ───────────────────── */
.dtask-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.dtask-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: var(--bg-3); font-size: 12px; font-weight: 600; user-select: none; }
.dtask-group-head:hover { background: var(--bg-4); }
.dtask-group-title { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.dtask-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--bg); color: var(--text-3); font-size: 10px; font-weight: 700; }
.dtask-overdue { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 600;
  color: #f87171; background: rgba(248,113,113,.12); padding: 2px 7px; border-radius: 10px; }
.dtask-group-body { padding: 4px 8px; }
.dtask-empty { color: var(--text-3); font-size: 11px; padding: 8px 4px; text-align: center; }
