/* ============================================================
   NeverMiss CRM — Design System
   Light theme, clean Stripe/Notion aesthetic
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-light:  #eef2ff;
  --accent-text:   #4338ca;

  --bg-primary:    #ffffff;
  --bg-secondary:  #f8f9fb;
  --bg-tertiary:   #f1f3f6;

  --text-primary:  #111827;
  --text-secondary:#374151;
  --text-muted:    #6b7280;
  --text-faint:    #9ca3af;

  --border:        #e5e7eb;
  --border-strong: #d1d5db;

  --sidebar-width: 220px;
  --header-height: 56px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.14);

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;

  /* Stage colors */
  --cold:         #6b7280;
  --interested:   #f59e0b;
  --demo:         #3b82f6;
  --appt:         #8b5cf6;
  --closed:       #10b981;
  --dq:           #ef4444;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font: inherit; }
input, textarea, select { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

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

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.nav-section {
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent-text); font-weight: 600; }

.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-name { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.user-email { font-size: 11px; color: var(--text-muted); }

.btn-signout {
  width: 100%;
  margin-top: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  font-size: 12px;
  color: var(--text-muted);
  transition: all .15s;
}
.btn-signout:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }

/* ── Main content ───────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--header-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Panes ──────────────────────────────────────────────────── */
.pane { display: none; }
.pane.active { display: block; }

/* Pipeline: #content becomes a flex column so kanban fills remaining height */
#content.pipeline-mode {
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0; /* bottom padding handled by kanban-board */
}

/* Higher specificity than .pane.active { display: block } */
#content.pipeline-mode #pane-pipeline {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

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

.btn-ghost { background: none; color: var(--text-secondary); border: none; padding: 7px 10px; }
.btn-ghost:hover { background: var(--bg-secondary); color: var(--text-primary); }

