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

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1a1a2e;
  background: #f5f6fa;
  min-height: 100vh;
}

a { color: #164381; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: relative;
}
.nav-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex-shrink: 0; min-width: 0; }
.nav-brand img { width: 90px; height: auto; display: block; flex-shrink: 0; } /* >75px min per brand book p.9 */
.nav-brand span { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; color: #164381; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.nav-toggle { display: none; background: none; border: none; font-size: 19px; line-height: 1; cursor: pointer; padding: 4px 6px; color: #374151; }
.nav-links { display: flex; align-items: center; gap: 16px; font-size: 13px; color: #6b7280; white-space: nowrap; }
.nav-links a { color: #6b7280; text-decoration: none; }
.nav-links a:hover { color: #111; }
.nav-divider { width: 1px; height: 14px; background: #e5e7eb; display: inline-block; }
.nav-user-name { color: #6b7280; }

/* Below this width the full link row no longer fits comfortably next to a
   variable-length page title — collapse it into a hamburger dropdown
   instead of letting the browser wrap mid-phrase across two ragged lines
   (fixed 2026-09-29, reported as "the menu gets messy" when the window is
   narrowed). The bell stays outside the collapsed menu since it's an
   admin-facing signal that shouldn't be one extra tap away. */
@media (max-width: 880px) {
  .nav-brand span { display: none; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 52px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 24px 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    z-index: 60;
  }
  .nav-links.nav-links--open { display: flex; }
  .nav-links a, .nav-links .nav-user-name { width: 100%; padding: 9px 0; border-bottom: 1px solid #f3f4f6; }
  .nav-links .nav-divider { display: none; }
}

/* ── Main layout ──────────────────────────────────────────── */
main { padding: 32px 24px; max-width: 1400px; margin: 0 auto; }

.page { display: flex; flex-direction: column; gap: 24px; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card-title    { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.card-subtitle { color: #6b7280; margin-bottom: 24px; }

/* ── Login ────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-wrapper .card { width: 100%; max-width: 400px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row   { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-group--submit { margin-bottom: 16px; }

label { font-size: 13px; font-weight: 500; color: #374151; }

input[type="email"],
input[type="password"],
input[type="file"],
select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: #164381;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.btn-primary {
  padding: 9px 20px;
  background: #164381;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover:not(:disabled) { background: #0f2f5c; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-secondary {
  padding: 9px 20px;
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn-secondary:hover { background: #f3f4f6; }

/* ── Google sign-in button ───────────────────────────────── */
.btn-google {
  display: inline-flex;
  align-items: center;
  padding: 10px 24px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  margin-top: 8px;
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover {
  background: #f9fafb;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  text-decoration: none;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  border-left: 3px solid #ef4444;
  background: #fef2f2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash-success {
  border-left-color: #16a34a;
  background: #f0fdf4;
  color: #15803d;
}
.flash-amber {
  border-left-color: #d97706;
  background: #fffbeb;
  color: #78350f;
}

/* ── Processing panel ─────────────────────────────────────── */
.processing-card   { max-width: 520px; }

.processing-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.processing-title  { font-size: 16px; font-weight: 600; }
.processing-timer  { font-size: 13px; color: #6b7280; margin-top: 2px; }

.processing-spinner {
  width: 28px; height: 28px; flex-shrink: 0;
  border: 3px solid #e5e7eb;
  border-top-color: #164381;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-spinner {
  width: 11px; height: 11px; flex-shrink: 0;
  border: 2px solid #d1d5db;
  border-top-color: #164381;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}

.processing-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  padding: 0;
}
.processing-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #9ca3af;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background 0.3s, color 0.3s;
}
.processing-steps li::before {
  content: '○';
  font-size: 16px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}
.processing-steps li.step-done {
  color: #6b7280;
}
.processing-steps li.step-done::before { content: '✓'; color: #16a34a; }
.processing-steps li.step-active {
  background: #eff6ff;
  color: #0f2f5c;
  font-weight: 500;
}
.processing-steps li.step-active::before { content: '▶'; color: #164381; font-size: 12px; }

.processing-note { font-size: 12px; color: #9ca3af; }
.processing-detail { font-size: 13px; color: #6b7280; margin-top: 10px; min-height: 18px; }
.processing-error  { color: #b91c1c; }

/* ── Rerun action ─────────────────────────────────────────── */
.rerun-bar { margin: 12px 0; }

/* ── Upload hint ──────────────────────────────────────────── */
.upload-hint {
  font-size: 12px;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 4px;
}
.upload-hint ul { margin: 6px 0 0; padding-left: 18px; }
.upload-hint li { margin-bottom: 2px; }

/* ── Results ──────────────────────────────────────────────── */
.upload-card h2   { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.summary-bar      { padding: 12px 16px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; font-size: 13px; }

/* ── Status board ─────────────────────────────────────────── */
.status-board {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status-tile {
  flex: 1;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  background: #fff;
  transition: transform 0.1s, box-shadow 0.1s, border-color 0.15s;
}
.status-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.status-tile:active { transform: translateY(0); }

.status-tile-count {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.status-tile-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.status-tile--empty { opacity: 0.4; }

.status-tile--hp { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.status-tile--hf { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.status-tile--mf { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.status-tile--lf { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.status-tile--nf { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-tile--ce { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.status-tile--nr { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.status-tile--all { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.warn-count       { color: #b45309; }
.ok-count         { color: #15803d; }

.warnings-block {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
}
.warnings-block summary { cursor: pointer; font-weight: 500; color: #92400e; }
.warnings-block ul { margin-top: 8px; padding-left: 20px; line-height: 1.8; }

.col-mapping-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 14px 18px;
  font-size: 13px;
  color: #991b1b;
  margin-bottom: 8px;
}
.col-mapping-error ul { margin: 6px 0 0 0; padding-left: 20px; line-height: 1.8; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

/* History table (run-history-table) — decided 2026-09-29: this table has
   grown to 11-12 columns (adding Delete for admins pushed it over), wide
   enough to force horizontal scroll on a normal laptop screen. Tightened
   padding/font plus truncating the two free-text columns (Run name,
   Affinity's CSV-upload label) — the exact values are still one tooltip
   hover away — rather than letting every column stay full-width. */
#run-history-table { font-size: 12.5px; }
#run-history-table th, #run-history-table td { padding: 7px 8px; }
#run-history-table td:not(.rh-wide) { white-space: nowrap; }
#run-history-table .rh-wide {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#run-history-table .csv-check-text { max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.rh-row { cursor: pointer; }
.rh-row:hover { background: #f9fafb; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th { position: sticky; top: 0; background: #f9fafb; z-index: 2; }
th { padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
tr.row-alt td { background: #f9fafb; }
.td-desc { max-width: 260px; }

/* ── Leads table: frozen header row + Name column ────────────────────── */
.leads-table-wrapper { max-height: 70vh; overflow: auto; }
#leads-table th:nth-child(3),
#leads-table td:nth-child(3) {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
  box-shadow: 1px 0 0 #e5e7eb;
}
#leads-table tr.row-alt td:nth-child(3) { background: #f9fafb; }
#leads-table thead th:nth-child(3) { z-index: 3; background: #f9fafb; }

/* ── Filters ──────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 0 8px;
}
.filter-input, .filter-select {
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  height: 32px;
  width: auto;
}
.filter-input  { min-width: 180px; }
.filter-select { min-width: 140px; }
.filter-input:focus, .filter-select:focus {
  outline: none;
  border-color: #164381;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.filter-active {
  border-color: #164381;
  background: #eff6ff;
}
.btn-reset {
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: #6b7280;
  height: 32px;
}
.btn-reset:hover { background: #f3f4f6; }
.filter-count { font-size: 12px; color: #6b7280; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.btn-page {
  padding: 5px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}
.btn-page:hover:not(:disabled) { background: #f3f4f6; }
.btn-page:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 13px; color: #374151; }

/* ── Description expand ───────────────────────────────────── */
.btn-expand {
  background: none;
  border: none;
  color: #164381;
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  text-decoration: underline;
}

.actions-bar   { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.actions-note  { font-size: 12px; color: #9ca3af; }

/* ── Settings page ───────────────────────────────────────── */
.settings-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  background: #fff;
}
.settings-textarea:focus {
  outline: none;
  border-color: #164381;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.settings-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 13px;
  background: #fff;
}
.settings-input:focus {
  outline: none;
  border-color: #164381;
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 10px;
}
.settings-table th {
  text-align: left;
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
}
.settings-table td { padding: 4px 4px; }
.btn-add-row {
  font-size: 13px;
  color: #164381;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.btn-add-row:hover { text-decoration: underline; }
.btn-remove-row {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.btn-remove-row:hover { color: #ef4444; }
.row-pending-delete td { opacity: 0.4; text-decoration: line-through; }
.row-pending-delete .btn-remove-row { opacity: 1; text-decoration: none; color: #164381; font-weight: 500; }
.settings-source-label {
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

/* ── Run history page ─────────────────────────────────────── */
.run-title    { font-size: 18px; font-weight: 600; }
.back-link    { font-size: 13px; color: #6b7280; white-space: nowrap; }
.back-link:hover { color: #164381; }

code { font-size: 12px; background: #f3f4f6; padding: 2px 5px; border-radius: 3px; }

/* ── Status badges ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-hp { background: #dcfce7; color: #166534; }
.badge-hf { background: #d1fae5; color: #065f46; }
.badge-mf { background: #fef9c3; color: #854d0e; }
.badge-lf { background: #fef3c7; color: #92400e; }
.badge-nf   { background: #fee2e2; color: #991b1b; }
.badge-ce   { background: #ffedd5; color: #9a3412; }
.badge-nr   { background: #ede9fe; color: #5b21b6; }
.badge-seen       { background: #ede9fe; color: #5b21b6; font-size: 11px; cursor: default; }
.badge-in-affinity{ background: #dbeafe; color: #0f2f5c; font-size: 11px; cursor: default; }
.badge-upgraded   { background: #dcfce7; color: #15803d; font-size: 11px; cursor: default; font-weight: 600; }

/* ── Qualification Logic page ─────────────────────────────── */
.qual-pipeline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.qual-pipeline-step {
  flex: 1;
  min-width: 160px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.qual-pipeline-step:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.qual-pipeline-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #164381;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}
.qual-pipeline-step-title { font-size: 13px; font-weight: 600; }
.qual-pipeline-step-sub   { font-size: 12px; color: #6b7280; margin-top: 2px; }

.qual-section { margin-top: 8px; }
.qual-section-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.qual-section-sub   { font-size: 13px; color: #6b7280; margin-bottom: 16px; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 500;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}
.chip-prio   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.chip-second { background: #fef9c3; color: #854d0e; border-color: #fde68a; }
.chip-stage  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.chip-vertical { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }

.theme-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 800px) {
  .theme-card-grid { grid-template-columns: 1fr; }
}
.theme-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 18px;
  background: #f9fafb;
}
.theme-card-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.theme-card-desc  { font-size: 13px; color: #4b5563; line-height: 1.6; margin-bottom: 10px; }

.callout {
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.7;
}
.callout-title { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.callout-opportunistic { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.callout-excluded      { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

.qual-table th, .qual-table td { font-size: 13px; }
.qual-table td { vertical-align: middle; }

.qual-example {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.7;
}

.qual-updated {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 8px;
}

.anchor-target { scroll-margin-top: 24px; }

/* ── Affinity push button ─────────────────────────────────────────────────── */
.btn-affinity {
  display: inline-block;
  padding: 8px 18px;
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-affinity:hover { background: #6d28d9; }

/* ── Push result banner ───────────────────────────────────────────────────── */
/* ── Push summary card (above results table) ─────────────────────────────── */
.push-summary-card {
  margin-bottom: 20px;
  padding: 16px 20px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
}
.push-summary-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.push-summary-title {
  font-weight: 700;
  font-size: 13px;
  color: #4c1d95;
}
.push-summary-meta {
  font-size: 12px;
  color: #7c3aed;
}
.push-summary-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.push-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 1px solid #e9d5ff;
  border-radius: 8px;
  padding: 8px 14px;
  min-width: 80px;
}
.push-stat--muted .push-stat-count { color: #6b7280; }
.push-stat--muted { border-color: #e5e7eb; }
.push-stat--error .push-stat-count { color: #dc2626; }
.push-stat--error { border-color: #fecaca; background: #fff5f5; }
.push-stat-count {
  font-size: 22px;
  font-weight: 700;
  color: #4c1d95;
  line-height: 1.1;
}
.push-stat-label {
  font-size: 11px;
  color: #6b7280;
  margin-top: 3px;
  text-align: center;
}
.push-summary-sub {
  font-size: 12px;
  color: #7c3aed;
  margin-bottom: 4px;
}
.push-errors-detail {
  margin-top: 10px;
  font-size: 13px;
}
.push-errors-detail > summary {
  cursor: pointer;
  font-weight: 600;
  color: #dc2626;
  font-size: 12px;
  user-select: none;
}
.push-errors-explain {
  font-size: 12px;
  color: #6b7280;
  margin: 8px 0 6px;
  line-height: 1.5;
}
.push-errors-list {
  margin: 0 0 0 16px;
  padding: 0;
  font-size: 12px;
  color: #7c3aed;
  line-height: 1.7;
}

/* ── Run header with right-aligned actions ───────────────────────────────── */
.run-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.run-header-left {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
}
.run-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Confirmation modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 0;
  gap: 16px;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}
.modal-subtitle {
  font-size: 13px;
  color: #6b7280;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: #9ca3af;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}
.modal-close:hover { color: #374151; }

.modal-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px 24px;
}
@media (max-width: 600px) {
  .modal-columns { grid-template-columns: 1fr; }
}

.modal-col {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}
.modal-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.modal-col-hp { background: #dcfce7; color: #166534; }
.modal-col-mf { background: #dbeafe; color: #1e40af; }
.modal-col-nf { background: #f3f4f6; color: #374151; }
.modal-col-count {
  background: rgba(0,0,0,0.10);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.modal-lead-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.modal-lead-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.modal-lead-item:last-child { border-bottom: none; }
.modal-lead-name {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-lead-link {
  color: #164381;
  text-decoration: none;
}
.modal-lead-link:hover {
  text-decoration: underline;
}
.modal-lead-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 1px;
}
.modal-lead-empty {
  list-style: none;
  padding: 12px;
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
}
.modal-lead-more {
  padding: 6px 12px;
  font-size: 11px;
  color: #6b7280;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 24px;
  border-top: 1px solid #f3f4f6;
  padding-top: 16px;
}

/* ── Processing page success state ───────────────────────────────────────── */
.processing-success-icon {
  width: 40px;
  height: 40px;
  background: #dcfce7;
  color: #166534;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.processing-summary {
  margin: 16px 0 0;
  padding: 14px 18px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  line-height: 1.5;
}

/* ── Active push banner on run page ─────────────────────────────────────── */
.push-active {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 16px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 8px;
  font-size: 13px;
  color: #5b21b6;
}
.push-active-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  flex-shrink: 0;
}
.btn-affinity--busy {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Pushed badge in history table ──────────────────────────────────────── */
.badge-pushed {
  display: inline-block;
  padding: 2px 8px;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.badge-pushed-log {
  background: #ede9fe;
  color: #5b21b6;
}

/* ── My Leads quick-filter chips ─────────────────────────────────────────── */
.my-leads-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0 4px;
}
.btn-chip {
  padding: 5px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 16px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
}
.btn-chip:hover { background: #f3f4f6; border-color: #9ca3af; }
.btn-chip--active {
  background: #eff6ff;
  border-color: #164381;
  color: #0f2f5c;
}

/* ── Apollo export button ─────────────────────────────────────────────────── */
.btn-apollo {
  padding: 5px 14px;
  border: 1.5px solid #059669;
  border-radius: 6px;
  background: #fff;
  color: #065f46;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s;
  height: 32px;
  margin-left: auto;
}
.btn-apollo:hover { background: #f0fdf4; }
.apollo-confirm {
  font-size: 12px;
  color: #15803d;
  font-weight: 500;
  white-space: nowrap;
}

/* Admin alert bell (header) */
#alert-bell-wrap { position: relative; display: inline-block; }
#alert-bell { background: none; border: none; cursor: pointer; font-size: 15px; padding: 0; line-height: 1; position: relative; }
#alert-count { position: absolute; top: -7px; right: -9px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: #dc2626; color: #fff; font-size: 10px; line-height: 15px; text-align: center; font-weight: 600; }
#alert-panel { position: absolute; right: 0; top: 26px; width: 340px; max-height: 60vh; overflow-y: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 9998; text-align: left; }
.alert-item { padding: 12px 14px; border-bottom: 1px solid #f3f4f6; }
.alert-item:last-child { border-bottom: none; }
.alert-title { font-size: 13px; font-weight: 600; color: #111827; margin-bottom: 4px; }
.alert-msg { font-size: 12px; color: #4b5563; line-height: 1.45; margin-bottom: 8px; }
.alert-actions { display: flex; gap: 8px; }
.alert-btn, .alert-btn-primary { font-size: 12px; padding: 4px 10px; border-radius: 5px; cursor: pointer; border: 1px solid #d1d5db; background: #fff; color: #374151; }
.alert-btn-primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.alert-btn:disabled, .alert-btn-primary:disabled { opacity: .5; cursor: default; }
.alert-empty { padding: 16px 14px; font-size: 13px; color: #9ca3af; }

.badge-llm-country { background: #e0e7ff; color: #3730a3; font-size: 10px; cursor: default; font-weight: 600; padding: 1px 5px; border-radius: 4px; vertical-align: middle; }
.badge-geo-assumed { background: #fef3c7; color: #92400e; font-size: 10px; cursor: default; font-weight: 600; padding: 1px 5px; border-radius: 4px; vertical-align: middle; }



/* Bulk resolve bar for Needs-review leads (run results) */
.bulk-review-bar { border: 1px solid #c4b5fd; background: #faf5ff; border-radius: 8px; padding: 12px 16px; margin: 0 0 14px; }
.bulk-review-title { font-weight: 700; font-size: 14px; color: #5b21b6; margin-bottom: 8px; }
.bulk-review-sub { font-weight: 400; font-size: 12px; color: #6b7280; margin-left: 8px; }
.bulk-review-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 6px; }
.bulk-review-step { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #7c3aed; min-width: 72px; }
.bulk-review-count { font-size: 12px; font-weight: 600; color: #374151; }
.bulk-review-hint { font-size: 11px; color: #9ca3af; }
.bulk-review-action { font-size: 13px; color: #374151; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bulk-review-action select { font-size: 12px; padding: 3px 6px; width: auto; min-width: 130px; max-width: 190px; flex: 0 0 auto; }
.bulk-review-action select:disabled { opacity: .5; }
#bulk-apply-btn:disabled { opacity: .5; cursor: not-allowed; }


/* Button spinner — see the script in base.html. Works on any <button>: the wheel
   takes the button's own text colour, so it suits primary, secondary and danger. */
.is-loading { pointer-events: none; cursor: progress; }
.is-loading::before {
  content: ''; display: inline-block; width: .85em; height: .85em; margin-right: .5em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.12em; animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .is-loading::before { animation-duration: 2.4s; } }

/* Nav sections (dropdowns) */
.nav-group { position: relative; }
.nav-group-btn { background: none; border: none; font: inherit; color: #6b7280; cursor: pointer; padding: 0; }
.nav-group-btn:hover, .nav-group--open .nav-group-btn { color: #111; }
.nav-group--active .nav-group-btn, .nav-link--active { color: #111 !important; font-weight: 500; }
.nav-caret { font-size: 10px; margin-left: 2px; }
.nav-menu { display: none; position: absolute; top: calc(100% + 10px); left: -12px; min-width: 190px; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.08); padding: 6px 0; z-index: 50; }
.nav-group--open .nav-menu { display: block; }
.nav-menu a { display: block; padding: 8px 16px; color: #374151; }
.nav-menu a:hover { background: #f9fafb; color: #111; }
@media (max-width: 880px) {
  .nav-group-btn { width: 100%; text-align: left; padding: 9px 0; border-bottom: 1px solid #f3f4f6; font-weight: 500; color: #111; }
  .nav-caret { display: none; }
  .nav-menu { display: block; position: static; border: none; box-shadow: none; padding: 0 0 0 14px; min-width: 0; }
  .nav-menu a { padding: 9px 0; }
}

/* Needs-review per-lead actions */
.review-form { display: flex; flex-direction: column; gap: 4px; align-items: stretch; min-width: 170px; margin-bottom: 8px; }
.review-form:last-child { margin-bottom: 0; }
.review-row { display: flex; gap: 4px; }
.review-input { font-size: 11px; padding: 3px 4px; width: 100%; box-sizing: border-box; }
.review-row .review-input { flex: 1; min-width: 0; }
.review-find, .review-btn { font-size: 11px; padding: 3px 6px; border: 1px solid #d1d5db; border-radius: 4px; background: #f9fafb; cursor: pointer; color: #374151; }
.review-btn { width: 100%; }
.review-btn--quiet { color: #6b7280; }
.review-assume { padding-top: 6px; border-top: 1px dashed #e5e7eb; }
