/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --sidebar-w: 240px;
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --sidebar-bg:#0f172a;
  --sidebar-hover: #1e293b;
  --accent:    #6366f1;
  --accent-hover: #4f46e5;
  --text:      #0f172a;
  --text-muted:#64748b;
  --border:    #e2e8f0;
  --radius:    12px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);

  /* Stage colors (dynamic via inline --stage-color) */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { font-size: 24px; }
.brand-text  { color: rgba(255,255,255,.7); font-size: 16px; }
.brand-text strong { color: #fff; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item i { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.manager-info { flex: 1; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.manager-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.manager-name { color: rgba(255,255,255,.8); font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { color: rgba(255,255,255,.5); text-decoration: none; font-size: 18px; transition: color .15s; }
.btn-logout:hover { color: #f87171; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}
.content-area {
  padding: 28px 32px;
  max-width: 1400px;
}
/* Страница Лиды (канбан) — на всю ширину */
.content-area:has(.kanban-board) {
  max-width: 100%;
  min-width: fit-content;
  padding-top: 8px;
  padding-right: 16px;
  padding-left: 16px;
}

/* ── Mobile topbar ────────────────────────────────────────── */
.mobile-topbar {
  position: sticky; top: 0;
  background: var(--sidebar-bg);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
  z-index: 90;
}
.btn-hamburger {
  background: none; border: none;
  color: #fff; font-size: 22px;
  cursor: pointer; padding: 2px;
  line-height: 1;
}
.mobile-brand { color: #fff; font-weight: 600; font-size: 16px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .content-area:has(.kanban-board) { padding: 8px 4px; }
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-title  { font-size: 22px; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-muted); margin: 2px 0 0; font-size: 13px; }

/* ── Leads header (канбан страница) ──────────────────────── */
.leads-header {
  margin-bottom: 12px;
  min-width: fit-content;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding-bottom: 6px;
}
.leads-header-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.leads-header-row2 {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-subtitle-inline {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
}
@media (max-width: 991px) {
  .leads-header { min-width: auto; }
  .leads-header-row1 { flex-wrap: wrap; }
  .leads-header-row1 select { flex: 1; min-width: 140px !important; }
  .leads-header-row2 { flex-wrap: wrap; }
  .leads-header-row2 .search-input-wrap { max-width: 100% !important; }
  .leads-header-row2 .page-title { font-size: 16px; }
}

/* ── Filters bar ──────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.stage-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.stage-pill:hover { border-color: var(--accent); color: var(--accent); }
.stage-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill-count {
  background: rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.stage-pill.active .pill-count { background: rgba(255,255,255,.25); }

.search-form { flex: 1; min-width: 200px; max-width: 360px; }
.search-input-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input { padding-left: 36px; padding-right: 32px; border-radius: 20px; border-color: var(--border); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.search-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); text-decoration: none; font-size: 15px; }
.search-clear:hover { color: var(--text); }

/* ── Leads grid ───────────────────────────────────────────── */
.leads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.lead-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .18s, box-shadow .18s;
  overflow: hidden;
  border: 1.5px solid var(--border);
}
.lead-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.lead-card.paused { border-color: #f59e0b; background: #fffbeb; }

.lead-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.paused-badge {
  font-size: 11px; font-weight: 600;
  color: #d97706;
  background: #fef3c7;
  padding: 2px 8px; border-radius: 10px;
}

.lead-card-body { padding: 0 14px 12px; flex: 1; }
.lead-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.lead-username { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.lead-details { margin-top: 8px; }
.detail-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 3px;
}
.detail-row i { width: 14px; flex-shrink: 0; }

.lead-last-seen {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}

.lead-card-footer { padding: 10px 14px; border-top: 1px solid var(--border); }

/* ── Stage badges ─────────────────────────────────────────── */
.lead-stage-badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.stage-badge {
  background: var(--stage-bg, #e2e8f0);
  color: var(--stage-color, #475569);
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-weight: 600; color: var(--text); }

/* ── Lead detail ──────────────────────────────────────────── */
.lead-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  transition: all .15s;
  white-space: nowrap;
}
.btn-back:hover { border-color: var(--accent); color: var(--accent); }
.lead-detail-title { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-detail-title h2 { margin: 0; font-size: 20px; font-weight: 700; }
.btn-pause {
  white-space: nowrap;
  font-weight: 500;
  border-radius: 8px;
}

.lead-detail-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .lead-detail-grid { grid-template-columns: 1fr; }
}

/* ── Info card ────────────────────────────────────────────── */
.info-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  overflow: hidden;
}
.info-card-title {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  background: #f8fafc;
}
.info-rows { padding: 4px 0; }
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  display: flex;
  flex-direction: column;
  color: var(--text-muted);
  font-size: 12px;
  min-width: 130px;
  flex-shrink: 0;
}
.info-label-db {
  display: block;
  font-size: 10px; color: #94a3b8;
  font-weight: 400; margin-top: 0;
  font-family: 'Courier New', monospace;
  padding-left: 20px;
  line-height: 1.3;
}
.info-value { font-weight: 500; font-size: 13px; word-break: break-word; }

/* ── Stage select ─────────────────────────────────────────── */
.stage-select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px 14px; }
.stage-select-grid .stage-option:last-child { grid-column: 1 / -1; }
.stage-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  transition: all .15s;
  color: var(--text-muted);
}
.stage-option input[type=radio] { display: none; }
.stage-option:hover { border-color: currentColor; }
.stage-option.selected {
  background: var(--stage-bg, #e2e8f0);
  color: var(--stage-color, #475569);
  border-color: var(--stage-color, #94a3b8);
}

/* ── Chat ─────────────────────────────────────────────────── */
.chat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 520px;
}
.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-count { font-size: 12px; font-weight: 400; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-empty { text-align: center; color: var(--text-muted); padding: 32px; font-size: 13px; }

.chat-bubble {
  max-width: 80%;
  display: flex;
  flex-direction: column;
}
.chat-bubble.user { align-self: flex-start; align-items: flex-start; }
.chat-bubble.bot  { align-self: flex-end;   align-items: flex-end; }

.bubble-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble.user .bubble-content {
  background: #f1f5f9;
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-bubble.bot .bubble-content {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* ── Notes ────────────────────────────────────────────────── */
.notes-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-top: 16px;
}
.notes-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  background: #f8fafc;
}
.note-form { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.note-textarea {
  resize: none;
  font-size: 13px;
  border-color: var(--border);
}
.note-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

.notes-list { padding: 8px 0; }
.note-item { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }
.note-item:last-child { border-bottom: none; }
.note-meta { display: flex; justify-content: space-between; margin-bottom: 5px; }
.note-author { font-size: 12px; font-weight: 600; color: var(--accent); }
.note-date   { font-size: 11px; color: var(--text-muted); }
.note-text   { font-size: 13px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.login-logo p  { color: var(--text-muted); font-size: 13px; margin: 0; }

.form-label { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.input-group-text { background: #f8fafc; border-color: var(--border); color: var(--text-muted); }
.form-control { border-color: var(--border); font-size: 14px; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }

.btn-login {
  background: var(--accent); border-color: var(--accent);
  padding: 10px; font-weight: 600; font-size: 14px;
  border-radius: 10px;
}
.btn-login:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-primary {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
.btn-primary:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
}
.btn-outline-primary {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}
.btn-outline-primary:hover {
  background: var(--accent) !important;
  color: #fff !important;
}

/* ── Nav badge ────────────────────────────────────────────── */
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ── Kanban board ─────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow: visible;
  align-items: stretch;
  padding-bottom: 16px;
  min-height: calc(100vh - 160px);
  cursor: grab;
}
.kanban-board.board-grabbing {
  cursor: grabbing;
  user-select: none;
}

.kanban-col {
  flex: 0 0 210px;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: none;
  overflow: visible;
}

/* ── Мобильный канбан — компактный дизайн ──────────────── */
@media (max-width: 991px) {
  .leads-header { min-width: auto; }
  /* Канбан — убираем overflow чтобы sticky работал */
  .kanban-board {
    gap: 6px;
    min-height: auto;
    overflow: visible;
    -webkit-overflow-scrolling: touch;
  }
  /* Закреплённые заголовки колонок */
  .kanban-col { overflow: visible; }
  .kanban-col-header {
    position: sticky;
    z-index: 10;
    padding: 6px 8px;
    gap: 2px;
  }
  .kanban-col {
    flex: 0 0 11%;
    min-width: 11%;
  }
  .kanban-col-title { font-size: 11px; }
  .kanban-col-count { font-size: 10px; padding: 1px 6px; min-width: 18px; }
  .kanban-col-budget { font-size: 10px; }
  .kanban-col-hint { display: none; }
  .kanban-col-body {
    padding: 4px;
    gap: 4px;
    min-height: 40px;
  }
  /* Карточки — компактные */
  .kanban-card { border-radius: 6px; border-width: 1px; }
  .kanban-card-link { padding: 6px 8px; }
  .kanban-card-name { font-size: 11px; margin-bottom: 2px; gap: 3px; }
  .kanban-card-meta { font-size: 10px; gap: 3px; margin-bottom: 1px; }
  .kanban-card-meta i { font-size: 9px; }
  .kanban-card-time { font-size: 9px !important; }
  .kanban-card-tags { padding: 1px 8px 4px; gap: 3px; }
  .kanban-tag { font-size: 8px; padding: 1px 5px; }
  .source-badge { font-size: 7px; padding: 0px 3px; margin-right: 2px; }
  .kanban-paused-dot { font-size: 8px; }
  /* Комментарий */
  .kanban-card-comment { padding: 2px 8px 0; }
  .kanban-card-comment.comment-empty { display: none; }
  .kanban-comment-input { font-size: 10px; min-height: 22px; padding: 2px 6px; }
  /* Кнопки действий */
  .kanban-card-actions { padding: 0 8px 4px; }
}

.kanban-col-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  border-top: 4px solid transparent;
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
/* Dynamic stage colors via inline CSS variables */
.kanban-col-header {
  border-top-color: var(--stage-color, #3b82f6);
  background: var(--stage-bg, #eff6ff);
}
.kanban-col-budget {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.kanban-col-hint {
  font-size: 10px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  padding-top: 2px;
  opacity: 0.75;
}
.kanban-col-hint .bi { font-size: 9px; margin-right: 2px; }

.kanban-col-title { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-col-count {
  background: rgba(0,0,0,.08);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}

.kanban-col-body {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: calc(100vh - 250px);
  background: #f8fafc;
  border-left: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}

.kanban-card {
  background: var(--surface);
  border-radius: 8px;
  border: 1.5px solid var(--border);
  cursor: grab;
  transition: box-shadow .15s;
  /* Блокируем контекстное меню и выделение при удержании на мобильных */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.kanban-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.kanban-card.paused { border-color: #f59e0b; background: #fffbeb; }
.kanban-ghost { opacity: 0.4; background: #e0e7ff; border: 2px dashed var(--accent); }
.kanban-dragging { box-shadow: var(--shadow-lg); transform: rotate(1deg); cursor: grabbing; }
/* Drag mode active: карточка готова к перетаскиванию (двойной клик/тап) */
.kanban-card.drag-mode-active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(99,102,241,.18), var(--shadow-lg);
  cursor: grab;
  animation: drag-pulse .8s ease-in-out infinite alternate;
}
@keyframes drag-pulse {
  from { outline-color: var(--accent); }
  to   { outline-color: #818cf8; }
}

.kanban-card-link {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
}
.kanban-card-link:hover { color: var(--text); }
.kanban-card-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kanban-paused-dot { font-size: 10px; }
.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.kanban-card-meta i { font-size: 11px; }

/* ── Chat send area ───────────────────────────────────────── */
.chat-card { max-height: none; }
.chat-messages { max-height: 380px; }

.chat-send-area {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  align-items: flex-end;
}
.chat-send-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color .15s;
  background: #fff;
}
.chat-send-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: background .15s;
}
.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-error {
  padding: 6px 12px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
  border-top: 1px solid #fee2e2;
}

/* ── Tasks (lead page) ────────────────────────────────────── */
.task-create-form {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.tasks-list {
  padding: 6px 0;
}
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: #f8fafc; }
.task-item.completed { opacity: 0.55; }
.task-item.completed .task-title { text-decoration: line-through; }

.task-check {
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  font-size: 17px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
  transition: color .15s;
}
.task-check:hover { color: var(--accent); }
.task-item.completed .task-check { color: #10b981; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 500; line-height: 1.4; }
.task-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.task-meta  { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.task-due   { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.task-due.overdue { color: #dc2626; font-weight: 600; }
.task-auto-badge {
  font-size: 10px;
  font-weight: 600;
  background: #ede9fe;
  color: #5b21b6;
  padding: 1px 6px;
  border-radius: 6px;
}

.task-delete {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  font-size: 14px;
  color: #cbd5e1;
  transition: color .15s;
  flex-shrink: 0;
}
.task-delete:hover { color: #ef4444; }
.task-empty {
  padding: 20px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Tasks page ───────────────────────────────────────────── */
.new-task-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  padding: 16px;
  box-shadow: var(--shadow);
}

.tasks-group-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 4px;
}
.tasks-group-header.group-overdue  { color: #dc2626; border-color: #fca5a5; }
.tasks-group-header.group-today    { color: #b45309; border-color: #fcd34d; }
.tasks-group-header.group-tomorrow { color: #1d4ed8; border-color: #93c5fd; }
.tasks-group-header.group-done     { color: #64748b; }
.tasks-group-count {
  background: rgba(0,0,0,.07);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  margin-left: 4px;
}

.tasks-table {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  transition: background .1s;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #f8fafc; }
.task-row.completed { opacity: 0.5; }
.task-row.completed .task-title { text-decoration: line-through; }

.task-row-body { flex: 1; min-width: 0; }
.task-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}
.task-lead-link {
  text-decoration: none;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  white-space: nowrap;
}
.task-lead-link:hover { color: var(--accent-hover); }

/* ── Kanban card comment ─────────────────────────────────── */
.kanban-card-comment {
  padding: 4px 10px 0;
}
.kanban-comment-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  resize: none;
  min-height: 28px;
  max-height: 60px;
  background: #fafafa;
  color: var(--text);
  transition: border-color .2s;
  overflow-y: auto;
}
.kanban-comment-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.kanban-comment-input::placeholder {
  color: #aaa;
}

/* ── Source badges (TG / IG) ────────────────────────────── */
.source-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 3px;
  line-height: 1.2;
}
.source-badge.tg {
  background: #e3f0ff;
  color: #0088cc;
}
.source-badge.ig {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #e8a0bf 100%);
  color: #c13584;
}

/* ── Kanban card actions ──────────────────────────────────── */
.kanban-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 10px 8px;
  gap: 4px;
}
.kanban-action-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  transition: all .15s;
}
.kanban-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0f0ff;
}
.kanban-card-time {
  font-size: 11px !important;
  color: #94a3b8 !important;
}
.kanban-task-dot { font-size: 9px; }
.kanban-empty-placeholder {
  text-align: center;
  padding: 24px 12px;
  color: #cbd5e1;
  font-size: 12px;
  font-style: italic;
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
}

/* ── Funnel Edit Mode ────────────────────────────────────── */
.funnel-edit-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; margin-bottom: 12px;
  background: #fef9c3; border: 1px solid #fde047;
  border-radius: var(--radius); font-size: 13px;
}
.funnel-edit-toolbar .toolbar-label {
  font-weight: 600; color: #854d0e; margin-right: auto;
}
.edit-mode .kanban-card { pointer-events: none; opacity: .5; }
.edit-mode .kanban-col-body { min-height: 40px; }
.edit-mode .kanban-col-header { cursor: grab; }
.edit-mode .kanban-col-header:active { cursor: grabbing; }

.edit-header-row {
  display: flex; align-items: center; gap: 6px; width: 100%;
}
.edit-header-row input.edit-label-input {
  flex: 1; font-size: 12px; font-weight: 600;
  padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; min-width: 0;
}
.edit-header-row .edit-icon-btn,
.edit-header-row .edit-color-btn,
.edit-header-row .edit-delete-btn {
  border: none; background: none; cursor: pointer;
  font-size: 14px; padding: 2px 4px; border-radius: 4px;
  line-height: 1;
}
.edit-header-row .edit-delete-btn { color: #ef4444; }
.edit-header-row .edit-delete-btn:hover { background: #fee2e2; }
.edit-header-row .edit-color-btn:hover,
.edit-header-row .edit-icon-btn:hover { background: #f1f5f9; }

.edit-autotask-row {
  display: flex; gap: 6px; margin-top: 6px; font-size: 11px;
}
.edit-autotask-row input {
  padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; font-size: 11px;
}
.edit-autotask-row input.at-text { flex: 1; min-width: 0; }
.edit-autotask-row input.at-days { width: 50px; text-align: center; }

.edit-require-reason-row {
  margin-top: 6px; font-size: 11px; color: var(--text-muted);
}
.edit-require-reason-row label {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
}
.edit-require-reason-row input[type="checkbox"] {
  accent-color: var(--primary); width: 14px; height: 14px;
}

.kanban-add-col {
  min-width: 180px; display: flex; align-items: center;
  justify-content: center; border: 2px dashed var(--border);
  border-radius: var(--radius); cursor: pointer;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: all .15s;
}
.kanban-add-col:hover { border-color: var(--accent); color: var(--accent); background: #eef2ff; }

/* Color picker popup */
.color-picker-popup {
  position: absolute; top: 100%; left: 0; z-index: 200;
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; box-shadow: var(--shadow-lg);
  display: flex; flex-wrap: wrap; gap: 6px; width: 168px;
}
.color-picker-popup .cp-swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .1s;
}
.color-picker-popup .cp-swatch:hover { transform: scale(1.2); }
.color-picker-popup .cp-swatch.active { border-color: #0f172a; }

/* Icon picker popup */
.icon-picker-popup {
  position: absolute; top: 100%; left: 0; z-index: 200;
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; box-shadow: var(--shadow-lg);
  display: flex; flex-wrap: wrap; gap: 4px; width: 220px;
}
.icon-picker-popup .ip-item {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer; font-size: 16px;
}
.icon-picker-popup .ip-item:hover { background: #f1f5f9; }
.icon-picker-popup .ip-item.active { background: #e0e7ff; }

/* Delete stage modal */
.stage-delete-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.4); display: flex;
  align-items: center; justify-content: center;
}
.stage-delete-modal .sdm-box {
  background: #fff; border-radius: var(--radius);
  padding: 24px; max-width: 400px; width: 90%;
  box-shadow: var(--shadow-lg);
}
.stage-delete-modal .sdm-box h4 { margin: 0 0 12px; font-size: 16px; }
.stage-delete-modal .sdm-box select { width: 100%; padding: 6px 10px; margin: 8px 0 16px; border-radius: 8px; border: 1px solid var(--border); }
.stage-delete-modal .sdm-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Manager chat bubble ─────────────────────────────────── */
.chat-bubble.manager { align-self: flex-end; align-items: flex-end; }
.chat-bubble.manager .bubble-content {
  background: #1e40af;
  color: #fff;
  border-bottom-right-radius: 4px;
}
/* Deleted messages — pink tint */
.chat-bubble.deleted .bubble-content {
  background: #fce4ec !important;
  color: #880e4f !important;
  opacity: 0.75;
}
.chat-bubble.deleted .bubble-time { color: #c2185b; }
/* System messages — centered info line */
.chat-bubble.system {
  align-self: center;
  align-items: center;
  max-width: 100%;
}
.chat-bubble.system .bubble-content {
  background: #fff3e0;
  color: #e65100;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
  text-align: center;
  border: 1px dashed #ffcc80;
}
.bubble-sender {
  font-size: 11px;
  font-weight: 600;
  color: #1e40af;
  margin-bottom: 2px;
  padding: 0 4px;
}

/* ── Chat templates ──────────────────────────────────────── */
.chat-templates {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  background: #fafbfc;
}
.quick-tpl-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
  white-space: nowrap;
}
.quick-tpl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f0f0ff;
}

/* ── Screen trigger (bot screen picker) ──────────────────── */
.screen-trigger-area {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
  position: relative;
}
.screen-trigger-row {
  display: flex;
  gap: 6px;
}
.screen-trigger-btn {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 14px;
  border: 1.5px solid #7c3aed;
  background: linear-gradient(135deg, #f5f3ff, #ede9fe);
  color: #7c3aed;
  cursor: pointer;
  transition: all .15s;
  font-weight: 600;
  white-space: nowrap;
}
.screen-trigger-btn:hover {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-color: #6d28d9;
  color: #6d28d9;
  box-shadow: 0 2px 8px rgba(124,58,237,.15);
}
.screen-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 12px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  z-index: 100;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}
.screen-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: #7c3aed;
}
.screen-picker-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.screen-picker-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.screen-picker-list {
  overflow-y: auto;
  max-height: 300px;
  padding: 6px 0;
}
.screen-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 8px 14px 4px;
}
.screen-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  transition: background .1s;
  color: var(--text);
}
.screen-item:hover {
  background: #f5f3ff;
}
.screen-item.current {
  background: #ede9fe;
  font-weight: 600;
}
.screen-item-label {
  flex: 1;
}
.screen-current-badge {
  font-size: 9px;
  background: #7c3aed;
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
}
.screen-trigger-success {
  color: #16a34a;
  font-size: 12px;
  padding: 6px 0 2px;
  font-weight: 500;
}
.screen-picker-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

/* ── Modal overlay ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

/* ── Priority badges & icons ─────────────────────────────── */
.priority-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
  margin-right: 4px;
  flex-shrink: 0;
}
.priority-icon.high {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fca5a5;
}
.priority-icon.low {
  background: #f0fdf4;
  color: #16a34a;
  border: 1.5px solid #86efac;
}
.task-priority-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
}
.task-priority-badge.priority-high {
  background: #fef2f2;
  color: #dc2626;
}
.task-priority-badge.priority-low {
  background: #f0fdf4;
  color: #16a34a;
}

/* ── Settings ─────────────────────────────────────────────── */
.settings-page { max-width: 700px; }
.excluded-list { display: flex; flex-direction: column; gap: 8px; }
.excluded-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #f8fafc; border-radius: 10px;
  border: 1px solid var(--border);
}
.excluded-info { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.excluded-name { font-weight: 600; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Inline editing ──────────────────────────────────────── */
.inline-edit {
  width: 100%;
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  background: transparent;
  color: var(--text);
  transition: all .15s;
}
.inline-edit:hover { border-color: var(--border); background: #f8fafc; }
.inline-edit:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.inline-edit.saving { border-color: #f59e0b; background: #fffbeb; }
.inline-edit.saved  { border-color: #10b981; background: #ecfdf5; }
.inline-edit.save-error { border-color: #ef4444; background: #fef2f2; }

.inline-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%2364748b' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
}

.inline-edit-textarea {
  width: 100%;
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
  resize: none;
  min-height: 32px;
  transition: all .15s;
}
.inline-edit-textarea:hover { border-color: var(--border); background: #f8fafc; }
.inline-edit-textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

/* ── Toggle switch ───────────────────────────────────────── */
.inline-toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.inline-toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #cbd5e1; border-radius: 22px; transition: .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: .2s;
}

/* Stage automation button */
.btn-stage-auto {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: #a78bfa; font-size: 12px; opacity: 0.5; transition: all .2s;
  border-radius: 4px;
}
.btn-stage-auto:hover { opacity: 1; background: #ede9fe; color: #7c3aed; }

/* Stage automation popover */
.stage-auto-popover {
  position: fixed; z-index: 9999; width: 270px;
  background: #fff; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18); border: 1px solid #e2e8f0;
  overflow: hidden; animation: popIn .15s ease;
}
@keyframes popIn { from { opacity:0; transform: translateY(-4px); } to { opacity:1; transform: none; } }
.sa-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  font-weight: 600; font-size: 13px; color: #1e293b;
}
.sa-close { background: none; border: none; cursor: pointer; color: #94a3b8; font-size: 16px; }
.sa-list { max-height: 240px; overflow-y: auto; padding: 8px; }
.sa-item {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border-radius: 8px; margin-bottom: 4px; background: #f8fafc;
}
.sa-item-name { flex: 1; font-size: 12px; font-weight: 600; color: #1e293b; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sa-item-badges { display: flex; gap: 3px; }
.sa-badge { font-size: 9px; padding: 2px 5px; border-radius: 4px; white-space: nowrap; }
.sa-badge.trigger { background: #dbeafe; color: #1d4ed8; }
.sa-badge.action { background: #f3e8ff; color: #7c3aed; }
.sa-toggle { position: relative; width: 28px; height: 16px; flex-shrink: 0; }
.sa-toggle input { opacity: 0; width: 0; height: 0; }
.sa-slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 16px; transition: .2s; }
.sa-slider::before { content:''; position: absolute; height: 12px; width: 12px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.sa-toggle input:checked + .sa-slider { background: #22c55e; }
.sa-toggle input:checked + .sa-slider::before { transform: translateX(12px); }
.sa-empty { text-align: center; padding: 16px; color: #94a3b8; font-size: 12px; }
.sa-link {
  display: block; text-align: center; padding: 10px; font-size: 12px;
  color: #7c3aed; text-decoration: none; border-top: 1px solid #e2e8f0;
  font-weight: 600;
}
.sa-link:hover { background: #f5f3ff; }
.inline-toggle input:checked + .toggle-slider { background: var(--accent); }
.inline-toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Auto-tags ───────────────────────────────────────────── */
.tags-container { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; }
.auto-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 14px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.auto-tag.tag-client   { background: #dbeafe; color: #1d4ed8; }
.auto-tag.tag-payment  { background: #ede9fe; color: #5b21b6; }
.auto-tag.tag-model    { background: #fce7f3; color: #9d174d; }
.auto-tag.tag-region   { background: #d1fae5; color: #065f46; }
.auto-tag.tag-license  { background: #fef3c7; color: #92400e; }

/* ── Kanban card tags ────────────────────────────────────── */
.kanban-card-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 12px 8px; }
.kanban-tag { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 8px; white-space: nowrap; line-height: 1.3; }
.kanban-tag.custom-tag { border: 1px solid; }

/* ── Lead tags editor ────────────────────────────────────── */
.lead-tags-wrap { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 8px; }
.lead-tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px; border: 1px solid;
}
.lead-tag-chip .tag-remove {
  cursor: pointer; font-size: 10px; opacity: .6; margin-left: 2px;
}
.lead-tag-chip .tag-remove:hover { opacity: 1; }
.lead-tag-add-btn {
  font-size: 11px; padding: 2px 8px; border-radius: 12px; border: 1px dashed #94a3b8;
  background: transparent; color: #64748b; cursor: pointer;
}
.lead-tag-add-btn:hover { border-color: #3b82f6; color: #3b82f6; }
.tag-add-popover {
  position: absolute; z-index: 100; background: white; border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 6px; min-width: 200px;
}
.tag-add-popover .tag-color-dots { display: flex; gap: 4px; }
.tag-add-popover .tag-dot {
  width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent;
}
.tag-add-popover .tag-dot.active { border-color: #1e293b; }

/* ── Info section headers ────────────────────────────────── */
.info-section-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 16px 6px; border-bottom: 1px solid var(--border);
}
.info-row .info-value.editable { flex: 1; }

/* ── Funnel Text Editor ─────────────────────────────────── */
.funnel-editor-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .funnel-editor-grid { grid-template-columns: 1fr; }
}

.funnel-screen-list {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  position: sticky;
  top: 20px;
}

.funnel-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 10px 14px 6px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.funnel-screen-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: all .15s;
  flex-wrap: wrap;
}
.funnel-screen-item:hover { background: #f8fafc; }
.funnel-screen-item.active {
  background: #eef2ff;
  border-left: 3px solid var(--accent);
}
.funnel-screen-item.modified { background: #fffbeb; }
.funnel-screen-item.active.modified { background: #eef2ff; }

.screen-name { font-weight: 500; font-size: 13px; flex: 1; min-width: 80px; }
.screen-id-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}
.override-badge {
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 6px;
  border-radius: 10px;
}

.editor-content { padding: 16px; }
.editor-section { margin-bottom: 20px; }
.editor-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.editor-textarea {
  font-family: 'Inter', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 160px;
  resize: vertical;
}

.editor-preview {
  margin-top: 8px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}

.button-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.btn-label-input { flex: 1; font-size: 13px; }
.btn-callback-id {
  font-size: 11px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  min-width: 100px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.save-status {
  font-size: 13px;
  font-weight: 500;
  margin-left: 8px;
}
.status-success { color: #10b981; }
.status-error   { color: #ef4444; }
.status-info    { color: #6366f1; }

/* ── Passport Photos ─────────────────────────────────────── */
.passport-photos { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 0; }
.passport-photo-card { text-align: center; }
.passport-photo-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.passport-photo-card img {
  width: 113px; height: 85px; border-radius: 8px;
  border: 2px solid var(--border); cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  object-fit: cover;
}
.passport-photo-card img:hover { transform: scale(1.03); box-shadow: var(--shadow); }
.passport-pdf-link {
  display: flex; align-items: center; gap: 8px; padding: 20px 24px;
  border: 2px dashed var(--border); border-radius: 8px; color: #dc2626;
  font-weight: 600; font-size: 14px; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.passport-pdf-link:hover { background: #fef2f2; border-color: #dc2626; }
.passport-pdf-link i { font-size: 28px; }
.btn-delete-doc { background:none; border:none; color:#ef4444; cursor:pointer;
  font-size:14px; font-weight:700; margin-left:6px; vertical-align:middle; }
.btn-delete-doc:hover { color:#dc2626; }
.btn-download-doc { color:#6366f1; font-size:13px; margin-left:6px; vertical-align:middle;
  text-decoration:none; transition: color .15s; }
.btn-download-doc:hover { color:#4f46e5; }
.doc-empty { text-align:center; padding:24px 16px; }
.doc-thumb { cursor:pointer; }
.doc-date { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.doc-date .bi { font-size: 9px; margin-right: 2px; }

/* ── Chat photo thumbnails ──────────────────────────────── */
.chat-photo-thumb {
  width: 113px; height: 85px; border-radius: 8px; cursor: pointer;
  object-fit: cover; border: 1px solid rgba(255,255,255,.2);
  transition: transform .15s, opacity .15s;
}
.chat-photo-thumb:hover { transform: scale(1.03); opacity: .9; }

/* ── Lightbox ───────────────────────────────────────────── */
.lightbox-overlay {
  display:none; position:fixed; top:0; left:0; width:100%; height:100%;
  background:rgba(0,0,0,.85); z-index:9999; justify-content:center; align-items:center;
}
.lightbox-overlay.active { display:flex; }
.lightbox-content { position:relative; max-width:90vw; max-height:90vh; text-align:center; }
.lightbox-content img { max-width:90vw; max-height:85vh; border-radius:8px; object-fit:contain; }
.lightbox-close {
  position:absolute; top:-16px; right:-16px; width:36px; height:36px;
  background:#fff; border:none; border-radius:50%; font-size:22px; font-weight:700;
  color:#333; cursor:pointer; display:flex; align-items:center; justify-content:center;
  box-shadow:0 2px 8px rgba(0,0,0,.3); transition: transform .15s;
}
.lightbox-close:hover { transform:scale(1.1); }
.lightbox-download {
  display:inline-flex; align-items:center; gap:6px; margin-top:12px;
  padding:8px 20px; background:#fff; color:#333; border-radius:8px;
  text-decoration:none; font-weight:600; font-size:14px;
  transition: background .15s, transform .15s;
}
.lightbox-download:hover { background:#e5e7eb; transform:scale(1.03); }

/* ── Funnel Map ──────────────────────────────────────────── */
.funnel-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.funnel-section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.funnel-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 700px;
}
.fn-level {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: nowrap;
  padding: 4px 0;
}
.fn-arrow-down {
  width: 2px;
  height: 20px;
  background: #cbd5e1;
  margin: 2px auto;
  position: relative;
}
.fn-arrow-down::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: -4px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #cbd5e1;
}
.fn-arrow-right {
  width: 20px;
  height: 2px;
  background: #cbd5e1;
  align-self: center;
  position: relative;
}
.fn-arrow-right::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -4px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid #cbd5e1;
}
/* Node card */
.fn-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid;
  background: var(--surface);
  min-width: 110px;
  max-width: 160px;
  text-align: center;
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}
.fn-node:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.fn-node-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}
.fn-node-count {
  font-size: 16px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  min-width: 32px;
}
/* Color types */
.fn-type-buttons        { border-color: #3b82f6; }
.fn-type-buttons .fn-node-count  { background: #dbeafe; color: #1d4ed8; }
.fn-type-text           { border-color: #10b981; }
.fn-type-text .fn-node-count     { background: #d1fae5; color: #065f46; }
.fn-type-photo          { border-color: #f59e0b; }
.fn-type-photo .fn-node-count    { background: #fef3c7; color: #92400e; }
.fn-type-terminal       { border-color: #22c55e; background: #f0fdf4; }
.fn-type-terminal .fn-node-count { background: #dcfce7; color: #166534; }
.fn-type-warmup         { border-color: #8b5cf6; }
.fn-type-warmup .fn-node-count   { background: #ede9fe; color: #5b21b6; }
/* Legend */
.fn-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.fn-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.fn-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid;
}
/* Branch lines */
.fn-branch-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
  margin-bottom: 2px;
}
.fn-branch-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
/* Horizontal flow row */
.fn-hflow {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 0;
}
/* Responsive */
@media (max-width: 991px) {
  .funnel-flow { min-width: 600px; }
  .fn-node { min-width: 90px; max-width: 130px; padding: 6px 10px; }
  .fn-node-label { font-size: 10px; }
  .fn-node-count { font-size: 13px; }
}

/* ── Funnel Constructor (node editor) ────────────────── */
.constructor-page {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  gap: 0;
  height: calc(100vh - 120px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.btn-xs { padding: 2px 8px; font-size: 12px; border-radius: 4px; }

/* Left panel - palette */
.constructor-left {
  border-right: 1.5px solid var(--border);
  overflow-y: auto;
  background: #f8fafc;
}
.palette-group { border-bottom: 1px solid var(--border); }
.palette-group.collapsed .palette-item { display: none; }
.palette-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 12px; cursor: pointer;
  user-select: none; letter-spacing: 0.5px;
}
.palette-group-title:hover { background: #f1f5f9; }
.palette-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px 6px 16px; cursor: pointer; font-size: 13px;
  border-left: 3px solid transparent; transition: all .1s;
}
.palette-item:hover { background: #e2e8f0; }
.palette-item-active { background: #dbeafe !important; border-left-color: var(--accent); font-weight: 600; }
.palette-item-disabled { opacity: 0.4; }
.palette-count {
  font-size: 11px; background: #e2e8f0; color: #475569;
  padding: 1px 6px; border-radius: 8px; font-weight: 600;
}

/* Center panel - canvas */
.constructor-center {
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}
.flow-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; border-bottom: 1px solid var(--border);
  background: #fafbfc; min-height: 40px;
}

/* Drawflow overrides */
#drawflow { background: #f5f7fa; }
.drawflow .drawflow-node {
  background: none !important; border: none !important;
  box-shadow: none !important; padding: 0 !important;
  min-height: auto !important; width: auto !important;
}
.drawflow .drawflow-node .inputs {
  display: flex !important;
  position: absolute !important; left: 2px !important; top: 50% !important;
  transform: translateY(-50%) !important; z-index: 6 !important;
}
.drawflow .drawflow-node .outputs {
  display: block !important;
  position: absolute !important; right: -6px !important; top: 0 !important;
  bottom: 0 !important; width: 14px !important;
}
.drawflow .drawflow-node .input, .drawflow .drawflow-node .output {
  width: 12px !important; height: 12px !important; border-radius: 50% !important;
  border: 2.5px solid #94a3b8 !important; background: white !important;
  cursor: crosshair; z-index: 5 !important; position: relative !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.15) !important;
  transition: all .15s ease !important;
}
.drawflow .drawflow-node .input {
  border-color: #10b981 !important;
}
.drawflow .drawflow-node .output {
  border-color: #3b82f6 !important;
  position: absolute !important; right: 0 !important;
}
.drawflow .drawflow-node .input:hover {
  background: #10b981 !important; border-color: #059669 !important;
  transform: scale(1.3) !important;
}
.drawflow .drawflow-node .output:hover {
  background: #3b82f6 !important; border-color: #1d4ed8 !important;
  transform: scale(1.3) !important;
}
.drawflow .connection .main-path {
  stroke: #94a3b8; stroke-width: 2;
}
.drawflow .connection .main-path:hover { stroke: #3b82f6; stroke-width: 3; }
.drawflow .drawflow-node.selected .node-card {
  box-shadow: 0 0 0 3px var(--accent); transform: scale(1.02);
}
.drawflow .drawflow-delete { display: none; }

/* Node card inside Drawflow */
.node-card {
  background: var(--surface); border: 2px solid #94a3b8;
  border-radius: 10px; min-width: 160px; max-width: 220px;
  font-size: 12px; overflow: hidden; transition: box-shadow .15s, transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.node-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.node-type-buttons { border-color: #3b82f6; }
.node-type-text { border-color: #10b981; }
.node-type-photo { border-color: #f59e0b; }
.node-type-mixed { border-color: #8b5cf6; }
.node-type-terminal { border-color: #22c55e; background: #f0fdf4; }
.node-type-checklist { border-color: #0ea5e9; background: #f0f9ff; }
.node-disabled .node-card { opacity: 0.4; border-style: dashed; }
.node-stage-bar {
  height: 4px;
  border-radius: 10px 10px 0 0;
}
.node-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; font-weight: 600; font-size: 12px;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.node-off-badge {
  font-size: 9px; background: #fecaca; color: #dc2626;
  padding: 1px 4px; border-radius: 3px; font-weight: 700;
}
.node-custom-badge {
  font-size: 9px; background: #dbeafe; color: #1d4ed8;
  padding: 1px 4px; border-radius: 3px; font-weight: 700;
}
.node-pause-badge {
  font-size: 9px; background: #fef3c7; color: #d97706;
  padding: 1px 4px; border-radius: 3px; font-weight: 700;
}
.node-preview {
  padding: 4px 10px; font-size: 11px; color: #64748b;
  max-height: 36px; overflow: hidden;
}
.node-count {
  padding: 2px 10px 4px; font-size: 11px; font-weight: 600; color: #475569;
}
.node-btns { border-top: 1px solid #e2e8f0; }
.node-btn-label {
  padding: 3px 10px; font-size: 11px; color: #334155;
  border-bottom: 1px solid #f1f5f9;
}
.node-btn-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: #3b82f6; color: white; font-size: 8px; font-weight: 700;
  margin-right: 3px; flex-shrink: 0;
}
/* Output dots: hide numbers, keep dots small and clean */
.drawflow .drawflow-node .output[data-num] {
  position: relative;
}
.node-input-label { color: #10b981; font-style: italic; }

/* Start node (welcome) — green */
.node-start .node-card,
.node-card.node-start {
  border-color: #16a34a !important;
  border-width: 3px;
  box-shadow: 0 0 12px rgba(22, 163, 74, 0.25);
}
.node-start .node-header,
.node-card.node-start .node-header {
  background: #dcfce7;
}
.node-start-icon {
  color: #16a34a;
  font-weight: 700;
}

/* Finish nodes (terminal) — red */
.node-finish .node-card,
.node-card.node-finish {
  border-color: #dc2626 !important;
  border-width: 3px;
  box-shadow: 0 0 12px rgba(220, 38, 38, 0.2);
  background: #fff5f5;
}
.node-finish .node-header,
.node-card.node-finish .node-header {
  background: #fef2f2;
}
.node-finish-icon {
  font-size: 11px;
}

/* Telegram Preview */
.tg-preview {
  margin-top: 10px;
  padding: 14px;
  background: #e8dfd5;
  border-radius: 10px;
  max-width: 300px;
}
.tg-bubble {
  background: #dcf8c6;
  border-radius: 8px 8px 0 8px;
  padding: 8px 10px;
  position: relative;
  font-size: 13px;
  line-height: 1.5;
  color: #111;
  word-wrap: break-word;
}
.tg-bubble a { color: #5b9dff; text-decoration: underline; }
.tg-time {
  text-align: right;
  font-size: 10px;
  color: #8fad80;
  margin-top: 2px;
}
.tg-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.tg-btn {
  text-align: center;
  padding: 7px 12px;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #4ea4f6;
  cursor: default;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

/* Trace Path */
.node-traced .node-card {
  box-shadow: 0 0 0 3px #f59e0b, 0 4px 12px rgba(245, 158, 11, 0.3) !important;
  z-index: 5;
}
.drawflow .connection.connection-traced .main-path {
  stroke: #f59e0b !important;
  stroke-width: 3 !important;
  stroke-dasharray: 8 4;
  animation: traceDash 1s linear infinite;
}
@keyframes traceDash {
  to { stroke-dashoffset: -12; }
}

/* Minimap */
#minimap {
  position: absolute;
  bottom: 12px;
  right: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  cursor: crosshair;
  z-index: 10;
}

/* Right panel - properties */
.constructor-right {
  border-left: 1.5px solid var(--border);
  overflow-y: auto; background: #fafbfc;
}
.props-section { margin-bottom: 16px; }
.props-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.5px;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.form-label-sm { font-size: 11px; font-weight: 600; color: #475569; margin-bottom: 2px; display: block; }
.props-btn-row-wrap {
  margin-bottom: 6px;
}
.props-btn-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; background: white; border-radius: 6px; border: 1px solid var(--border);
}
.props-btn-row.has-data, .props-btn-row.has-tag {
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
}
.props-btn-row.has-data { border-bottom-color: #93c5fd; }
.props-btn-row.has-tag { border-bottom-color: #fbbf24; }
.props-btn-row.has-data.has-tag { border-bottom-color: #93c5fd; }
.props-btn-data-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 6px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-top: none;
}
.props-btn-data-row + .props-btn-tag-row { border-radius: 0 0 6px 6px; }
.props-btn-data-row:last-child { border-radius: 0 0 6px 6px; }
.props-btn-tag-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px 6px;
  background: #fefce8;
  border-radius: 0 0 6px 6px;
  border: 1px solid #fbbf24;
  border-top: none;
}
.tag-color-dots { display: flex; gap: 3px; }
.tag-dot {
  width: 14px; height: 14px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: border-color .15s;
}
.tag-dot:hover { opacity: .8; }
.tag-dot.active { border-color: #1e293b; }
.props-kv-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.props-screen-name-input {
  border: 1px solid transparent;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 2px 6px;
  width: 100%;
  border-radius: 6px;
  color: var(--text);
  transition: all .15s;
}
.props-screen-name-input:hover {
  background: #f0f4f8;
  border-color: var(--border);
}
.props-screen-name-input:focus {
  background: white;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 24px; width: 420px; max-width: 90vw;
}

/* Funnel selector */
.funnel-selector {
  display: flex;
  align-items: center;
  gap: 4px;
}
.funnel-selector select {
  font-weight: 500;
}
.btn-xs {
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 6px;
}

/* ── Validation ── */
.validation-badge {
  position: absolute;
  top: -6px; right: -6px;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.badge-error-bg { background: #ef4444; }
.badge-warning-bg { background: #f59e0b; }

.validation-summary-badge {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; padding: 4px 10px;
  border-radius: 6px; font-weight: 600;
}
.validation-summary-badge.badge-error { background: #fef2f2; color: #ef4444; }
.validation-summary-badge.badge-warning { background: #fffbeb; color: #f59e0b; }
.validation-summary-badge.badge-tip { background: #f0fdf4; color: #22c55e; }
.validation-summary-badge.badge-field { background: #f5f3ff; color: #8b5cf6; }
.badge-count { font-size: 14px; font-weight: 700; }

.validation-section { border-left: 3px solid; padding-left: 12px; margin-bottom: 16px; }

.validation-item {
  padding: 8px 12px; margin-bottom: 6px;
  background: var(--surface); border-radius: 6px;
  border: 1px solid #e2e8f0;
  transition: background .15s;
}
.validation-item:hover { background: #f8fafc; }
.validation-item-message { font-size: 13px; font-weight: 600; }
.validation-item-detail { font-size: 11px; color: #64748b; margin-top: 2px; }

.node-validation-highlight {
  animation: validationPulse 0.5s ease-in-out 3;
}
@keyframes validationPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,.3); }
}

/* ── Custom Fields D&D ── */
.drag-handle { cursor: grab; color: #94a3b8; margin-right: 4px; font-size: 14px; }
.custom-field-row { transition: background .15s, border-top .15s; border-top: 2px solid transparent; }
.custom-field-row.dragging { opacity: 0.4; background: #e0e7ff; }
.custom-field-row.drag-over { border-top: 2px solid var(--primary); }

.cf-delete-btn {
  opacity: 0; border: none; background: none; color: #ef4444;
  cursor: pointer; padding: 2px 4px; font-size: 12px; transition: opacity .15s;
  flex-shrink: 0;
}
.info-row:hover .cf-delete-btn { opacity: 0.7; }
.cf-delete-btn:hover { opacity: 1 !important; }

#addFieldForm {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 10px; margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 1100px) {
  .constructor-page { grid-template-columns: 180px 1fr 280px; }
}
@media (max-width: 800px) {
  .constructor-page { grid-template-columns: 1fr; height: auto; }
  .constructor-left, .constructor-right { border: none; }
}

/* ── FAB: Create Lead ── */
.fab-create-lead {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #22c55e;
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(34,197,94,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab-create-lead:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(34,197,94,0.5);
}
.fab-create-lead:active {
  transform: scale(0.95);
}
@media (max-width: 768px) {
  .fab-create-lead {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 22px;
  }
}
/* Modal overlay for create lead */
#createLeadModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Lead History Timeline ───────────────────────────────── */
.lead-history-timeline {
  padding: 8px 0;
  max-height: 300px;
  overflow-y: auto;
}
.history-item {
  display: flex;
  gap: 10px;
  padding: 6px 12px;
  position: relative;
}
.history-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 22px;
  bottom: -6px;
  width: 2px;
  background: #e2e8f0;
}
.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  margin-top: 6px;
  flex-shrink: 0;
}
.history-content {
  flex: 1;
  min-width: 0;
}
.history-action {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
}
.history-action i {
  margin-right: 4px;
}
.history-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 1px;
}

/* ── Phone duplicate warning ─────────────────────────────── */
.phone-dup-warning {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
  color: #92400e;
}
.phone-dup-warning .dup-lead-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #d97706;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.phone-dup-warning .dup-lead-link:hover {
  color: #b45309;
}

/* ── Manager role badges ─────────────────────────────────── */
.role-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.role-badge.role-admin { background: #dbeafe; color: #1e40af; }
.role-badge.role-social_manager { background: #fce7f3; color: #9d174d; }
.role-badge.role-showroom_manager { background: #d1fae5; color: #065f46; }

/* ── Showroom page ───────────────────────────────────────── */
.showroom-page { max-width: 720px; }
.showroom-page h2 { color: var(--text-primary); font-size: 22px; font-weight: 700; }

/* ── Analytics page ──────────────────────────────────────── */
.analytics-page h2 { color: var(--text-primary); font-size: 22px; font-weight: 700; }
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
}
.chart-bars { padding: 8px 0; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
}
.bar-label {
  width: 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  text-align: right;
}
.bar-track {
  flex: 1;
  height: 22px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}
.bar-value {
  width: 45px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  flex-shrink: 0;
}
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.analytics-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
.analytics-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.analytics-table tr:hover td {
  background: var(--bg-hover);
}
.conv-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #dcfce7;
  color: #16a34a;
  font-weight: 700;
  font-size: 12px;
}
.conv-bar-wrap {
  position: relative;
  height: 22px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}
.conv-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.conv-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}
