:root {
  color-scheme: light;
  --paper: #f5f4ee;
  --surface: #ffffff;
  --surface-soft: #f9f8f4;
  --ink: #17221d;
  --muted: #66716b;
  --line: rgba(23, 34, 29, 0.12);
  --line-strong: rgba(23, 34, 29, 0.2);
  --forest: #115d4f;
  --forest-deep: #0b443a;
  --forest-soft: #dcebe4;
  --blue: #315f9c;
  --blue-soft: #e6edf7;
  --amber: #a66117;
  --amber-soft: #f7ead7;
  --red: #a43d38;
  --red-soft: #f5e2df;
  --shadow: 0 24px 70px rgba(22, 35, 28, 0.09);
  --shadow-soft: 0 12px 32px rgba(22, 35, 28, 0.07);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(17, 93, 79, 0.08), transparent 24rem),
    var(--paper);
}

button, textarea, input { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, a:focus-visible, .lead-card:focus-visible { outline: 3px solid rgba(49, 95, 156, 0.32); outline-offset: 3px; }

.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; }

.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: 0 22px 54px; }

.topbar {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; width: max-content; color: inherit; text-decoration: none; }
.brand > span:last-child { display: flex; align-items: baseline; gap: 7px; }
.brand strong { font-size: 1.04rem; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
.brand-mark { position: relative; width: 30px; height: 30px; display: block; }
.brand-mark i { position: absolute; display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--forest); }
.brand-mark i:nth-child(1) { left: 1px; top: 11px; }
.brand-mark i:nth-child(2) { right: 1px; top: 3px; background: var(--blue); }
.brand-mark i:nth-child(3) { right: 3px; bottom: 1px; background: #83aa8d; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; height: 1px; background: var(--line-strong); transform-origin: left center; }
.brand-mark::before { width: 20px; left: 7px; top: 14px; transform: rotate(-24deg); }
.brand-mark::after { width: 18px; left: 8px; top: 16px; transform: rotate(24deg); }

.primary-nav { display: flex; align-items: center; gap: 5px; padding: 5px; background: rgba(255,255,255,0.48); border: 1px solid var(--line); border-radius: 999px; }
.nav-item { min-height: 38px; padding: 8px 16px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 0.88rem; font-weight: 700; cursor: pointer; }
.nav-item.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 5px 14px rgba(22,35,28,0.08); }
.nav-count { display: inline-grid; place-items: center; min-width: 20px; min-height: 20px; margin-left: 4px; padding: 0 5px; border-radius: 99px; color: var(--forest-deep); background: var(--forest-soft); font-size: 0.74rem; }

.account-area { justify-self: end; display: flex; align-items: center; gap: 10px; }
.account-area { position: relative; }
.source-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 650; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3e9b72; box-shadow: 0 0 0 4px rgba(62,155,114,0.12); }
.avatar-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); font-size: 0.75rem; font-weight: 800; cursor: pointer; }
.account-menu { position: absolute; z-index: 1600; top: 48px; right: 0; width: 240px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.account-menu strong, .account-menu span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu span { margin-top: 4px; color: var(--muted); font-size: 0.8rem; }
.account-menu button { width: 100%; margin-top: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); font-weight: 750; cursor: pointer; }

.screen { animation: fade-in 0.24s ease; }
.discover-screen { padding-top: 66px; }
.search-hero { max-width: 920px; margin: 0 auto; text-align: center; }
.eyebrow, .panel-label { margin: 0 0 10px; color: var(--forest); font-size: 0.72rem; line-height: 1.2; font-weight: 800; text-transform: uppercase; letter-spacing: 0.14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 16px; font-size: clamp(2.6rem, 6vw, 5.2rem); line-height: 0.96; letter-spacing: -0.055em; font-weight: 650; }
.hero-copy { max-width: 650px; margin: 0 auto; color: var(--muted); font-size: 1.04rem; line-height: 1.7; }

