/* ── Reset & variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #050505;
  --surface:   #0d0d0d;
  --surface2:  #111;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --blue:      #0AACB8;
  --blue-dim:  rgba(10,172,184,0.12);
  --blue-glow: rgba(10,172,184,0.25);
  --green:     #4ADE80;
  --green-dim: rgba(74,222,128,0.12);
  --red:       #EF4444;
  --red-dim:   rgba(239,68,68,0.12);
  --orange:    #F97316;
  --orange-dim:rgba(249,115,22,0.12);
  --yellow:    #EAB308;
  --yellow-dim:rgba(234,179,8,0.12);
  --purple:    #A78BFA;
  --purple-dim:rgba(167,139,250,0.12);
  --text:      rgba(255,255,255,0.92);
  --muted:     rgba(255,255,255,0.4);
  --dim:       rgba(255,255,255,0.2);
  --mono:      'JetBrains Mono', 'Courier New', monospace;
  --sans:      -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --sidebar-w: 220px;
  --header-h:  52px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand .brand-icon {
  width: 28px; height: 28px;
  background: var(--blue-dim);
  border: 1px solid var(--blue-glow);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.sidebar-brand .brand-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

/* Send mode badge */
.mode-badge {
  margin: 10px 12px;
  padding: 6px 10px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s;
}
.mode-badge:hover { opacity: 0.8; }
.mode-badge.dry-run {
  background: var(--orange-dim);
  border: 1px solid rgba(249,115,22,0.35);
  color: var(--orange);
}
.mode-badge.live {
  background: var(--green-dim);
  border: 1px solid rgba(74,222,128,0.35);
  color: var(--green);
}

/* Cap meter */
.cap-meter {
  margin: 0 12px 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cap-meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 5px;
}
.cap-meter-label span { color: var(--text); font-weight: 600; }
.cap-bar-track {
  height: 4px;
  background: var(--border2);
  border-radius: 2px;
  overflow: hidden;
}
.cap-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--blue);
  transition: width 0.4s ease;
}
.cap-bar-fill.danger { background: var(--red); }
.cap-bar-fill.warn   { background: var(--orange); }

/* Nav */
.nav-section-label {
  padding: 10px 14px 4px;
  font-size: 10px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  border-radius: 0;
  font-size: 12.5px;
  font-weight: 500;
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
  user-select: none;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-link.active {
  color: var(--blue);
  background: var(--blue-dim);
  border-left-color: var(--blue);
}
.nav-link .nav-icon { font-size: 14px; width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--red-dim);
  color: var(--red);
  border-radius: 8px;
  padding: 1px 6px;
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 700;
}
.nav-badge.blue {
  background: var(--blue-dim);
  color: var(--blue);
}

.sidebar-bottom {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.run-btn {
  width: 100%;
  padding: 9px;
  background: var(--blue);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.3px;
}
.run-btn:hover { opacity: 0.9; }
.run-btn:active { transform: scale(0.98); }
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.run-btn.running { background: var(--orange); }

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

/* Top bar */
#topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  background: var(--surface);
}
.topbar-title {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
}
.topbar-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.refresh-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.refresh-btn:hover { color: var(--text); border-color: var(--blue); }

/* Content */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

/* ── Cards / Grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-card .stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--mono);
  line-height: 1;
  color: var(--text);
}
.stat-card .stat-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}
.stat-card.blue   .stat-value { color: var(--blue); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red    .stat-value { color: var(--red); }
.stat-card.purple .stat-value { color: var(--purple); }

/* Row of panels */
.panel-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) { .panel-row { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.panel-header .ph-icon { color: var(--blue); }
.panel-body { padding: 14px 16px; }

/* ── Funnel ────────────────────────────────────────────────────────────────── */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
}
.funnel-row:hover .funnel-bar-fill { filter: brightness(1.2); }
.funnel-state {
  width: 160px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.funnel-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.funnel-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--blue);
  transition: width 0.4s ease;
}
.funnel-count {
  width: 40px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.table-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
  margin-right: 4px;
}
.toolbar-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.table-toolbar .spacer { flex: 1; }

