/* Prospector Dashboard — Theme & Components */

:root {
  color-scheme: light;
  --bg: #f8f8f7;
  --bg-inset: #f0efed;
  --surface: #ffffff;
  --surface-hover: #f5f4f2;
  --surface-raised: #ffffff;
  --overlay: rgba(0, 0, 0, 0.4);
  --border: #e5e3df;
  --border-subtle: #eeecea;
  --ring: rgba(99, 102, 241, 0.4);
  --text: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-muted: #9c9c9c;
  --text-on-primary: #ffffff;
  --primary: #6366f1;
  --primary-hover: #5558e6;
  --primary-soft: rgba(99, 102, 241, 0.1);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.08);
  --success: #22c55e;
  --warning: #f59e0b;
  --info: #3b82f6;
  --discovered: #3b82f6;
  --discovered-bg: rgba(59, 130, 246, 0.1);
  --enriched: #f59e0b;
  --enriched-bg: rgba(245, 158, 11, 0.1);
  --qualified: #22c55e;
  --qualified-bg: rgba(34, 197, 94, 0.1);
  --contacted: #8b5cf6;
  --contacted-bg: rgba(139, 92, 246, 0.1);
  --exported: #a855f7;
  --exported-bg: rgba(168, 85, 247, 0.1);
  --rejected: #78716c;
  --rejected-bg: rgba(120, 113, 108, 0.1);
  --score-high: #16a34a;
  --score-mid: #d97706;
  --score-low: #a8a29e;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08);
}

.dark {
  color-scheme: dark;
  --bg: #09090b;
  --bg-inset: #050506;
  --surface: #141416;
  --surface-hover: #1e1e21;
  --surface-raised: #1a1a1d;
  --overlay: rgba(0, 0, 0, 0.7);
  --border: #28282c;
  --border-subtle: #1e1e22;
  --ring: rgba(129, 140, 248, 0.4);
  --text: #ededef;
  --text-secondary: #9898a0;
  --text-muted: #5c5c66;
  --text-on-primary: #09090b;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-soft: rgba(129, 140, 248, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 20px rgba(0,0,0,0.6);
}

/* Base */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--primary-soft); color: var(--text); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px; font-family: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all 150ms ease;
  border: 1px solid transparent; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--text-on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-xs { padding: 2px 8px; font-size: 11px; border-radius: 4px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; background: transparent;
  border: 1px solid var(--border); border-radius: 7px;
  color: var(--text-secondary); cursor: pointer; transition: all 150ms ease; font-size: 14px;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-muted); }

/* Inputs */
.input {
  width: 100%; padding: 8px 12px; background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-family: inherit; font-size: 13px;
  outline: none; transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--text-muted); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; line-height: 1.6; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group .hint { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 4px; }
