:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647087;
  --line: #dce2eb;
  --paper: #ffffff;
  --canvas: #f3f5f8;
  --navy: #142a4a;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #177a52;
  --amber: #9a5b00;
  --red: #b42318;
  --shadow: 0 18px 50px rgba(24, 39, 75, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.shell { min-height: 100vh; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 22px clamp(20px, 4vw, 64px); background: var(--navy); color: white;
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 2.5vw, 2rem); font-weight: 650; }
.eyebrow, .step { margin: 0; font-size: .74rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow { color: #9ec5ff; }
.step { color: var(--blue); }
.session-actions { display: flex; align-items: center; gap: 14px; color: #d9e6f7; font-size: .9rem; }

.workspace {
  width: min(1440px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 42px);
  display: grid; grid-template-columns: minmax(300px, 410px) minmax(0, 1fr); gap: 24px;
}
.composer, .conversation { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.composer { padding: 26px; align-self: start; position: sticky; top: 20px; }
.conversation { padding: 26px; min-height: 70vh; }
.section-heading { margin-bottom: 22px; }
.section-heading h2 { margin: 6px 0 0; font-size: 1.35rem; }

form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; font-size: .88rem; font-weight: 650; }
input, select, textarea {
  width: 100%; border: 1px solid #cbd3df; border-radius: 10px; padding: 11px 12px;
  color: var(--ink); background: white; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; }
#lead-fields, #company-fields { display: grid; gap: 16px; }
.hint { color: var(--muted); font-weight: 450; }
.status { min-height: 1.25rem; margin: 0; color: var(--muted); font-size: .86rem; }
.status.error { color: var(--red); }

.button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { color: var(--navy); background: white; }
.button.danger { color: white; background: var(--red); }
.button.ghost { color: var(--navy); background: #eaf0f8; }

.messages { display: grid; gap: 16px; }
.message { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: #fbfcfe; }
.message p { margin: 0; line-height: 1.55; }
.message h3 { margin: 0 0 10px; font-size: 1.03rem; }
.message h4 { margin: 18px 0 7px; }
.system-message { border-left: 4px solid var(--blue); }
.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.status-queued, .status-running { color: var(--blue-dark); background: #e8f0ff; }
.status-completed, .status-approved { color: var(--green); background: #e5f6ee; }
.status-failed, .status-rejected { color: var(--red); background: #feeceb; }
.status-revision_requested { color: var(--amber); background: #fff3d6; }
.meta { color: var(--muted); font-size: .8rem; margin-top: 7px; }
.result-text { white-space: pre-wrap; line-height: 1.55; font-family: inherit; }
.lead-card { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.lead-card a { color: var(--blue-dark); overflow-wrap: anywhere; }
.source-list { padding-left: 20px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.empty { color: var(--muted); font-style: italic; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .composer { position: static; }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .session-actions { width: 100%; justify-content: space-between; }
  .workspace { padding: 12px; }
  .composer, .conversation { padding: 18px; border-radius: 14px; }
}

[hidden] {
  display: none !important;
}

