:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #1f2933;
  --muted: #627084;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eef2f7 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

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

.hint {
  margin: 0 0 16px;
  color: var(--muted);
}

.hint code,
.mono {
  font-family: var(--mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-idle {
  background: #e5e7eb;
  color: #374151;
}

.badge-running {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-completed {
  background: #d1fae5;
  color: #047857;
}

.badge-failed {
  background: #fee2e2;
  color: #b91c1c;
}

.drop-zone {
  border: 2px dashed #c7d2e0;
  border-radius: 12px;
  background: #fafbfc;
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background: #f0f6ff;
}

.drop-title {
  margin: 0 0 8px;
  font-weight: 600;
}

.file-preview {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #eef2f7;
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: #e5edf5;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  transition: width 0.25s ease;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #fbfcfd;
  min-height: 220px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.domain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.domain-list li {
  padding: 6px 0;
  border-bottom: 1px solid #edf2f7;
  font-size: 0.92rem;
}

.domain-list li:last-child {
  border-bottom: none;
}

.completion-banner {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.completion-banner p {
  margin: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fafc;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  cursor: default;
}

.hidden {
  display: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfd;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.leads-list {
  margin-top: 16px;
}

.leads-list details {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: #fbfcfd;
}

.leads-list summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.92rem;
}

.lead-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.run-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--text);
  font-size: 0.82rem;
}

.meta-chip.on {
  background: #d1fae5;
  color: #047857;
}

.meta-chip.off {
  background: #f3f4f6;
  color: var(--muted);
}

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

.leads-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  border: 1px solid var(--border);
  background: #fbfcfd;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-btn.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

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

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.leads-table th,
.leads-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.leads-table th {
  background: #fbfcfd;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.leads-table tbody tr:last-child td {
  border-bottom: none;
}

.leads-table tbody tr:hover {
  background: #f8fafc;
}

.lead-domain {
  font-family: var(--mono);
  font-weight: 600;
}

.lead-type-label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.contact-email {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.contact-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.contact-badge-standard {
  background: #dbeafe;
  color: #1d4ed8;
}

.contact-badge-enrichment {
  background: #fef3c7;
  color: #b45309;
}

.contact-badge-legacy {
  background: #e5e7eb;
  color: #374151;
}

.contact-name {
  color: var(--muted);
  font-size: 0.8rem;
}

.dns-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dns-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
}

.dns-chip.true {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.dns-chip.false {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.legacy-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.85rem;
}

.admin-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.admin-nav-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.admin-nav-btn.is-active {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.admin-panel.hidden {
  display: none;
}

.settings-meta {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.settings-status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.settings-status-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.settings-status-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.settings-status-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.runs-status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.runs-status-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.runs-status-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.runs-status-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.admin-spinner {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.4rem;
  vertical-align: -0.125rem;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: admin-spin 0.8s linear infinite;
}

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

.btn-loading {
  pointer-events: none;
  opacity: 0.75;
}

.settings-group {
  margin-top: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.settings-group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.settings-group h3 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.settings-field {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfc;
}

.settings-field-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.settings-label {
  display: block;
  font-weight: 600;
}

.settings-description {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.settings-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.settings-source {
  display: inline-flex;
  align-items: center;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #e5e7eb;
  color: #374151;
}

.settings-source-override {
  background: #dbeafe;
  color: #1d4ed8;
}

.inline-actions {
  flex-wrap: wrap;
}

.toggle {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.analytics-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.analytics-card {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-card-label {
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.analytics-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.analytics-funnel h3,
.analytics-earnings h3,
.analytics-webhook h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.card-nested {
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfd;
}

.funnel-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funnel-step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.funnel-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #3b82f6);
}

.analytics-earnings-value {
  margin: 0 0 8px;
  font-size: 2rem;
  font-weight: 700;
}

.analytics-webhook-url {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
}

.analytics-days-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}

.analytics-days-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
}

.analytics-status {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
}

.analytics-status-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.analytics-status-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
  }

  .completion-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