.form-result { font-size: 12px; }
.form-result.success { color: var(--success); }
.form-result.error { color: var(--danger); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
}
.badge.discovered { background: var(--discovered-bg); color: var(--discovered); }
.badge.enriched { background: var(--enriched-bg); color: var(--enriched); }
.badge.qualified { background: var(--qualified-bg); color: var(--qualified); }
.badge.contacted { background: var(--contacted-bg); color: var(--contacted); }
.badge.exported { background: var(--exported-bg); color: var(--exported); }
.badge.rejected { background: var(--rejected-bg); color: var(--rejected); }
.badge.email { background: rgba(99,102,241,0.1); color: #818cf8; }
.badge.sms { background: rgba(245,158,11,0.1); color: #f59e0b; }
.badge.sent { background: rgba(59,130,246,0.1); color: #60a5fa; }
.badge.delivered { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge.failed, .badge.bounced { background: rgba(239,68,68,0.1); color: #f87171; }
.badge.replied { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge.active { background: rgba(34,197,94,0.1); color: #4ade80; }
.badge.paused { background: rgba(245,158,11,0.1); color: #f59e0b; }
.badge.archived { background: rgba(120,113,108,0.1); color: #a8a29e; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--bg-inset);
}
tbody td { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
tbody tr { transition: background 150ms ease; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }

/* Score */
.score { font-weight: 700; font-size: 13px; font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.score.high { color: var(--score-high); }
.score.mid { color: var(--score-mid); }
.score.low { color: var(--score-low); }

/* Contact icons */
.contact-icons { display: flex; gap: 4px; align-items: center; }
.contact-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 5px; font-size: 13px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); transition: all 150ms ease; text-decoration: none;
}
.contact-icon:hover { background: var(--primary-soft); color: var(--primary); }

/* Stat cards */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 20px; box-shadow: var(--shadow-xs);
}
.stat-card .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.stat-card .sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-card.discovered { border-left: 3px solid var(--discovered); }
.stat-card.enriched { border-left: 3px solid var(--enriched); }
.stat-card.qualified { border-left: 3px solid var(--qualified); }
.stat-card.contacted { border-left: 3px solid var(--contacted); }
.stat-card.exported { border-left: 3px solid var(--exported); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--border-subtle); }
.pagination .info { font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: var(--overlay);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); animation: modal-in 200ms ease;
}
.modal.modal-lg { max-width: 780px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 600; }
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: none; border: none; border-radius: 6px;
  color: var(--text-muted); font-size: 18px; cursor: pointer; transition: all 150ms ease;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 16px 20px; border-top: 1px solid var(--border-subtle);
}

/* Login */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-secondary); font-size: 13px; margin-bottom: 20px; }
.login-error { color: var(--danger); font-size: 12px; margin-top: 10px; display: none; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 52px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .logo {
  width: 28px; height: 28px; background: var(--primary); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: var(--text-on-primary);
}
.topbar-brand > span:first-of-type { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.env-badge {
  font-size: 10px; padding: 1px 7px; background: var(--primary-soft);
  color: var(--primary); border-radius: 999px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.refresh-indicator { font-size: 12px; color: var(--text-muted); margin-right: 4px; }

/* Tabs */
.tab-bar { display: flex; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 150ms ease; white-space: nowrap; margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--primary); }
.tab-btn .count {
  margin-left: 6px; font-size: 11px; padding: 1px 7px;
  background: var(--primary-soft); border-radius: 999px; color: var(--primary); font-weight: 600;
}

/* Shell & Layout */
.shell { display: none; min-height: 100vh; flex-direction: column; }
.shell.active { display: flex; }
.main { flex: 1; padding: 20px; overflow-y: auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Filters */
.filters-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle); flex-wrap: wrap;
}

/* Bulk bar */
.bulk-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--primary-soft); border-bottom: 1px solid var(--border-subtle);
  font-size: 12px; font-weight: 500; color: var(--primary);
}

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.detail-item .label {
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: 600; margin-bottom: 3px;
}
.detail-item .value { font-size: 13px; font-weight: 500; }
.detail-item .value a { color: var(--primary); }
.detail-section { margin-top: 20px; }
.detail-section h3 { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.kv-item { display: flex; flex-direction: column; gap: 2px; }
.kv-key { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kv-val { font-size: 13px; word-break: break-word; }
.signal-item { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
.signal-check { color: var(--success); font-weight: 600; }
.social-links { display: flex; gap: 6px; flex-wrap: wrap; }
.social-link {
  display: inline-flex; align-items: center; padding: 4px 10px;
  background: var(--primary-soft); border-radius: 6px; font-size: 12px;
  color: var(--primary); font-weight: 500; transition: background 150ms ease;
}
.social-link:hover { background: rgba(99,102,241,0.2); text-decoration: none; }

.status-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }

/* Sequence builder */
.seq-steps-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.seq-steps-header h3 { font-size: 13px; font-weight: 600; }
.seq-step {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; animation: fade-in 200ms ease;
}
.step-num {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary); border-radius: 6px;
  font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.step-fields { flex: 1; display: grid; grid-template-columns: 110px 1fr 140px; gap: 8px; }
.step-connector { width: 2px; height: 8px; background: var(--border); margin: 0 auto; }

/* Variable buttons */
.var-buttons { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.var-btn {
  padding: 2px 8px; background: var(--primary-soft); color: var(--primary);
  border: none; border-radius: 4px; font-size: 11px; font-weight: 500;
  cursor: pointer; font-family: 'JetBrains Mono', monospace; transition: background 150ms ease;
}
.var-btn:hover { background: rgba(99,102,241,0.2); }

/* Template preview */
.tpl-preview {
  padding: 16px; background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; line-height: 1.6; white-space: pre-wrap;
  min-height: 80px; color: var(--text-secondary);
}
.tpl-preview .var-highlight {
  background: var(--primary-soft); color: var(--primary); padding: 1px 4px;
  border-radius: 3px; font-weight: 500;
}

/* States */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.loading-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-left: 6px;
}
.ts { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.font-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* Animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Responsive */
@media (max-width: 768px) {
  .topbar { padding: 0 12px; }
  .tab-bar { padding: 0 12px; }
  .main { padding: 12px; }
  .detail-grid, .kv-grid { grid-template-columns: 1fr; }
  .step-fields { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .modal { margin: 12px; }
}
@media (max-width: 480px) {
  .tab-btn { padding: 10px 10px; font-size: 12px; }
  .filters-row { flex-direction: column; }
  .stat-card { padding: 12px 16px; }
  .stat-card .value { font-size: 22px; }
}