.prompt-box { margin-top: 34px; padding: 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); text-align: left; }
.prompt-box textarea { display: block; width: 100%; min-height: 82px; max-height: 180px; padding: 6px 7px 12px; resize: vertical; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: clamp(1.08rem, 2vw, 1.34rem); line-height: 1.5; }
.prompt-box textarea::placeholder { color: #8b948f; }
.prompt-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; padding-top: 13px; border-top: 1px solid var(--line); }
.search-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; gap: 15px; min-height: 46px; padding: 11px 18px; border-radius: 999px; font-weight: 750; cursor: pointer; }
.search-button { border: 0; background: var(--forest); color: #fff; box-shadow: 0 10px 24px rgba(17,93,79,0.22); }
.search-button:hover { background: var(--forest-deep); }
.search-button b { font-size: 1.2rem; font-weight: 400; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.secondary-button.compact { min-height: 38px; padding: 7px 14px; font-size: 0.84rem; }

.suggestion-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 0.82rem; }
.suggestion-row button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.56); color: var(--ink); cursor: pointer; }
.suggestion-row button:hover { background: var(--surface); }
.search-status { min-height: 22px; margin: 13px 0 0; color: var(--muted); font-size: 0.82rem; }
.search-status.is-error { color: var(--red); }
.search-status.is-success { color: var(--forest); }
.recent-searches { margin-top: 46px; text-align: left; }
.recent-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.recent-heading h2 { margin: 0; font-size: 0.9rem; letter-spacing: -0.01em; }
.recent-heading span { color: var(--muted); font-size: 0.75rem; }
.recent-search-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.recent-search-button { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.58); text-align: left; cursor: pointer; }
.recent-search-button:hover { background: var(--surface); }
.recent-search-button strong, .recent-search-button span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-search-button strong { font-size: 0.82rem; }
.recent-search-button span { margin-top: 5px; color: var(--muted); font-size: 0.7rem; }

.results-workspace { margin-top: 76px; scroll-margin-top: 20px; }
.results-heading, .result-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.results-heading h2 { margin-bottom: 8px; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; letter-spacing: -0.035em; }
.result-disclosure { margin-bottom: 0; color: var(--muted); font-size: 0.9rem; }
.result-disclosure strong { color: var(--ink); }
.result-toolbar { align-items: center; margin-top: 22px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,0.52); }
.view-switch { display: flex; gap: 3px; }
.view-button { min-width: 72px; padding: 8px 13px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 0.84rem; font-weight: 750; cursor: pointer; }
.view-button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 5px 14px rgba(22,35,28,0.07); }
.toolbar-meta { display: flex; align-items: center; gap: 15px; color: var(--muted); font-size: 0.82rem; font-weight: 650; }
.filter-panel { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.62); }
.filter-panel > span { margin-right: 3px; color: var(--muted); font-size: 0.75rem; font-weight: 750; }
.filter-chip { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.74rem; font-weight: 750; cursor: pointer; }
.filter-chip.is-active { border-color: var(--forest); background: var(--forest-soft); color: var(--forest-deep); }

.workspace-grid { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.summary-panel, .result-canvas { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-soft); }
.summary-panel { padding: 20px; }
.metric-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.metric-row article { min-width: 0; }
.metric-row strong { display: block; font-size: 1.45rem; letter-spacing: -0.04em; }
.metric-row span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.68rem; }
.active-search, .selected-preview { padding-top: 20px; }
.criteria-list { display: flex; flex-wrap: wrap; gap: 6px; }
.criteria-list span { padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); border: 1px solid var(--line); font-size: 0.76rem; font-weight: 650; }
.selected-preview { margin-top: 20px; border-top: 1px solid var(--line); }
.selected-preview strong { font-size: 0.96rem; }
.selected-preview p { margin: 4px 0 11px; color: var(--muted); font-size: 0.82rem; }
.selected-preview button { padding: 0; border: 0; background: transparent; color: var(--forest); font-size: 0.8rem; font-weight: 800; cursor: pointer; }
.source-note { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.72rem; line-height: 1.5; }

