:root {
  --ink: #13201f;
  --muted: #64716f;
  --line: #dce1dc;
  --paper: #fffefa;
  --canvas: #f3f1e9;
  --teal: #087f7a;
  --teal-dark: #075c58;
  --teal-soft: #e9f4f1;
  --lime: #c9f45a;
  --lime-soft: #f0fad5;
  --red: #b3483d;
  --red-soft: #fff0ed;
  --amber: #9a6607;
  --amber-soft: #fff5de;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(22, 40, 37, .07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 16px; background: var(--canvas); }
.boot-mark, .brand-mark { position: relative; display: inline-block; width: 28px; height: 32px; }
.boot-mark::before, .boot-mark::after, .brand-mark i { content: ""; position: absolute; left: 2px; width: 24px; height: 11px; border-radius: 3px; transform: skewY(-24deg); }
.boot-mark::before, .brand-mark i:first-child { top: 3px; background: var(--teal); }
.boot-mark::after, .brand-mark i:last-child { bottom: 3px; background: var(--lime); }

.app { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; flex-direction: column; width: 248px; padding: 24px 16px 18px; border-right: 1px solid var(--line); background: rgba(255, 254, 250, .94); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 4px 8px; color: var(--ink); font-size: 17px; font-weight: 850; letter-spacing: -.025em; text-decoration: none; }
.brand-mark { flex: 0 0 28px; }
.nav { display: grid; gap: 5px; margin-top: 38px; }
.nav-item { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font-weight: 720; }
.nav-item:hover, .nav-item:focus-visible { color: var(--ink); background: #f2f3ee; outline: none; }
.nav-item.active { color: var(--teal-dark); background: var(--teal-soft); }
.nav-icon { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid currentColor; border-radius: 7px; font-size: 16px; font-weight: 450; }
.nav-item b { min-width: 22px; padding: 2px 6px; border-radius: 5px; background: #e8ebe7; color: var(--muted); font-size: 11px; text-align: center; }
.sidebar-note { display: flex; gap: 12px; align-items: flex-start; margin-top: auto; padding: 15px 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sidebar-note strong, .sidebar-note small, .account strong, .account small { display: block; }
.sidebar-note strong { font-size: 13px; }
.sidebar-note small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.live-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 5px rgba(8, 127, 122, .12); }
.account { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 11px; align-items: center; padding: 18px 8px 0; }
.account strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account small { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; background: var(--ink); font-size: 12px; font-weight: 850; }

.main { min-height: 100vh; margin-left: 248px; }
.view { display: none; width: min(1240px, calc(100% - 56px)); margin: 0 auto; padding: 58px 0 90px; }
.view.active { display: block; }
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: start; }
.page-head > div:first-child { max-width: 820px; }
.eyebrow, .card-kicker { display: block; margin-bottom: 11px; color: var(--teal-dark); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.08; }
h1 { margin-bottom: 15px; font-size: clamp(34px, 4vw, 58px); font-weight: 850; }
h2 { margin-bottom: 0; font-size: 24px; }
h3 { font-size: 17px; }
.page-head p { max-width: 700px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.environment { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); font-size: 12px; }
.environment span { width: 8px; height: 8px; border-radius: 50%; background: #b7beb9; }
.environment.online span { background: var(--teal); box-shadow: 0 0 0 4px rgba(8, 127, 122, .11); }

.alert { margin-top: 24px; padding: 14px 16px; border: 1px solid #e3c883; border-radius: 10px; color: #6e4b09; background: var(--amber-soft); }
.alert.error { border-color: #ecc0ba; color: var(--red); background: var(--red-soft); }
.alert.success { border-color: #b7d8d1; color: var(--teal-dark); background: var(--teal-soft); }

.leadmap-view { width: min(1480px, calc(100% - 40px)); padding-top: 38px; }
.leadmap-view .page-head { align-items: end; }
.leadmap-view .page-head h1 { max-width: 980px; font-size: clamp(34px, 4vw, 54px); }
.leadmap-shell { margin-top: 28px; overflow: hidden; border-color: #cbd3cf; background: #090d13; box-shadow: 0 24px 70px rgba(15, 31, 29, .12); }
.leadmap-shell-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 58px; padding: 8px 12px 8px 18px; border-bottom: 1px solid #25303a; color: #e8f2ff; background: #101720; }
.leadmap-shell-head > div { display: grid; grid-template-columns: 10px auto; align-items: center; column-gap: 10px; }
.leadmap-shell-head .live-dot { grid-row: 1 / 3; margin-top: 0; background: var(--lime); box-shadow: 0 0 0 5px rgba(201, 244, 90, .1); }
.leadmap-shell-head strong { font-size: 13px; }
.leadmap-shell-head small { color: #8395a6; font-size: 10px; }
.leadmap-shell-head .button.quiet { min-height: 38px; border-color: #2c3b49; color: #dce8f2; background: #17212c; }
#leadmap-frame { display: block; width: 100%; height: min(820px, calc(100vh - 150px)); min-height: 650px; border: 0; background: #07090f; }
.leadmap-guide { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #25303a; color: #9aabba; background: #101720; }
.leadmap-guide span { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 8px 12px; font-size: 11px; }
.leadmap-guide span + span { border-left: 1px solid #25303a; }
.leadmap-guide b { display: grid; place-items: center; width: 21px; height: 21px; border: 1px solid #3d4b58; border-radius: 5px; color: var(--lime); font: 800 9px/1 ui-monospace, monospace; }

.workflow { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; margin: 42px 0 22px; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 254, 250, .72); }
.workflow-step { display: flex; align-items: center; gap: 10px; color: #87918f; }
.workflow-step > span { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #c9cfca; border-radius: 8px; font: 780 11px/1 ui-monospace, monospace; }
.workflow-step strong, .workflow-step small { display: block; }
.workflow-step strong { font-size: 12px; }
.workflow-step small { margin-top: 1px; font-size: 10px; }
.workflow-step.current, .workflow-step.done { color: var(--teal-dark); }
.workflow-step.current > span { border-color: var(--teal); color: #fff; background: var(--teal); }
.workflow-step.done > span { border-color: var(--teal); background: var(--teal-soft); }
.workflow-line { height: 1px; margin: 0 18px; background: #d7dcd8; }

.builder-grid { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(340px, .78fr); gap: 18px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.source-card, .setup-card { padding: 23px; }
.setup-card { position: sticky; top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.card-kicker { margin-bottom: 6px; }
.selection-count { padding: 5px 8px; border-radius: 6px; color: var(--teal-dark); background: var(--teal-soft); font-size: 11px; font-weight: 800; }

.drop-zone { display: grid; justify-items: center; padding: 46px 24px; border: 1px dashed #aab6b1; border-radius: 12px; background: #faf9f4; text-align: center; transition: border-color .15s, background .15s; }
.drop-zone.dragging { border-color: var(--teal); background: var(--teal-soft); }
.drop-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 18px; border: 1px solid var(--teal); border-radius: 11px; color: var(--teal-dark); background: var(--teal-soft); font-size: 23px; }
.drop-zone h3 { margin-bottom: 8px; font-size: 20px; }
.drop-zone p { max-width: 480px; margin-bottom: 20px; color: var(--muted); }
.drop-zone > small { margin-top: 16px; color: #7a8582; font-size: 11px; }
.drop-actions { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }
.fallback-import { width: min(100%, 440px); margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.fallback-import summary { min-height: 34px; cursor: pointer; font-weight: 760; }
.fallback-import p { margin: 4px auto 8px; font-size: 11px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font-size: 13px; font-weight: 780; text-decoration: none; }
.button:hover, .button:focus-visible { border-color: var(--teal); outline: 3px solid rgba(8, 127, 122, .12); outline-offset: 1px; }
.button.primary { border-color: var(--teal); color: #fff; background: var(--teal); }
.button.quiet { background: #f6f5ef; }
.button.text { min-height: 40px; padding-inline: 8px; border-color: transparent; color: var(--teal-dark); background: transparent; }
.button:disabled { cursor: not-allowed; opacity: .48; }

.picker-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.search-field { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.search-field span { color: var(--teal); font-size: 20px; }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.select-row { display: flex; justify-content: space-between; align-items: center; min-height: 48px; margin-top: 12px; padding: 0 4px; color: var(--muted); font-size: 12px; }
.check-line { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 700; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--teal); }
.lead-list { max-height: 520px; overflow-y: auto; border-top: 1px solid var(--line); }
.lead-item { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 72px; padding: 11px 8px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lead-item:hover { background: #fafbf7; }
.lead-item > input { position: absolute; opacity: 0; }
.custom-check { display: grid; place-items: center; width: 21px; height: 21px; border: 1px solid #b8c1bd; border-radius: 6px; color: transparent; background: #fff; font-size: 11px; font-weight: 900; }
.lead-item > input:focus-visible + .custom-check { outline: 3px solid rgba(8, 127, 122, .18); }
.lead-item > input:checked + .custom-check { border-color: var(--teal); color: #fff; background: var(--teal); }
.lead-main { min-width: 0; }
.lead-main strong, .lead-main small, .lead-score b, .lead-score small { display: block; }
.lead-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.lead-main small { overflow: hidden; margin-top: 3px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.lead-score { min-width: 48px; text-align: right; }
.lead-score b { font-size: 13px; }
.lead-score small { color: var(--muted); font-size: 9px; text-transform: uppercase; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend, .field > span { display: block; margin-bottom: 9px; color: #44504e; font-size: 12px; font-weight: 800; }
.output-choice { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; min-height: 76px; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.output-choice + .output-choice { margin-top: 9px; }
.output-choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); box-shadow: inset 0 0 0 1px var(--teal); }
.output-choice > input { position: absolute; opacity: 0; }
.output-radio { width: 19px; height: 19px; margin-top: 1px; border: 1px solid #aab6b1; border-radius: 50%; background: #fff; }
.output-choice:has(input:checked) .output-radio { border: 5px solid var(--teal); }
.output-copy strong, .output-copy small { display: block; }
.output-copy strong { font-size: 13px; }
.output-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.recommended { padding: 3px 6px; border-radius: 4px; color: #476100; background: var(--lime-soft); font-size: 9px; font-weight: 850; text-transform: uppercase; }
.profession-block { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.field select { width: 100%; min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; }
.field select:focus { border-color: var(--teal); outline: 3px solid rgba(8, 127, 122, .12); }
.confirm-box { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; margin-top: 12px; padding: 13px; border: 1px solid #dfd8c8; border-radius: 10px; background: #faf7ef; cursor: pointer; }
.confirm-box input { width: 18px; height: 18px; margin: 2px 0 0; }
.confirm-box strong, .confirm-box small { display: block; }
.confirm-box strong { font-size: 12px; }
.confirm-box small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.setup-summary { display: grid; gap: 8px; margin: 20px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.setup-summary div { display: flex; justify-content: space-between; gap: 15px; font-size: 11px; }
.setup-summary span { color: var(--muted); }
.setup-summary strong { text-align: right; }
.button.launch { width: 100%; justify-content: space-between; min-height: 52px; padding-inline: 17px; border-color: var(--ink); color: #fff; background: var(--ink); font-size: 14px; }
.button.launch:not(:disabled):hover { border-color: var(--teal); background: var(--teal-dark); }
.launch-help { margin: 10px 0 0; color: var(--muted); font-size: 10px; text-align: center; }

.production { margin-top: 18px; padding: 25px; }
.production-top { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.production-top p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.status { padding: 6px 9px; border-radius: 6px; color: var(--teal-dark); background: var(--teal-soft); font: 800 10px/1.2 ui-monospace, monospace; text-transform: uppercase; }
.status[data-state="failed"], .status[data-state="partial"] { color: var(--red); background: var(--red-soft); }
.status[data-state="queued"], .status[data-state="running"] { color: var(--amber); background: var(--amber-soft); }
.progress-track { height: 7px; margin: 22px 0 16px; overflow: hidden; border-radius: 9px; background: #e8ece8; }
.progress-track span { display: block; width: var(--progress, 0%); height: 100%; border-radius: inherit; background: var(--teal); transition: width .35s ease; }
.production-metrics { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 11px; }
.production-metrics div { padding: 13px 15px; }
.production-metrics div + div { border-left: 1px solid var(--line); }
.production-metrics strong, .production-metrics span { display: block; }
.production-metrics strong { font-size: 21px; }
.production-metrics span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.batch-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.result-list { margin-top: 16px; border-top: 1px solid var(--line); }
.result-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 66px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.result-row strong, .result-row small { display: block; }
.result-row small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.result-links { display: flex; gap: 7px; }
.result-links a { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--teal-dark); font-size: 11px; font-weight: 780; text-decoration: none; }
.result-links a:hover { border-color: var(--teal); }

.page-head.compact h1 { font-size: clamp(34px, 4vw, 48px); }
.history-layout { display: grid; grid-template-columns: minmax(380px, .8fr) minmax(0, 1.2fr); gap: 18px; margin-top: 36px; align-items: start; }
.history-card, .history-detail { min-height: 510px; padding: 20px; }
.history-detail { position: sticky; top: 20px; }
.history-head { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.job-list { display: grid; }
.job-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 76px; padding: 12px 5px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; text-align: left; }
.job-item:hover, .job-item:focus-visible, .job-item.active { padding-inline: 10px; border-radius: 8px; background: var(--teal-soft); outline: 0; }
.job-item strong, .job-item small { display: block; }
.job-item small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.job-status { padding: 5px 7px; border-radius: 5px; color: var(--teal-dark); background: var(--teal-soft); font: 750 9px/1.2 ui-monospace, monospace; text-transform: uppercase; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.pagination span { color: var(--muted); font-size: 11px; }
.empty-detail { display: grid; min-height: 450px; place-content: center; justify-items: center; text-align: center; }
.empty-detail > span { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--teal); font-size: 22px; }
.empty-detail p { max-width: 270px; margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.detail-head { display: flex; justify-content: space-between; gap: 15px; align-items: start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin-top: 5px; }
.detail-meta { color: var(--muted); font-size: 11px; }
.mobile-header, .mobile-nav { display: none; }

@media (max-width: 1080px) {
  .builder-grid { grid-template-columns: 1fr; }
  .setup-card { position: static; }
  .history-layout { grid-template-columns: 1fr; }
  .history-detail { position: static; }
}

@media (max-width: 780px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .mobile-header { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; min-height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0; border-bottom: 1px solid var(--line); background: rgba(255, 254, 250, .94); backdrop-filter: blur(16px); }
  .mobile-header .brand { padding-left: 0; }
  .plan-pill { padding: 5px 8px; border-radius: 5px; color: var(--teal-dark); background: var(--teal-soft); font-size: 10px; font-weight: 800; text-transform: capitalize; }
  .view { width: min(100% - 32px, 680px); padding: 34px 0 58px; }
  .page-head { grid-template-columns: 1fr; gap: 17px; }
  .environment { justify-self: start; }
  .workflow { grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 12px; }
  .workflow-line { display: none; }
  .workflow-step { gap: 7px; }
  .workflow-step small { display: none; }
  .workflow-step > span { width: 29px; height: 29px; }
  .mobile-nav { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr); min-height: calc(60px + env(safe-area-inset-bottom)); padding: 5px 12px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255, 254, 250, .96); backdrop-filter: blur(15px); }
  .mobile-nav button { display: grid; place-content: center; justify-items: center; gap: 1px; min-height: 50px; border: 0; color: var(--muted); background: transparent; font-size: 10px; font-weight: 750; }
  .mobile-nav button span { font-size: 20px; line-height: 1; }
  .mobile-nav button.active { color: var(--teal-dark); }
}

@media (max-width: 520px) {
  .view { width: calc(100% - 24px); }
  h1 { font-size: clamp(33px, 10vw, 43px); }
  .page-head p { font-size: 15px; }
  .workflow-step div { display: none; }
  .workflow-step { justify-content: center; }
  .source-card, .setup-card, .production, .history-card, .history-detail { padding: 17px 14px; border-radius: 13px; }
  .drop-zone { padding: 31px 14px; }
  .drop-actions { width: 100%; }
  .drop-actions .button { width: 100%; }
  .leadmap-view { width: calc(100% - 16px); padding-top: 24px; }
  .leadmap-view .page-head { padding-inline: 4px; }
  .leadmap-shell { margin-top: 20px; border-radius: 11px; }
  .leadmap-shell-head { padding-left: 12px; }
  .leadmap-shell-head small { display: none; }
  .leadmap-shell-head .button { padding-inline: 10px; font-size: 11px; }
  #leadmap-frame { height: calc(100vh - 126px); min-height: 610px; }
  .leadmap-guide { display: none; }
  .picker-toolbar { grid-template-columns: 1fr; }
  #replace-file { justify-self: start; }
  .output-choice { grid-template-columns: 22px minmax(0, 1fr); }
  .recommended { grid-column: 2; justify-self: start; }
  .production-top { display: grid; }
  .status { justify-self: start; }
  .production-metrics div { padding-inline: 9px; }
  .result-row { grid-template-columns: 1fr; padding-block: 13px; }
  .result-links { flex-wrap: wrap; }
  .page-head.compact .button { justify-self: start; }
  .history-card, .history-detail { min-height: 0; }
  .empty-detail { min-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
