:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #18221d;
  background: #e8ede9;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

.map-stage,
#map {
  position: absolute;
  inset: 0;
}

.control-panel {
  position: absolute;
  z-index: 10;
  top: 18px;
  left: 18px;
  width: min(350px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 22px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 22px;
  background: rgba(249, 251, 249, 0.94);
  box-shadow: 0 24px 70px rgba(25, 46, 34, 0.18);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #397a58;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 4vw, 2.1rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
}

.status-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 6px;
  border: 2px solid #f8faf8;
  border-radius: 50%;
  background: #3aa76d;
  box-shadow: 0 0 0 4px rgba(58, 167, 109, 0.16);
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mobile-panel-toggle {
  display: none;
}

.intro {
  margin: 14px 0 17px;
  color: #617068;
  font-size: 0.88rem;
  line-height: 1.45;
}

.summary-card {
  display: grid;
  gap: 3px;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid #d9e6dd;
  border-radius: 14px;
  background: #edf6f0;
}

#summary-count {
  color: #174f32;
  font-size: 1rem;
  font-weight: 800;
}

#summary-detail {
  color: #62806e;
  font-size: 0.75rem;
}

.field-group {
  display: grid;
  gap: 6px;
  margin-bottom: 13px;
}

.field-group label {
  color: #53625a;
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.025em;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  fill: none;
  stroke: #6e7d74;
  stroke-linecap: round;
  stroke-width: 1.8;
}

input[type="search"],
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d8dfda;
  border-radius: 11px;
  outline: none;
  background: #fff;
  color: #26332c;
  font-size: 0.84rem;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

input[type="search"] {
  padding: 9px 12px 9px 38px;
}

select {
  padding: 8px 30px 8px 11px;
}

input[type="search"]:focus,
select:focus {
  border-color: #4b9b6e;
  box-shadow: 0 0 0 3px rgba(75, 155, 110, 0.14);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 10px;
}

.location-card {
  margin: 1px 0 14px;
  padding: 11px;
  border: 1px solid #d7e3db;
  border-radius: 13px;
  background: #f2f7f3;
}

.location-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  gap: 9px;
}

.location-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 39px;
  padding: 7px 11px;
  border: 1px solid #347b55;
  border-radius: 10px;
  background: #ffffff;
  color: #236443;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.location-button:hover {
  background: #e9f3ec;
}

.location-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.location-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
}

.radius-field {
  display: grid;
  gap: 4px;
  color: #53625a;
  font-size: 0.68rem;
  font-weight: 750;
}

.radius-field select {
  width: 100%;
  min-height: 39px;
}

.radius-field select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.location-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
}

.location-meta p {
  margin: 0;
  color: #6d7e73;
  font-size: 0.69rem;
  line-height: 1.35;
}

.location-meta button {
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #286b48;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.user-location-dot {
  position: relative;
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #2878e3;
  box-shadow: 0 2px 9px rgba(22, 70, 137, 0.35);
}

.user-location-dot::before {
  position: absolute;
  z-index: -1;
  inset: -10px;
  border-radius: 50%;
  background: rgba(40, 120, 227, 0.2);
  content: "";
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 0 16px;
  color: #445149;
  cursor: pointer;
  font-size: 0.81rem;
}

.checkbox-row input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #27774e;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.button-row button {
  min-height: 41px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 750;
  transition:
    transform 120ms ease,
    background 120ms ease;
}

.button-row button:active {
  transform: translateY(1px);
}

.primary-button {
  border: 1px solid #226a45;
  background: #226a45;
  color: #fff;
}

.primary-button:hover {
  background: #185839;
}

.secondary-button {
  border: 1px solid #d5ddd7;
  background: #fff;
  color: #435047;
}

.secondary-button:hover {
  background: #f0f4f1;
}

.panel-note {
  margin: 14px 0 0;
  color: #7d8a82;
  font-size: 0.71rem;
  line-height: 1.4;
}

.loading-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  background: rgba(234, 239, 235, 0.9);
  color: #3c4b42;
  font-size: 0.88rem;
  font-weight: 700;
  transition: opacity 180ms ease;
}

.loading-overlay.is-hidden {
  pointer-events: none;
  opacity: 0;
}

.loader {
  width: 21px;
  height: 21px;
  border: 3px solid #bbcec0;
  border-top-color: #27774e;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-banner {
  position: absolute;
  z-index: 20;
  right: 18px;
  bottom: 24px;
  max-width: 410px;
  padding: 13px 16px;
  border: 1px solid #d98c82;
  border-radius: 12px;
  background: #fff2f0;
  box-shadow: 0 12px 35px rgba(83, 26, 21, 0.14);
  color: #812f27;
  font-size: 0.82rem;
}

.maplibregl-ctrl-top-right {
  top: 12px;
  right: 12px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid rgba(35, 64, 47, 0.12);
  border-radius: 11px !important;
  box-shadow: 0 8px 25px rgba(27, 52, 37, 0.14) !important;
}

