:root {
  color-scheme: light;
  --bg: #f7f6f1;
  --surface: #ffffff;
  --surface-warm: #fbfaf6;
  --surface-accent: #eff6ff;
  --text: #111827;
  --muted: #667085;
  --line: #e6e1d7;
  --strong-line: #cfc7b7;
  --accent: #172554;
  --accent-2: #1e3a8a;
  --accent-soft: #dbeafe;
  --warning: #9a5b13;
  --danger: #b42318;
  --ok: #1d4ed8;
  --shadow: 0 14px 40px rgba(17, 24, 39, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 246, 241, 0.92) 240px),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-loading-card {
  display: grid;
  justify-items: center;
  gap: 20px;
  text-align: center;
}

.auth-loading-card h1 {
  margin-bottom: 6px;
  font-size: 24px;
}

.auth-loading-card .subtle {
  margin: 0;
}

.auth-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(18, 43, 76, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-spinner {
    animation-duration: 1.8s;
  }
}

.auth-card {
  width: min(100%, 440px);
  display: grid;
  gap: 24px;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 148px;
  height: auto;
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: 30px;
}

.auth-card .subtle {
  margin-bottom: 0;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form input {
  width: 100%;
}

.auth-form .primary-button {
  min-height: 44px;
}

.auth-status {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--danger);
}

.auth-status.is-success {
  color: var(--ok);
}

.auth-status.is-neutral {
  color: var(--muted);
}

.auth-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px 32px;
  border-bottom: 1px solid rgba(230, 225, 215, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-home-link {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
}

.brand-home-link:focus-visible {
  outline: 3px solid rgba(30, 58, 138, 0.18);
  outline-offset: 4px;
}

.brand-logo {
  display: block;
  width: 132px;
  height: auto;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 23px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.18;
}

.status-pill {
  min-width: 128px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-warm);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

.workspace {
  padding-bottom: 44px;
}

.band {
  width: 100%;
}

.band-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 32px;
}

.progress-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.progress-panel {
  overflow: hidden;
}

.progress-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff 0%, #f2f7ef 100%);
}

.progress-header h2,
.progress-header p {
  margin-bottom: 0;
}

.job-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.job-meta strong {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(23, 37, 84, 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.subtle {
  color: var(--muted);
}

.sync-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.66fr);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.panel-heading p {
  margin-bottom: 0;
}

.upload-panel {
  padding-bottom: 16px;
}

.sync-config,
.sync-run {
  min-width: 0;
  padding: 16px 0;
}

.sync-run {
  border-left: 1px solid var(--line);
}

.sync-progress {
  margin-top: 18px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 162px;
  margin: 16px;
  padding: 22px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  background: var(--surface-warm);
  cursor: pointer;
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease;
}

.dropzone:hover {
  border-color: var(--accent-2);
  background: #f5f8ff;
}

.dropzone:focus-within {
  border-color: var(--accent-2);
  outline: 3px solid rgba(30, 58, 138, 0.14);
  background: #f5f8ff;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border: 1px solid rgba(23, 37, 84, 0.2);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.dropzone small {
  color: var(--muted);
}

.dropzone strong,
.dropzone small {
  overflow-wrap: anywhere;
}

.url-import {
  display: grid;
  gap: 10px;
  margin: 0 16px 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-warm);
}

.url-import small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.url-import-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.url-import-controls input {
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.url-import-controls input:focus {
  outline: 3px solid rgba(30, 58, 138, 0.14);
  border-color: var(--accent-2);
}

.url-import-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.url-import-result[hidden] {
  display: none;
}

.url-import-result p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.field-label {
  display: grid;
  gap: 6px;
  margin: 0 16px 12px;
  color: #374151;
  font-size: 13px;
  font-weight: 650;
}

.label-note {
  color: var(--muted);
  font-weight: 500;
}

.field-label input,
.field-label select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 11px;
}

.field-label input:focus,
.field-label select:focus {
  outline: 3px solid rgba(30, 58, 138, 0.14);
  border-color: var(--accent-2);
}

