/* Lead Generation Agent — dashboard styles */

:root {
  --bg:            #0d1117;
  --bg-raised:     #141b25;
  --bg-sunken:     #0a0e14;
  --surface:       #172029;
  --border:        #232e3b;
  --border-soft:   #1b242f;

  --text:          #e5edf5;
  --text-muted:    #8296ab;
  --text-faint:    #5b6d80;

  --accent:        #4d94ff;
  --accent-strong: #2f7ff0;
  --accent-soft:   rgba(77, 148, 255, 0.14);

  --ok:            #35c48b;
  --warn:          #e0a32e;
  --err:           #f0645f;
  --debug:         #7c8fa3;

  --radius:   12px;
  --radius-s: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 15px; }
h2 { font-size: 14px; }
p  { margin: 0; }

.muted  { color: var(--text-muted); font-size: 12.5px; }
.mono   { font-family: var(--mono); }
.hidden, [hidden] { display: none !important; }

/* ------------------------------------------------------------- top bar --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #7b5cff);
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.brand-text { min-width: 0; }
.brand-text p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.chip-quiet { color: var(--text-faint); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.dot-idle    { background: var(--text-faint); }
.dot-ok      { background: var(--ok); }
.dot-err     { background: var(--err); }
.dot-running { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 var(--accent-soft); }
  50%      { opacity: .55; box-shadow: 0 0 0 5px transparent; }
}

/* ---------------------------------------------------------------- tabs --- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 63px;
  z-index: 19;
}

.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- main --- */

main { padding: 20px 24px 48px; max-width: 1500px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.split-files { grid-template-columns: minmax(280px, 0.85fr) minmax(0, 2fr); margin-bottom: 0; }

@media (max-width: 1000px) {
  .split, .split-files { grid-template-columns: 1fr; }
  main { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .tabs { padding: 0 14px; }
}

/* --------------------------------------------------------------- cards --- */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-head { margin-bottom: 14px; }
.card-head.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------------------------------------- form --- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; grid-column: span 3; min-width: 0; }
.field-narrow { grid-column: span 2; }
.field-wide   { grid-column: span 4; }

@media (max-width: 620px) {
  .field, .field-narrow, .field-wide { grid-column: span 6; }
}

.label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.label em { color: var(--accent); font-style: normal; }

.field input,
.search-input,
.select-wrap select {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder, .search-input::placeholder { color: var(--text-faint); }

.field input:focus,
.search-input:focus,
.select-wrap select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.hint { font-size: 11px; color: var(--text-faint); }

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.target-preview { font-size: 12.5px; min-width: 0; }
.target-preview strong { color: var(--text); font-weight: 500; }

.actions { display: flex; gap: 8px; }

.form-error {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-s);
  background: rgba(240, 100, 95, .1);
  border: 1px solid rgba(240, 100, 95, .3);
  color: #ff9a96;
  font-size: 12.5px;
}

/* ------------------------------------------------------------ outreach --- */

.outreach-block {
  margin-top: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  background: rgba(0, 0, 0, .12);
}

.outreach-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  list-style: none;
}
.outreach-block > summary::-webkit-details-marker { display: none; }
.outreach-block > summary::before {
  content: "▸";
  margin-right: 6px;
  font-size: 9px;
  color: var(--text-faint);
  transition: transform .15s;
  display: inline-block;
}
.outreach-block[open] > summary::before { transform: rotate(90deg); }
.outreach-block > summary > span:first-of-type { flex: 1; color: var(--text); }

.outreach-fields { padding: 4px 12px 14px; }
.field-full { grid-column: span 6; }

.field textarea {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 9px 11px;
  width: 100%;
  resize: vertical;
  min-height: 56px;
}
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea::placeholder { color: var(--text-faint); }

.banner {
  padding: 11px 14px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 12.5px;
  margin-bottom: 16px;
  color: var(--text-muted);
}
.banner b { color: var(--text); font-weight: 500; }
.banner.is-warn { border-color: rgba(224, 163, 46, .45); background: rgba(224, 163, 46, .07); }
.banner.is-ok   { border-color: rgba(53, 196, 139, .4);  background: rgba(53, 196, 139, .06); }
.banner code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg-sunken);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

