:root {
  --bg: #f4efe4;
  --panel: #fffdf8;
  --ink: #1f2a33;
  --ink-soft: #4f5f6d;
  --accent: #0b6e67;
  --accent-strong: #0a4f4b;
  --warm: #e09330;
  --border: #dfd3bf;
  --ok: #2f7d43;
  --off: #8a9aa5;
  --shadow: 0 16px 36px rgba(31, 42, 51, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 15% 15%, #f8f3e8 0%, var(--bg) 45%, #efe4cf 100%);
  position: relative;
}

.bg-shape {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(0.5px);
}

.bg-shape-a {
  width: 22rem;
  height: 22rem;
  background: linear-gradient(120deg, rgba(11, 110, 103, 0.28), rgba(255, 253, 248, 0.05));
  left: -5rem;
  top: -4rem;
}

.bg-shape-b {
  width: 28rem;
  height: 28rem;
  background: linear-gradient(120deg, rgba(224, 147, 48, 0.26), rgba(255, 253, 248, 0.1));
  right: -9rem;
  bottom: -10rem;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  animation: rise-in 320ms ease-out;
}

.app-layout {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: calc(100vh - 2rem);
}

.hero {
  margin-bottom: 0;
}

.eyebrow {
  margin: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 0.78rem;
}

.hero h1 {
  margin: 0.4rem 0 0.5rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
}

.hero p {
  margin: 0;
  color: var(--ink-soft);
}

.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 0;
}

#searchForm {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#searchForm label {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.postcode-row,
.radius-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.postcode-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 0.6rem;
  align-items: center;
}

#searchForm input[type="text"],
#searchForm input[type="number"],
#searchForm button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #cfc0a8;
  padding: 0.7rem 0.8rem;
  font-size: 0.98rem;
}

#searchForm input[type="text"]:focus,
#searchForm input[type="number"]:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(11, 110, 103, 0.2);
  outline-offset: 1px;
}

#searchForm button {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-color: transparent;
  cursor: pointer;
  font-weight: 600;
}

#searchForm button:disabled {
  opacity: 0.6;
  cursor: progress;
}

#radiusInput {
  accent-color: var(--accent);
  padding: 0;
  border: 0;
  height: 1.15rem;
}

.filters-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.2rem;
}

