:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --green-100: #dcfce7;
  --green-600: #059669;
  --green-700: #15803d;
  --amber-100: #fef3c7;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --blue-100: #dbeafe;
  --blue-600: #2563eb;
  --purple-100: #f3e8ff;
  --purple-600: #9333ea;
  --orange-100: #ffedd5;
  --orange-600: #ea580c;

  --bg: var(--slate-50);
  --surface: #ffffff;
  --ink: var(--slate-900);
  --muted: var(--slate-500);
  --line: var(--slate-200);
  --accent: var(--teal-600);
  --accent-hover: var(--teal-700);
  --accent-light: var(--teal-50);
  --error: var(--red-600);
  --warning: var(--amber-600);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --nav-bg: var(--slate-900);
  --nav-text: var(--slate-300);
  --nav-hover: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Top navigation ─── */
.topbar {
  align-items: center;
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  justify-content: space-between;
  padding: 0 28px;
  height: 56px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover {
  color: #ffffff;
  text-decoration: none;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-500);
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 4px;
  height: 100%;
}

.topbar nav a,
.link-button {
  background: transparent;
  border: 0;
  color: var(--nav-text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 0 12px;
  text-decoration: none;
  height: 100%;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  border-radius: 0;
  position: relative;
}
.topbar nav a:hover,
.link-button:hover {
  color: var(--nav-hover);
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
}
.topbar nav a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--teal-500);
  transition: width 0.2s;
}
.topbar nav a:hover::after {
  width: 60%;
}

/* ─── Page layout ─── */
.page {
  margin: 0 auto;
  max-width: 1200px;
  padding: 32px 28px 80px;
}

/* ─── Typography ─── */
h1 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 16px;
  color: var(--slate-700);
}

p {
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.6;
}
small {
  font-size: 13px;
  color: var(--muted);
}

/* ─── Toolbar ─── */
.toolbar {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 28px;
}
.toolbar > div {
  flex: 1;
  min-width: 0;
}
.toolbar p {
  margin: 0;
  font-size: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ─── Panels / Cards ─── */
.panel,
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.panel h2:first-child {
  margin-top: 0;
}

.auth-panel {
  margin: 80px auto;
  max-width: 400px;
}

/* ─── Buttons ─── */
button,
.button {
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

button:hover,
.button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
button:active,
.button:active {
  transform: translateY(1px);
}

button.link-button {
  background: transparent;
  border: none;
  color: var(--nav-text);
  font-weight: 500;
  padding: 0 12px;
  height: 100%;
  border-radius: 0;
}
button.link-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--nav-hover);
  box-shadow: none;
}

.actions form {
  margin: 0;
}

/* ─── Stack layout ─── */
.stack {
  display: grid;
  gap: 16px;
}

/* ─── Grid form ─── */
.grid-form {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, 1fr);
}
.wide {
  grid-column: 1 / -1;
}

/* ─── Labels & Inputs ─── */
label {
  color: var(--slate-700);
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 9px 12px;
  width: 100%;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

::placeholder {
  color: var(--slate-400);
}

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

tr:last-child td {
  border-bottom: none;
}

th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  white-space: nowrap;
}

tbody tr {
  transition: background 0.1s;
}
tbody tr:hover {
  background: var(--slate-50);
}

tbody td a {
  font-weight: 500;
}

/* ─── Status badges ─── */
.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.status.completed,
.status.ok,
.status.active,
.connected,
.status-qualified {
  background: var(--green-100);
  color: var(--green-700);
}
.status.failed,
.status.error,
.status-rejected {
  background: var(--red-100);
  color: var(--red-700);
}
.status.running,
.status.queued,
.status-building,
.status-new {
  background: var(--blue-100);
  color: var(--blue-600);
}
.status.maybe,
.status.warning,
.status.missing,
.status-reviewed,
.status-stale {
  background: var(--amber-100);
  color: var(--amber-700);
}
.status-exported {
  background: var(--purple-100);
  color: var(--purple-600);
}
.unreachable {
  background: var(--orange-100);
  color: var(--orange-600);
}