.result-canvas { min-height: 600px; overflow: hidden; }
.view-panel { display: none; height: 100%; }
.view-panel.is-active { display: block; }
#map-view { position: relative; min-height: 600px; }
#lead-map { height: 600px; background: #e9ede6; }
.map-legend { position: absolute; z-index: 500; left: 18px; bottom: 18px; display: flex; flex-wrap: wrap; gap: 13px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,0.92); box-shadow: var(--shadow-soft); color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.marker-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.marker-dot.interested { background: var(--forest); }
.marker-dot.later { background: var(--amber); }
.leaflet-control-zoom a { color: var(--ink) !important; }
.lead-map-marker { width: 29px !important; height: 29px !important; margin-left: -14px !important; margin-top: -14px !important; display: grid !important; place-items: center; border: 3px solid #fff; border-radius: 50% 50% 50% 16%; transform: rotate(-45deg); background: var(--blue); box-shadow: 0 5px 13px rgba(20,34,28,0.25); }
.lead-map-marker span { width: 7px; height: 7px; border-radius: 50%; background: #fff; }
.lead-map-marker.interested { background: var(--forest); }
.lead-map-marker.later { background: var(--amber); }
.lead-map-marker.rejected { background: #8b938f; opacity: 0.72; }

.card-stage { width: min(610px, 100%); margin: 0 auto; padding: 26px 22px 30px; }
.swipe-hint { display: flex; justify-content: space-between; gap: 12px; margin: 0 4px 13px; color: var(--muted); font-size: 0.72rem; }
.lead-card { --card-x: 0px; --card-rotation: 0deg; min-height: 455px; padding: 25px; border: 1px solid var(--line); border-radius: 25px; background: var(--surface); box-shadow: 0 18px 45px rgba(22,35,28,0.1); touch-action: pan-y; user-select: none; cursor: grab; transform: translate3d(var(--card-x), 0, 0) rotate(var(--card-rotation)); transform-origin: 50% 92%; will-change: transform; transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease; }
.lead-card::before { content: attr(data-swipe-label); position: absolute; z-index: 3; top: 28px; left: 28px; padding: 8px 12px; border: 2px solid currentColor; border-radius: 9px; color: var(--forest); background: rgba(255,255,255,0.9); font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; opacity: var(--swipe-opacity, 0); pointer-events: none; transform: rotate(-7deg); }
.lead-card { position: relative; }
.lead-card.is-dragging { cursor: grabbing; transition: none; }
.lead-card.is-leaving-right { --card-x: 115%; --card-rotation: 9deg; opacity: 0; pointer-events: none; }
.lead-card.is-leaving-left { --card-x: -115%; --card-rotation: -9deg; opacity: 0; pointer-events: none; }
.lead-card.is-leaving-up { transform: translateY(-80%) scale(0.94); opacity: 0; }
.lead-card-head { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.lead-category { margin: 0 0 8px; color: var(--forest); font-size: 0.7rem; font-weight: 850; text-transform: uppercase; letter-spacing: 0.12em; }
.lead-card h3 { margin-bottom: 6px; font-size: clamp(1.5rem, 4vw, 2.15rem); line-height: 1.08; letter-spacing: -0.035em; }
.lead-location { color: var(--muted); font-size: 0.88rem; }
.match-score { flex: 0 0 auto; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--forest-soft); color: var(--forest-deep); font-weight: 850; }
.contact-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 20px 0; }
.contact-chips span, .contact-chips a { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); color: var(--ink); text-decoration: none; font-size: 0.75rem; font-weight: 700; }
.reason-box { margin-top: 18px; padding: 17px; border-radius: 17px; background: var(--surface-soft); }
.reason-box h4 { margin: 0 0 10px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.reason-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.reason-list li { position: relative; padding-left: 19px; color: var(--muted); font-size: 0.87rem; line-height: 1.45; }
.reason-list li::before { content: ""; position: absolute; left: 0; top: 0.48em; width: 7px; height: 7px; border-radius: 50%; background: #72a383; }
.evidence-row { display: flex; justify-content: space-between; gap: 14px; margin-top: 19px; color: var(--muted); font-size: 0.76rem; }
.evidence-row a { color: var(--forest); font-weight: 750; text-decoration: none; }
.decision-row { display: flex; justify-content: center; align-items: center; gap: 22px; margin-top: 22px; }
.decision-button { display: grid; justify-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.decision-button span { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); box-shadow: 0 8px 18px rgba(22,35,28,0.08); font-size: 1.4rem; }
.decision-button small { font-size: 0.68rem; font-weight: 750; }
.decision-button.reject:hover span { color: var(--red); background: var(--red-soft); }
.decision-button.later:hover span { color: var(--amber); background: var(--amber-soft); }
.decision-button.interested:hover span { color: var(--forest); background: var(--forest-soft); }

.list-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 18px; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.84rem; }
th { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; }
td strong { display: block; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.status-badge { display: inline-flex; padding: 6px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 0.72rem; font-weight: 800; text-transform: capitalize; }
.status-badge.interested { background: var(--forest-soft); color: var(--forest); }
.status-badge.later { background: var(--amber-soft); color: var(--amber); }
.status-badge.rejected { background: var(--red-soft); color: var(--red); }
.row-action { border: 0; background: transparent; color: var(--forest); font-weight: 800; cursor: pointer; }

.shortlist-screen { padding: 70px 0; }
.page-heading { max-width: 680px; }
.page-heading h1 { font-size: clamp(2.5rem, 5vw, 4.5rem); }
.page-heading > p:last-child { color: var(--muted); line-height: 1.65; }
.shortlist-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-top: 36px; }
.shortlist-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-soft); }
.shortlist-card h3 { margin-bottom: 6px; }
.shortlist-card p { color: var(--muted); font-size: 0.85rem; }
.shortlist-card footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.shortlist-card a, .shortlist-card button { border: 0; background: transparent; color: var(--forest); text-decoration: none; font-weight: 800; cursor: pointer; }
.empty-state { max-width: 560px; margin: 55px auto 0; padding: 48px 25px; border: 1px dashed var(--line-strong); border-radius: var(--radius-xl); text-align: center; }
.empty-state > span { display: inline-grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--forest-soft); color: var(--forest); font-size: 1.6rem; }
.empty-state h2 { margin: 16px 0 7px; }
.empty-state p { margin-bottom: 20px; color: var(--muted); }