.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 7px; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Cards / Stat boxes ─────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--bg-tertiary);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-Cold          { background: #f3f4f6; color: var(--cold); }
.badge-Interested    { background: #fffbeb; color: #b45309; }
.badge-Demo          { background: #eff6ff; color: #1d4ed8; }
.badge-Appointment   { background: #f5f3ff; color: #6d28d9; }
.badge-Closed        { background: #f0fdf4; color: #15803d; }
.badge-NewLeads      { background: #f3f4f6; color: #6b7280; }
.badge-Contacted     { background: #fffbeb; color: #b45309; }
.badge-Interested    { background: #fef3c7; color: #d97706; }
.badge-CallOnly      { background: #e0f2fe; color: #0369a1; }
.badge-DemoScheduled { background: #eff6ff; color: #1d4ed8; }
.badge-DemoDone      { background: #f5f3ff; color: #6d28d9; }
.badge-ClosedWon     { background: #f0fdf4; color: #15803d; }
.badge-ClosedLost    { background: #f9fafb; color: #6b7280; }
.badge-DQ            { background: #fef2f2; color: #dc2626; }

.badge-audit { background: #fef3c7; color: #92400e; font-size: 10px; padding: 1px 5px; border-radius: 10px; font-weight: 600; vertical-align: middle; }
.badge-A { background: #fef2f2; color: #dc2626; }
.badge-B { background: #fffbeb; color: #b45309; }
.badge-C { background: #f3f4f6; color: #6b7280; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-toolbar {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  padding: 7px 11px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 10px center no-repeat;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  width: 220px;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); background-color: var(--bg-primary); }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
thead th:hover { color: var(--text-primary); }
thead th.sort-asc::after  { content: ' ↑'; }
thead th.sort-desc::after { content: ' ↓'; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }

tbody td {
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}

.td-muted { color: var(--text-muted); font-size: 12.5px; }
.td-name  { font-weight: 600; }
.td-actions { display: flex; gap: 6px; }

/* Checkbox column */
.cb-col { width: 40px; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* Quick stage select in table */
.stage-select {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-primary);
  cursor: pointer;
  outline: none;
}
.stage-select:focus { border-color: var(--accent); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ── Kanban ─────────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.kanban-col {
  flex-shrink: 0;
  width: 240px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.kanban-col-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kanban-col-title::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.col-NewLeads .kanban-col-title::before           { background: #6b7280; }
.col-ReadyforOutreach .kanban-col-title::before   { background: #10b981; }
.col-Contacted .kanban-col-title::before          { background: #b45309; }
.col-Interested .kanban-col-title::before          { background: #d97706; }
.col-DemoScheduled .kanban-col-title::before      { background: #1d4ed8; }
.col-DemoDone .kanban-col-title::before           { background: #6d28d9; }
.col-ClosedWon .kanban-col-title::before          { background: #15803d; }
.col-ClosedLost .kanban-col-title::before         { background: #6b7280; }
.col-DQ .kanban-col-title::before                 { background: #dc2626; }

.kanban-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 99px;
}

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  min-height: 60px;
}

.kanban-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  position: relative;
}

.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card.dragging { opacity: .5; box-shadow: var(--shadow-lg); }

.kanban-card-name { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.kanban-card-contact { font-size: 12px; color: var(--text-muted); margin-bottom: 7px; }

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card-date {
  font-size: 11px;
  color: var(--text-faint);
}

.kanban-col.drag-over { background: var(--accent-light); border: 2px dashed var(--accent); }

/* ── Lead Detail Panel (slide from right) ───────────────────── */
#leadPanel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow: hidden;
}

#leadPanel.open { transform: translateX(0); }

#leadOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.2);
  z-index: 99;
  display: none;
}
#leadOverlay.visible { display: block; }

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-close {
  background: none;
  border: none;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  transition: background .15s;
}
.panel-close:hover { background: var(--bg-secondary); color: var(--text-primary); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.panel-section {
  margin-bottom: 24px;
}

.panel-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

/* Sequence day toggles */
.seq-days { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seq-day {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all .15s;
}

.seq-day.sent {
  background: #f0fdf4;
  border-color: #86efac;
}

.seq-day-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.seq-day-ts    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.seq-day-check { color: #16a34a; font-size: 16px; margin-left: auto; }

/* Notes */
.note-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.note-ts { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.add-note-row { display: flex; gap: 8px; margin-top: 10px; }
.add-note-input {
  flex: 1;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}
.add-note-input:focus { border-color: var(--accent); }

/* ── Add Lead Modal ─────────────────────────────────────────── */
#addLeadModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
#addLeadModal.visible { display: flex; }

.modal-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); padding: 2px 6px; }
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ── Filter tabs ────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  width: fit-content;
  margin-bottom: 16px;
}

.filter-tab {
  padding: 5px 14px;
  border-radius: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all .15s;
}
.filter-tab.active { background: var(--bg-primary); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }

/* ── Phase 1 Progress ───────────────────────────────────────── */
.phase-card {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  color: #fff;
  margin-bottom: 24px;
}

.phase-label { font-size: 11.5px; font-weight: 700; opacity: .75; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.phase-title { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.phase-bar-bg { background: rgba(255,255,255,.25); border-radius: 99px; height: 10px; overflow: hidden; }
.phase-bar-fill { background: #fff; height: 100%; border-radius: 99px; transition: width .6s ease; }
.phase-detail { font-size: 12px; opacity: .8; margin-top: 10px; }

/* ── Today's actions ────────────────────────────────────────── */
.action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.action-item:last-child { border-bottom: none; }
.action-biz { font-weight: 600; font-size: 13.5px; }
.action-meta { font-size: 12px; color: var(--text-muted); }
.action-type { font-size: 12px; color: var(--accent); font-weight: 600; }
.action-phone a { color: var(--text-secondary); font-size: 12px; }

/* ── Scripts ────────────────────────────────────────────────── */
.scripts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.script-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}

.script-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.script-textarea {
  width: 100%;
  min-height: 160px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color .15s;
}
.script-textarea:focus { border-color: var(--accent); background: var(--bg-primary); }
.script-saved { font-size: 11px; color: #16a34a; }

/* ── Tasks ──────────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.task-item:hover { background: var(--bg-secondary); }
.task-item:last-child { border-bottom: none; }

.task-text {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
}
.task-text.done {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 2px;
  font-size: 14px;
  opacity: 0;
  transition: opacity .15s;
}
.task-item:hover .task-delete { opacity: 1; }
.task-delete:hover { color: #dc2626; }

/* ── Notifications ──────────────────────────────────────────── */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #fafaff; }
.notif-item.unread .notif-dot { background: var(--accent); }

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  margin-top: 5px;
}

.notif-msg { font-size: 13.5px; color: var(--text-primary); line-height: 1.5; }
.notif-time { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ── Sequences page ─────────────────────────────────────────── */
.seq-progress {
  display: flex;
  gap: 6px;
  align-items: center;
}

.seq-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.seq-dot.done { background: #16a34a; border-color: #16a34a; color: #fff; }
.seq-dot:not(.done):hover { border-color: var(--accent); color: var(--accent); }

/* ── Calendar ───────────────────────────────────────────────── */
.overdue-row { background: #fffbeb !important; }
.overdue-row:hover { background: #fef3c7 !important; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  #sidebar { display: none; }
  #leadPanel { width: 100%; }
  .scripts-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  #content.pipeline-mode { overflow-y: auto; display: block; }
  #content.pipeline-mode #pane-pipeline { flex: none; overflow: visible; }
  .kanban-board { flex: none; min-height: calc(100vh - 160px); align-items: flex-start; overflow-y: visible; padding-bottom: 80px; }
  .kanban-col { overflow: visible; }
  .kanban-cards { flex: none; overflow-y: visible; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: 4px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.ml-auto { margin-left: auto; }
.fw-600 { font-weight: 600; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row td { text-align: center; padding: 40px; color: var(--text-muted); }

/* Toast notification */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #dc2626; }

/* Pipeline section header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── SMYKM Indicator Dot ─────────────────────────────────── */
.smykm-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5e7eb;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: default;
  transition: background 0.15s;
}
.smykm-dot--yes {
  background: #22c55e;
}

/* ── Email Thread ────────────────────────────────────────── */
.email-thread-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0 8px;
  margin-bottom: 16px;
}

.email-thread-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
  font-style: italic;
}

/* Base bubble */
.email-bubble {
  max-width: 88%;
  border-radius: var(--radius-md);
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.55;
}

/* Outbound (right-aligned, accent) */
.email-bubble-out {
  align-self: flex-end;
  background: var(--accent-light);
  border: 1px solid #c7d2fe;
  color: var(--text-primary);
}

/* Inbound (left-aligned, neutral) */
.email-bubble-in {
  align-self: flex-start;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
}

/* Draft (dashed border override) */
.email-bubble-draft {
  border-style: dashed;
  opacity: 0.8;
}

.email-bubble-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.email-bubble-from {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
}

.email-bubble-badge {
  font-size: 11px;
  background: rgba(99,102,241,.12);
  color: var(--accent-text);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 500;
}

.email-bubble-draft-tag {
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 500;
}

.email-bubble-subject {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.email-bubble-body {
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.email-bubble-ts {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 5px;
  text-align: right;
}

.email-bubble-in .email-bubble-ts {
  text-align: left;
}

/* Compose area */
.email-compose {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.email-compose-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

/* ── Messaging Pane ─────────────────────────────────────── */
.messaging-layout {
  display: flex;
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.messaging-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.messaging-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.messaging-sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.msg-conv-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}

.msg-conv-item:hover  { background: var(--bg-secondary); }
.msg-conv-item.active { background: var(--accent-light); }

.msg-conv-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-conv-inbound-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.msg-conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

.msg-conv-time {
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-conv-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 7px;
}

.messaging-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.messaging-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 8px;
  text-align: center;
  padding: 40px;
}

.messaging-empty-icon {
  font-size: 42px;
  opacity: .4;
  margin-bottom: 8px;
}

.messaging-thread-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.messaging-thread-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.messaging-thread-header-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.messaging-thread-header-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.messaging-thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Override email-thread-list scroll within messaging panel */
.messaging-thread-body .email-thread-list {
  max-height: none;
  overflow: visible;
}

#pane-messaging,
#pane-sms {
  height: 100%;
  padding: 0;
  overflow: hidden;
}

/* ── Messaging pane sub-tabs (Email | SMS) ───────────── */
.msg-pane-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.msg-pane-tab {
  padding: 7px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.msg-pane-tab.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.msg-pane-tab:hover:not(.active) { color: var(--text-primary); }

/* ── Lead panel message toggle (Email | SMS) ─────────── */
.panel-msg-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.panel-msg-tab {
  padding: 4px 12px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.panel-msg-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.sms-empty-icon { font-size: 42px; margin-bottom: 12px; }

.sms-inbound-badge {
  display: inline-block;
  padding: 2px 7px;
  background: #dcfce7;
  color: #15803d;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.sms-conv-item {}

/* ── SMS Thread ──────────────────────────────────────── */
.sms-thread-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sms-bubble-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sms-bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 72%;
}

.sms-bubble-row--out {
  align-self: flex-end;
  align-items: flex-end;
}

.sms-bubble-row--in {
  align-self: flex-start;
  align-items: flex-start;
}

.sms-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.sms-bubble--out {
  background: #1d9bf0;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.sms-bubble--in {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.sms-bubble-time {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  padding: 0 4px;
}

.sms-status-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  vertical-align: middle;
}

/* ── SMS Compose ─────────────────────────────────────── */
.sms-compose {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.sms-compose-input {
  flex: 1;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  outline: none;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-secondary);
  transition: border-color .15s;
}
.sms-compose-input:focus { border-color: var(--accent); background: var(--bg-primary); }

/* ── Campaign Analytics Pane ────────────────────────── */
.stats-wrap { padding: 24px; max-width: 900px; }

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.stats-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.stats-controls { display: flex; gap: 8px; align-items: center; }

.analytics-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 3px;
}
.analytics-tab {
  padding: 5px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s;
}
.analytics-tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stats-summary-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  min-width: 110px;
  flex: 1;
}

.stat-card.delivered     { border-top: 3px solid #a3a3a3; }
.stat-card.opened        { border-top: 3px solid #22c55e; }
.stat-card.clicked       { border-top: 3px solid #3b82f6; }
.stat-card.bounced       { border-top: 3px solid var(--dq); }
.stat-card.audit-opened  { border-top: 3px solid #e8a04a; }

.stat-val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-pct {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.stats-table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stats-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.stats-table tr:hover td { background: var(--bg-secondary); }

.tbl-pct {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

.stats-loading,
.stats-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Engagement Badges (email thread bubbles) ────────── */
.engage-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

.engage-badge.opened    { background: #dcfce7; color: #166534; }
.engage-badge.clicked   { background: #dbeafe; color: #1e40af; }
.engage-badge.delivered { background: var(--bg-tertiary); color: var(--text-muted); }

/* ── Print / PDF export ──────────────────────────────── */
@media print {
  body > *:not(#docViewerModal) { display: none !important; }
  #docViewerModal {
    display: block !important;
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  #docViewerBox {
    box-shadow: none !important;
    max-height: none !important;
    border-radius: 0 !important;
  }
  #docViewerPrint { display: none !important; }
}
