/* ============================================================
 * Dispatch AI — styles.css (SMB CRM app)
 * ============================================================ */

:root {
  --bg: #f6f7fb;
  --bg-tint: #fafbff;
  --surface: #ffffff;
  --border: #e6e8ef;
  --border-soft: #f1f3f9;
  --text: #1a1d29;
  --text-muted: #6b7180;
  --text-soft: #93989f;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --brand-dark: #4338ca;
  --warn: #f59e0b;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --success: #059669;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --info-bg: #dbeafe;
  --info-text: #1e40af;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 20px 40px rgba(16, 24, 40, 0.08), 0 6px 12px rgba(16, 24, 40, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.center { text-align: center; }

/* App shell */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #d0d4dc; border-radius: 3px; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 6px; }
.brand-mark { width: 36px; height: 36px; background: var(--brand); color: #fff; font-weight: 800; border-radius: 8px; display: grid; place-items: center; letter-spacing: 0.5px; font-size: 17px; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; }
.nav a:hover { background: var(--border-soft); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-ico { font-size: 13px; width: 18px; display: inline-block; text-align: center; opacity: 0.8; }
.nav-badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 7px; min-width: 18px; text-align: center; }
.nav-section { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); padding: 14px 12px 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.sidebar-footer { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px; font-size: 12px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { color: var(--text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-link { background: transparent; border: 0; color: var(--text-muted); padding: 8px; font-size: 12px; text-align: left; width: 100%; }
.btn-link:hover { color: var(--danger); }
.main { padding: 28px 32px; max-width: 1400px; }

/* View headers */
.view-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.view-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.view-head p { margin: 0; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { background: var(--bg-tint); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--surface); border-color: #fca5a5; color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-lg { padding: 11px 18px; font-size: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 6px; width: 28px; height: 28px; font-size: 13px; color: var(--text-muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--border-soft); color: var(--text); }

/* Cards / grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card h2 { margin: 0 0 14px; font-size: 16px; }
.card h3 { margin: 14px 0 8px; font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi-grid.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-label { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-sub { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.kpi.warn { border-color: var(--warn); background: linear-gradient(0deg, var(--warn-bg) 0%, var(--surface) 60%); }
.kpi.warn .kpi-value { color: var(--warn-text); }
.kpi.success { border-color: var(--success); background: linear-gradient(0deg, var(--success-bg) 0%, var(--surface) 60%); }
.kpi.success .kpi-value { color: var(--success-text); }

.section-h { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 18px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.section-h .small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-soft); }

/* Lists / rows */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; cursor: pointer; gap: 12px; }
.list-row:hover { background: var(--bg-tint); }
.row-title { font-weight: 600; }
.row-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.row-flex { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Pills / badges */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--border-soft); color: var(--text); font-size: 11px; font-weight: 600; }
.pill-warn { background: var(--warn-bg); color: var(--warn-text); }
.pill-success { background: var(--success-bg); color: var(--success-text); }

/* Lead status badges */
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--border-soft); color: var(--text); }
.status-new { background: var(--brand-soft); color: var(--brand-dark); }
.status-researched { background: #f1f5f9; color: #475569; }
.status-contacted { background: var(--info-bg); color: var(--info-text); }
.status-follow-up { background: #fed7aa; color: #9a3412; }
.status-replied { background: var(--success-bg); color: var(--success-text); }
.status-meeting { background: #cffafe; color: #155e75; }
.status-won { background: var(--success-bg); color: var(--success-text); }
.status-lost { background: var(--danger-bg); color: var(--danger-text); }
.status-not-interested { background: #f3f4f6; color: #4b5563; }

/* Job status badges */
.job-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.job-status-scheduled { background: var(--brand-soft); color: var(--brand-dark); }
.job-status-in_progress { background: #fef3c7; color: var(--warn-text); }
.job-status-complete { background: #d1fae5; color: var(--success-text); }
.job-status-invoiced { background: var(--info-bg); color: var(--info-text); }
.job-status-paid { background: #cffafe; color: #155e75; }
.job-status-cancelled { background: var(--border-soft); color: var(--text-muted); }

.status-select { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 12px; max-width: 180px; }
.link { color: var(--brand); font-size: 12px; font-weight: 500; }
.link-strong { background: transparent; border: 0; color: var(--brand); padding: 0; font-weight: 600; font-size: 13px; cursor: pointer; text-align: left; }
.link-strong:hover { text-decoration: underline; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; }
.toolbar input[type="search"] { flex: 1; min-width: 240px; }

/* Table */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: var(--bg-tint); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; position: sticky; top: 0; }
.table tr:hover td { background: var(--bg-tint); }
.table .notes-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
.actions-cell { display: flex; gap: 6px; }
.num-cell { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Forms */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted); gap: 6px; }
.form label.full { grid-column: 1 / -1; }
.form input, .form select, .form textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; color: var(--text); font-family: inherit; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.lbl { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 0 6px; }
textarea, input[type="date"], input[type="datetime-local"] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; width: 100%; font-family: inherit; }

/* Modal — wider, no internal scroll, balanced grid
   Backdrop scrolls instead of the inner modal so users see everything in one
   continuous read. Width grows comfortably to 1080px on big screens, with a
   small horizontal padding so the modal still has breathing room. */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 18, 30, 0.4);
  z-index: 100;
  overflow-y: auto;
  padding: 40px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: min(1080px, 100%);
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  margin: auto 0;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.modal-head h2 { margin: 0 0 4px; font-size: 22px; }
.modal-head p { margin: 0; }
.modal-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.modal-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
.block { margin-bottom: 18px; }
.block.highlight { background: var(--brand-soft); border: 1px solid #c7d2fe; border-radius: 10px; padding: 12px 14px; }
.block h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 8px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--text-muted); }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1a1d29; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 200; }
.toast[hidden] { display: none; }

/* Client cards */
.client-card-meta { display: flex; gap: 14px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.lifetime-revenue { font-weight: 700; color: var(--success-text); font-variant-numeric: tabular-nums; }

/* Job timeline */
.job-detail-amount { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.job-timeline { display: flex; flex-direction: column; gap: 10px; }
.job-timeline-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.job-timeline-row b { color: var(--text); }
.job-timeline-row .timeline-time { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ============================================================
 * Admin-only elements — hidden unless body has .is-admin
 * Triple-layered (HTML attribute, inline style, this CSS rule)
 * so a non-admin never sees admin UI even if JS fails to run.
 * ============================================================ */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: flex !important; }

/* ============================================================
 * Internal workspace — visual rebrand when at internal.dispatch-cs.com
 * Subtle accent color change so you instantly know which app you're in.
 * Same triple-lock as admin elements: hidden by default, revealed only
 * when body has .is-internal-eligible (set by JS after IS_INTERNAL check).
 * ============================================================ */
.internal-only { display: none !important; }
body.is-internal-eligible .internal-only { display: flex !important; }

/* When fully in internal mode, shift the brand accent so it's visually distinct */
body.is-internal .brand-mark {
  background: var(--success);
}
body.is-internal .nav a.active {
  background: var(--success-bg);
  color: var(--success-text);
}
body.is-internal .brand-sub {
  color: var(--success);
  font-weight: 600;
}

/* ============================================================
 * Preview / paywall banner — shown above content area
 * ============================================================ */
.preview-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}
.preview-banner[data-tone="preview"] { background: var(--brand-soft); color: var(--text); }
.preview-banner[data-tone="warn"]    { background: var(--warn-bg);  color: var(--warn-text); }
.preview-banner[data-tone="muted"]   { background: var(--border-soft); color: var(--text-muted); }
.preview-banner b { font-weight: 700; }
.banner-cta {
  font-weight: 700;
  color: var(--brand);
  white-space: nowrap;
  text-decoration: none;
}
.banner-cta:hover { text-decoration: underline; }
.preview-banner[data-tone="warn"]  .banner-cta { color: var(--warn-text); }
.preview-banner[data-tone="muted"] .banner-cta { color: var(--text); }

/* ============================================================
 * Upgrade modal — two-card layout for self-serve vs custom
 * ============================================================ */
.upgrade-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0 6px;
}
.upgrade-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upgrade-card-alt { background: var(--bg-tint); }
.upgrade-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  margin-bottom: 4px;
}
.upgrade-card-alt .upgrade-tag { color: var(--text-muted); }
.upgrade-card h3 { margin: 0; font-size: 16px; }
.upgrade-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 4px 0 2px;
}
.upgrade-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.upgrade-period {
  font-size: 13px;
  color: var(--text-muted);
}
.upgrade-btn { margin-top: auto; }

@media (max-width: 700px) {
  .upgrade-options { grid-template-columns: 1fr; }
}

/* ============================================================
 * Paywall modal body
 * ============================================================ */
.paywall-body { padding: 16px 4px; }
.paywall-body p { font-size: 15px; line-height: 1.5; margin: 0 0 12px; }
.paywall-points {
  list-style: none;
  padding: 0;
  margin: 14px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.paywall-points li {
  position: relative;
  padding-left: 24px;
  font-size: 13.5px;
  color: var(--text);
}
.paywall-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--success);
  font-weight: 700;
}
.paywall-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ============================================================
 * Pills (extra variants)
 * ============================================================ */
