:root {
  --bg: #f7f8f5;
  --ink: #1f2828;
  --muted: #687474;
  --line: #cfd8d3;
  --panel: #ffffff;
  --accent: #1b6f69;
  --accent-2: #9d5a32;
  --warn: #a33f3f;
  --soft: #e7f2ef;
  --shadow: 0 16px 42px rgba(31, 40, 40, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.shell {
  width: min(1320px, calc(100% - 28px));
  margin: 24px auto;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip span {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

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

.input-panel {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  overflow: hidden;
  padding: 18px;
}

.workflow-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.workflow-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.workflow-head strong {
  font-size: 14px;
}

.workflow-head span,
.loop-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workflow-steps,
.loop-steps {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.workflow-steps li,
.loop-steps li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.workflow-steps li::before,
.loop-steps li::before {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 5px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
}

.workflow-steps li:not(:last-child)::after,
.loop-steps li:not(:last-child)::after {
  content: "↓";
  grid-column: 1;
  margin-top: -2px;
  color: var(--line);
  text-align: center;
  line-height: 1;
}

.workflow-steps li span,
.loop-steps li span {
  min-width: 0;
  grid-column: 2;
  grid-row: 1 / span 2;
  overflow-wrap: anywhere;
}

.workflow-steps li.complete,
.loop-steps li.complete {
  color: var(--ink);
}

.workflow-steps li.complete::before,
.loop-steps li.complete::before {
  border-color: var(--accent);
  background: var(--accent);
}

.workflow-steps li.active,
.loop-steps li.active {
  color: var(--accent-2);
}

.workflow-steps li.active::before,
.loop-steps li.active::before {
  border-color: var(--accent-2);
  background: #f8e8dd;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.source-lock {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.source-lock strong {
  color: var(--muted);
  font-size: 13px;
}

.source-lock span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

input, textarea, select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fbfcfa;
  font: inherit;
  font-size: 14px;
}

textarea { resize: vertical; }

.location-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-top: -5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.location-mode span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.all-usa-row {
  min-height: 24px;
  color: var(--ink);
}

input:disabled,
textarea:disabled {
  opacity: .72;
  cursor: not-allowed;
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

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

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

button {
  min-width: 0;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.secondary {
  color: var(--accent);
  background: #fff;
}

.danger {
  border-color: var(--warn);
  background: var(--warn);
}

.settings-panel {
  display: grid;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.settings-head span {
  min-width: 0;
  max-width: 190px;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-head strong {
  color: var(--ink);
  font-size: 13px;
}

.monitor-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 16px;
}

.run-context {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.run-context span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.run-context strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.metrics div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfa;
}

.metrics strong {
  display: block;
  font-size: 27px;
}

.metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.progress {
  height: 11px;
  margin: 14px 0;
  border-radius: 999px;
  background: #e2e9e5;
  overflow: hidden;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px;
  align-items: end;
  gap: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.lead-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 10px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 520px;
}

.export-actions button {
  min-width: 76px;
}

.lead-toolbar div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lead-toolbar strong {
  font-size: 14px;
}

.lead-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
  min-height: 430px;
  max-height: 62vh;
  overflow: auto;
}

.tab-pane.active { display: block; }

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

th, td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

th:nth-child(1), td:nth-child(1) { width: 25%; }
th:nth-child(2), td:nth-child(2) { width: 10%; }
th:nth-child(3), td:nth-child(3) { width: 34%; }
th:nth-child(4), td:nth-child(4) { width: 10%; }
th:nth-child(5), td:nth-child(5) { width: 7%; }
th:nth-child(6), td:nth-child(6) { width: 14%; }

.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lead-actions button {
  padding: 6px 9px;
  font-size: 12px;
}

tr.excluded {
  opacity: .45;
}

.log {
  margin: 0;
  padding: 12px 0 0 22px;
}

.log li {
  margin-bottom: 10px;
  padding-right: 8px;
  color: var(--ink);
}

.log-time {
  color: var(--muted);
  font-size: .9em;
  font-weight: 800;
  white-space: nowrap;
}

.muted { color: var(--muted); }
.bad { color: var(--warn); }

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

  .status-strip {
    justify-content: flex-start;
  }

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

  .metrics {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .control-strip {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 20px, 1320px);
    margin: 14px auto;
  }

  .grid-two,
  .control-strip,
  .actions {
    grid-template-columns: 1fr;
  }

  .lead-toolbar,
  .location-mode,
  .export-actions,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .location-mode span {
    text-align: left;
  }

  .export-actions {
    width: 100%;
    max-width: none;
  }

  .export-actions button {
    width: 100%;
  }

  .tabs {
    gap: 12px;
  }

  table {
    min-width: 760px;
    table-layout: auto;
  }

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

  h1 {
    font-size: 25px;
  }
}