.toast { position: fixed; z-index: 2000; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 13px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 0.84rem; opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.loading-overlay { position: fixed; z-index: 2500; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(245,244,238,0.8); backdrop-filter: blur(8px); }
.loading-card { width: min(390px, 100%); padding: 34px 28px; border: 1px solid var(--line); border-radius: 25px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.loading-card strong { display: block; margin-top: 18px; font-size: 1.1rem; }
.loading-card p { margin: 8px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.loading-orbit { position: relative; display: inline-block; width: 42px; height: 42px; border: 2px solid var(--forest-soft); border-radius: 50%; }
.loading-orbit::after { content: ""; position: absolute; width: 9px; height: 9px; top: -4px; left: 15px; border-radius: 50%; background: var(--forest); animation: orbit 1s linear infinite; transform-origin: 5px 25px; }

@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .primary-nav { position: fixed; z-index: 1200; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(255,255,255,0.94); box-shadow: var(--shadow-soft); }
  .source-pill { display: none; }
  .discover-screen { padding-top: 45px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .summary-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
  .metric-row { grid-column: 1 / -1; }
  .selected-preview { margin-top: 0; padding-top: 0; border-top: 0; }
  .source-note { grid-column: 1 / -1; margin-top: 0; }
  .shortlist-grid { grid-template-columns: repeat(2, 1fr); }
  .recent-search-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .app-shell { padding: 0 12px 90px; }
  .topbar { min-height: 66px; }
  .brand small { display: none; }
  .discover-screen { padding-top: 34px; }
  h1 { font-size: clamp(2.55rem, 15vw, 4.2rem); }
  .hero-copy { font-size: 0.94rem; }
  .prompt-box { margin-top: 25px; padding: 13px; border-radius: 20px; }
  .prompt-actions { align-items: stretch; }
  .search-button { padding: 10px 15px; }
  .suggestion-row { justify-content: flex-start; }
  .results-workspace { margin-top: 58px; }
  .results-heading { align-items: start; }
  .results-heading .secondary-button { flex: 0 0 auto; font-size: 0.78rem; }
  .result-toolbar { align-items: stretch; flex-direction: column; }
  .view-switch { display: grid; grid-template-columns: repeat(3, 1fr); }
  .toolbar-meta { justify-content: space-between; }
  .summary-panel { display: block; }
  .active-search, .selected-preview { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
  #map-view, #lead-map, .result-canvas { min-height: 520px; }
  #lead-map { height: 520px; }
  .map-legend { right: 12px; left: 12px; bottom: 12px; border-radius: 14px; }
  .card-stage { padding: 16px 10px 24px; }
  .swipe-hint span:nth-child(2) { display: none; }
  .lead-card { min-height: 440px; padding: 20px; }
  .match-score { width: 52px; height: 52px; }
  .decision-row { gap: 16px; }
  .shortlist-grid { grid-template-columns: 1fr; }
  .recent-search-list { grid-template-columns: 1fr; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
