:root {
  --bg:       #0f0f13;
  --surface:  #1a1a24;
  --border:   #2a2a3a;
  --primary:  #6c63ff;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --error:    #ef4444;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --radius:   12px;
  --header-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 48px;
}

/* ── Header ── */
header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
  flex-shrink: 0;
}
.status-dot.running { background: var(--warning); animation: pulse 1s infinite; }
.status-dot.done    { background: var(--success); }
.status-dot.error   { background: var(--error); }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── Tab Bar ── */
.tab-bar {
  display: flex;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 10;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 4px;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab.active            { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

/* ── Layout ── */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.tab-pane         { display: none; }
.tab-pane.active  { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ── Form ── */
.form-group { margin-bottom: 10px; }

label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

input, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--primary); }
select option { background: var(--surface); }

/* ── Buttons ── */
.btn {
  border: none;
  cursor: pointer;
  font-weight: 600;
  border-radius: 8px;
  transition: opacity 0.15s, transform 0.1s;
  font-size: 14px;
  padding: 10px 16px;
  white-space: nowrap;
}
.btn:active    { transform: scale(0.97); }
.btn:disabled  { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border);  color: var(--text); }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-large     { width: 100%; padding: 14px; font-size: 16px; margin-top: 6px; }
.btn-small     { padding: 7px 14px; font-size: 13px; }

/* ── Agent run card header ── */
.agent-run-card { }

.agent-run-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.agent-icon-lg   { font-size: 28px; flex-shrink: 0; line-height: 1.1; }
.agent-run-info  { flex: 1; min-width: 0; }
.agent-run-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.agent-run-desc  { font-size: 13px; color: var(--muted); }

/* ── Badge ── */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
  align-self: flex-start;
}
.badge.idle    { background: rgba(100,116,139,.15); color: var(--muted); }
.badge.running { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge.done    { background: rgba(34,197,94,.15);   color: var(--success); }
.badge.error   { background: rgba(239,68,68,.15);   color: var(--error); }

/* ── Agent result containers ── */
.agent-result-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Shared result primitives ── */
.r-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
  margin-top: 14px;
}
.r-label:first-child { margin-top: 0; }

.r-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}

.top-chip {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(108,99,255,.15);
  color: var(--primary);
  border-radius: 20px;
  padding: 1px 7px;
  vertical-align: middle;
  margin-left: 6px;
}

/* ── Niche Scout results ── */
.niche-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
}
.niche-row:last-of-type { margin-bottom: 0; }
.niche-row.is-top { border-color: rgba(108,99,255,.35); }

