:root {
  --bg: #0f1419;
  --surface: #1a2028;
  --surface-2: #232b36;
  --border: #2f3844;
  --text: #e6edf3;
  --text-dim: #8b98a8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --new: #6366f1;
  --contacted: #0ea5e9;
  --responded: #8b5cf6;
  --won: #22c55e;
  --lost: #ef4444;
  --disqualified: #6b7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: grid; place-items: center;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 600; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.top-actions { display: flex; align-items: center; gap: 16px; }
.user-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
}
.user-chip::before {
  content: '●';
  color: var(--success);
  margin-right: 6px;
}
.sync-status { text-align: right; font-size: 12px; }
.sync-status .label { display: block; color: var(--text-dim); }
.sync-status span:last-child { font-weight: 500; }

.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--text-dim); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.stats {
  display: flex;
  gap: 12px;
  padding: 20px 28px 0;
  flex-wrap: wrap;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 110px;
}
.stat .num { font-size: 22px; font-weight: 600; }
.stat .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.stat.accent .num { color: var(--accent); }
.stat.warn .num { color: var(--warn); }

.stale-banner {
  margin: 20px 28px 0;
  padding: 12px 16px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--warn);
  font-size: 14px;
}
.stale-banner.hidden { display: none; }

.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(230px, 1fr));
  gap: 12px;
  padding: 20px 28px 40px;
  overflow-x: auto;
}
.column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-height: 200px;
}
.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding: 0 4px;
}
.column-header .count {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px;
}
.status-new .status-dot, .col-new .status-dot { background: var(--new); }
.status-contacted .status-dot, .col-contacted .status-dot { background: var(--contacted); }
.status-responded .status-dot, .col-responded .status-dot { background: var(--responded); }
.status-won .status-dot, .col-won .status-dot { background: var(--won); }
.status-lost .status-dot, .col-lost .status-dot { background: var(--lost); }
.status-disqualified .status-dot, .col-disqualified .status-dot { background: var(--disqualified); }

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card.stale { border-color: var(--warn); }
.card .company { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--text-dim); }
.badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge.score {
  background: var(--accent);
  color: white;
}
.badge.type { background: var(--surface); border: 1px solid var(--border); }
.badge.stale { background: var(--warn); color: #1a1a1a; }

.card .pain {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}
.empty h2 { color: var(--text); margin: 0 0 8px; }
.empty.hidden { display: none; }

.backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.backdrop.hidden { display: none; }

.detail {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 20;
  padding: 24px 28px;
}
.detail.hidden { display: none; }
.close-btn {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover { color: var(--text); }

.detail h2 { margin: 0 0 6px; font-size: 22px; }
.detail .link { color: var(--accent); font-size: 13px; text-decoration: none; }
.detail .link:hover { text-decoration: underline; }
.detail .section { margin-top: 24px; }
.detail .section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin: 0 0 8px;
  font-weight: 600;
}
.detail .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.detail .row:last-child { border-bottom: none; }
.detail .row .label { color: var(--text-dim); }

.status-select {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.interactions { margin-top: 8px; }
.interaction {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
  margin-bottom: 6px;
  font-size: 13px;
  position: relative;
}
.interaction .when { color: var(--text-dim); font-size: 11px; margin-bottom: 2px; }
.interaction .type-tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--accent);
  border-radius: 3px;
  font-size: 10px;
  margin-right: 6px;
  text-transform: uppercase;
  font-weight: 600;
}
.interaction .remove {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
}
.interaction .remove:hover { color: var(--danger); }

.log-form {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 8px;
  margin-top: 10px;
}
.log-form select, .log-form input, .log-form textarea {
  padding: 9px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

.outreach-block {
  background: var(--surface-2);
  padding: 14px;
  border-radius: 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.copy-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.notes-input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.hidden { display: none; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

.hidden { display: none; }

.conf-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.conf-verified { background: rgba(34, 197, 94, 0.2); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.4); }
.conf-inferred { background: rgba(59, 130, 246, 0.2); color: var(--accent); border: 1px solid rgba(59, 130, 246, 0.4); }
.conf-guessed { background: rgba(245, 158, 11, 0.2); color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.4); }
.conf-none { background: rgba(107, 114, 128, 0.2); color: var(--text-dim); border: 1px solid rgba(107, 114, 128, 0.4); }

.verified {
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  margin-left: 4px;
}

.email-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.email-cell a { color: var(--accent); text-decoration: none; }
.email-cell a:hover { text-decoration: underline; }
.copy-email {
  padding: 2px 7px !important;
  font-size: 12px !important;
  line-height: 1;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.view.hidden { display: none; }

/* Reports view */
.reports-grid {
  display: grid;
  gap: 16px;
  padding: 24px 28px;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
}
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.report-card.missing {
  opacity: 0.6;
  border-style: dashed;
}
.report-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.report-card-title { margin: 0; font-size: 15px; font-weight: 600; }
.report-card-cadence { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.report-card-when {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.report-summary {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.report-summary .kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}
.report-summary .kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.report-summary .kpi b { font-size: 13px; }
.kpi.critical { border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.kpi.high     { border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }
.kpi.moderate { border-color: rgba(59, 130, 246, 0.4); color: #93c5fd; }
.kpi.low      { color: var(--text-dim); }
.kpi.good     { border-color: rgba(34, 197, 94, 0.4); color: #86efac; }

.report-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}
.report-list li { margin-bottom: 2px; }
.report-list strong { color: var(--text); font-weight: 600; }

.report-card details {
  margin-top: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.report-card details summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-dim);
  user-select: none;
}
.report-card details summary:hover { color: var(--text); }
.report-card pre {
  margin: 8px 0 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.45;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.severity-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 6px;
}
.severity-critical { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.severity-high     { background: rgba(245, 158, 11, 0.25); color: #fcd34d; }
.severity-medium   { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.severity-low      { background: rgba(107, 114, 128, 0.25); color: var(--text-dim); }
