/* ============================================================
   MitchPolly Web — Dark Theme
   ============================================================ */

:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --surface3:     #2d333b;
  --border:       #30363d;
  --border-light: #444c56;
  --text:         #c9d1d9;
  --text-muted:   #8b949e;
  --text-subtle:  #6e7681;
  --accent:       #58a6ff;
  --accent-dim:   #1f3d5c;
  --green:        #3fb950;
  --green-dim:    #1a3d23;
  --yellow:       #d29922;
  --yellow-dim:   #3d2e0a;
  --red:          #f85149;
  --red-dim:      #3d1c1a;
  --purple:       #a371f7;
  --pink:         #ec4899;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --radius:       6px;
  --radius-lg:    10px;
  --sidebar-w:    210px;
  --transition:   0.15s ease;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

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

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon { font-size: 20px; }
.brand-name { font-weight: 600; font-size: 15px; color: var(--text); }

.sidebar-nav {
  list-style: none;
  padding: 8px 0;
  flex: 1;
}

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

.nav-link:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }
.nav-icon { font-size: 12px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.btn-add-lead {
  display: block;
  text-align: center;
  padding: 7px 12px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}
.btn-add-lead:hover { border-color: var(--border-light); background: var(--surface3); text-decoration: none; }

/* ============================================================
   Main content
   ============================================================ */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 24px 28px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

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

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}

.card-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-link { font-size: 12px; font-weight: 400; text-transform: none; letter-spacing: 0; }

