/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Warm Premium palette — terracotta accent on warm ivory paper */
  --primary: #A14E22; /* deep terracotta — passes AA text (4.5:1) on paper */
  --primary-hover: #8F4420;
  --primary-light: #F6E7DC;
  --bg: #FBF7F0;
  --bg-subtle: #F4EDE2;
  --surface: #FFFDF9;
  --border: #E7DDD0;
  --border-strong: #D8CBB8;
  --text: #211C16;
  --text-muted: #6E655A;
  --text-subtle: #736455; /* warm-muted — AA contrast on paper */
  --success: #4E7B4D;
  --error: #C0492F;
  --warning: #94610E; /* deep amber — AA text on paper */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 1px 2px rgba(33,28,22,0.04), 0 2px 8px rgba(33,28,22,0.05);
  --shadow-md: 0 6px 24px rgba(33,28,22,0.07), 0 2px 6px rgba(33,28,22,0.04);
  --shadow-lg: 0 18px 50px rgba(33,28,22,0.10), 0 4px 12px rgba(33,28,22,0.06);
  --transition: 0.15s ease;
  --success-light: #EAF2E8;
  --warning-light: #FBF3E0;
  --error-light: #F8E9E4;
  --info: #3E6B96;
  --info-light: #EAF1F7;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] #app-header {
  background: rgba(28,24,20,0.92);
}

[data-theme="dark"] {
  --primary: #D98A55;
  --primary-hover: #E09968;
  --primary-light: #3A2A1F;
  --bg: #1A1611;
  --bg-subtle: #221C15;
  --surface: #262019;
  --border: #3A322A;
  --border-strong: #4A4036;
  --text: #F3ECE2;
  --text-muted: #B6A99A;
  --text-subtle: #9A8C7A;
  --success: #7FB07C;
  --error: #E0785E;
  --warning: #E0BC5E;
  --shadow: 0 1px 3px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4);
  --success-light: #1C2A1A;
  --warning-light: #2A2113;
  --error-light: #2E1A14;
  --info: #7FA8CC;
  --info-light: #12202E;
}

/* Warm Premium: serif display headings */
h1, h2, h3, h4, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.logo-text, .brand { font-family: var(--serif); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1;
  transition: all var(--transition);
  margin-left: 6px;
}
.theme-toggle:hover { background: var(--bg-subtle); border-color: var(--border-strong); }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────── */
#app-header {
  background: rgba(255,255,255,0.92);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text);
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: #fbf1e9;
  color: var(--primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-btn {
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: -0.1px;
  position: relative;
}

.nav-btn:hover { background: var(--primary-light); color: var(--primary); }
.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(16,185,129,0.3);
}
.nav-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--error);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface);
}

.sort-th {
  background: none;
  border: none;
  padding: 0;
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition);
}
.sort-th:hover { color: var(--primary); }

/* ── Main Content ────────────────────────────────────────────────── */
#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
  line-height: 1.5;
}

/* ── Form Elements ───────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input::placeholder, textarea::placeholder { color: var(--text-subtle); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: -0.1px;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  box-shadow: 0 1px 4px rgba(16,185,129,0.25), 0 0 0 1px rgba(16,185,129,0.1);
}
.btn-primary:hover {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-hover) 100%);
  box-shadow: 0 3px 10px rgba(16,185,129,0.35), 0 0 0 1px rgba(16,185,129,0.15);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(16,185,129,0.2); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 1px 4px rgba(16,185,129,0.25);
}
.btn-success:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-danger {
  background: var(--error);
  color: #fff;
  box-shadow: 0 1px 4px rgba(239,68,68,0.25);
}
.btn-danger:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 15px;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Input Section ───────────────────────────────────────────────── */
.url-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.url-input-row input {
  flex: 1;
}

