:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --text: #172033;
  --muted: #637083;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #dff4f0;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --warm: #b45309;
  --warm-soft: #ffedd5;
  --rose: #be123c;
  --rose-soft: #ffe4e6;
  --shadow: 0 14px 48px rgba(27, 39, 59, 0.1);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1b212b;
    --surface-strong: #222b36;
    --text: #f2f6fb;
    --muted: #a9b4c2;
    --line: #313b49;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123d38;
    --blue: #60a5fa;
    --blue-soft: #132f55;
    --warm: #f59e0b;
    --warm-soft: #3e2c12;
    --rose: #fb7185;
    --rose-soft: #421923;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-strong: #f1f5f9;
  --text: #172033;
  --muted: #637083;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #dff4f0;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --warm: #b45309;
  --warm-soft: #ffedd5;
  --rose: #be123c;
  --rose-soft: #ffe4e6;
  --shadow: 0 14px 48px rgba(27, 39, 59, 0.1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12161d;
  --surface: #1b212b;
  --surface-strong: #222b36;
  --text: #f2f6fb;
  --muted: #a9b4c2;
  --line: #313b49;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: #123d38;
  --blue: #60a5fa;
  --blue-soft: #132f55;
  --warm: #f59e0b;
  --warm-soft: #3e2c12;
  --rose: #fb7185;
  --rose-soft: #421923;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block,
.topbar,
.topbar-actions,
.command-title,
.panel-header,
.source-item,
.lead-row,
.sidebar-footer,
.action-row,
.run-row,
.run-row-main,
.status-line {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand-title {
  font-size: 16px;
  font-weight: 750;
}

.brand-subtitle,
.metric-note,
.panel p,
.workflow-card p,
.settings-label,
.sidebar-footer,
.source-meta,
.run-meta {
  color: var(--muted);
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-footer {
  margin-top: auto;
  gap: 8px;
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.main-area {
  min-width: 0;
  padding: 28px;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.topbar-actions {
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.theme-button,
.primary-link,
.primary-button,
.secondary-button {
  min-height: 36px;
  border-radius: 6px;
  font-weight: 750;
}

.theme-button {
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
}

.theme-button.is-active {
  background: var(--accent);
  color: #ffffff;
}

.primary-link,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--accent);
  color: #ffffff;
  text-decoration: none;
}

.primary-button:hover,
.primary-link:hover {
  background: var(--accent-strong);
}

.secondary-button {
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
}

.danger-safe {
  background: var(--blue);
}

.danger-safe:hover {
  background: #1d4ed8;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.workflow-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric-card strong {
  font-size: 23px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-wide {
  grid-row: span 2;
}

.panel-tall {
  align-self: start;
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header p {
  margin-bottom: 0;
}

.badge {
  flex: none;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--warm-soft);
  color: var(--warm);
  font-size: 12px;
  font-weight: 800;
}

.pipeline-form,
.outreach-form,
.send-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.send-form {
  margin-top: 18px;
  grid-template-columns: 1fr 1fr;
}

.pipeline-form label,
.outreach-form label,
.send-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.span-2 {
  grid-column: span 2;
}

.span-all {
  grid-column: 1 / -1;
}

textarea {
  resize: vertical;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.switch-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.switch-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.switch-label {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface-strong);
  color: var(--text) !important;
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  font-size: 13px !important;
}

.switch-label input {
  width: 16px;
}

.action-row {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.command-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #101822;
}

.muted-box {
  background: #151b24;
}

.command-title {
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #1f2937;
  color: #e5edf5;
  font-size: 12px;
  font-weight: 800;
}

pre {
  min-height: 92px;
  max-height: 320px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: #b9f6ca;
  white-space: pre-wrap;
  word-break: break-word;
}

.source-list,
.lead-stack,
.settings-grid,
.run-list {
  display: grid;
  gap: 10px;
}

.source-item {
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.source-name {
  font-weight: 800;
}

.source-pill,
.run-pill {
  padding: 5px 8px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.source-pill.ready,
.run-pill.succeeded {
  background: var(--accent);
}

.source-pill.review,
.run-pill.running {
  background: var(--warm);
}

.source-pill.optional {
  background: var(--blue);
}

.source-pill.missing,
.run-pill.failed {
  background: var(--rose);
}

.lead-stack {
  margin-top: 16px;
}

.lead-row {
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.lead-row strong {
  min-width: 88px;
}

.lead-row span:last-child {
  color: var(--muted);
}

.lead-type {
  min-width: 112px;
  padding: 6px 8px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.lead-type.email {
  background: var(--accent);
}

.lead-type.form {
  background: var(--warm);
}

.lead-type.social {
  background: var(--rose);
}

.runs-panel,
.settings-panel {
  margin-top: 18px;
}

.run-row {
  justify-content: space-between;
  align-items: stretch;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.run-row-main {
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.run-title {
  font-weight: 800;
}

.run-meta,
.run-command {
  font-size: 12px;
}

.run-command {
  max-width: 100%;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.run-actions {
  display: grid;
  align-content: center;
  justify-items: end;
  gap: 8px;
}

.workflow-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.workflow-card {
  min-height: 180px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.step-index {
  width: 34px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 850;
}

.workflow-card a {
  margin-top: auto;
  color: var(--accent-strong);
  font-weight: 800;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

code {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: var(--accent-strong);
  font-size: 13px;
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .metric-grid,
  .workflow-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .main-area {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .primary-link,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .primary-link {
    justify-content: center;
  }

  .nav-list,
  .metric-grid,
  .workflow-board,
  .pipeline-form,
  .outreach-form,
  .send-form,
  .compact-grid,
  .switch-row,
  .switch-row.three,
  .switch-row.two,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: 1;
  }

  .lead-row,
  .run-row {
    align-items: stretch;
    flex-direction: column;
  }

  .run-actions {
    justify-items: stretch;
  }

  h1 {
    font-size: 24px;
  }
}

/* Leads screening table (Claude) */
.leads-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leads-table th, .leads-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.leads-table thead th { background: var(--surface-strong); color: var(--muted); position: sticky; top: 0; }
.leads-table td.reason-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.quality-pill { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.quality-pill.good { background: var(--accent-soft); color: var(--accent-strong); }
.quality-pill.warn { background: var(--warm-soft); color: var(--warm); }
.quality-pill.muted { background: var(--surface-strong); color: var(--muted); }
#leadsQueueSelect { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }

/* Connection banner + form hint (Claude) */
.conn-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius); background: var(--rose-soft); color: var(--rose); font-size: 14px; }
.conn-banner.cloud-mode { background: var(--blue-soft); color: var(--blue); }
.conn-banner code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; }
.form-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.token-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.token-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

@media (max-width: 840px) {
  .token-row {
    grid-template-columns: 1fr;
  }
}
