:root {
  --ink: #17221d;
  --muted: #647169;
  --paper: #f4f2eb;
  --panel: #fffef9;
  --line: #dcded6;
  --green: #174f3b;
  --green-soft: #dcebe3;
  --amber: #a86516;
  --amber-soft: #f7e8cf;
  --red: #9e423a;
  --red-soft: #f5dfdb;
  --shadow: 0 18px 50px rgba(27, 48, 38, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 231, 221, 0.65), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.shell { width: min(1500px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(44px, 6vw, 72px); font-weight: 500; letter-spacing: -.045em; line-height: .95; }
.subtitle { margin: 16px 0 0; color: var(--muted); font-size: 17px; }
.sync-state { display: flex; gap: 9px; align-items: center; margin-top: 8px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.7); color: var(--muted); font-size: 13px; }
.sync-state:hover { border-color: #afbbb3; background: #fff; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #c5a352; box-shadow: 0 0 0 4px rgba(197,163,82,.14); }
.sync-state.ready .sync-dot { background: #43a16f; box-shadow: 0 0 0 4px rgba(67,161,111,.14); }
.sync-state.error .sync-dot { background: var(--red); }

.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; margin: 36px 0 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--line); box-shadow: var(--shadow); }
.metrics article { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 20px; background: var(--panel); }
.metrics span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metrics strong { font-family: Georgia, serif; font-size: 28px; font-weight: 500; }

.workspace { display: grid; grid-template-columns: minmax(520px, 1.15fr) minmax(390px, .85fr); min-height: 680px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.queue-panel { min-width: 0; border-right: 1px solid var(--line); }
.toolbar { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding: 18px; border-bottom: 1px solid var(--line); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
input, select { min-height: 42px; padding: 0 12px; }
textarea { resize: vertical; padding: 10px 12px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: #689680; box-shadow: 0 0 0 3px rgba(23,79,59,.1); }
.search-field input { min-width: 220px; }
.result-count { padding: 14px 20px 8px; color: var(--muted); font-size: 13px; }
.lead-list { max-height: 720px; overflow: auto; padding: 4px 10px 14px; }
.lead-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; width: 100%; margin: 0; padding: 15px 12px; border: 0; border-bottom: 1px solid #e8e8e1; border-radius: 10px; background: transparent; color: inherit; text-align: left; }
.lead-row:hover { background: #f3f6f2; }
.lead-row.active { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.lead-main { min-width: 0; }
.lead-title { display: block; overflow: hidden; font-size: 15px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.lead-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; color: var(--muted); font-size: 12px; }
.lead-contact { display: block; margin-top: 7px; overflow: hidden; color: #3f4d45; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; gap: 6px; align-items: flex-start; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: #e9ece8; color: #526059; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.badge.new, .badge.contacted { background: var(--amber-soft); color: var(--amber); }
.badge.ready, .badge.interested, .badge.live { background: var(--green-soft); color: var(--green); }
.badge.generating { background: #e1e7f4; color: #385584; }
.badge.declined, .badge.failed { background: var(--red-soft); color: var(--red); }
.badge.archived { background: #e5e5e1; color: #646963; }
.reviewed-mark { color: var(--green); font-weight: 900; }

.detail-panel { position: relative; min-width: 0; padding: 30px; background: #faf9f3; }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 590px; padding: 40px; text-align: center; }
.empty-mark { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 18px; border-radius: 20px; background: var(--green); color: white; font-family: Georgia, serif; font-size: 20px; }
.empty-state h2 { margin: 0; font: 500 30px/1 Georgia, serif; }
.empty-state p { max-width: 330px; margin: 12px 0 0; color: var(--muted); line-height: 1.55; }
.detail-heading { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.detail-heading h2 { max-width: 520px; margin: 0; font: 500 34px/1.05 Georgia, serif; letter-spacing: -.025em; }
.detail-heading > div > p:last-child { margin: 9px 0 0; color: var(--muted); }
.detail-links { display: grid; gap: 8px; align-content: start; text-align: right; }
.map-link { align-self: flex-start; white-space: nowrap; color: var(--green); font-size: 13px; font-weight: 750; text-decoration: none; }
.map-link[hidden] { display: none; }
.run-banner { margin-top: 18px; padding: 12px 14px; border: 1px solid #bfcce0; border-radius: 10px; background: #edf2fa; color: #385584; font-size: 13px; line-height: 1.45; }
.run-banner.failed { border-color: #e1b6af; background: var(--red-soft); color: var(--red); }
.run-banner.succeeded { border-color: #b9d7c7; background: var(--green-soft); color: var(--green); }
.form-grid { display: grid; gap: 14px; }
.form-grid.two-up { grid-template-columns: 1fr 1fr; }
.form-grid label { display: grid; gap: 7px; color: #4f5b54; font-size: 12px; font-weight: 750; }
.form-grid label small { color: var(--muted); font-weight: 500; }
.form-grid.single-row { margin-top: 14px; }
.compact-grid { margin-top: 14px; }
.full-label { display: grid; gap: 7px; color: #4f5b54; font-size: 12px; font-weight: 750; }
.section-label { margin: 25px 0 12px; color: var(--green); font-size: 11px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.review-check { display: flex; gap: 12px; margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.review-check input { width: 18px; min-height: 18px; margin-top: 2px; accent-color: var(--green); }
.review-check span { display: grid; gap: 3px; }
.review-check strong { font-size: 13px; }
.review-check small { color: var(--muted); line-height: 1.35; }
.activity { margin-top: 26px; padding-top: 1px; border-top: 1px solid var(--line); }
.activity-list { display: grid; gap: 11px; }
.activity-item { display: grid; grid-template-columns: 9px 1fr; gap: 10px; align-items: start; }
.activity-dot { width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: #8ba397; }
.activity-item div { display: grid; gap: 3px; }
.activity-item strong { font-size: 12px; text-transform: capitalize; }
.activity-item span:last-child, .activity-empty { margin: 0; color: var(--muted); font-size: 11px; }
.activity-empty.error { color: var(--red); }
.action-row { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 16px; margin: 28px -30px -30px; padding: 15px 30px; border-top: 1px solid var(--line); background: rgba(250,249,243,.96); backdrop-filter: blur(10px); }
.workflow-actions { display: flex; flex-wrap: wrap; gap: 7px; grid-column: 1 / -1; }
.workflow-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #425048; font-size: 12px; font-weight: 750; }
.workflow-button:hover { border-color: #9daaa2; }
.workflow-button.approve, .workflow-button.retry { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.workflow-button.decline { color: var(--red); }
.action-row.busy button { pointer-events: none; opacity: .55; }
#save-message { margin-right: auto; color: var(--muted); font-size: 13px; }
#save-message.error { color: var(--red); }
#save-button { min-height: 43px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--green); color: white; font-weight: 800; }
#save-button:hover { background: #103e2e; }
#save-button:disabled { cursor: wait; opacity: .65; }
.no-results { padding: 70px 20px; color: var(--muted); text-align: center; }
.modal-overlay { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(16, 29, 23, .54); backdrop-filter: blur(8px); }
.modal-overlay[hidden] { display: none; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 30px; border: 1px solid rgba(255,255,255,.45); border-radius: 20px; background: var(--panel); box-shadow: 0 28px 80px rgba(7, 18, 13,.28); }
.auth-card { width: min(440px, 100%); }
.modal-card h2 { margin: 0; font: 500 36px/1.05 Georgia, serif; letter-spacing: -.025em; }
.auth-card > p:not(.eyebrow) { margin: 14px 0 22px; color: var(--muted); line-height: 1.55; }
.auth-card form { display: grid; gap: 14px; }
.auth-card label { display: grid; gap: 7px; color: #4f5b54; font-size: 12px; font-weight: 750; }
.modal-card button[type="submit"] { min-height: 44px; border: 0; border-radius: 9px; background: var(--green); color: white; font-weight: 800; }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.close-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.secondary-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.74); color: var(--ink); font-weight: 750; }
.secondary-button:hover { background: #fff; border-color: #aeb9b2; }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 950px) {
  .shell { width: min(100% - 24px, 760px); padding: 24px 0; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 20px; }
  .sync-state { display: inline-flex; margin-top: 0; }
  .metrics { grid-template-columns: repeat(6, minmax(100px, 1fr)); overflow-x: auto; }
  .metrics article { display: grid; gap: 8px; }
  .workspace { grid-template-columns: 1fr; }
  .queue-panel { border-right: 0; }
  .lead-list { max-height: 520px; }
  .detail-panel { border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .metrics { margin-top: 24px; }
  .detail-panel { padding: 22px 18px; }
  .detail-heading { display: grid; }
  .form-grid.two-up { grid-template-columns: 1fr; }
  .action-row { margin: 24px -18px -22px; padding: 14px 18px; }
  .badges .badge:last-child { display: none; }
  .topbar-actions { align-items: stretch; flex-direction: column; }
}