.input-sources {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #fbf1e9;
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

/* ── Loading ─────────────────────────────────────────────────────── */
.loading-screen {
  text-align: center;
  padding: 80px 20px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-right-color: rgba(16,185,129,0.4);
  border-right-color: color-mix(in srgb, var(--primary) 40%, transparent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.loading-subtext {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ── Review Screen ───────────────────────────────────────────────── */
.review-section {
  margin-bottom: 24px;
}

.review-section h3 {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.services-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.service-item input,
.service-item textarea {
  background: var(--surface);
}

.trust-signals-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trust-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
}

.trust-tag button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
}

/* ── Preview Screen ──────────────────────────────────────────────── */
.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.viewport-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.viewport-btn {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.viewport-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.preview-frame-wrapper {
  background: #e2e8f0;
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  justify-content: center;
  min-height: 600px;
  transition: all 0.3s;
}

.preview-frame-wrapper iframe {
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: #fff;
  width: 100%;
  height: 800px;
  transition: width 0.3s;
}

.preview-frame-wrapper.mobile iframe {
  width: 375px;
  box-shadow: var(--shadow-lg);
}

.share-link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: #fbf1e9;
  border: 1px solid rgba(161,78,34,0.22);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.share-link-box input {
  flex: 1;
  border-color: rgba(161,78,34,0.22);
}

.expiry-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
}

.expiry-badge.expiry-urgent {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}

/* ── Client Log ──────────────────────────────────────────────────── */
.client-table {
  width: 100%;
  border-collapse: collapse;
}

.client-table th,
.client-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.client-table thead {
  position: sticky;
  top: 64px;
  z-index: 5;
}

.client-table thead tr {
  border-bottom: 2px solid var(--border);
}

.client-table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.client-table tbody tr {
  transition: background var(--transition);
}

.client-table tbody tr:hover {
  background: var(--primary-light);
}

[data-theme="dark"] .client-table tbody tr:hover {
  background: rgba(16,185,129,0.08);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.empty-table-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 32px !important;
  font-size: 14px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.sent { background: #dbeafe; color: #1d4ed8; }
.status-badge.viewed { background: #fef3c7; color: #92400e; }
.status-badge.sold { background: #d1fae5; color: var(--primary); }
.status-badge.draft { background: #f1f5f9; color: #475569; }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #fbf1e9;
  color: var(--primary);
  border: 1px solid rgba(161,78,34,0.22);
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 40px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
  display: block;
  opacity: 0.8;
}
.empty-state-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-state p {
  max-width: 360px;
  margin: 0 auto 20px;
  line-height: 1.7;
  font-size: 14px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0 16px; }
  #app { padding: 20px 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .service-item { grid-template-columns: 1fr; }
  .preview-controls { flex-direction: column; align-items: stretch; }
  .url-input-row { flex-direction: column; }
  /* Tables scroll horizontally; thead cannot be sticky inside overflow-x:auto */
  .client-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lead-analytics { flex-direction: column; gap: 6px; }
  .filter-row input { max-width: 100%; }
  .inline-action-row { flex-direction: column; align-items: stretch; }
  .preview-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 480px) {
  .modal-box { padding: 20px; }
  .confirm-box { padding: 20px; width: calc(100% - 24px); }
  .card { padding: 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn-group { gap: 6px; }
}


/* ── Toast Notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out, toastOut 0.2s ease-in forwards;
  animation-delay: 0s, 3s;
  max-width: 360px;
  line-height: 1.4;
  letter-spacing: -0.1px;
}

.toast-success { background: #5b3a22; color: #fbf1e9; border-left: 3px solid var(--success); }
.toast-error   { background: #7f1d1d; color: #fef2f2; border-left: 3px solid var(--error); }
.toast-info    { background: #1e3a8a; color: #eff6ff; border-left: 3px solid #60a5fa; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(32px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(32px); }
}

/* ── Loading Enhancements ────────────────────────────────────────── */
.loading-elapsed {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 16px;
  font-variant-numeric: tabular-nums;
}

/* ── Skeleton Loading ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.skeleton-h { height: 12px; margin-bottom: 8px; }
.skeleton-h-lg { height: 32px; margin-bottom: 10px; }
.skeleton-w-1\/2 { width: 50%; }
.skeleton-w-2\/3 { width: 66%; }
.skeleton-w-full { width: 100%; }

/* ── Preview Business Header ─────────────────────────────────────── */
.preview-biz-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  flex-wrap: wrap;
}
.preview-biz-location {
  color: var(--text-muted);
  font-size: 12px;
}
.preview-biz-industry {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ── Stale Banner Dismiss ─────────────────────────────────────────── */
.stale-banner { position: relative; padding-right: 36px; }
.stale-banner-close {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition);
}
.stale-banner-close:hover { color: var(--text); }

/* ── Preview Link Cell ────────────────────────────────────────────── */
.preview-link-cell {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.preview-link-cell:hover { text-decoration: underline; }

/* ── Preview Enhancements ────────────────────────────────────────── */
.preview-tools-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ── Character Count ─────────────────────────────────────────────── */
.char-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 4px;
}

.char-count.warn { color: var(--warning); }
.char-count.good { color: var(--success); }

/* ── Example Data Button ─────────────────────────────────────────── */
.example-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.example-chip {
  padding: 5px 12px;
  background: #fbf1e9;
  color: var(--primary);
  border: 1px solid rgba(161,78,34,0.22);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.example-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.status-select {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
}
.status-select:hover { border-color: var(--border-strong); }
.status-select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px rgba(16,185,129,0.15); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 15%, transparent); }

/* ── Dashboard stats ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card-icon {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend-up { color: var(--success); }
.stat-trend-neutral { color: var(--text-muted); }

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  line-height: 1.5;
}

/* Color accent variants — set as inline style: --card-accent */
.stat-card-blue  { border-top: 3px solid #4A7BA6; }
.stat-card-green { border-top: 3px solid var(--success); }
.stat-card-amber { border-top: 3px solid var(--warning); }
.stat-card-purple { border-top: 3px solid #8b5cf6; }
.stat-card-rose  { border-top: 3px solid #f43f5e; }

.pipeline-tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: capitalize;
}

.pipeline-tag strong { color: var(--text); }
.pipeline-new { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.pipeline-contacted { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.pipeline-qualified { border-color: rgba(161,78,34,0.22); background: #fbf1e9; color: var(--primary); }
.pipeline-closed { border-color: rgba(161,78,34,0.22); background: #fbf1e9; color: var(--primary); }
.pipeline-lost { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.pipeline-open { border-color: #bfdbfe; background: #eff6ff; color: #1e40af; }
.pipeline-in_progress { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.pipeline-done { border-color: rgba(161,78,34,0.22); background: #fbf1e9; color: var(--primary); }

/* Activity list */
.activity-list {
  list-style: none;
  padding: 0;
}

.activity-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.activity-list li:last-child { border-bottom: none; }

.activity-kind {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.activity-kind.lead { background: #dbeafe; color: #1d4ed8; }
.activity-kind.edit { background: #fef3c7; color: #92400e; }

.activity-ts {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.modal-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 22px;
  line-height: 1.5;
}

.input-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Go-live result banner ───────────────────────────────────────────── */
.golive-result {
  background: #fbf1e9;
  border: 1px solid rgba(161,78,34,0.22);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 14px;
}

.golive-result h4 {
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.golive-result a { color: var(--primary); }

.golive-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Lead expansion ──────────────────────────────────────────────────── */
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  font-family: inherit;
  transition: color var(--transition);
}

.btn-link:hover { text-decoration: underline; }

.lead-row-expanded td { background: var(--primary-light); }

[data-theme="dark"] .lead-row-expanded td { background: rgba(16,185,129,0.10); background: color-mix(in srgb, var(--primary) 10%, transparent); }

.lead-detail-row td {
  padding: 10px 16px 16px;
  background: var(--bg-subtle);
  border-top: none !important;
  font-size: 14px;
}

[data-theme="dark"] .lead-detail-row td { background: var(--bg); }

.lead-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
}

/* ── Lead notes textarea ─────────────────────────────────────────── */
.lead-notes-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-notes-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  min-height: 56px;
}

.lead-notes-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

/* ── Filter row ──────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-row input {
  flex: 1;
  min-width: 180px;
  max-width: 340px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.filter-count {
  font-size: 12px;
  color: var(--text-subtle);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Inline action row (email/compare inputs below preview controls) */
.inline-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.inline-action-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Fade transition ─────────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Version history (dashboard) ─────────────────────────────────── */
.version-detail-row td {
  padding: 16px;
  background: var(--bg);
  border-top: none !important;
}

.expansion-loading,
.expansion-error {
  text-align: center;
}

.expansion-loading {
  color: var(--text-muted);
}

.expansion-error {
  color: var(--error);
}

.version-history h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
}

.version-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.version-item {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.version-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 8px;
  gap: 8px;
}

.version-note {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 0;
}

.version-current {
  background: #fbf1e9;
  border-color: rgba(161,78,34,0.22);
}

.badge-current {
  display: inline-block;
  padding: 2px 8px;
  background: var(--success);
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 8px;
}

/* ── Progress bar (generation) ───────────────────────────────────– */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ── Lead analytics ──────────────────────────────────────────────– */
.lead-analytics {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.analytics-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.analytics-item strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Preview thumbnail ───────────────────────────────────────────– */
.preview-thumb {
  margin-top: 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 280px;
}

.preview-thumb-img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg);
}

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  justify-content: center;
}

.page-info {
  font-size: 12px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

/* ── Confirm Modal ───────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.18s ease;
}

.confirm-message {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 22px;
  line-height: 1.6;
  font-weight: 500;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border: none;
}
.btn-danger:hover { background: #dc2626; }

.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 1px 4px rgba(245,158,11,0.25);
}
.btn-warning:hover { opacity: 0.9; transform: translateY(-1px); }

/* ── Quick Filter Buttons ────────────────────────────────────────── */
.quick-filters {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.quick-filter-btn {
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  line-height: 1.5;
}

.quick-filter-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.quick-filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(16,185,129,0.25);
}

/* ── Undo Toast ──────────────────────────────────────────────────── */
.toast-undo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.undo-btn {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.undo-btn:hover { background: rgba(255,255,255,0.3); }

/* ── Site Notes ──────────────────────────────────────────────────── */
.site-notes-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}
.site-notes-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }

/* ── Keyboard Shortcuts Modal ────────────────────────────────────── */
.shortcuts-backdrop {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.shortcuts-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  overflow-y: auto;
}

.shortcuts-box h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.shortcuts-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.shortcuts-table tr:last-child td { border-bottom: none; }

.shortcuts-table td:first-child {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--primary);
  width: 50px;
  font-size: 15px;
}

/* ── Status color dots ───────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.status-dot-new      { background: var(--text-muted); }
.status-dot-contacted { background: var(--primary); }
.status-dot-qualified { background: var(--success); }
.status-dot-closed   { background: var(--warning); }
.status-dot-lost     { background: var(--error); }
.status-dot-open     { background: var(--warning); }
.status-dot-in_progress { background: var(--primary); }
.status-dot-done     { background: var(--success); }
.status-dot-wont_do  { background: var(--error); }

/* ── Follow-up overdue badge ─────────────────────────────────────── */
.followup-overdue {
  color: var(--error);
  font-size: 9px;
  vertical-align: middle;
  margin-left: 4px;
  cursor: default;
}

/* ── Copy button ─────────────────────────────────────────────────── */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  vertical-align: middle;
  transition: all 0.15s;
}
.copy-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── Lead Score Badge ────────────────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
  cursor: default;
  letter-spacing: 0;
}
.score-high { background: #dcfce7; color: #15803d; }
.score-med  { background: #fef9c3; color: #854d0e; }
.score-low  { background: #f1f5f9; color: #64748b; }
[data-theme="dark"] .score-high { background: #14532d; color: #86efac; }
[data-theme="dark"] .score-med  { background: #422006; color: #fde047; }
[data-theme="dark"] .score-low  { background: #1e293b; color: #94a3b8; }

/* ── Lead notes snippet (inline preview) ────────────────────────── */
.lead-notes-snippet {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

/* ── Search highlight ────────────────────────────────────────────── */
mark.search-mark {
  background: #fef08a;
  color: #1e293b;
  border-radius: 2px;
  padding: 0 1px;
}
[data-theme="dark"] mark.search-mark { background: #713f12; color: #fef9c3; }

/* ── Edit SLA row borders ────────────────────────────────────────── */
.sla-green { border-left: 3px solid var(--success); }
.sla-amber { border-left: 3px solid var(--warning); }
.sla-red   { border-left: 3px solid var(--error); }

/* ── Tone analysis badges (inline in edit row request cell) ──────── */
.tone-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  cursor: default;
  white-space: nowrap;
}
.tone-badge-high   { background: #fee2e2; color: #b91c1c; }
.tone-badge-medium { background: #fef3c7; color: #92400e; }
[data-theme="dark"] .tone-badge-high   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .tone-badge-medium { background: #451a03; color: #fcd34d; }

/* ── Tone analysis warning panel (in expanded edit detail) ───────── */
.tone-warning {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border-left: 3px solid;
}
.tone-warning-high   { background: #fff1f2; border-color: #ef4444; color: #7f1d1d; }
.tone-warning-medium { background: #fffbeb; border-color: #f59e0b; color: #78350f; }
[data-theme="dark"] .tone-warning-high   { background: #3b0a0a; border-color: #f87171; color: #fca5a5; }
[data-theme="dark"] .tone-warning-medium { background: #3b1a00; border-color: #fbbf24; color: #fcd34d; }
.tone-warning-meta {
  font-size: 11px;
  opacity: 0.65;
  margin-left: 6px;
}

/* ── Dashboard last-refreshed label ─────────────────────────────── */
.last-refreshed {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Pipeline Bar Chart ──────────────────────────────────────────── */
.pipeline-chart {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.pipeline-chart-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.pipeline-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 80px;
}

.pipeline-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  max-width: 80px;
  height: 100%;
}

.pipeline-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.pipeline-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height 0.3s ease;
}

.pipeline-bar-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.pipeline-bar-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: capitalize;
  white-space: nowrap;
  text-align: center;
}

/* ── Stale Leads Banner ──────────────────────────────────────────── */
.stale-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #92400e;
  margin-bottom: 12px;
}

[data-theme="dark"] .stale-banner {
  background: #1c1407;
  border-color: #78350f;
  color: #fbbf24;
}

.stale-banner-btn {
  background: none;
  border: 1px solid currentColor;
  color: inherit;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}
.stale-banner-btn:hover { opacity: 0.8; }

/* ── Discover tab ────────────────────────────────────────────────── */
.star-rating {
  color: #f59e0b;
  font-size: 12px;
  letter-spacing: -1px;
}

.no-website-badge {
  display: inline-block;
  padding: 2px 7px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

[data-theme="dark"] .no-website-badge {
  background: #450a0a;
  border-color: #991b1b;
}

.discover-loading {
  text-align: center;
  padding: 40px 20px;
  margin-top: 24px;
}

/* ── Domain search ───────────────────────────────────────────────── */

.ds-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.ds-available { background: #d1fae5; color: var(--primary); }
.ds-taken     { background: #fee2e2; color: #991b1b; }
.ds-unknown   { background: #f3f4f6; color: #6b7280; }
.ds-domain    { font-family: monospace; font-size: 14px; font-weight: 500; }

[data-theme="dark"] .ds-available { background: #5b3a22; color: #6ee7b7; }
[data-theme="dark"] .ds-taken     { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .ds-unknown   { background: #374151; color: #9ca3af; }

/* ── Sparkline chart ─────────────────────────────────────────────── */

.sparkline-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sparkline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.sparkline-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.sparkline-legend {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sparkline-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.sparkline-dot-leads { background: #4A7BA6; }
.sparkline-dot-edits { background: #f59e0b; }
.sparkline-svg {
  width: 100%;
  height: 64px;
  display: block;
  overflow: visible;
}
.sparkline-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.sparkline-leads { stroke: #4A7BA6; }
.sparkline-edits { stroke: #f59e0b; }

/* ── Activity feed ───────────────────────────────────────────────── */
.activity-list li {
  gap: 8px;
}

.activity-name {
  font-weight: 500;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-status-label {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: capitalize;
}

/* ── Bulk progress ───────────────────────────────────────────────── */
.bulk-progress {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.bulk-progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

/* ── Follow-up Badges ────────────────────────────────────────────── */
.followup-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  line-height: 1.6;
}
.fu-overdue { background: #fee2e2; color: #b91c1c; }
.fu-today   { background: #fef3c7; color: #92400e; }
.fu-soon    { background: #eff6ff; color: #1d4ed8; }
[data-theme="dark"] .fu-overdue { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .fu-today   { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .fu-soon    { background: #172554; color: #93c5fd; }

/* ── Review Completeness ─────────────────────────────────────────── */
.review-completeness {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.review-completeness-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}
.completeness-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: default;
}
.chip-ok      { background: #dcfce7; color: #15803d; }
.chip-missing { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
[data-theme="dark"] .chip-ok      { background: #14532d; color: #86efac; }
[data-theme="dark"] .chip-missing { color: var(--text-subtle); }

/* ── Bulk Status Icons ────────────────────────────────────────────── */
.bulk-status-cell {
  display: inline-block;
  width: 18px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
}
.bulk-pending { color: var(--text-muted); }
.bulk-running { color: #f59e0b; }
.bulk-done    { color: var(--success); }
.bulk-error   { color: var(--error); }

/* ── Admin Key Status Indicator ─────────────────────────────────── */
.key-status-dot {
  display: inline-block;
  font-size: 10px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1;
}
.key-status-ok  { color: var(--success); }
.key-status-error { color: var(--error); }

/* ── Audit Log ───────────────────────────────────────────────────── */
.audit-action-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.audit-details {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── AI Receptionist ─────────────────────────────────────────────── */
.rec-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.rec-status-dot.enabled  { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.rec-status-dot.disabled { background: var(--text-subtle); }

.call-status-answered { background: #d1fae5; color: var(--primary); }
.call-status-missed   { background: #fee2e2; color: #b91c1c; }
.call-status-voicemail { background: #ede9fe; color: #5b21b6; }

[data-theme="dark"] .call-status-answered { background: #022c22; color: #6ee7b7; }
[data-theme="dark"] .call-status-missed   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .call-status-voicemail { background: #2e1065; color: #c4b5fd; }

.n8n-guide-step {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.n8n-guide-step:last-child { border-bottom: none; }

.n8n-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.n8n-step-body {
  flex: 1;
  min-width: 0;
}

.n8n-step-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.n8n-step-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.code-block {
  display: block;
  margin: 8px 0;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  word-break: break-all;
  color: var(--text);
  white-space: pre-wrap;
}

.rec-faq-row { align-items: start; }
@media (max-width: 640px) {
  .rec-faq-row {
    grid-template-columns: 1fr !important;
  }
}

.rec-call-row:hover { background: var(--bg-subtle); }

/* ── Mobile Responsive (enhanced) ───────────────────────────────── */
@media (max-width: 768px) {
  /* Nav scrolls horizontally; thead can't be sticky inside overflow-x:auto */
  .header-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
  }
  .header-nav::-webkit-scrollbar { display: none; }
  .client-table thead { position: static; }
  .pipeline-bars { height: 60px; gap: 6px; }
  .pipeline-bar-label { font-size: 9px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* Tighten stat cards so 2-col layout works at 375px */
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 24px; letter-spacing: -0.5px; }
  .stat-card-icon { font-size: 22px; margin-bottom: 8px; }
  /* Toast must not overflow the screen edges */
  #toast-container { left: 12px; right: 12px; }
  .toast { max-width: 100%; }
  /* Preview iframe manageable on small screens */
  .preview-frame-wrapper { min-height: 320px; }
  .preview-frame-wrapper iframe { height: 480px; }
  .quick-filters { gap: 4px; }
  .quick-filter-btn { padding: 3px 7px; font-size: 11px; }
  .pipeline-bars { gap: 4px; }
}

/* ── Step Indicator ──────────────────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.step span { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.step.active span { color: var(--primary); font-weight: 600; }
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 2px solid var(--border);
  color: var(--text-muted);
}
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.completed .step-num { background: var(--success-light); border-color: var(--success); color: var(--success); }
.step-line {
  height: 2px;
  min-width: 40px;
  max-width: 80px;
  flex: 1;
  background: var(--border);
  margin-bottom: 20px;
}
.step-line.completed { background: var(--success); }

/* ── Accessibility ──────────────────────────────────────────────────── */

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 8px;
  z-index: 10000;
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.1s;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* Universal focus indicator — visible, high contrast */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Override for inputs/selects that already have border focus style */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 0;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.25);
}

/* Nav tab focus */
.nav-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Button focus */
.btn:focus-visible,
button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

/* Sort table header focus */
.sort-th:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Forced colors / Windows High Contrast mode */
@media (forced-colors: active) {
  .btn, button, a {
    forced-color-adjust: none;
    border: 2px solid ButtonText;
  }
  :focus-visible {
    outline: 3px solid Highlight;
  }
  .nav-btn.active {
    background: Highlight;
    color: HighlightText;
  }
  .logo-icon {
    background: Highlight;
    color: HighlightText;
  }
  .nav-badge {
    background: ButtonText;
    color: ButtonFace;
  }
}

/* Reduced motion — disable all transitions and animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .skeleton { animation: none; background: var(--bg-subtle); }
  .progress-fill::after { animation: none; }
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Mobile Nav ────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: 240px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 99;
  padding: 16px;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.mobile-nav-drawer.open { display: flex; }
.mobile-nav-drawer .nav-btn { width: 100%; text-align: left; }
.table-scroll-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 768px) {
  .header-nav { display: none; }
  .nav-hamburger { display: flex; align-items: center; }
  .header-inner { max-width: 100%; }
  #app { padding: 16px 12px; }
  .card { padding: 16px 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Field-level validation ─────────────────────────────────────── */
.field-error-input {
  border-color: var(--error) !important;
  background: var(--error-light) !important;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.15);
}
.field-error-msg {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--error);
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}
.field-error-msg::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Notes saved hint ────────────────────────────────────────────── */
.notes-saved-hint {
  display: inline-block;
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.notes-saved-hint--visible { opacity: 1; }

/* ── Copy success flash ──────────────────────────────────────────── */
.btn-copy-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
  transition: background 0.2s, border-color 0.2s;
}

/* ── Empty state CTA ─────────────────────────────────────────────── */
.empty-state-cta {
  margin-top: 16px;
}

/* ── Mobile modal bottom sheet ───────────────────────────────────── */
@media (max-width: 520px) {
  .modal-overlay { align-items: flex-end; }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUpSheet 0.25s ease;
  }
}
@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── Mobile table improvements ───────────────────────────────────── */
@media (max-width: 640px) {
  .table-scroll-wrap table { min-width: 480px; }
  td, th { padding: 8px 10px; font-size: 13px; }
}
@media (max-width: 480px) {
  .card-title { font-size: 16px; }
  .btn { padding: 7px 12px; font-size: 13px; }
}

/* ── Outreach draft panel ─────────────────────────────────────────── */
.outreach-draft-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.outreach-draft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.outreach-draft-close {
  font-size: 13px;
  color: var(--text-muted);
}
.outreach-draft-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.outreach-draft-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.outreach-draft-value {
  font-size: 14px;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
}
.outreach-draft-body {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.6;
  margin: 0;
}
.outreach-draft-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Preview analytics bar ───────────────────────────────────────── */
.preview-analytics-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.analytics-stat { color: var(--text); }
.analytics-divider { color: var(--border-strong); }
.btn-success-muted {
  background: var(--success-light) !important;
  color: var(--success) !important;
  border-color: var(--success) !important;
  cursor: default;
}

/* ── Next actions card ───────────────────────────────────────────── */
.next-actions-list { display: flex; flex-direction: column; gap: 10px; }
.next-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  flex-wrap: wrap;
}
.next-action-warn { background: var(--warning-light); border: 1px solid #fde68a; }
.next-action-info { background: var(--info-light); border: 1px solid #bfdbfe; }
.next-action-ok { background: var(--success-light); border: 1px solid rgba(161,78,34,0.22); color: var(--success); font-weight: 600; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }

/* ── Knowledge Base ──────────────────────────────────────────────── */
.kb-root { max-width: 920px; margin: 0 auto; }
.kb-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 20px; }
.kb-title { font-family: var(--serif); font-size: clamp(24px, 4vw, 34px); font-weight: 600; color: var(--text); }
.kb-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; max-width: 48ch; }
.kb-reviewed { color: var(--text-subtle); font-size: 12px; margin-top: 2px; }
.kb-search-wrap { flex: 1; min-width: 220px; max-width: 360px; }
.kb-search { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text); }
.kb-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.kb-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.kb-pill { border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: 999px; cursor: pointer; transition: all var(--transition); }
.kb-pill:hover { border-color: var(--primary); color: var(--primary); }
.kb-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.kb-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.kb-item { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); font-family: inherit; }
.kb-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kb-item-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); }
.kb-item-title { font-size: 15px; font-weight: 600; color: var(--text); }
.kb-item-date { font-size: 12px; color: var(--text-subtle); }
.kb-empty { color: var(--text-muted); font-size: 14px; padding: 20px 0; }
.kb-back { margin-bottom: 16px; }
.kb-article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; }
.kb-article-meta { font-size: 12px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.kb-article-title { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--text); margin-bottom: 18px; }
.kb-article-body { font-size: 15px; line-height: 1.7; color: var(--text); }
.kb-article-body p { margin: 0 0 14px; }
.kb-article-body ul, .kb-article-body ol { margin: 0 0 14px; padding-left: 22px; }
.kb-article-body li { margin-bottom: 6px; }
.kb-article-body code { background: var(--bg-subtle); padding: 2px 6px; border-radius: 5px; font-size: 13px; color: var(--text); }
.kb-article-body .ds-available { color: var(--success); font-weight: 700; }
.kb-article-body .ds-taken { color: var(--error); font-weight: 700; }
.kb-changelog { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.kb-changelog-title { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
.kb-changelog ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.kb-changelog li { font-size: 13px; color: var(--text-muted); }
.kb-changelog-date { display: inline-block; min-width: 78px; font-weight: 700; color: var(--primary); margin-right: 8px; }

/* ── Runbook / KB link affordances ──────────────────────────────── */
.help-btn { border: 1px solid var(--border-strong); color: var(--primary); background: var(--primary-light); margin-left: 4px; }
.help-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (max-width: 600px) {
  .kb-article { padding: 20px 18px; }
  .kb-changelog-date { display: block; margin-bottom: 2px; }
}

/* ── Accessibility ───────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.kb-search:focus-visible { outline-offset: 0; }
.btn:focus-visible, .nav-btn:focus-visible { outline-offset: 2px; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