.field-label input {
  min-height: 40px;
}

.owner-field {
  margin-bottom: 14px;
}

.owner-checklist {
  display: grid;
  gap: 8px;
  max-height: 230px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.owner-check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.owner-check:hover {
  background: var(--surface-warm);
}

.owner-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.owner-check span {
  overflow-wrap: anywhere;
}

.run-actions {
  display: grid;
  gap: 10px;
  padding: 4px 16px 16px;
}

.run-actions button {
  width: 100%;
  text-align: center;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease;
}

.run-hint {
  margin: -4px 16px 12px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.notice {
  min-height: auto;
  margin: 0 16px;
  padding: 10px 12px;
  border: 1px solid #eadbc0;
  border-radius: 8px;
  background: #fff9ed;
  color: var(--warning);
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

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

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 1;
  border-color: #e7e2d8;
  background: #f5f3ed;
  color: #9a9387;
}

.run-actions .run-step-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(23, 37, 84, 0.13);
}

.run-actions .run-step-locked {
  border-color: #e7e2d8;
  background: #f5f3ed;
  color: #9a9387;
}

.run-actions .run-step-complete {
  border-color: rgba(23, 37, 84, 0.22);
  background: var(--accent-soft);
  color: var(--accent);
}

.ghost-button {
  background: #fff;
  color: var(--text);
}

.summary-list {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.summary-list.compact {
  padding: 0;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child {
  border-bottom: 0;
}

.artifact-item strong {
  max-width: 72%;
  text-align: right;
  overflow-wrap: anywhere;
}

.outcome-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-warm);
}

.outcome-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.outcome-metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.outcome-metric span,
.outcome-metric small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.outcome-metric strong {
  font-size: 21px;
  line-height: 1.15;
}

.dropoff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dropoff-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.dropoff-item span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.uploaded-links {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.uploaded-links a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.lead-list-history {
  display: grid;
  gap: 10px;
  margin: 16px 16px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-warm);
}

.lead-list-history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lead-list-history-heading > div {
  display: grid;
  gap: 2px;
}

.lead-list-history-actions {
  display: flex !important;
  grid-auto-flow: column;
  gap: 8px !important;
}

.lead-list-enrichment-status {
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(23, 37, 84, 0.2);
  border-radius: 8px;
  background: var(--surface-accent);
}

.lead-list-enrichment-status[hidden] {
  display: none;
}

.lead-list-enrichment-status > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.lead-list-enrichment-status .progress-track {
  height: 8px;
}

.lead-list-enrichment-status .progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 180ms ease;
}

.lead-list-history-heading small,
.lead-list-history-item span,
.lead-list-history-item small,
.lead-list-history-empty {
  color: var(--muted);
}

.lead-list-history-items {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  scrollbar-gutter: stable;
}

.lead-list-history-item {
  display: grid;
  flex: 0 0 min(340px, 85vw);
  gap: 3px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.lead-list-history-item:hover,
.lead-list-history-item:focus-visible {
  border-color: var(--accent-2);
}

.lead-list-history-item.active {
  border-color: var(--accent);
  background: var(--surface-accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.lead-list-history-item span,
.lead-list-history-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-list-history-empty {
  margin: 4px 0;
}

.file-import-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 16px 16px;
  padding: 12px;
  border: 1px solid rgba(23, 37, 84, 0.2);
  border-radius: 8px;
  background: var(--surface-accent);
}

.file-import-result[hidden] {
  display: none;
}

.file-import-result p {
  margin: 0;
}

.file-import-result button {
  flex: 0 0 auto;
}

.master-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 16px 0;
}

.master-summary[hidden] {
  display: none;
}

.master-metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(23, 37, 84, 0.16);
  border-radius: 8px;
  background: var(--surface-accent);
}

.master-metric span,
.master-metric small {
  color: var(--muted);
}

.master-metric span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.master-metric strong {
  color: var(--accent);
  font-size: 24px;
  line-height: 1.1;
}

