/* ============================================================
   PileOps Permit Intelligence — Main Stylesheet
   Dark professional theme
   ============================================================ */

:root {
  --bg: #0f1117;
  --bg2: #161b22;
  --card-bg: #1c2230;
  --card-bg2: #202736;
  --border: #2d3748;
  --border-light: #374151;
  --text: #e2e8f0;
  --text-muted: #718096;
  --text-dim: #4a5568;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

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

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1e3a5f 0%, #0f1117 100%);
}

.brand-icon {
  font-size: 24px;
  color: var(--primary);
  line-height: 1;
}

.brand-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: white;
  letter-spacing: .5px;
}

.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-section {
  padding: 16px 0 8px;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  padding: 0 16px 6px;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  color: var(--text-muted);
  border-radius: 0;
  transition: all .15s;
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover {
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(59,130,246,.15);
  color: var(--primary);
  border-right: 2px solid var(--primary);
}

.nav-icon { font-size: 13px; opacity: .7; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.username { color: var(--text-muted); }

.logout-btn {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}
.logout-btn:hover { color: var(--danger); text-decoration: none; }

/* ============================================================
   Main Content
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px;
  max-width: calc(100vw - var(--sidebar-w));
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.card-body {
  padding: 18px;
}

.card-body.p-0 { padding: 0; }

/* ============================================================
   Dashboard Stats
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  font-size: 22px;
  opacity: .7;
}

.stat-primary { border-top: 3px solid var(--primary); }
.stat-success { border-top: 3px solid var(--success); }
.stat-warning { border-top: 3px solid var(--warning); }
.stat-info    { border-top: 3px solid var(--info); }
.stat-dark    { border-top: 3px solid var(--text-dim); }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: white;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid .card:first-child { grid-column: span 2; }
}

/* ============================================================
   Tables
   ============================================================ */
.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table thead th {
  background: var(--card-bg2);
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table thead th a {
  color: var(--text-muted);
  text-decoration: none;
}
.table thead th a:hover { color: var(--text); }

.table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

.table tbody tr:hover { background: var(--card-bg2); }

.table tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr.row-confirmed { background: rgba(34,197,94,.05); }
.table tbody tr.row-rejected  { background: rgba(239,68,68,.05); opacity: .7; }
.table tbody tr.tier-header-row { background: var(--bg2); }
.table tbody tr.tier-header-row td { padding: 8px 14px; color: var(--text-muted); }
.table tbody tr.error-row td { background: rgba(239,68,68,.08); color: var(--danger); padding: 4px 14px 8px; font-size: 12px; }

.lead-row { cursor: pointer; }

.col-score { width: 70px; }

/* ============================================================
   Score Badges
   ============================================================ */
.score-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}
.score-badge.score-lg { font-size: 18px; padding: 4px 14px; }
.score-badge.score-high   { background: rgba(34,197,94,.2);  color: #4ade80; }
.score-badge.score-medium { background: rgba(245,158,11,.2); color: #fbbf24; }
.score-badge.score-low    { background: rgba(107,114,128,.2); color: #9ca3af; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-lg { font-size: 14px; padding: 4px 12px; }
.badge-success { background: rgba(34,197,94,.2); color: var(--success); }
.badge-error   { background: rgba(239,68,68,.2); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.2); color: var(--warning); }
.badge-info    { background: rgba(6,182,212,.2); color: var(--info); }
.badge-neutral { background: var(--card-bg2); color: var(--text-muted); }
.badge-running { background: rgba(59,130,246,.2); color: var(--primary); }

/* ============================================================
   Signal chips
   ============================================================ */
.signal-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  margin-right: 3px;
  margin-bottom: 2px;
  white-space: nowrap;
}
.signal-chip.tier-1 { background: rgba(239,68,68,.2);  color: #f87171; }
.signal-chip.tier-2 { background: rgba(245,158,11,.2); color: #fbbf24; }
.signal-chip.tier-3 { background: rgba(59,130,246,.2); color: #93c5fd; }
.signal-chip.tier-4 { background: rgba(107,114,128,.2); color: #9ca3af; }

/* ============================================================
   Tier badges
   ============================================================ */
.tier-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.tier-badge.t1, .t1 { background: rgba(239,68,68,.25); color: #f87171; }
.tier-badge.t2, .t2 { background: rgba(245,158,11,.25); color: #fbbf24; }
.tier-badge.t3, .t3 { background: rgba(59,130,246,.25); color: #93c5fd; }
.tier-badge.t4, .t4 { background: rgba(107,114,128,.25); color: #9ca3af; }

/* ============================================================
   Source tag
   ============================================================ */
.source-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(6,182,212,.15);
  color: var(--info);
  font-size: 11px;
  font-family: monospace;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }

.btn-primary  { background: var(--primary);  color: white; }
.btn-success  { background: var(--success);  color: white; }
.btn-danger   { background: var(--danger);   color: white; }
.btn-outline  { background: transparent; border: 1px solid var(--border-light); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--text-muted); padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm       { padding: 4px 10px; font-size: 12px; }
.btn-xs       { padding: 2px 8px; font-size: 11px; border-radius: 4px; }
.btn-full     { width: 100%; justify-content: center; }
.btn-active   { opacity: .8; box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }
.btn-warning  { background: var(--warning); color: #0f1117; }

.btn-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-confirm { background: rgba(34,197,94,.2); color: var(--success); }
.btn-confirm:hover { background: rgba(34,197,94,.4); }
.btn-reject  { background: rgba(239,68,68,.2); color: var(--danger); }
.btn-reject:hover { background: rgba(239,68,68,.4); }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }

input[type=text], input[type=password], input[type=number],
input[type=email], select, textarea {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  width: 100%;
  transition: border .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
input::placeholder { color: var(--text-dim); }

.input-sm { width: 80px; }

/* ============================================================
   Filter card
   ============================================================ */
.filter-card { margin-bottom: 16px; }
.filter-form { padding: 14px 18px; }
.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-input  { flex: 1; min-width: 140px; }
.filter-search { flex: 2; min-width: 200px; }
.filter-select { flex: 1; min-width: 140px; }
.filter-score  { width: 100px; flex: none; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-btn {
  padding: 4px 10px;
  border-radius: 5px;
  background: var(--card-bg2);
  color: var(--text-muted);
  font-size: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  transition: all .1s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-info { margin-left: auto; font-size: 12px; color: var(--text-muted); }

/* ============================================================
   Lead Detail
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.feedback-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.feedback-bar.feedback-confirmed { border-left: 4px solid var(--success); }
.feedback-bar.feedback-rejected  { border-left: 4px solid var(--danger); }
.feedback-status { display: flex; align-items: center; gap: 12px; }
.feedback-actions { display: flex; gap: 8px; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin-bottom: 16px;
}
.info-pair {}
.info-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .5px; margin-bottom: 2px; }
.info-value { color: var(--text); font-size: 13px; }
.info-value.mono { font-family: monospace; font-size: 13px; }

.description-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.description-text { color: var(--text-muted); font-size: 13px; line-height: 1.7; }

.map-link { margin-left: 8px; font-size: 12px; }

/* Signals */
.signals-list { display: flex; flex-direction: column; gap: 10px; }

.signal-item {
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.signal-item.tier-1 { border-left: 3px solid #ef4444; }
.signal-item.tier-2 { border-left: 3px solid #f59e0b; }
.signal-item.tier-3 { border-left: 3px solid #3b82f6; }
.signal-item.tier-4 { border-left: 3px solid #6b7280; }

.signal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--card-bg2);
}
.signal-info { display: flex; align-items: center; gap: 8px; }
.signal-name { font-weight: 600; font-size: 13px; color: var(--text); }
.signal-count { font-size: 11px; color: var(--text-muted); }
.signal-weight { display: flex; align-items: center; gap: 4px; }
.weight-label { font-size: 10px; color: var(--text-dim); }
.weight-value { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.signal-snippets { padding: 8px 12px; }
.snippet {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 4px;
  font-family: monospace;
  line-height: 1.5;
}

/* Score breakdown */
.score-breakdown { text-align: center; }
.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border: 6px solid;
}
.score-circle.score-high   { border-color: var(--success); }
.score-circle.score-medium { border-color: var(--warning); }
.score-circle.score-low    { border-color: var(--text-dim); }
.score-number { font-size: 28px; font-weight: 700; color: white; }
.score-label  { font-size: 11px; color: var(--text-muted); }

.score-bar-container { margin-bottom: 16px; }
.score-bar-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; }
.score-fill-high   { background: var(--success); }
.score-fill-medium { background: var(--warning); }
.score-fill-low    { background: var(--text-dim); }

.tier-summary { text-align: left; }
.tier-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }

/* Contacts */
.contacts-list { display: flex; flex-direction: column; gap: 12px; }
.contact-item {}
.contact-role { font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; letter-spacing: .5px; }
.contact-name { font-size: 14px; color: var(--text); }
.contact-value { font-size: 13px; }

.contact-mini { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* PDF list */
.pdf-list { display: flex; flex-direction: column; gap: 8px; }
.pdf-item { display: flex; align-items: center; gap: 8px; }
.pdf-icon { font-size: 16px; }
.pdf-link { font-size: 13px; font-family: monospace; }

/* ============================================================
   Info lists
   ============================================================ */
.info-list { display: flex; flex-direction: column; gap: 8px; }
.info-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ============================================================
   Bar charts
   ============================================================ */
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-item { display: flex; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--text-muted); min-width: 90px; text-align: right; text-decoration: none; }
.bar-label:hover { color: var(--primary); text-decoration: none; }
.bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.bar-fill-county { background: var(--info); }
.bar-count { font-size: 12px; color: var(--text-muted); min-width: 30px; }

/* ============================================================
   Scanner page
   ============================================================ */
.scan-form { }
.scan-options { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.form-group-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.form-group-inline label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.scraper-name { font-weight: 500; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.pulse { animation: pulse 1.5s infinite; }

/* ============================================================
   Confidence indicator
   ============================================================ */
.confidence-indicator {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.confidence-high   { background: rgba(34,197,94,.2);  color: var(--success); }
.confidence-medium { background: rgba(245,158,11,.2); color: var(--warning); }
.confidence-low    { background: rgba(107,114,128,.2); color: var(--text-muted); }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-container { margin-bottom: 16px; }
.flash {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
.flash-success { background: rgba(34,197,94,.15);  color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.flash-error   { background: rgba(239,68,68,.15);  color: var(--danger);  border: 1px solid rgba(239,68,68,.3); }
.flash-info    { background: rgba(59,130,246,.15); color: var(--primary); border: 1px solid rgba(59,130,246,.3); }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state a { color: var(--primary); }

/* ============================================================
   Login page
   ============================================================ */
.login-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 12px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: white;
  margin-bottom: 4px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 13px;
}

.login-tagline {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  background: rgba(59,130,246,.15);
  color: var(--primary);
  border-radius: 12px;
  font-size: 11px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-footer {
  font-size: 12px;
  color: var(--text-dim);
}

/* ============================================================
   Settings / help
   ============================================================ */
.help-text p { margin-bottom: 12px; color: var(--text-muted); font-size: 13px; line-height: 1.7; }
.help-text code {
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: monospace;
  color: var(--info);
}
.mt-1 { margin-top: 8px; }

/* ============================================================
   Utility classes
   ============================================================ */
.text-sm     { font-size: 12px; }
.text-xs     { font-size: 11px; }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: monospace; }

/* ============================================================
   CRM / Sales Activity
   ============================================================ */
.outreach-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.outreach-new        { background: #1e2a35; color: #8899aa; }
.outreach-contacted  { background: #1a3048; color: #5ba8d8; }
.outreach-interested { background: #1f3a28; color: #4caf50; }
.outreach-quoted     { background: #3a2d0f; color: #f0a500; }
.outreach-won        { background: #1a3a20; color: #2ecc71; border: 1px solid #2ecc71; }
.outreach-lost       { background: #2d1a1a; color: #e74c3c; }

.outreach-stages {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.outreach-stage-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-muted);
  transition: all 0.15s;
}
.outreach-stage-btn:hover           { border-color: var(--border); color: var(--text); }
.outreach-stage-btn.active          { font-weight: 700; }
.outreach-stage-btn.outreach-new.active        { background: #1e2a35; color: #8899aa; border-color: #4a5a6a; }
.outreach-stage-btn.outreach-contacted.active  { background: #1a3048; color: #5ba8d8; border-color: #5ba8d8; }
.outreach-stage-btn.outreach-interested.active { background: #1f3a28; color: #4caf50; border-color: #4caf50; }
.outreach-stage-btn.outreach-quoted.active     { background: #3a2d0f; color: #f0a500; border-color: #f0a500; }
.outreach-stage-btn.outreach-won.active        { background: #1a3a20; color: #2ecc71; border-color: #2ecc71; }
.outreach-stage-btn.outreach-lost.active       { background: #2d1a1a; color: #e74c3c; border-color: #e74c3c; }

.outreach-notes {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.outreach-notes:focus { outline: none; border-color: var(--primary); }

/* ============================================================
   Pipeline Funnel
   ============================================================ */
.pipeline-funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.funnel-label {
  font-size: 12px;
  min-width: 80px;
  text-align: right;
  color: var(--text-muted);
}
.funnel-bar-wrap {
  flex: 1;
  height: 22px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.funnel-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  min-width: 2px;
}
.funnel-count {
  font-size: 12px;
  min-width: 32px;
  color: var(--text-muted);
  text-align: right;
}
.funnel-new        { background: linear-gradient(90deg, #3a4a5c, #2a3848); }
.funnel-contacted  { background: linear-gradient(90deg, #1a4060, #1a3050); }
.funnel-interested { background: linear-gradient(90deg, #1f5030, #1a3828); }
.funnel-quoted     { background: linear-gradient(90deg, #5a4010, #4a3010); }
.funnel-won        { background: linear-gradient(90deg, #1a7030, #1a5025); }
.funnel-lost       { background: linear-gradient(90deg, #5a1a1a, #401212); }

/* ============================================================
   Score Distribution Chart
   ============================================================ */
.score-dist {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dist-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 52px;
  text-align: right;
  font-family: monospace;
}
.dist-bar-wrap {
  flex: 1;
  height: 16px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.dist-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
}
.dist-90 { background: #22c55e; }
.dist-70 { background: #4ade80; }
.dist-50 { background: #f59e0b; }
.dist-30 { background: #fbbf24; }
.dist-10 { background: #6b7280; }
.dist-0  { background: #374151; }
.dist-count {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}

/* ============================================================
   Top Leads card
   ============================================================ */
.top-lead-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.top-lead-row:last-child { border-bottom: none; }
.top-lead-row:hover { text-decoration: none; }
.top-lead-score {
  flex-shrink: 0;
}
.top-lead-info {
  flex: 1;
  min-width: 0;
}
.top-lead-addr {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-lead-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.top-lead-arrow {
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}

/* ============================================================
   KPI Cards — enhanced
   ============================================================ */
.stat-body { flex: 1; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.kpi-primary::after   { background: var(--primary); }
.kpi-success::after   { background: var(--success); }
.kpi-warning::after   { background: var(--warning); }
.kpi-info::after      { background: var(--info); }
.kpi-muted::after     { background: var(--text-dim); }

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: white;
  line-height: 1;
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}
.kpi-icon {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 20px;
  opacity: .2;
}
.kpi-delta {
  font-size: 11px;
  color: var(--success);
  margin-top: 4px;
}

/* ============================================================
   Source tag colors
   ============================================================ */
.source-tag.src-seattle        { background: rgba(59,130,246,.15); color: #93c5fd; }
.source-tag.src-seattle_trade  { background: rgba(99,102,241,.15); color: #a5b4fc; }
.source-tag.src-clark_county   { background: rgba(34,197,94,.15);  color: #86efac; }
.source-tag.src-tacoma         { background: rgba(245,158,11,.15); color: #fcd34d; }
.source-tag.src-pierce_county  { background: rgba(239,68,68,.15);  color: #fca5a5; }
.source-tag.src-spokane_city   { background: rgba(168,85,247,.15); color: #d8b4fe; }
.source-tag.src-spokane_county { background: rgba(192,72,219,.15); color: #e879f9; }
.source-tag.src-cowlitz_county { background: rgba(20,184,166,.15); color: #5eead4; }
.source-tag.src-kitsap_county  { background: rgba(6,182,212,.15);  color: #67e8f9; }
.source-tag.src-mybuildingpermit { background: rgba(16,185,129,.15); color: #6ee7b7; }

/* ============================================================
   Scanner progress / live status
   ============================================================ */
.scanner-live-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.scanner-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(59,130,246,.15);
  border: 1px solid rgba(59,130,246,.3);
  color: var(--primary);
  font-size: 12px;
}
.scanner-chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.2s infinite;
}

/* ============================================================
   Enricher status badge
   ============================================================ */
.enrich-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.enrich-pending  { background: rgba(245,158,11,.15); color: var(--warning); }
.enrich-done     { background: rgba(34,197,94,.15);  color: var(--success); }
.enrich-failed   { background: rgba(239,68,68,.15);  color: var(--danger); }

/* ============================================================
   Responsive tweaks
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main-content { margin-left: 0; max-width: 100vw; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .filter-row { flex-direction: column; }
  .filter-input, .filter-select, .filter-search, .filter-score { min-width: 100%; }
}

/* ============================================================
   Help Tooltips
   ============================================================ */
.help-tip {
  position: relative;
  cursor: help;
  margin-left: 4px;
  color: var(--text-dim);
  font-size: 12px;
}
.help-tip:hover { color: var(--text-muted); }
.help-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #e2e8f0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
  width: 220px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  border: 1px solid var(--border);
  z-index: 1000;
  pointer-events: none;
  text-transform: none;
  letter-spacing: normal;
}

/* ============================================================
   CRM Calendar & Activity Log
   ============================================================ */
.activity-log { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  display: flex; gap: 12px; padding: 10px 14px;
  border-radius: 6px; border-left: 3px solid var(--border);
  background: var(--bg2);
}
.activity-item.type-call { border-left-color: #3b82f6; }
.activity-item.type-email { border-left-color: #8b5cf6; }
.activity-item.type-meeting { border-left-color: #22c55e; }
.activity-item.type-site_visit { border-left-color: #f97316; }
.activity-item.type-quote { border-left-color: #eab308; }
.activity-item.type-note { border-left-color: #6b7280; }
.activity-icon { font-size: 16px; opacity: .6; flex-shrink: 0; padding-top: 2px; }
.activity-content { flex: 1; min-width: 0; }
.activity-subject { font-size: 13px; font-weight: 600; color: var(--text); }
.activity-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.activity-meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.calendar-day { margin-bottom: 20px; }
.calendar-date-header {
  font-size: 13px; font-weight: 700; color: var(--text);
  padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.calendar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 6px; background: var(--bg2);
  margin-bottom: 6px;
}
.calendar-time { font-size: 12px; color: var(--primary); font-weight: 600; min-width: 60px; }
.calendar-info { flex: 1; }
.calendar-subject { font-size: 13px; color: var(--text); }
.calendar-detail { font-size: 11px; color: var(--text-muted); }

/* Agent Status */
.agent-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.agent-name { font-size: 15px; font-weight: 700; color: white; margin-bottom: 4px; }
.agent-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.agent-stat { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.agent-stat-label { color: var(--text-muted); }
.agent-stat-value { color: var(--text); font-weight: 500; }

/* ============================================================
   Smooth scroll + focus ring
   ============================================================ */
html { scroll-behavior: smooth; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ============================================================
   Print styles
   ============================================================ */
@media print {
  .sidebar, .page-actions, .filter-card, .feedback-actions { display: none !important; }
  .main-content { margin-left: 0; }
  .card { break-inside: avoid; }
}