/* Inputs */
input[type=text], input[type=search], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input[type=text]:focus,
input[type=search]:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
}
input[type=search] { min-width: 200px; }
select { cursor: pointer; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }
.mono { font-family: var(--mono); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid var(--blue-glow); }
.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(74,222,128,0.25); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.badge-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(249,115,22,0.25); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(234,179,8,0.25); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(167,139,250,0.25); }
.badge-dim    { background: rgba(255,255,255,0.05); color: var(--muted); border: 1px solid var(--border); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.pagination .spacer { flex: 1; }
.page-btn {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  transition: color 0.12s, border-color 0.12s;
}
.page-btn:hover:not(:disabled) { color: var(--blue); border-color: var(--blue); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info { font-family: var(--mono); font-size: 11px; }

/* ── Run History ───────────────────────────────────────────────────────────── */
.run-row { display: flex; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.run-row:last-child { border-bottom: none; }
.run-date { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 85px; }
.run-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.run-stat { font-family: var(--mono); font-size: 11px; }
.run-stat.sent  { color: var(--green); }
.run-stat.skip  { color: var(--muted); }
.run-stat.fail  { color: var(--red); }
.run-stat.scrape { color: var(--blue); }

/* ── Log terminal ──────────────────────────────────────────────────────────── */
#log-terminal {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #a8ff78;
  height: calc(100vh - 140px);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
#log-terminal .log-warn  { color: var(--yellow); }
#log-terminal .log-error { color: var(--red); }
#log-terminal .log-info  { color: var(--blue); }
#log-terminal .log-dim   { color: rgba(255,255,255,0.3); }

.log-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.ws-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
}
.ws-indicator.connected { background: var(--green); }
.ws-status { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ── Suppression ───────────────────────────────────────────────────────────── */
.supp-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.supp-add-row input { flex: 1; }

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-blue   { background: var(--blue); color: #000; }
.btn-green  { background: var(--green); color: #000; }
.btn-red    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-dim    { background: rgba(255,255,255,0.06); color: var(--muted); border: 1px solid var(--border2); }

.supp-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 480px;
  overflow-y: auto;
}
.supp-entry {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  gap: 8px;
}
.supp-entry span { flex: 1; }
.supp-entry button {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.12s;
}
.supp-entry button:hover { opacity: 1; }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 780px;
}
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }

.setting-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.setting-key {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--blue);
  margin-bottom: 4px;
  font-weight: 700;
}
.setting-desc {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}
.setting-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.setting-input-row input, .setting-input-row select { flex: 1; }
.setting-save-btn {
  padding: 6px 12px;
  background: var(--blue-dim);
  border: 1px solid var(--blue-glow);
  color: var(--blue);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.setting-save-btn:hover { background: rgba(10,172,184,0.2); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
#modal-overlay.open { display: flex; }

#modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: min(900px, 95vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.modal-header h2 {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-top: -1px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }

/* Lead detail tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Key-value grid */
.kv-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
  font-size: 12px;
}
.kv-key { color: var(--muted); font-family: var(--mono); font-size: 11px; padding-top: 1px; }
.kv-val { color: var(--text); word-break: break-all; }
.kv-val a { color: var(--blue); text-decoration: none; }
.kv-val a:hover { text-decoration: underline; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 1px; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.timeline-item:last-child { border-bottom: none; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 3px; flex-shrink: 0; }
.tl-time { color: var(--muted); font-family: var(--mono); min-width: 130px; }
.tl-event { color: var(--blue); font-family: var(--mono); font-weight: 700; }
.tl-from { color: var(--muted); }
.tl-to { color: var(--green); }
.tl-action { color: var(--text); font-size: 10.5px; margin-top: 2px; }

/* Email body */
.email-body-wrap {
  background: #000;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.7;
}

/* ── Transition actions ─────────────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.action-btn {
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--mono);
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.action-btn:hover {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-dim);
}

/* ── Niche breakdown ────────────────────────────────────────────────────────── */
.niche-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
}
.niche-name { width: 130px; color: var(--muted); text-transform: capitalize; }
.niche-bar-track { flex: 1; height: 5px; background: var(--border); border-radius: 2.5px; overflow: hidden; }
.niche-bar-fill  { height: 100%; background: var(--blue); border-radius: 2.5px; }
.niche-count { width: 35px; text-align: right; font-family: var(--mono); color: var(--text); font-weight: 700; }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Empty / loading states ─────────────────────────────────────────────────── */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.loading {
  padding: 30px 20px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  font-family: var(--mono);
}

/* ── Toast ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.ok   { border-color: var(--green);  color: var(--green); }
#toast.err  { border-color: var(--red);    color: var(--red); }
#toast.info { border-color: var(--blue);   color: var(--blue); }
#toast.warn { border-color: #f59e0b;       color: #f59e0b; }

/* ── Nav label/desc ────────────────────────────────────────────────────────── */
.nav-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.nav-title {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-desc {
  font-size: 10px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.nav-link.active .nav-desc { color: rgba(10,172,184,0.6); }

/* ── AI Chat Widget ─────────────────────────────────────────────────────────── */
#chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--blue);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(10,172,184,0.4);
  z-index: 300;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}
#chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(10,172,184,0.55);
}
#chat-bubble.open { background: var(--surface2); color: var(--muted); box-shadow: none; }

#chat-panel {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 360px;
  height: 520px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  z-index: 299;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

#chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.chat-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
}
.chat-header-sub {
  font-size: 11px;
  color: var(--dim);
  flex: 1;
}
#chat-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
}
#chat-close:hover { color: var(--text); background: rgba(255,255,255,0.05); }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.chat-msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--blue-dim);
  border: 1px solid var(--blue-glow);
  color: var(--text);
  border-bottom-right-radius: 3px;
}
.chat-msg.ai {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 3px;
}
.chat-msg.ai.thinking {
  color: var(--muted);
  font-style: italic;
}

#chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 7px 10px;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}
#chat-input:focus { border-color: var(--blue); }
#chat-input::placeholder { color: var(--dim); }
#chat-send {
  width: 34px;
  height: 34px;
  background: var(--blue);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  align-self: flex-end;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chat-send:hover { opacity: 0.85; }
#chat-send:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Client Modal ────────────────────────────────────────────────────────────── */
#client-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
#client-modal-overlay.open { opacity: 1; pointer-events: all; }
#client-modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 680px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
#client-modal::-webkit-scrollbar { width: 4px; }
#client-modal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.cf-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.cf-section:last-child { border-bottom: none; }
.cf-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}
.cf-row {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
}
.cf-row:last-child { margin-bottom: 0; }
.cf-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cf-field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.cf-field input,
.cf-field select,
.cf-field textarea {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 7px 10px;
  outline: none;
  resize: vertical;
}
.cf-field input:focus,
.cf-field select:focus,
.cf-field textarea:focus { border-color: var(--blue); }
.cf-services {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.cf-service-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.cf-service-toggle:hover { border-color: var(--border2); }
.cf-service-toggle input[type=checkbox] { accent-color: var(--blue); width: 14px; height: 14px; }
.cf-service-toggle input:checked ~ .cf-svc-label { color: var(--blue); }
.cf-service-toggle:has(input:checked) {
  border-color: var(--blue-glow);
  background: var(--blue-dim);
}
.cf-svc-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; }
.cf-svc-icon { font-size: 15px; }
.cf-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 0 14px 14px;
}

/* ── Client table service badges ─────────────────────────────────────────────── */
.svc-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--blue-dim);
  color: var(--blue);
  margin: 1px;
  white-space: nowrap;
}
.svc-badge.off { background: transparent; color: var(--dim); border: 1px solid var(--border); }

/* ── Client stats panel ───────────────────────────────────────────────────────── */
.client-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.client-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.client-stat-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.client-stat-value { font-size: 22px; font-weight: 700; font-family: var(--mono); }
.csv-drop-zone {
  border: 2px dashed var(--border2);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-top: 8px;
}
.csv-drop-zone:hover { border-color: var(--blue); background: var(--blue-dim); color: var(--blue); }
.widget-snippet {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--green);
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Agents ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
