:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --blue: #3b82f6;
  --yellow: #eab308;
  --green: #22c55e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.brand span { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.token-status { font-size: 12px; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-actions { display: flex; gap: 8px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.filters .input { flex: 1 1 auto; min-width: 120px; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { background: #32425c; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn.full { width: 100%; margin-top: 8px; }

.table-wrap { overflow-x: auto; }
.table-wrap.short { max-height: 220px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--panel); }
.empty { text-align: center; color: var(--muted); padding: 20px; }
.muted { color: var(--muted); font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #0b1220;
}
.badge-New { background: var(--blue); color: #fff; }
.badge-Contacted { background: var(--yellow); }
.badge-Qualified { background: var(--green); color: #06210f; }

/* Value-score tiers — visually distinct from pipeline status pills above */
.tier-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.tier-hot {
  background: rgba(249, 115, 22, 0.2);
  color: #fdba74;
  border-color: rgba(249, 115, 22, 0.45);
}
.tier-warm {
  background: rgba(14, 165, 233, 0.15);
  color: #7dd3fc;
  border-color: rgba(14, 165, 233, 0.4);
}
.tier-cold {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.35);
}
.value-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.commission-cell {
  font-size: 11px;
  color: var(--muted);
  max-width: 220px;
  line-height: 1.35;
}
.reason-list {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  color: var(--text);
  max-width: 280px;
}
.reason-list li { margin-bottom: 2px; }
.top-note { margin-bottom: 12px; }

.row-actions button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}
.row-actions button:hover { color: var(--text); }
.unverified-flag { color: var(--yellow); font-size: 11px; }

.sidebar .compliance {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  line-height: 1.4;
}
.field-label { display: block; margin: 10px 0 4px; font-size: 12px; color: var(--muted); }
.sidebar .input { width: 100%; }
.checkbox { display: block; margin-top: 8px; font-size: 13px; }
.selectors { margin-top: 10px; }
.selectors summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.selectors .input { margin-top: 6px; }

.queue-status, .scrape-history { margin-top: 16px; }
.queue-status h3, .scrape-history h3 { font-size: 13px; margin: 0 0 6px; }
.queue-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 32px;
  font-size: 12px;
}
.history-table th, .history-table td { font-size: 11px; padding: 5px 6px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal.hidden, .toast.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 380px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h3 { margin-top: 0; }
.modal-card .input { width: 100%; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 6px;
  z-index: 60;
  max-width: 320px;
  font-size: 13px;
}
.toast.error { border-left-color: #ef4444; }
.toast.success { border-left-color: var(--green); }

/* Confidence score triage badges (triage speed only — not a compliance override). */
.conf {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.conf-high { background: rgba(34, 197, 94, 0.18); color: var(--green, #22c55e); }
.conf-mid { background: rgba(234, 179, 8, 0.18); color: #eab308; }
.conf-low { background: rgba(239, 68, 68, 0.18); color: #ef4444; }

.email-type {
  font-size: 10px;
  text-transform: uppercase;
  padding: 0 4px;
  border-radius: 4px;
  border: 1px solid var(--border);
  opacity: 0.8;
}
.email-type-business { color: var(--green, #22c55e); }
.email-type-freemail { color: #eab308; }

.lic {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

.signal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  max-width: 220px;
}
.signal-chip {
  display: inline-block;
  font-size: 10px;
  line-height: 1.3;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.25);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-flag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(167, 139, 250, 0.15);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.layout.single {
  grid-template-columns: 1fr;
}
.layout.single .panel + .panel { margin-top: 0; }
.hidden { display: none !important; }

.panel-head.tight { margin-top: 20px; }
.filters .grow { flex: 2 1 240px; }

.badge-state-candidate { background: var(--yellow); color: #0b1220; }
.badge-state-approved { background: var(--green); color: #06210f; }
.badge-state-rejected { background: #ef4444; color: #fff; }

.vert {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.mx-ok {
  font-size: 10px;
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 4px;
  padding: 0 3px;
}
.mx-fail {
  font-size: 10px;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 4px;
  padding: 0 3px;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 110px;
}
.stat-n { font-size: 22px; font-weight: 700; }
.stat-l { font-size: 11px; color: var(--muted); margin-top: 2px; }

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.analytics-grid .span2 { grid-column: 1 / -1; }
.analytics-grid h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); }
@media (max-width: 800px) {
  .analytics-grid { grid-template-columns: 1fr; }
  .analytics-grid .span2 { grid-column: auto; }
  .tabs { order: 3; width: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px; }
}