.master-table-wrap {
  width: calc(100% - 32px);
  max-height: min(70vh, 720px);
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.lead-list-search {
  display: grid;
  gap: 7px;
  margin: 16px;
}

.lead-list-search label {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.lead-list-search-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lead-list-search-control input {
  width: min(620px, 100%);
}

.lead-list-search-control span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.sync-scope p,
.sync-scope-option small {
  color: var(--muted);
}
.sync-scope-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

.sync-scope {
  display: grid;
  gap: 8px;
  margin: 16px;
  padding: 0;
  border: 0;
}

.sync-scope legend {
  margin-bottom: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 650;
}

.sync-scope-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.sync-scope-option:has(input:checked) {
  border-color: var(--accent-2);
  background: var(--accent-soft);
}

.sync-scope-option span {
  display: grid;
  gap: 2px;
}

.sync-scope-option small {
  font-weight: 500;
}

.sync-scope p {
  margin: 2px 0 0;
  font-size: 12px;
}

@media (max-width: 760px) {
  .lead-list-search-control {
    align-items: stretch;
    flex-direction: column;
  }

  .lead-list-search-control span {
    white-space: normal;
  }
}

#preview-table {
  min-width: 2400px;
}

#preview-table th,
#preview-table td {
  min-width: 140px;
}

#preview-table th {
  position: sticky;
  top: 0;
  z-index: 3;
}

#preview-table th:nth-child(2),
#preview-table td:nth-child(2),
#preview-table th:nth-child(5),
#preview-table td:nth-child(5),
#preview-table th:nth-child(6),
#preview-table td:nth-child(6),
#preview-table th:nth-child(7),
#preview-table td:nth-child(7),
#preview-table th:nth-child(16),
#preview-table td:nth-child(16) {
  min-width: 220px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  max-width: 260px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 76px;
  background: #fbfaf6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

.score {
  display: inline-block;
  min-width: 46px;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--surface-warm);
  text-align: center;
}

.icp-badge {
  display: inline-block;
  min-width: 76px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.icp-badge.good {
  background: var(--accent-soft);
  color: var(--ok);
}

.icp-badge.bad {
  background: #fee4e2;
  color: var(--danger);
}

.icp-badge.unknown {
  background: var(--surface-warm);
  color: var(--muted);
}

.score.good {
  color: var(--ok);
}

.score.warn {
  color: var(--warning);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

.progress-body {
  display: grid;
  gap: 13px;
  padding: 16px 20px 18px;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: #ebe7dc;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #2563eb);
  transition: width 180ms ease;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.status-cards[hidden] {
  display: none;
}

.status-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(23, 37, 84, 0.18);
  border-radius: 8px;
  background: var(--surface-accent);
}

.status-card span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-card strong,
.status-card p {
  margin: 0;
  overflow-wrap: anywhere;
}

.status-card p {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(17, 24, 39, 0.22);
}

.modal-panel h2,
.modal-panel p {
  margin-bottom: 0;
}

.modal-copy {
  color: var(--text);
  font-size: 16px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-warm);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.note-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(23, 37, 84, 0.18);
  border-radius: 8px;
  background: var(--accent-soft);
}

.note-box span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.note-box strong {
  overflow-wrap: anywhere;
}

.modal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 18px;
  }

  .band-inner {
    padding-inline: 18px;
  }

  .progress-header,
  .sync-grid,
  .outcome-metrics,
  .dropoff-grid {
    grid-template-columns: 1fr;
  }

  .sync-run {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .job-meta {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .brand-logo {
    width: 104px;
  }

  .brand-lockup {
    flex: 1 1 100%;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-actions .status-pill {
    min-width: 0;
    max-width: 100%;
  }

  .panel-heading {
    flex-wrap: wrap;
  }

  .panel-heading .ghost-button {
    width: 100%;
  }

  .url-import-controls {
    grid-template-columns: 1fr;
  }

  .url-import-result {
    align-items: stretch;
    flex-direction: column;
  }
}