/* ─── Job summary ─── */
.job-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}
.job-summary > div {
  background: var(--slate-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.job-summary strong {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.job-summary span {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-800);
}

/* ─── Progress bar ─── */
.progress {
  background: var(--slate-100);
  border-radius: 999px;
  height: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}
.progress span {
  background: var(--accent);
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ─── Events list ─── */
.events {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.events li {
  border-left: 3px solid var(--line);
  padding: 6px 0 6px 12px;
  font-size: 14px;
  line-height: 1.5;
}
.events li.error {
  border-color: var(--red-500);
  background: var(--red-100);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 6px 12px;
}
.events li.warning {
  border-color: var(--amber-600);
  background: var(--amber-100);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 6px 12px;
}
.events time {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.error-text {
  color: var(--red-600);
  font-weight: 600;
}

.answer {
  color: var(--ink);
  background: var(--teal-50);
  padding: 10px 14px;
  border-radius: var(--radius);
  border-left: 3px solid var(--teal-500);
}

.question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* ─── Flash messages ─── */
.flash {
  border-radius: var(--radius);
  margin-bottom: 16px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14px;
}
.flash.success {
  background: var(--green-100);
  color: var(--green-700);
  border: 1px solid #bbf7d0;
}
.flash.warning {
  background: var(--amber-100);
  color: var(--amber-700);
  border: 1px solid #fde68a;
}
.flash.error {
  background: var(--red-100);
  color: var(--red-700);
  border: 1px solid #fecaca;
}
.flash.info {
  background: var(--blue-100);
  color: var(--blue-600);
  border: 1px solid #bfdbfe;
}

/* ─── Checklist ─── */
.checklist {
  margin-bottom: 28px;
}
.checklist-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.checklist-item {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.checklist-item.done {
  background: var(--green-100);
  border-color: #bbf7d0;
}
.checklist-item.missing {
  background: var(--amber-100);
  border-color: #fde68a;
}
.checklist-icon {
  font-weight: 700;
  width: 16px;
  text-align: center;
}
.checklist-action {
  color: var(--amber-700);
  font-size: 12px;
  width: 100%;
  margin-top: 2px;
}

/* ─── Diagnostics grid ─── */
.diag-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.diag-card {
  background: var(--slate-50);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.diag-card strong {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.diag-card span {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-800);
  word-break: break-all;
}
.diag-card small {
  display: block;
  margin-top: 4px;
}
.diag-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
}
.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

/* ─── Warnings ─── */
.warnings-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.warning-item {
  border-left: 3px solid var(--amber-600);
  margin-bottom: 8px;
  padding: 10px 14px;
  background: var(--amber-100);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14px;
}

/* ─── Lead status badges (reuse .status but with semantic names) ─── */
.status.status-new {
  background: var(--blue-100);
  color: var(--blue-600);
}
.status.status-reviewed {
  background: var(--amber-100);
  color: var(--amber-700);
}
.status.status-qualified {
  background: var(--green-100);
  color: var(--green-700);
}
.status.status-rejected {
  background: var(--red-100);
  color: var(--red-700);
}
.status.status-exported {
  background: var(--purple-100);
  color: var(--purple-600);
}
.status.status-maybe {
  background: var(--orange-100);
  color: var(--orange-600);
}

/* ─── Filter bar ─── */
.filter-bar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.filter-bar label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-600);
  gap: 4px;
}
.filter-bar input,
.filter-bar select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  min-width: 0;
  background: var(--surface);
}
.filter-bar .button,
.filter-bar button {
  padding: 6px 14px;
  font-size: 13px;
}

/* ─── Lead detail ─── */
.lead-detail-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr 1fr;
}
.lead-detail-grid .wide {
  grid-column: 1 / -1;
}
.lead-detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--slate-500);
  margin-bottom: 4px;
}
.lead-detail-field p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}
.lead-detail-field ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.lead-detail-field li {
  margin-bottom: 3px;
  font-size: 14px;
}

/* ─── Review form ─── */
.review-form {
  max-width: 500px;
}
.review-form label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
}
.review-form textarea,
.review-form select {
  width: 100%;
  margin-top: 4px;
}
.review-form select {
  min-height: 38px;
}

/* ─── Offering & ICP cards ─── */
.offering-card,
.icp-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
  transition: box-shadow 0.15s;
}
.offering-card:hover,
.icp-card:hover {
  box-shadow: var(--shadow-sm);
}
.offering-card p,
.icp-card p {
  font-size: 14px;
  margin: 6px 0 0;
}

/* ─── HR ─── */
/* ─── Score breakdown table ─── */
.score-table {
  min-width: auto;
  width: auto;
  font-size: 13px;
  border: none;
  box-shadow: none;
}
.score-table td {
  border: none;
  padding: 4px 12px 4px 0;
}
.score-table td:last-child {
  padding-right: 0;
}

/* ─── Evidence mapping table ─── */
.evidence-table {
  min-width: auto;
  width: 100%;
  font-size: 13px;
}
.evidence-table th {
  padding: 6px 10px;
}
.evidence-table td {
  padding: 4px 10px;
}
.quote-cell {
  font-size: 12px;
  color: var(--muted);
  max-width: 300px;
}

/* ─── Evidence links ─── */
.evidence-links {
  margin-top: 6px;
}
.evidence-links a {
  font-size: 12px;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}

/* ─── Responsive ─── */
@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
  }
  .topbar nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    gap: 0;
    height: 44px;
    border-top: 1px solid rgba(255,255,255,0.08);
  }
  .topbar nav a,
  .link-button {
    padding: 0 10px;
    font-size: 13px;
  }
  .page {
    padding: 20px 16px 60px;
  }
  .toolbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
  .grid-form,
  .job-summary {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar label {
    grid-template-columns: 1fr;
  }
  .lead-detail-grid {
    grid-template-columns: 1fr;
  }
  .diag-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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