.niche-info  { flex: 1; min-width: 0; }
.niche-name  { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.niche-sub   { font-size: 12px; color: var(--muted); }

.niche-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.niche-score { font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1; }

.comp-tag {
  font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  text-transform: uppercase;
}
.comp-low    { background: rgba(34,197,94,.12);  color: var(--success); }
.comp-med    { background: rgba(245,158,11,.12); color: var(--warning); }
.comp-high   { background: rgba(239,68,68,.12);  color: var(--error); }

/* ── Brand Builder results ── */
.brand-hero-block { text-align: center; padding: 6px 0 16px; }
.brand-name-big   { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.brand-tagline-italic { font-size: 14px; color: var(--muted); font-style: italic; }

.swatches { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.swatch   { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }

.trust-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.trust-badge {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(108,99,255,.1);
  color: var(--primary);
  border: 1px solid rgba(108,99,255,.2);
}

.copy-block { margin-bottom: 2px; }
.copy-block p {
  font-size: 14px; line-height: 1.65; color: var(--text);
  background: var(--bg); border-radius: 8px; padding: 10px 12px;
}

.email-subjects { display: flex; flex-direction: column; gap: 6px; }
.email-subject  {
  font-size: 13px; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text);
}

/* ── Product Hunter results ── */
.product-list { display: flex; flex-direction: column; gap: 8px; }

.product-item {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.product-item.is-top { border-color: rgba(108,99,255,.35); }

.product-details { flex: 1; min-width: 0; }
.product-title   { font-size: 13px; font-weight: 600; margin-bottom: 4px; line-height: 1.4; }
.product-meta    { font-size: 12px; color: var(--muted); margin-bottom: 2px; }

.product-right   { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.product-margin  { font-size: 14px; font-weight: 800; color: var(--success); }
.product-price   { font-size: 11px; color: var(--muted); white-space: nowrap; }
.product-score   { font-size: 18px; font-weight: 800; color: var(--primary); }

/* ── Store Builder results ── */
.store-status-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 2px;
}
.store-status-row .check { color: var(--success); font-size: 16px; flex-shrink: 0; }
.store-domain { flex: 1; font-weight: 600; font-size: 14px; min-width: 0; }

.page-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.page-chip  {
  font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(34,197,94,.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,.2);
}

/* ── Ad Creator results ── */
.ad-card { }

.ad-type {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--primary); margin-bottom: 10px;
}
.ad-hook   { font-size: 16px; font-weight: 700; line-height: 1.4; margin-bottom: 12px; }
.ad-script {
  font-size: 13px; line-height: 1.7; color: var(--text);
  background: var(--bg); border-radius: 8px; padding: 10px 12px;
}

/* ── Sales Analyst results ── */
.kpi-row { display: flex; gap: 8px; }
.kpi-card {
  flex: 1;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 10px; text-align: center;
}
.kpi-value { font-size: 22px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-lbl   { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

.health-row {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px; margin-bottom: 2px;
}
.health-score-circle {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid var(--primary);
  background: rgba(108,99,255,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: var(--primary);
  flex-shrink: 0;
}
.health-info  { flex: 1; min-width: 0; }
.health-title { font-weight: 600; margin-bottom: 3px; }
.health-sub   { font-size: 12px; color: var(--muted); line-height: 1.5; }

.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 10px 12px;
}
.rec-item.high   { border-left-color: var(--error); }
.rec-item.medium { border-left-color: var(--warning); }
.rec-item.low    { border-left-color: var(--muted); }

.rec-action { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.rec-impact { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.rec-tags   { display: flex; gap: 5px; flex-wrap: wrap; }
.rec-tag {
  font-size: 10px; font-weight: 600;
  padding: 1px 7px; border-radius: 20px;
  background: rgba(100,116,139,.15); color: var(--muted);
}

.goal-list { display: flex; flex-direction: column; gap: 7px; }
.goal-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; }
.goal-dot  {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0; margin-top: 6px;
}

/* ── UGC Sourcer results ── */
.creator-card  { }

.creator-top {
  display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.creator-handle    { font-size: 16px; font-weight: 700; }
.creator-followers { font-size: 12px; color: var(--muted); margin-left: auto; }

.platform-chip {
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.chip-instagram { background: rgba(225,48,108,.12); color: #e1306c; }
.chip-tiktok    { background: rgba(105,201,208,.12); color: #69c9d0; }

.creator-scores { display: flex; gap: 14px; margin-bottom: 7px; }
.creator-score-item { font-size: 12px; color: var(--muted); }
.creator-score-val  { font-weight: 700; color: var(--text); }

.creator-style { font-size: 12px; color: var(--muted); margin-bottom: 5px; font-style: italic; }
.creator-why   { font-size: 12px; color: var(--muted); line-height: 1.5; margin-bottom: 10px; }

.dm-box   { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.dm-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.dm-text  { font-size: 13px; line-height: 1.65; color: var(--text); }

/* ── Log ── */
.log-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.log-header h2 { margin-bottom: 0; }

.log-container {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  height: 260px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-entry          { line-height: 1.45; }
.log-entry .ts      { color: var(--muted); margin-right: 5px; }
.log-entry .agent   { color: var(--primary); font-weight: 600; margin-right: 5px; }
.log-entry.info     { color: var(--text); }
.log-entry.success  { color: var(--success); }
.log-entry.warning  { color: var(--warning); }
.log-entry.error    { color: var(--error); }
.log-entry.done     { color: var(--success); }

/* ── Pipeline raw results ── */
.results-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  color: var(--text);
  margin: 0;
}