.filters-title {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.check-option input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.tradition-row {
  margin: 0;
  padding: 0;
  border: 0;
}

.tradition-row legend {
  padding: 0;
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.segment-control {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.segment-control input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment-control label {
  display: inline-block;
  border: 1px solid #cfc0a8;
  border-radius: 999px;
  padding: 0.36rem 0.7rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
  cursor: pointer;
  background: #fffdfa;
}

.segment-control input[type="radio"]:checked + label {
  border-color: #93c8b7;
  background: #e8f4ef;
  color: #154f43;
  font-weight: 600;
}

.status {
  margin: 0.65rem 0 0;
  min-height: 1.25rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.status.error {
  color: #9d2f2f;
}

.status.success {
  color: var(--ok);
}

.map-column {
  min-height: calc(100vh - 2rem);
}

.map {
  min-height: calc(100vh - 2rem);
  height: calc(100vh - 2rem);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-reset-control {
  margin: 10px 10px 0 0;
}

.map-reset-button {
  appearance: none;
  border: 1px solid rgba(31, 42, 51, 0.14);
  background: rgba(255, 253, 248, 0.96);
  color: #22303a;
  border-radius: 10px;
  padding: 0.48rem 0.7rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(31, 42, 51, 0.16);
}

.map-reset-button:hover {
  background: #fff;
}

.site-footer {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
  color: var(--ink-soft);
}

.site-footer p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
}

.site-footer p + p {
  margin-top: 0.35rem;
}

.site-footer a {
  color: #0c5a8a;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.results-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.results-panel h2 {
  margin: 0;
  padding: 1rem 1rem 0.7rem;
  border-bottom: 1px solid var(--border);
  font-family: "Source Serif 4", Georgia, serif;
}

.results-list {
  list-style: decimal;
  margin: 0;
  padding: 0.9rem 1.4rem 1.1rem;
  overflow-y: scroll;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
  scrollbar-color: #9fb0bc #eef2f4;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1 1 auto;
}

.results-list li {
  padding: 0.55rem 0.35rem 0.5rem;
  border-bottom: 1px dashed #d7cab4;
}

.result-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: #0c2c45;
  text-align: left;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.result-meta {
  font-size: 0.84rem;
  color: var(--ink-soft);
  margin-top: 0.2rem;
}

.popup h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  font-family: "Source Serif 4", Georgia, serif;
  line-height: 1.2;
}

.gm-style .popup {
  max-width: 340px;
  padding-top: 0;
}

.gm-style .gm-style-iw-c {
  border-radius: 12px !important;
  padding: 0 !important;
}

.gm-style .gm-style-iw-d {
  margin: 0 !important;
  padding: 0.15rem 0.8rem 0.65rem !important;
}

.gm-style .gm-style-iw-chr {
  margin: 0 !important;
  padding: 0.45rem 0.45rem 0.1rem 0.7rem !important;
  min-height: 0 !important;
}

.gm-style .gm-style-iw-tc::after {
  background: #fff;
}

.popup-header {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 300px;
}

.popup-header-title {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.15;
  color: #25323c;
  font-weight: 700;
}

.popup-header-subtitle {
  font-size: 0.82rem;
  line-height: 1.2;
  color: #5d6b77;
  font-weight: 600;
}

.gm-style .gm-style-iw-ch {
  font-family: "Source Serif 4", Georgia, serif !important;
  font-size: 1.08rem !important;
  font-weight: 700 !important;
  line-height: 1.15 !important;
  color: #25323c !important;
}

.leaflet-popup-content,
.gm-style .gm-style-iw-d {
  max-height: min(52vh, 360px);
  overflow-y: scroll;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
  scrollbar-color: #9fb0bc #eef2f4;
  padding-right: 0.2rem;
}

.gm-style .gm-style-iw-d > div {
  max-width: 100%;
}

.gm-style .gm-ui-hover-effect {
  top: 2px !important;
  right: 2px !important;
  width: 32px !important;
  height: 32px !important;
}

.gm-style .gm-ui-hover-effect > span {
  margin: 7px !important;
}

.results-list::-webkit-scrollbar,
.leaflet-popup-content::-webkit-scrollbar,
.gm-style .gm-style-iw-d::-webkit-scrollbar {
  width: 10px;
}

.results-list::-webkit-scrollbar-thumb,
.leaflet-popup-content::-webkit-scrollbar-thumb,
.gm-style .gm-style-iw-d::-webkit-scrollbar-thumb {
  background: #9fb0bc;
  border-radius: 999px;
  border: 2px solid #eef2f4;
}

.results-list::-webkit-scrollbar-track,
.leaflet-popup-content::-webkit-scrollbar-track,
.gm-style .gm-style-iw-d::-webkit-scrollbar-track {
  background: #eef2f4;
  border-radius: 999px;
}

.popup-row {
  margin: 0.34rem 0;
  font-size: 0.88rem;
  line-height: 1.3;
}

.popup-row strong {
  font-weight: 600;
  color: #22303a;
}

.popup-summary {
  color: var(--ink-soft);
  margin-top: 0.16rem;
  margin-bottom: 0.38rem;
  line-height: 1.28;
  font-size: 0.84rem;
}

.popup-inferred {
  margin: 0.42rem 0 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.popup-inferred summary {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-weight: 600;
  padding: 0;
}

.popup-inferred-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid #c9d3da;
  background: #f3f7f9;
  color: #4f6371;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.popup-inferred-body {
  margin-top: 0.24rem;
  padding-left: 0.05rem;
}

.popup-collapsible {
  margin: 0.38rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.popup-collapsible summary {
  cursor: pointer;
  color: #4f5f6d;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0;
}

.popup-collapsible summary strong {
  color: #22303a;
  font-weight: 600;
}

.popup-collapsible[open] summary {
  margin-bottom: 0.16rem;
}

.popup-website-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.38rem;
}

.popup-website-link {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.35rem;
  color: #0c5a8a;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.3;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.popup-website-icon {
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  max-width: 14px;
  max-height: 14px;
  flex: 0 0 14px;
  margin-top: 1px;
}

.popup-website-link:hover {
  text-decoration: underline;
}

.map-context-action {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 180px;
}

.map-context-copy {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.3;
}

.map-context-button {
  appearance: none;
  border: 1px solid #0b6e67;
  background: #0b6e67;
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}

.map-context-button:hover {
  background: #0a5a54;
  border-color: #0a5a54;
}

.service-list {
  margin: 0.22rem 0 0;
  padding-left: 1rem;
}

.service-list li {
  margin: 0.12rem 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.14rem;
  margin-bottom: 0.34rem;
}

.icon-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.04rem 0.02rem;
  border-radius: 999px;
  border: 0;
  font-size: 0.73rem;
  background: transparent;
  color: #2d5f54;
}

.icon-badge.level-med,
.icon-badge.level-high,
.icon-badge.active {
  color: #2a5f53;
}

.icon-badge.inactive {
  color: var(--off);
}

.icon-badge svg {
  width: 13px;
  height: 13px;
  display: block;
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .left-column {
    max-height: none;
    display: contents;
  }

  .map-column {
    min-height: 0;
    order: 3;
  }

  .hero {
    order: 1;
  }

  .controls {
    order: 2;
  }

  .results-panel {
    order: 4;
  }

  .map {
    min-height: 52vh;
    height: 52vh;
  }

  .site-footer {
    margin-top: 0.85rem;
  }
}

@media (max-width: 960px) {
  .postcode-controls {
    grid-template-columns: 1fr;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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