.campaign-stats { margin-bottom: 12px; flex: 0 0 auto; }
.campaign-stats .stat-value { font-size: 17px; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill-draft     { color: var(--text-muted); }
.pill-running   { color: var(--accent); border-color: rgba(77, 148, 255, .5); }
.pill-paused    { color: var(--warn);   border-color: rgba(224, 163, 46, .5); }
.pill-completed { color: var(--ok);     border-color: rgba(53, 196, 139, .5); }
.pill-sent      { color: var(--ok);     border-color: rgba(53, 196, 139, .5); }
.pill-pending   { color: var(--text-muted); }
.pill-sending   { color: var(--accent); border-color: rgba(77, 148, 255, .5); }
.pill-failed    { color: var(--err);    border-color: rgba(240, 100, 95, .5); }
.pill-dry       { color: #b98cff;       border-color: rgba(185, 140, 255, .45); }

.recipient-row td { vertical-align: middle; }
.recipient-when { font-family: var(--mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.recipient-error { color: var(--err); font-size: 11px; }

.excluded-block { margin-top: 16px; }
.excluded-block summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  padding: 7px 0;
}
.excluded-list {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--mono);
  max-height: 180px;
  overflow: auto;
}
.excluded-list div { padding: 3px 0; border-bottom: 1px solid var(--border-soft); overflow-wrap: anywhere; }

.activity-block { margin-top: 16px; }
.activity-list {
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text-muted);
  max-height: 180px;
  overflow: auto;
}
.activity-list div { padding: 2px 0; overflow-wrap: anywhere; }
.activity-list time { color: var(--text-faint); margin-right: 8px; }

/* --------------------------------------------------------------- modal --- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 60;
}
.modal-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  width: min(640px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
}
.modal-body { overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; }
.modal-subject {
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  font-size: 13px;
}
.modal-pre {
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  margin: 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------- buttons --- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent-strong); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--text-faint); }

.btn-small { padding: 5px 11px; font-size: 12px; }
.btn-icon  { font-size: 10px; }

/* ------------------------------------------------------------ pipeline --- */

.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.stage {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-s);
  font-size: 13px;
  color: var(--text-faint);
  position: relative;
}

/* connector line between stage dots */
.stage:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 26px;
  bottom: -4px;
  width: 1px;
  background: var(--border);
}

.stage-dot {
  width: 9px;
  height: 9px;
  margin-left: 4px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-raised);
  flex-shrink: 0;
  transition: all .2s;
}

.stage-name { font-weight: 500; }
.stage-meta { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

.stage.is-active            { color: var(--text); background: var(--accent-soft); }
.stage.is-active .stage-dot { border-color: var(--accent); background: var(--accent); animation: pulse 1.4s infinite; }
.stage.is-done              { color: var(--text-muted); }
.stage.is-done .stage-dot   { border-color: var(--ok); background: var(--ok); }
.stage.is-failed            { color: #ff9a96; }
.stage.is-failed .stage-dot { border-color: var(--err); background: var(--err); }

.progress-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.pbar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-family: var(--mono);
}
.pbar-track {
  height: 5px;
  background: var(--bg-sunken);
  border-radius: 3px;
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7b5cff);
  border-radius: 3px;
  transition: width .25s ease;
}
.pbar-fill.has-failures { background: linear-gradient(90deg, var(--accent), var(--warn)); }

.run-meta {
  margin-top: auto;
  padding-top: 14px;
  font-size: 12px;
  line-height: 1.6;
}
.run-meta b { color: var(--text); font-weight: 500; }

/* ------------------------------------------------------------- console --- */

.console-card { min-height: 0; }

.console-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.select-wrap select { padding: 5px 9px; font-size: 12px; width: auto; }

.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); margin: 0; cursor: pointer; }

.log {
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  padding: 10px 4px 10px 0;
  height: 400px;
  overflow: auto;
  scrollbar-width: thin;
}

