:root {
  --ink: #17324a;
  --muted: #5e7180;
  --blue: #0674a9;
  --blue-dark: #04587f;
  --blue-soft: #eaf6fb;
  --green: #4b8f37;
  --green-soft: #edf7e9;
  --red: #b33b32;
  --red-soft: #fff0ee;
  --gold: #bd7b14;
  --surface: #ffffff;
  --background: #f4f8fa;
  --border: #d8e3e8;
  --shadow: 0 12px 34px rgba(23, 50, 74, 0.09);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--background);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(6, 116, 169, 0.08), transparent 30rem),
    var(--background);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.hero,
.map-panel,
.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 5vw, 52px);
}

.hero::after {
  content: "";
  position: absolute;
  width: 290px;
  height: 290px;
  right: -125px;
  top: -145px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(6, 116, 169, 0.18), rgba(75, 143, 55, 0.12));
  pointer-events: none;
}

.hero-copy,
.search-form,
.candidate-box {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-dark);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.hero-text {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.58;
}

.search-form {
  max-width: 880px;
  margin-top: 30px;
}

.search-form > label {
  display: block;
  margin-bottom: 9px;
  font-weight: 800;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.search-row input,
.filter-field input {
  width: 100%;
  border: 1px solid #b8cbd5;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-row input {
  min-height: 56px;
  padding: 0 17px;
  font-size: 1.02rem;
}

.search-row input:focus,
.filter-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(6, 116, 169, 0.13);
}

.search-row button {
  min-width: 128px;
  min-height: 56px;
  padding: 0 24px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.search-row button:hover {
  background: var(--blue-dark);
}

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

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

.search-help,
.search-status {
  margin: 9px 0 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.search-help {
  color: var(--muted);
}

.search-status {
  min-height: 1.3em;
  font-weight: 700;
}

.search-status--error {
  color: var(--red);
}

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

.search-status--loading,
.search-status--info {
  color: var(--blue-dark);
}

.candidate-box {
  max-width: 880px;
  margin-top: 17px;
  padding: 16px;
  border: 1px solid #bcd7e4;
  border-radius: var(--radius-md);
  background: var(--blue-soft);
}

.candidate-title {
  margin: 0 0 10px;
  font-weight: 800;
}

.candidate-list {
  display: grid;
  gap: 8px;
}

.candidate-button {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #aacbd9;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.candidate-button:hover,
.candidate-button:focus-visible {
  border-color: var(--blue);
  background: #f7fcfe;
}

.summary-panel {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 14px;
  margin: 18px 0;
}

.summary-card {
  min-height: 148px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 50, 74, 0.06);
}

.summary-card--place {
  background: linear-gradient(135deg, #0a648f, #087cac);
  color: #fff;
  border-color: transparent;
}

.summary-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-card--place .summary-label {
  color: rgba(255, 255, 255, 0.78);
}

.place-name {
  display: block;
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  line-height: 1.25;
}

.metric-value {
  display: block;
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.metric-value.is-yes {
  color: var(--green);
}

.metric-value.is-no {
  color: var(--red);
}

.metric-detail {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.map-panel,
.content-section {
  margin-top: 18px;
  padding: clamp(18px, 3vw, 28px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

.map-status {
  flex: none;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #376b29;
  font-size: 0.83rem;
  font-weight: 800;
}

.map-status--error {
  background: var(--red-soft);
  color: var(--red);
}

.data-warning {
  margin: -3px 0 13px;
  padding: 10px 13px;
  border-radius: 9px;
  background: #fff7e7;
  color: #795313;
  font-size: 0.9rem;
  font-weight: 700;
}

#map {
  width: 100%;
  height: clamp(420px, 58vw, 620px);
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #e9f0f3;
  overflow: hidden;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

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

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--blue);
}

.legend-dot--nearby {
  background: var(--green);
}

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

.water-pin {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 6px;
  background: var(--blue);
  box-shadow: 0 5px 14px rgba(23, 50, 74, 0.32);
  transform: rotate(-45deg);
}

.water-pin svg {
  width: 21px;
  height: 21px;
  fill: #fff;
  transform: rotate(45deg);
}

.water-pin--nearby {
  background: var(--green);
}

.water-pin--search {
  background: var(--red);
  width: 38px;
  height: 38px;
}

.leaflet-popup-content-wrapper {
  border-radius: 11px;
}

.popup-content {
  min-width: 190px;
  line-height: 1.45;
}

.popup-content span {
  color: var(--muted);
}

.popup-content a {
  display: inline-block;
  margin-top: 6px;
  color: var(--blue-dark);
  font-weight: 800;
}

.location-list {
  display: grid;
  gap: 10px;
}

.location-list--full {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.location-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 94px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.location-card:hover {
  border-color: #abc9d6;
  box-shadow: 0 7px 20px rgba(23, 50, 74, 0.07);
}

.location-main {
  min-width: 0;
}

.location-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.location-title-row h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.location-number {
  display: grid;
  place-items: center;
  flex: none;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.distance-badge {
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #376b29;
  font-size: 0.78rem;
  font-weight: 900;
}

.location-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.location-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex: none;
}

.text-button,
.primary-link {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.text-button {
  border: 1px solid #b9ccd5;
  background: #fff;
  color: var(--blue-dark);
  cursor: pointer;
}

.primary-link {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.primary-link:hover,
.primary-link:focus-visible {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.filter-field {
  display: block;
  width: min(320px, 100%);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.filter-field span {
  display: block;
  margin-bottom: 5px;
}

.filter-field input {
  min-height: 42px;
  padding: 0 12px;
}

.empty-message {
  margin: 0;
  padding: 18px;
  border: 1px dashed #b9ccd5;
  border-radius: 11px;
  background: #f8fbfc;
  color: var(--muted);
  text-align: center;
}

.app-footer {
  padding: 18px 5px 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .summary-panel {
    grid-template-columns: 1fr 1fr;
  }

  .summary-card--place {
    grid-column: 1 / -1;
  }

  .location-list--full {
    grid-template-columns: 1fr;
  }

  .section-heading--list {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-field {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 9px;
  }

  .hero,
  .map-panel,
  .content-section {
    border-radius: 16px;
  }

  .hero {
    padding: 23px 18px;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .search-row button {
    width: 100%;
  }

  .summary-panel {
    grid-template-columns: 1fr;
  }

  .summary-card--place {
    grid-column: auto;
  }

  .section-heading,
  .section-heading--map {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  #map {
    height: 480px;
  }

  .location-card {
    align-items: stretch;
    flex-direction: column;
  }

  .location-actions {
    justify-content: stretch;
  }

  .text-button,
  .primary-link {
    flex: 1 1 140px;
    text-align: center;
  }
}

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


/* Identità visiva CCM e intestazione definitiva */
.brand-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 28px;
}
.brand-logo {
  display: block;
  width: min(310px, 52vw);
  max-height: 92px;
  object-fit: contain;
  object-position: left center;
}
.network-intro {
  max-width: 520px;
  margin: 0;
  color: var(--blue-dark);
  font-weight: 750;
  line-height: 1.35;
  text-align: right;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.network-title-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 820px;
}
.network-title-wrap h2 {
  flex: 1 1 560px;
  margin: 0;
}
.network-count-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
}
.municipality-card .location-meta {
  margin-top: 7px;
}
@media (max-width: 720px) {
  .brand-row {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 24px;
  }
  .brand-logo {
    width: min(330px, 100%);
    max-height: 84px;
  }
  .network-intro {
    max-width: none;
    text-align: left;
  }
}


.place-context {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.4;
}