.card-body { padding: 16px; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: #79b8ff; border-color: #79b8ff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); border-color: var(--border-light); }

.btn-action {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-action:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  font-size: 12px;
  padding: 6px 12px;
}
.btn-danger-ghost:hover { color: var(--red); border-color: var(--red); }

.btn-edit { margin-left: auto; }

.btn-sm { font-size: 12px; padding: 4px 10px; }
.btn-find { padding: 9px 20px; font-size: 14px; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-stage { background: var(--surface3); color: var(--text-muted); border: 1px solid var(--border); }
.badge-cold   { color: var(--text-subtle); }
.badge-contacted { color: var(--accent); border-color: var(--accent-dim); background: var(--accent-dim); }
.badge-replied   { color: var(--purple); border-color: #3d2a5c; background: #2a1f3d; }
.badge-meeting   { color: var(--yellow); border-color: var(--yellow-dim); background: var(--yellow-dim); }
.badge-proposal  { color: var(--purple); border-color: #3d2a5c; background: #2a1f3d; }
.badge-closed_won  { color: var(--green); border-color: var(--green-dim); background: var(--green-dim); }
.badge-closed_lost { color: var(--red); border-color: var(--red-dim); background: var(--red-dim); }
.badge-nurture   { color: var(--pink); border-color: #3d1f30; background: #2d1525; }
.badge-retainer  { color: var(--green); border-color: var(--green-dim); background: var(--green-dim); font-weight: 700; }

.score-badge {
  display: inline-block;
  width: 28px;
  text-align: center;
  padding: 2px 0;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 700;
}
.score-high { background: var(--green-dim); color: var(--green); }
.score-mid  { background: var(--yellow-dim); color: var(--yellow); }
.score-low  { background: var(--red-dim); color: var(--red); }
.score-none { background: var(--surface3); color: var(--text-subtle); }

.score-badge-lg {
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
}

.icp-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
}
.icp-trapped-product-owner { color: #38bdf8; background: #0c2537; border: 1px solid #1a4060; }
.icp-engineering-documentation-crisis { color: #c084fc; background: #1e1040; border: 1px solid #3d2060; }
.icp-other { color: var(--text-muted); background: var(--surface3); border: 1px solid var(--border); }

/* ============================================================
   Dashboard
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-value.accent { color: var(--accent); }
.stat-value.green  { color: var(--green); }

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

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pipeline-bars { padding: 12px 16px; }
.pipeline-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.pipeline-label { width: 90px; font-size: 12px; color: var(--text-muted); text-transform: capitalize; flex-shrink: 0; }
.pipeline-bar-wrap { flex: 1; background: var(--surface3); border-radius: 3px; height: 8px; overflow: hidden; }
.pipeline-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.pipeline-count { width: 24px; text-align: right; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }

.followup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.followup-row:last-child { border-bottom: none; }
.followup-company { font-weight: 500; color: var(--text); display: block; }
.followup-action { font-size: 12px; color: var(--text-muted); }
.followup-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.due-date { font-size: 12px; color: var(--text-muted); }
.due-date.overdue, .overdue { color: var(--red); font-weight: 600; }

/* ============================================================
   Leads Table
   ============================================================ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-input {
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  width: 220px;
  transition: border-color var(--transition);
}
.filter-input:focus { outline: none; border-color: var(--accent); }

.filter-select {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.lead-count { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.batch-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.batch-bar.batch-bar-visible { display: flex; }
.batch-count { font-size: 13px; font-weight: 600; color: var(--accent); margin-right: 4px; }
.batch-progress { font-size: 12px; color: var(--text-muted); margin-left: 4px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

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

.leads-table th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.leads-table th.sortable { cursor: pointer; }
.leads-table th.sortable:hover { color: var(--text); }
.leads-table th.sort-desc .sort-icon::after { content: ' ↓'; }
.leads-table th.sort-asc  .sort-icon::after { content: ' ↑'; }
.sort-icon { color: var(--text-subtle); font-size: 11px; }

.leads-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.lead-row {
  cursor: pointer;
  transition: background var(--transition);
}
.lead-row:hover td { background: var(--surface2); }
.lead-row:last-child td { border-bottom: none; }

.col-id { color: var(--text-subtle); width: 40px; }
.col-company { font-weight: 500; }
.col-center { text-align: center; }
.col-dm { color: var(--text-muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.company-name { margin-right: 6px; }
.company-location { font-size: 0.75rem; color: var(--text-muted); }
.company-link { font-size: 11px; color: var(--text-subtle); }
.company-link:hover { color: var(--accent); }

.table-loading, .empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

.loading-placeholder {
  height: 40px;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
  margin: 16px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ============================================================
   Lead Detail
   ============================================================ */

.lead-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.lead-header-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.lead-website { font-size: 12px; }
.meta-sep { color: var(--text-subtle); }

.lead-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.draft-group {
  display: flex;
  align-items: center;
  gap: 0;
}

.draft-step-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  max-width: 170px;
}
.draft-step-select:focus { outline: none; }

.draft-group .btn-action { border-radius: var(--radius) 0 0 var(--radius); }

.result-panel {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}

.result-panel-header {
  padding: 10px 16px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.panel-close:hover { color: var(--text); }

#resultPanelBody { padding: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}

.field-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: none; }
.field-row.field-block { flex-direction: column; gap: 4px; }

.field-label {
  font-size: 12px;
  color: var(--text-muted);
  width: 120px;
  flex-shrink: 0;
  padding-top: 1px;
}
.field-row.field-block .field-label { width: auto; }
.field-value { font-size: 13px; flex: 1; word-break: break-word; }

.notes-pre {
  font-family: var(--font);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.6;
}

.stat-value.yellow { color: var(--yellow); }
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }

.activity-chart {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 16px 16px 0; height: 140px;
  position: relative;
}
.activity-chart::before, .activity-chart::after {
  content: ''; position: absolute; left: 16px; right: 16px;
  height: 1px; pointer-events: none;
}
.activity-chart::before { bottom: var(--goal-min-pct, 33%); border-top: 1px dashed var(--yellow); opacity: 0.5; }
.activity-chart::after  { bottom: var(--goal-strong-pct, 66%); border-top: 1px dashed var(--green); opacity: 0.5; }
.activity-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.activity-col-today .activity-label { color: var(--accent); font-weight: 600; }
.activity-bar-wrap { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.activity-bar { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 3px 3px 0 0; overflow: hidden; transition: height 0.4s ease; }
.activity-segment { width: 100%; flex-shrink: 0; }
.seg-email    { background: var(--accent); }
.seg-linkedin { background: #0a85d1; }
.seg-phone    { background: var(--green); }
.seg-other    { background: var(--surface3); }
.activity-count { font-size: 10px; color: var(--text-muted); height: 14px; line-height: 14px; }
.activity-label { font-size: 10px; color: var(--text-subtle); padding: 4px 0 8px; text-align: center; white-space: nowrap; }
.activity-legend { display: flex; align-items: center; gap: 12px; padding: 8px 16px 12px; font-size: 11px; color: var(--text-muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
.note-card-manual { border-left: 3px solid var(--accent); }
.note-card-system  { border-left: 3px solid var(--border-light); }
.note-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  background: var(--surface2);
}
.note-source {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.note-source-you { color: var(--accent); }
.note-date { font-size: 0.72rem; color: var(--text-subtle); }
.note-card-body { padding: 8px 10px; }
.note-text { margin: 0 0 4px; font-size: 13px; color: var(--text); line-height: 1.5; }
.note-reasoning { color: var(--text-muted); font-style: italic; }
.note-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 6px;
}
.note-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  margin-right: 2px;
}
.note-tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
}
.note-tag-signal  { background: var(--green-dim);  color: var(--green); }
.note-tag-concern { background: var(--yellow-dim); color: var(--yellow); }

.draft-pre {
  font-family: var(--font);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  line-height: 1.7;
}

.interaction-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.interaction-row:last-child { border-bottom: none; }

.interaction-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.interaction-channel {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  text-transform: uppercase;
}
.badge-channel-email    { background: var(--accent-dim); color: var(--accent); }
.badge-channel-linkedin { background: #1a2f45; color: #0a85d1; }
.badge-channel-phone    { background: var(--green-dim); color: var(--green); }
.badge-channel-other    { background: var(--surface3); color: var(--text-muted); }

.interaction-date { font-size: 12px; color: var(--text-muted); }
.interaction-notes { font-size: 13px; color: var(--text); }
.interaction-outcome { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.interaction-nextstep { font-size: 12px; color: var(--accent); margin-top: 2px; }

/* Result panel content */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.result-field {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.rf-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; letter-spacing: 0.04em; }
.rf-value { font-size: 14px; font-weight: 600; color: var(--text); }

.result-section { margin-bottom: 12px; }
.result-section strong { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 6px; }
.result-section p { font-size: 13px; color: var(--text); line-height: 1.6; }
.result-section ul { padding-left: 16px; font-size: 13px; line-height: 1.7; }
.result-section ul.concerns { color: var(--yellow); }

.result-saved { color: var(--green); font-size: 12px; margin-top: 10px; }
.result-link { color: var(--accent); }

.char-count { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.char-over  { color: var(--red); }
.url-text { font-size: 11px; color: var(--text-subtle); word-break: break-all; margin-top: 4px; }

.error-msg { color: var(--red); font-size: 13px; padding: 8px; background: var(--red-dim); border-radius: var(--radius); }

/* ============================================================
   Find page
   ============================================================ */

.find-card { margin-bottom: 16px; }
.find-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.find-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}
.stat-pill {
  font-size: 12px;
  color: var(--text-muted);
}
.stat-pill.green strong { color: var(--green); }
.stat-pill.muted strong { color: var(--text-subtle); }

.progress-log {
  padding: 12px 16px;
  background: var(--bg);
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
}

.log-line { color: var(--text-muted); }
.log-status { color: var(--text-muted); }
.log-error  { color: var(--red); }
.log-done   { color: var(--green); font-weight: 600; }

.progress-bar-wrap {
  height: 3px;
  background: var(--surface3);
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}
.results-title { font-size: 18px; font-weight: 600; }
.results-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.results-actions { display: flex; align-items: center; gap: 8px; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.result-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: border-color var(--transition), background var(--transition);
  display: flex;
  gap: 10px;
}
.result-card:hover { border-color: var(--accent); }
.result-card.selected { border-color: var(--green); background: var(--green-dim); }
.result-card.added    { opacity: 0.4; pointer-events: none; }

.result-card-check {
  font-size: 14px;
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
  width: 18px;
  opacity: 1;
  transition: opacity var(--transition);
}

.result-card-body { flex: 1; min-width: 0; }
.result-card-name { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 3px; }
.result-card-url  { font-size: 11px; color: var(--accent); display: block; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.result-source-tag { font-size: 10px; color: var(--text-subtle); background: var(--surface3); padding: 1px 6px; border-radius: 20px; display: inline-block; margin-top: 6px; }

.add-result-msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.add-result-msg.success { background: var(--green-dim); color: var(--green); border: 1px solid #2a5c36; }
.add-result-msg.error   { background: var(--red-dim);   color: var(--red);   border: 1px solid #5c2a2a; }

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-wide { max-width: 820px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal form { padding: 20px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Forms
   ============================================================ */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.form-grid-1 { grid-template-columns: 1fr; }
.form-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

input[type=text], input[type=number], input[type=datetime-local], input[type=email],
textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  padding: 7px 10px;
  width: 100%;
  transition: border-color var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-subtle); }

.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.checkbox-label input[type=checkbox] { width: auto; }

.edit-sections { display: flex; flex-direction: column; gap: 0; }
.edit-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.edit-section:last-child { border-bottom: none; }
.edit-section-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

/* ============================================================
   Spinner
   ============================================================ */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .section-grid { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .stats-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .form-grid   { grid-template-columns: 1fr; }
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 200;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  width: 38px; height: 38px;
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; z-index: 100; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .main { margin-left: 0; padding: 12px; padding-top: 56px; }

  /* General */
  .page-title { font-size: 16px; }
  .page-header { margin-bottom: 12px; }
  .section-grid { gap: 10px; }
  .card { margin-bottom: 10px; }
  .modal { max-height: 95vh; }
  .modal-wide { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }

  /* Dashboard */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stats-grid-5 { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 22px; }
  .activity-chart { height: 100px; }
  .activity-label { font-size: 9px; }
  .activity-count { font-size: 9px; }

  /* Lead detail action bar */
  .action-bar { gap: 5px; padding: 10px 12px; }
  .btn-action, .btn-danger-ghost { font-size: 11px; padding: 5px 9px; }
  .btn-edit { margin-left: 0; }
  .lead-header-row { flex-direction: column; gap: 8px; }
  .lead-header-badges { flex-wrap: wrap; }

  /* Leads table — hide low-value columns, keep: checkbox, company, stage, score, next due */
  .filters-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-input { grid-column: 1 / -1; width: 100%; }
  .filter-select { width: 100%; }
  .lead-count { grid-column: 1 / -1; }
  .leads-table th:nth-child(2),
  .leads-table td:nth-child(2),
  .leads-table th:nth-child(4),
  .leads-table td:nth-child(4),
  .leads-table th:nth-child(7),
  .leads-table td:nth-child(7),
  .leads-table th:nth-child(9),
  .leads-table td:nth-child(9),
  .leads-table th:nth-child(10),
  .leads-table td:nth-child(10) { display: none; }
  .leads-table th, .leads-table td { padding: 8px 8px; }
  .table-wrap { font-size: 12px; }

  /* Find page */
  .find-form { flex-direction: column; align-items: stretch; }
  .find-options { order: 2; }
  #startBtn { order: 3; width: 100%; justify-content: center; }
  .goal-presets { gap: 5px; }
  .preset-chip { font-size: 0.7rem; padding: 3px 8px; }
  .results-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .results-actions { width: 100%; flex-wrap: wrap; }
  #addSelectedBtn { flex: 1; justify-content: center; }
  .results-grid { grid-template-columns: 1fr; }
  .agent-stats { flex-wrap: wrap; gap: 6px; }
}