.log-line {
  display: grid;
  grid-template-columns: 62px 58px 1fr;
  gap: 10px;
  padding: 1px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border-left: 2px solid transparent;
}
.log-line:hover { background: rgba(255, 255, 255, .025); }

.log-time  { color: var(--text-faint); }
.log-level { font-weight: 600; letter-spacing: .02em; }
.log-msg   { color: #c3d1de; min-width: 0; }
.log-src   { color: var(--text-faint); }

.lvl-DEBUG   .log-level { color: var(--debug); }
.lvl-INFO    .log-level { color: var(--accent); }
.lvl-WARNING .log-level { color: var(--warn); }
.lvl-ERROR   .log-level, .lvl-CRITICAL .log-level { color: var(--err); }

.lvl-WARNING { border-left-color: rgba(224, 163, 46, .5); }
.lvl-ERROR, .lvl-CRITICAL { border-left-color: var(--err); background: rgba(240, 100, 95, .06); }
.lvl-ERROR .log-msg, .lvl-CRITICAL .log-msg { color: #ffb3b0; }

.log-event {
  padding: 5px 12px;
  margin: 5px 0;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.log-event b { color: var(--text); }
.log-event.is-good { color: var(--ok); border-left-color: var(--ok); }
.log-event.is-bad  { color: var(--err); border-left-color: var(--err); }

.log-empty { color: var(--text-faint); padding: 18px 14px; font-size: 12.5px; font-family: var(--sans); }

.console-foot {
  display: flex;
  justify-content: space-between;
  padding-top: 9px;
  font-size: 11.5px;
  font-family: var(--mono);
}

.stream-state { color: var(--text-faint); }
.stream-state.is-live   { color: var(--ok); }
.stream-state.is-live::before { content: "● "; }
.stream-state.is-error  { color: var(--err); }

/* -------------------------------------------------------------- result --- */

.result-card { border-color: var(--border); }
.result-card.is-good  { border-color: rgba(53, 196, 139, .45); }
.result-card.is-bad   { border-color: rgba(240, 100, 95, .45); }
.result-card.is-empty { border-color: rgba(224, 163, 46, .45); }

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

.stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  padding: 11px 13px;
}
.stat-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }
.stat.is-good .stat-value { color: var(--ok); }
.stat.is-warn .stat-value { color: var(--warn); }

.result-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.result-errors {
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  max-height: 150px;
  overflow: auto;
}
.result-errors div { padding: 2px 0; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- files --- */

.files-card, .preview-card { max-height: calc(100vh - 170px); }

.search-input { margin-bottom: 10px; }

.file-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }

.file-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  background: var(--bg-sunken);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.file-item:hover { border-color: var(--text-faint); }
.file-item.is-selected { border-color: var(--accent); background: var(--accent-soft); }

.file-name {
  font-size: 12.5px;
  font-weight: 500;
  overflow-wrap: anywhere;
  grid-column: 1;
}
.file-sub {
  grid-column: 1;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.file-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.file-new {
  color: var(--ok);
  border: 1px solid rgba(53, 196, 139, .4);
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
}

/* ------------------------------------------------------------- preview --- */

.preview-body { overflow: auto; flex: 1; min-height: 200px; scrollbar-width: thin; }

.lead-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12.5px;
}
.lead-table th, .lead-table td {
  text-align: left;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  max-width: 320px;
  overflow-wrap: anywhere;
}
.lead-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
  z-index: 1;
  border-bottom: 1px solid var(--border);
}
.lead-table td.col-index { color: var(--text-faint); font-family: var(--mono); font-size: 11px; width: 34px; }
.lead-table tbody tr:hover td { background: rgba(255, 255, 255, .022); }
.lead-table a { color: var(--accent); text-decoration: none; }
.lead-table a:hover { text-decoration: underline; }
.cell-empty { color: var(--text-faint); }

.preview-note {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border-radius: var(--radius-s);
  margin-top: 10px;
}

/* ---------------------------------------------------------- scrollbars --- */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3644; border-radius: 5px; border: 2px solid var(--bg-raised); }
::-webkit-scrollbar-thumb:hover { background: #3a495b; }

.result-note { margin-top: 10px; font-size: 12px; }
