:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-muted: #475569;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0369a1;
  --accent-soft: #e0f2fe;
  --warm: #b45309;
  --warm-soft: #fff7ed;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --warn: #9a3412;
  --warn-soft: #ffedd5;
  --danger: #991b1b;
  --danger-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  --font: "IBM Plex Sans", "Fira Sans", sans-serif;
  --mono: "Fira Sans", ui-monospace, monospace;
  --drawer-w: min(440px, 100vw);
  --ease: 180ms ease;
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dbeafe 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e2e8f0 0%, transparent 50%),
    var(--bg);
  line-height: 1.45;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.75rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0.75rem;
  top: 0.75rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.25rem 0.75rem;
  max-width: 1280px;
  margin: 0 auto;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem;
  background: linear-gradient(145deg, #0f172a 0%, #0369a1 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.brand-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
}

.brand h1 {
  margin: 0.1rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  max-width: 1280px;
  margin: 0.5rem auto 0;
  padding: 0 1.25rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}

.kpi-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.kpi-value {
  margin: 0.2rem 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  max-width: 1280px;
  margin: 0.9rem auto 0;
  padding: 0 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field input,
.field select,
.sort-field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 0.55rem;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.field input:focus,
.field select:focus,
.sort-field select:focus,
.icon-btn:focus-visible,
.btn-ghost:focus-visible,
.btn:focus-visible,
.leads-table tbody tr:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18);
}

.btn-ghost,
.btn,
.icon-btn {
  cursor: pointer;
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 0.55rem;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.btn-ghost {
  height: 2.45rem;
  padding: 0 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.btn-ghost:hover,
.btn:hover,
.icon-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #075985;
  border-color: #075985;
  color: #fff;
}

.layout {
  max-width: 1280px;
  margin: 0.9rem auto 2rem;
  padding: 0 1.25rem;
}

.list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.result-count {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
  font-weight: 500;
}

.sort-field {
  min-width: 10rem;
}

.table-wrap {
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.leads-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  font-weight: 600;
  padding: 0.65rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
}

.leads-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  transition: background var(--ease);
}

.leads-table tbody tr:hover,
.leads-table tbody tr[aria-selected="true"] {
  background: #f0f9ff;
}

.leads-table tbody tr[aria-selected="true"] {
  box-shadow: inset 3px 0 0 var(--accent);
}

.leads-table td {
  padding: 0.85rem 1rem;
  vertical-align: top;
}

.company-cell .name {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.company-cell .why {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.num {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-neutral {
  background: #f1f5f9;
  color: #334155;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill-info {
  background: var(--accent-soft);
  color: #075985;
}

.pill-warm {
  background: var(--warm-soft);
  color: var(--warm);
}

.contact-dots {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.contact-dot {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--ink-muted);
}

.contact-dot.on {
  background: var(--accent-soft);
  border-color: #7dd3fc;
  color: #0369a1;
}

.empty-state {
  margin: 0;
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ink-muted);
}

.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--drawer-w);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  animation: slide-in 220ms ease;
}

@keyframes slide-in {
  from {
    transform: translateX(18px);
    opacity: 0.6;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .drawer-panel,
  .leads-table tbody tr,
  .btn,
  .btn-ghost,
  .icon-btn,
  .field input,
  .field select {
    animation: none !important;
    transition: none !important;
  }
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.15rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.drawer-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 600;
}

.drawer-header h2 {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.drawer-sub {
  margin: 0.35rem 0 0;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-body {
  overflow-y: auto;
  padding: 1rem 1.15rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: #fbfdff;
}

.section-card h3 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.65rem 0.7rem;
}

.stat span {
  display: block;
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.stat strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.quote {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border-left: 3px solid var(--accent);
  background: #f8fafc;
  color: #1e293b;
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.bad-quote {
  border-left-color: #c2410c;
  background: #fff7ed;
  margin-bottom: 0.55rem;
}

.bad-quote:last-child {
  margin-bottom: 0;
}

.channel-callout {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.people-list {
  display: grid;
  gap: 0.65rem;
}

.person-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
}

.person-role {
  margin: 0.15rem 0 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.meta-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.meta-list dt,
.meta-list .label {
  color: var(--ink-muted);
  font-weight: 500;
}

.meta-list a {
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
}

.meta-list a:hover {
  text-decoration: underline;
}

.notes {
  margin: 0;
  white-space: pre-wrap;
  color: #1e293b;
  font-size: 0.92rem;
}

@media (max-width: 980px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .kpi-row,
  .filters {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .meta-list li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}
