@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600&family=Barlow+Condensed:wght@400;600;700&display=swap');

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

:root {
  /* Backgrounds - Refined palette */
  --bg-base: #0d1117;
  --bg-page: #0d1117;
  --bg-sidebar: #111820;
  --bg-card: #131c27;
  --bg-card-hover: #1a2333;
  --bg-surface: #111820;
  --border: #1e2d3d;
  --border-hover: rgba(0, 229, 200, 0.19);
  
  /* Accent Colors */
  --accent-primary: #00e5c8;
  --accent-hover: #00bfa8;
  --accent-muted: rgba(0, 229, 200, 0.08);
  
  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #7a8fa6;
  --text-secondary-light: #c4d4e3;
  --text-body: #8fa8c0;
  --text-label: #00e5c8;
  --text-muted: #7a8fa6;
  
  /* Legacy for compat */
  --bg: #0d1117;
  --bg-2: #111820;
  --bg-3: #131c27;
  --text: #ffffff;
  --text-2: #7a8fa6;
  --text-3: #7a8fa6;
  --red: #ef4444;
  --red-dim: rgba(239,68,68,0.12);
  --radius: 4px;
  --accent: #00e5c8;
  --surface: #111820;
}

html { font-size: 14px; }
body {
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { text-decoration: none; color: inherit; }

/* ─── APP LAYOUT ─── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: 200px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  padding: 0 16px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  transition: all 0.1s;
  cursor: pointer;
  border-left: 2px solid transparent;
  padding-left: 18px;
  margin-left: -2px;
}
.sidebar-link::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.sidebar-link:hover { color: var(--text-primary); }
.sidebar-link.active { 
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  background: var(--accent-muted);
  padding-left: 18px;
}

.sidebar-logout {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  color: var(--text-secondary);
}
.sidebar-logout:hover { color: var(--text-primary); }

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  min-height: 100vh;
  background: var(--bg-page);
}

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── STATS ROW ─── */
.stats-row {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}
.stat-item {
  flex: 1;
  padding: 0 0 20px 0;
  margin-right: 32px;
}
.stat-item:last-child { margin-right: 0; }
.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-value.stat-red { color: var(--red); }
.stat-label {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
  margin-top: 8px;
}

/* ─── TABLES ─── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
  padding: 0 0 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.08s;
}
tbody tr:hover { background: var(--bg-card-hover); }
tbody td {
  padding: 11px 0;
  font-size: 13px;
  color: var(--text-secondary);
}
tbody td:first-child { color: var(--text-primary); }

/* ─── PRIORITY DOT ─── */
.priority-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}
.dot-high { background: var(--red); }
.dot-medium { background: var(--accent-primary); }
.dot-low { background: var(--text-secondary); }

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.03em;
}
.badge-high { background: var(--red-dim); color: var(--red); }
.badge-medium { color: var(--accent-primary); border: 1px solid var(--accent-primary); }
.badge-low { color: var(--text-secondary); border: 1px solid var(--border); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.btn:hover { opacity: 0.9; }
.btn-ghost { color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--accent-muted); color: var(--text-primary); border-color: var(--accent-primary); }
.btn-primary { 
  background: var(--accent-primary); 
  color: var(--bg-base); 
  border: none;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-danger { color: var(--red); border: 1px solid var(--border); }
.btn-danger:hover { background: var(--red-dim); }

/* ─── PANELS / CARDS ─── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}
.panel:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-muted);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
}

/* ─── FORMS ─── */
input, select, textarea {
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 8px 11px;
  outline: none;
  width: 100%;
  transition: border-color 0.1s;
}
input::placeholder { color: var(--text-secondary); }
input:focus, select:focus, textarea:focus { 
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
}

/* ─── MODALS ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 480px;
  max-width: 90vw;
}
.modal-title { 
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 16px; 
  font-weight: 600; 
  color: var(--text-primary); 
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ─── WHY THIS LEAD LABEL ─── */
.why-this-lead {
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-label);
}

/* ─── PROGRESS STEPPER ─── */
.progress-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stepper-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.stepper-circle.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-base);
}
.stepper-circle.completed {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-base);
}
.stepper-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background 0.15s;
}
.stepper-line.active {
  background: var(--accent-primary);
}

/* ─── PILL / CHIP ─── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.pill.selected {
  border-color: var(--accent-primary);
  background: var(--accent-muted);
  color: var(--accent-primary);
}
.pill:hover {
  border-color: var(--accent-primary);
}

/* ─── MISC ─── */
.form-group { margin-bottom: 12px; }
.form-group label { 
  display: block; 
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
  font-size: 11px; 
  text-transform: uppercase; 
  letter-spacing: 0.08em; 
  color: var(--text-label); 
  margin-bottom: 6px;
  font-weight: 600;
}
.scan-status { 
  display: none; 
  align-items: center; 
  gap: 10px; 
  padding: 10px 14px; 
  background: var(--bg-card); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  margin-bottom: 16px; 
  font-size: 13px; 
  color: var(--text-secondary); 
}
.spinner { 
  width: 14px; 
  height: 14px; 
  border: 1.5px solid var(--border); 
  border-top-color: var(--accent-primary); 
  border-radius: 50%; 
  animation: spin 0.6s linear infinite; 
  flex-shrink: 0; 
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast { 
  position: fixed; 
  bottom: 20px; 
  right: 20px; 
  background: var(--bg-card); 
  border: 1px solid var(--border); 
  padding: 10px 16px; 
  border-radius: var(--radius); 
  font-size: 13px; 
  color: var(--text-primary); 
  opacity: 0; 
  transform: translateY(8px); 
  transition: all 0.2s; 
  pointer-events: none; 
  z-index: 200; 
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--accent-primary); color: var(--accent-primary); }

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .sidebar { width: 160px; min-width: 160px; }
  .main-content { padding: 20px 16px; }
}

/* ─── TYPOGRAPHY OVERRIDES ─── */
body { font-size: 16px; }
.text-muted, .text-secondary, [class*='subtitle'], [class*='subtext'] { 
  color: var(--text-secondary) !important; 
}
th, [class*='col-header'], thead td { 
  color: var(--text-label) !important; 
  font-size: 0.75rem; 
  letter-spacing: 0.05em; 
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
}
.lead-card p, .lead-card span:not(.badge) { 
  color: var(--text-secondary) !important; 
  font-size: 0.875rem; 
}

/* Ensure proper contrast */
* { color: inherit; }
body { 
  font-size: 16px; 
  color: var(--text-primary); 
}
p, span, small, label, td, th, div { opacity: 1 !important; }
.stat-label, [class*='label'], [class*='subtitle'], [class*='meta'] { 
  color: var(--text-label) !important; 
  font-size: 0.8rem; 
  letter-spacing: 0.06em; 
  font-family: 'Barlow Condensed', system-ui, -apple-system, sans-serif;
}
th { color: var(--text-label) !important; }
.card p, .card span, .lead-card p, .lead-card span { 
  color: var(--text-secondary) !important; 
}
