:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #dfe5ee;
  --line-strong: #c7d0dd;
  --blue: #2563eb;
  --teal: #0f766e;
  --green: #12805c;
  --amber: #b7791f;
  --red: #c2410c;
  --purple: #6d5bd0;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.07);
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-family: var(--font);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.lead-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.lead-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 24px 18px;
}
.brand img { display: block; width: auto; height: 34px; }
.lead-sidebar nav { display: grid; gap: 5px; }
.lead-sidebar a { text-decoration: none; }
.lead-sidebar nav a {
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  padding: 10px 12px;
}
.lead-sidebar nav a.active,
.lead-sidebar nav a:hover {
  background: #eef4ff;
  color: var(--blue);
}
.run-panel {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}
.run-panel span,
.metric-grid span,
.section-label,
.eyebrow,
.filter-bar span,
.claim-row span,
.notes-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.run-panel strong { display: block; margin: 7px 0 5px; font-size: 13px; overflow-wrap: anywhere; }
.run-panel span:not(:first-child) { display: block; margin-top: 12px; }
.run-panel p { margin: 0; }

.lead-workspace {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 28px;
}
.lead-header,
.metric-grid article,
.lead-list-panel,
.lead-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  min-width: 0;
  padding: 24px;
}
.lead-header > div:first-child { max-width: 850px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-width: 220px; }

.eyebrow,
.section-label { margin: 0 0 7px; color: var(--blue); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 40px; line-height: 1; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.5; }
.lead-header p:last-child { margin-bottom: 0; }

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
  padding: 0 14px;
  text-decoration: none;
}
.primary-action {
  border: 0;
  background: var(--ink);
  color: #fff;
}
.secondary-action {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
}
.secondary-action.is-disabled {
  cursor: not-allowed;
  opacity: .48;
  pointer-events: none;
}
.primary-action:hover,
.secondary-action:hover { transform: translateY(-1px); }
.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: .62;
  transform: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric-grid article { min-height: 92px; padding: 16px; }
.metric-grid strong { display: block; margin-top: 8px; font-size: 34px; line-height: 1; letter-spacing: 0; }
.metric-grid article:nth-child(1) strong { color: var(--blue); }
.metric-grid article:nth-child(2) strong { color: var(--teal); }
.metric-grid article:nth-child(3) strong { color: var(--purple); }
.metric-grid article:nth-child(4) strong { color: var(--green); }

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(350px, .75fr);
  gap: 16px;
  align-items: start;
}
.lead-list-panel,
.lead-detail { min-width: 0; padding: 18px; }

.filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px 160px;
  gap: 10px;
  margin-bottom: 12px;
}
.filter-bar label,
.notes-field {
  display: grid;
  gap: 6px;
}
.filter-bar input,
.filter-bar select,
.notes-field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}
.notes-field textarea { resize: vertical; min-height: 92px; }

.candidate-table { display: grid; gap: 6px; }
.candidate-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) 66px minmax(135px, .9fr) 118px 72px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}
button.candidate-row:hover,
button.candidate-row.active {
  border-color: #9bbcff;
  background: #f7faff;
}
.candidate-head {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.property-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.property-cell strong,
.property-cell span,
.candidate-row > span,
.candidate-row > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.property-cell span { color: var(--muted); font-size: 12px; }
.property-cell .status-chip { margin-top: 3px; }
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pill,
.score-pill,
.status-chip,
.source-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  min-height: 26px;
  padding: 5px 9px;
  text-transform: uppercase;
}
.score-a { background: #ecfdf3; color: var(--green); }
.score-b { background: #eef4ff; color: var(--blue); }
.score-c { background: #fff8e6; color: var(--amber); }
.score-reject { background: #fff1eb; color: var(--red); }
.status-chip { border: 1px solid var(--line); background: #f8fafc; color: var(--muted); }
.source-chip {
  border: 1px solid #b8ddd8;
  background: #effaf8;
  color: var(--teal);
}

.detail-heading,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.detail-heading { margin-bottom: 14px; }
.identity-list {
  display: grid;
  gap: 0;
  margin: 0 0 14px;
}
.identity-list div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.identity-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.identity-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-bottom: 14px;
}

.claim-panel,
.review-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.claim-panel .panel-heading { margin-bottom: 8px; }
.claim-panel .panel-heading span { color: var(--muted); font-size: 12px; font-weight: 800; }
#claimList { display: grid; gap: 8px; }
.claim-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}
.claim-row strong { font-size: 13px; }
.claim-row a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.claim-row a:hover { text-decoration: underline; }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0 12px;
}
.segmented button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.segmented button.active {
  border-color: #9bbcff;
  background: #eef4ff;
  color: var(--blue);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}

@media (max-width: 1120px) {
  .lead-shell { grid-template-columns: 1fr; }
  .lead-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
  .lead-sidebar nav {
    display: flex;
    flex-wrap: wrap;
    flex: 1 1 420px;
  }
  .run-panel { margin-top: 0; flex: 1 1 260px; }
  .review-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .lead-workspace { padding: 16px; }
  .lead-header { display: grid; padding: 18px; }
  .toolbar { justify-content: flex-start; min-width: 0; }
  h1 { font-size: 34px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: 1fr; }
  .candidate-head { display: none; }
  .candidate-row {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 0;
  }
  .candidate-row > span,
  .candidate-row > strong,
  .property-cell strong,
  .property-cell span { white-space: normal; }
  .zip-cell::before,
  .manager-cell::before,
  .phone-cell::before,
  .score-cell::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    margin-bottom: 2px;
  }
  .identity-list div { grid-template-columns: 1fr; gap: 4px; }
  .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .lead-sidebar { padding: 16px; }
  .lead-sidebar nav a { flex: 1 1 auto; }
  .metric-grid { grid-template-columns: 1fr; }
  .primary-action,
  .secondary-action { width: 100%; }
}