.maplibregl-popup-content {
  width: min(360px, calc(100vw - 40px));
  max-height: min(520px, calc(100vh - 80px));
  padding: 0 !important;
  overflow: hidden;
  border-radius: 16px !important;
  box-shadow: 0 18px 50px rgba(22, 40, 29, 0.22) !important;
}

.maplibregl-popup-close-button {
  z-index: 2;
  top: 7px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #4a5b50;
  font-size: 1.2rem;
}

.maplibregl-popup-close-button:hover {
  background: #eaf1ec;
}

.popup-shell {
  max-height: min(520px, calc(100vh - 80px));
  overflow-y: auto;
}

.popup-heading {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 15px 44px 13px 16px;
  border-bottom: 1px solid #e2e9e4;
  background: rgba(247, 250, 248, 0.97);
  backdrop-filter: blur(8px);
}

.popup-heading strong {
  display: block;
  color: #1e3327;
  font-size: 0.91rem;
}

.popup-heading span {
  color: #718078;
  font-size: 0.72rem;
}

.lead-card {
  padding: 15px 16px;
  border-bottom: 1px solid #e7ece8;
}

.lead-card:last-child {
  border-bottom: 0;
}

.lead-card h2 {
  margin: 0 0 5px;
  padding-right: 18px;
  color: #1d2d24;
  font-size: 1rem;
  line-height: 1.25;
}

.lead-category {
  margin: 0 0 11px;
  color: #32724e;
  font-size: 0.72rem;
  font-weight: 750;
}

.lead-detail {
  margin: 6px 0;
  color: #57655d;
  font-size: 0.78rem;
  line-height: 1.42;
}

.lead-detail strong {
  color: #34433a;
}

.lead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.lead-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 6px 10px;
  border: 1px solid #cfdcd3;
  border-radius: 9px;
  color: #256844;
  font-size: 0.72rem;
  font-weight: 750;
  text-decoration: none;
}

.lead-actions a:hover {
  background: #eff6f1;
}

@media (max-width: 700px) {
  .control-panel {
    top: auto;
    bottom: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    max-height: min(68dvh, 590px);
    padding: 16px;
    overflow-x: hidden;
    border-radius: 17px;
    transition:
      max-height 220ms ease,
      padding 220ms ease;
  }

  .intro,
  .panel-note {
    display: none;
  }

  .brand-row {
    align-items: center;
  }

  .brand-row > div:first-child,
  .filter-grid > .field-group {
    min-width: 0;
  }

  .location-card {
    margin-bottom: 11px;
  }

  .location-button {
    min-width: 0;
    padding-inline: 8px;
    font-size: 0.74rem;
  }

  h1 {
    font-size: clamp(1.35rem, 7vw, 1.75rem);
    white-space: nowrap;
  }

  .brand-actions {
    flex-direction: row-reverse;
  }

  .brand-actions .status-dot {
    display: none;
  }

  .mobile-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid #cfdad2;
    border-radius: 10px;
    background: #ffffff;
    color: #315a42;
    cursor: pointer;
    font-size: 0.74rem;
    font-weight: 800;
  }

  .summary-card {
    margin: 12px 0;
    padding: 10px 12px;
  }

  .filter-controls {
    padding-bottom: max(2px, env(safe-area-inset-bottom));
  }

  .control-panel.is-collapsed {
    max-height: 132px;
    overflow: hidden;
  }

  .control-panel.is-collapsed .filter-controls {
    display: none;
  }

  .maplibregl-ctrl-top-right {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    bottom: auto;
  }

  .maplibregl-ctrl-bottom-right {
    right: 8px;
    bottom: 142px;
    max-width: calc(100vw - 16px);
  }

  .maplibregl-popup.lead-popup {
    position: absolute;
    z-index: 30;
    inset: auto 10px max(10px, env(safe-area-inset-bottom)) 10px !important;
    width: auto;
    max-width: none !important;
    transform: none !important;
  }

  .lead-popup .maplibregl-popup-tip {
    display: none;
  }

  .lead-popup .maplibregl-popup-content {
    width: 100%;
    max-height: min(58dvh, 520px);
    border: 1px solid rgba(42, 83, 58, 0.14);
    border-radius: 19px !important;
    box-shadow: 0 18px 55px rgba(17, 42, 27, 0.28) !important;
    animation: lead-sheet-in 190ms ease-out;
  }

  .lead-popup .popup-shell {
    max-height: min(58dvh, 520px);
    overscroll-behavior: contain;
  }

  .lead-popup .popup-heading {
    padding-top: 21px;
  }

  .lead-popup .popup-heading::before {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 38px;
    height: 4px;
    border-radius: 999px;
    background: #c6d2ca;
    content: "";
    transform: translateX(-50%);
  }

  .lead-popup .maplibregl-popup-close-button {
    top: 10px;
    right: 10px;
  }

  @keyframes lead-sheet-in {
    from {
      opacity: 0;
      transform: translateY(14px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

@media (max-width: 420px) {
  .control-panel {
    padding: 14px;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  h1 {
    font-size: 1.25rem;
  }

  .field-group {
    margin-bottom: 10px;
  }
}