.pill-muted { background: var(--border-soft); color: var(--text-muted); }

/* ============================================================
 * Automations page
 * ============================================================ */
.auto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.auto-card { display: flex; flex-direction: column; gap: 12px; }
.auto-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.auto-card-head h2 { margin: 0; font-size: 16px; }
.auto-trigger { margin: 0; font-size: 13px; color: var(--text-muted); }
.auto-trigger b { color: var(--text); font-weight: 600; }
.auto-steps { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.auto-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-tint);
}
.auto-step-meta { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.auto-step-subject { font-weight: 600; margin: 4px 0 6px; font-size: 13px; }
.auto-step-body {
  margin: 0;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.5;
}

/* ============================================================
 * CSV/XLS import modal — column mapping table
 * ============================================================ */
.import-step { padding: 14px 4px; }
.import-map {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 13px;
}
.import-map th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.import-map td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.import-map select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
}
.combined-mapping {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.combined-mapping > .muted { font-size: 11px; }

/* ============================================================
 * Segmented toggle (Business / Residential on Generate Leads)
 * ============================================================ */
.seg-toggle {
  display: inline-flex;
  background: var(--border-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 0;
}
.seg-btn {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.seg-active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
 * Sales Pipeline — Kanban board
 * ============================================================ */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.pipeline-col {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.pipeline-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.pipeline-col-head h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text); }
.pipeline-col-count {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.pipeline-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.pipeline-empty { text-align: center; margin: 24px 0; }

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.1s ease, box-shadow 0.1s ease, transform 0.05s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pipeline-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }
.pipeline-card:active { transform: scale(0.99); }

.pipeline-card-title { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.pipeline-card-sub { font-size: 12px; color: var(--text-muted); }
.pipeline-card-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
}
.pipeline-card-seq { color: var(--text-muted); }
.pipeline-card-progress { color: var(--brand); font-weight: 600; }

.pipeline-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-soft);
  font-size: 11px;
}
.pipeline-card-age { color: var(--text-muted); }
.pipeline-card-next { color: var(--text); font-weight: 600; }

