:root {
  --bg: #f3f2ee;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --text: #122018;
  --muted: #68736c;
  --border: #dedbd4;
  --green: #003f2f;
  --green-2: #0b5a42;
  --gold: #e5ad16;
  --red: #dc342b;
  --gray-pin: #9da19e;
  --chip-green: #dff1e5;
  --chip-gold: #fff2cf;
  --chip-red: #ffe3df;
  --shadow: 0 2px 10px rgba(20, 32, 26, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body {
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.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-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  color: #fff;
  background: linear-gradient(90deg, #003321 0%, #004632 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 3px 12px rgba(0, 30, 20, 0.18);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-left {
  min-width: 0;
}

.icon-button {
  width: 54px;
  height: 60px;
  color: #fff;
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 156px;
}

.brand-leaf {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  color: var(--green);
  background: var(--gold);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.brand-name {
  display: grid;
  line-height: 0.95;
  letter-spacing: 1px;
}

.brand-name strong {
  font-size: 18px;
}

.brand-name span {
  font-size: 15px;
}

.top-nav {
  display: flex;
  height: 60px;
}

.top-nav a {
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  border-bottom: 3px solid transparent;
}

.top-nav a.active {
  color: #ffd45a;
  border-bottom-color: var(--gold);
}

.global-search {
  width: min(360px, 32vw);
}

.global-search input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.23);
  border-radius: 7px;
}

.global-search input::placeholder {
  color: rgba(255, 255, 255, 0.72);
}

.user-chip {
  display: grid;
  gap: 1px;
  padding-right: 22px;
  line-height: 1.15;
}

.user-chip strong {
  font-size: 13px;
}

.user-chip span {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 238px minmax(640px, 1fr) 366px;
  gap: 8px;
  min-height: calc(100vh - 60px);
  padding: 14px;
}

.filter-rail,
.workspace,
.insight-rail {
  min-width: 0;
}

.filter-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rail-heading,
.section-heading,
.rail-section-heading,
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rail-heading h2,
.section-heading h2,
.rail-section-heading h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.rail-heading button,
.rail-section-heading button {
  color: var(--green);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  color: #39423d;
  font-size: 12px;
  font-weight: 800;
}

select,
.global-search input,
.filter-rail input[type="search"] {
  min-width: 0;
}

select,
.filter-rail input[type="search"] {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  color: #26342c;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.range-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

input[type="range"] {
  width: 100%;
}

.range-value {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.toggle-row input {
  width: 34px;
  height: 18px;
}

.button {
  min-height: 34px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.button.primary {
  color: #fff;
  background: linear-gradient(180deg, #00543e, #003d2c);
  border: 1px solid #003523;
  box-shadow: var(--shadow);
}

.button.secondary {
  color: var(--green);
  background: #fff;
  border: 1px solid var(--green);
}

.button.export {
  width: fit-content;
  min-width: 78px;
  color: #fff;
  background: var(--green-2);
  border: 0;
}

.filter-summary-panel {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.filter-summary-panel h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
}

.filter-summary {
  display: grid;
  gap: 8px;
}

.filter-token {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 0 10px;
  color: #4d5751;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
}

.filter-token b {
  color: var(--text);
}

.rail-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.import-block {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.import-block input {
  max-width: 100%;
  font-size: 12px;
}

.import-block p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  gap: 14px;
  align-content: start;
}

.map-panel,
.leads-panel,
.insight-rail section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-panel,
.leads-panel {
  padding: 14px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 13px;
  color: #47534c;
  font-size: 12px;
  font-weight: 700;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.active-dot {
  background: var(--green-2);
}

.contacted-dot {
  background: var(--gold);
}

.removed-dot {
  background: var(--red);
}

.low-dot {
  background: var(--gray-pin);
}

.map-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.map-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.map-notice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.lead-map {
  position: relative;
  min-height: 348px;
  margin-top: 13px;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 72%, rgba(60, 110, 88, 0.16), transparent 20%),
    radial-gradient(circle at 72% 34%, rgba(54, 98, 78, 0.13), transparent 28%),
    linear-gradient(32deg, transparent 0 48%, rgba(222, 164, 42, 0.5) 48% 49%, transparent 49%),
    linear-gradient(128deg, transparent 0 58%, rgba(222, 164, 42, 0.42) 58% 59%, transparent 59%),
    #e8eee6;
  border: 1px solid #d5dbd3;
  border-radius: 4px;
}

.map-grid-overlay {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 63, 47, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 63, 47, 0.06) 1px, transparent 1px);
  background-size: 8.33% 16.66%;
  pointer-events: none;
}

.map-city-label {
  position: absolute;
  z-index: 1;
  padding: 3px 7px;
  color: #132119;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(0, 63, 47, 0.12);
  border-radius: 5px;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 0 #fff;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.map-marker {
  position: absolute;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #fff;
  background: var(--green-2);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 10px;
  font-weight: 900;
}

.map-marker span {
  transform: rotate(45deg);
}

.map-marker.high {
  background: var(--green);
}

.map-marker.medium,
.map-marker.contacted,
.map-marker.waiting-response {
  background: var(--gold);
}

.map-marker.low {
  background: var(--gray-pin);
}

.map-marker.removed {
  background: var(--red);
}

.map-marker:focus-visible {
  outline: 3px solid #1f78ff;
  outline-offset: 3px;
}

.map-meta {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 3;
  padding: 5px 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 63, 47, 0.1);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.small-muted {
  color: var(--muted);
  font-size: 12px;
}

.table-heading {
  align-items: flex-start;
  margin-bottom: 12px;
}

.table-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.table-actions label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.lead-table-wrap {
  overflow-x: auto;
}

.lead-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.lead-table th,
.lead-table td {
  padding: 12px 10px;
  border-bottom: 1px solid #ece8e1;
  text-align: left;
  vertical-align: middle;
}

.lead-table th {
  color: #4d5851;
  font-size: 11px;
  font-weight: 800;
}

.lead-table td {
  font-size: 12px;
}

.lead-table tbody tr:hover {
  background: #fbfaf7;
}

.property-cell {
  display: grid;
  gap: 2px;
}

.property-cell strong {
  color: var(--green);
  font-size: 13px;
}

.property-cell span {
  color: var(--muted);
  font-size: 11px;
}

.score-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--green);
  background: #eff7ed;
  border: 1px solid #acd8a6;
  border-radius: 50%;
  font-weight: 900;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.active,
.tag.new {
  color: #0b5a2f;
  background: var(--chip-green);
}

.tag.contacted,
.tag.waiting-response {
  color: #8a5900;
  background: var(--chip-gold);
  border: 1px solid #f1cd72;
}

.tag.dead-lead,
.tag.not-a-fit {
  color: var(--red);
  background: var(--chip-red);
  border: 1px solid #ffaca6;
}

.tag.high {
  color: #d91616;
  background: #fff0ee;
  border: 1px solid #ffb7b2;
}

.tag.medium {
  color: #8a5900;
  background: var(--chip-gold);
  border: 1px solid #f1cd72;
}

.tag.low {
  color: #45524b;
  background: #ecefed;
  border: 1px solid #d4dad6;
}

.empty-state {
  display: none;
  padding: 22px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty-state.visible {
  display: block;
}

.table-footer {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.pager {
  display: flex;
  gap: 6px;
}

.pager button {
  min-width: 28px;
  height: 28px;
  color: var(--green);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-weight: 900;
}

.pager button.active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-action {
  min-height: 26px;
  padding: 0 9px;
  color: var(--green);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
}

.table-action.primary-action {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.table-action.warning-action {
  color: #7a5100;
  background: var(--chip-gold);
  border-color: #efc45a;
}

.table-action.disabled {
  color: #828a85;
  background: #eeeeeb;
  cursor: not-allowed;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 25, 17, 0.34);
}

.drawer-backdrop[hidden] {
  display: none;
}

.property-drawer {
  width: min(460px, 100vw);
  height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 44px rgba(0, 25, 17, 0.18);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  color: #fff;
  background: var(--green);
}

.drawer-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.drawer-header p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.drawer-header button {
  align-self: start;
  min-height: 30px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 900;
}

.drawer-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.drawer-content section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-content h3 {
  margin: 0 0 8px;
  color: #334139;
  font-size: 12px;
  text-transform: uppercase;
}

.drawer-content p {
  margin: 0;
  color: #24332b;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.detail-link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-link-list a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: #fff;
  background: var(--green);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.detail-link-list.secondary-links a {
  color: var(--green);
  background: var(--chip-gold);
  border: 1px solid #efc45a;
}

.drawer-muted {
  color: var(--muted);
}

.insight-rail {
  display: grid;
  align-content: start;
  gap: 10px;
}

.insight-rail section {
  padding: 14px;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.compact-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.compact-item strong {
  color: var(--green);
  font-size: 12px;
  line-height: 1.25;
}

.compact-item .meta {
  color: var(--muted);
  font-size: 11px;
}

.ranked-list .compact-item {
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
}

.ranked-list .compact-item > .meta {
  grid-column: 2;
  overflow-wrap: anywhere;
}

.rank {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #fff;
  background: var(--green);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
}

.price-delta.up {
  color: #008d45;
  font-weight: 900;
}

.price-delta.down {
  color: var(--red);
  font-weight: 900;
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 238px minmax(0, 1fr);
  }

  .insight-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-search {
    width: 280px;
  }
}

@media (max-width: 860px) {
  .app-topbar {
    position: static;
    display: grid;
    gap: 10px;
    padding: 10px 14px;
    overflow: hidden;
  }

  .icon-button,
  .top-nav,
  .user-chip {
    display: none;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  .global-search {
    min-width: 0;
    width: 100%;
  }

  .app-shell {
    display: block;
    padding: 10px;
  }

  .filter-rail,
  .workspace,
  .insight-rail {
    min-width: 0;
    margin-bottom: 10px;
  }

  .lead-table-wrap {
    max-width: 100%;
  }

  .lead-map {
    min-height: 280px;
  }

  .insight-rail {
    grid-template-columns: 1fr;
  }
}