/* Age color-coding — left border accent */
.pipeline-card.age-fresh { border-left: 3px solid var(--success); }
.pipeline-card.age-warm  { border-left: 3px solid var(--warn); }
.pipeline-card.age-cold  { border-left: 3px solid var(--danger); }

@media (max-width: 1100px) {
  .pipeline-board {
    grid-template-columns: repeat(3, minmax(240px, 1fr));
  }
}
@media (max-width: 700px) {
  .pipeline-board {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
 * Message history timeline (lead modal)
 * ============================================================ */
.msg-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  background: var(--bg-tint);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.msg-row-date {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.msg-row-subject { font-size: 13px; font-weight: 600; line-height: 1.3; }
.msg-row-meta    { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.msg-row-status  { padding-top: 1px; }

/* ============================================================
 * Send Queue page
 * ============================================================ */
.queue-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 32px; }
.queue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.queue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.queue-template { font-weight: 700; font-size: 15px; color: var(--text); }
.queue-meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.queue-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.queue-preview {
  background: var(--bg-tint);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
}
.queue-to, .queue-subject { margin-bottom: 6px; color: var(--text); }
.queue-to b, .queue-subject b { color: var(--text-muted); font-weight: 600; }
.queue-body {
  margin: 6px 0 0;
  font-family: inherit;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text);
  line-height: 1.55;
  font-size: 13px;
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
}
.btn-ghost:hover { background: var(--border-soft); color: var(--text); }

/* Responsive */
@media (max-width: 1100px) {
  .kpi-grid, .kpi-grid.kpi-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .auto-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: column; }
  .main { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
}

/* ── Edit & Send + Template editor (in-house compose) ── */
.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); font-size: 13px; color: var(--text); font-family: inherit;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }
textarea.input { resize: vertical; }
.input-sm { padding: 5px 8px; font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-field input { width: auto; }
.editsend-body, .tmpl-editor-body { max-height: 70vh; overflow-y: auto; padding: 4px 2px; }

.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tmpl-step { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.tmpl-step-head { display: flex; align-items: center; gap: 12px; }
.tmpl-step-head .field-label { flex: 1; }

.auto-card-head-actions { display: flex; align-items: center; gap: 8px; }
