.asp-app {
  --asp-primary: #2ba0a3;
  --asp-primary-deep: #1f7f82;
  --asp-secondary: #65bc7b;
  --asp-accent: #3b404a;
  --asp-text: #24272d;
  --asp-muted: #6b7280;
  --asp-bg: #f4f7f7;
  --asp-surface: #ffffff;
  --asp-line: rgba(59, 64, 74, 0.08);
  --asp-shadow: 0 24px 60px rgba(36, 39, 45, 0.08);
  --asp-ease: cubic-bezier(0.32, 0.72, 0, 1);
  --asp-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --asp-font-display: "Montserrat", sans-serif;
  --asp-font-body: "Open Sans", sans-serif;
  box-sizing: border-box;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0;
  color: var(--asp-text);
  font-family: var(--asp-font-body);
}

.asp-app *,
.asp-app *::before,
.asp-app *::after {
  box-sizing: border-box;
}

.asp-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

.asp-eyebrow {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(43, 160, 163, 0.1);
  color: var(--asp-primary-deep);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.asp-brand h1,
.asp-brand h2 {
  margin: 0;
  font-family: var(--asp-font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--asp-accent);
}

.asp-brand p {
  margin: 0.7rem 0 0;
  max-width: 36rem;
  color: var(--asp-muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.asp-count {
  flex-shrink: 0;
  min-width: 7.5rem;
  padding: 1rem 1.15rem;
  border-radius: 1.25rem;
  background: var(--asp-surface);
  box-shadow: var(--asp-shadow);
  text-align: center;
  font-family: var(--asp-font-display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--asp-primary);
  line-height: 1;
  transition: transform 0.45s var(--asp-ease-out), box-shadow 0.45s var(--asp-ease);
}

.asp-count.is-pulse {
  transform: scale(1.05);
  box-shadow: 0 18px 40px rgba(43, 160, 163, 0.2);
}

.asp-count small {
  display: block;
  margin-top: 0.4rem;
  color: var(--asp-muted);
  font-family: var(--asp-font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.asp-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1.1rem;
  padding: 1rem;
  border: 1px solid var(--asp-line);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
}

.asp-field {
  display: grid;
  gap: 0.4rem;
}

.asp-field span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--asp-muted);
}

.asp-field input,
.asp-field select {
  width: 100%;
  height: 3rem;
  padding: 0 0.95rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  background: var(--asp-surface);
  color: var(--asp-text);
  font: inherit;
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px var(--asp-line);
  transition: box-shadow 0.35s var(--asp-ease), transform 0.35s var(--asp-ease);
}

.asp-field input:focus,
.asp-field select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(43, 160, 163, 0.45), 0 0 0 4px rgba(43, 160, 163, 0.12);
}

.asp-reset {
  height: 3rem;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--asp-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.35s var(--asp-ease), background 0.35s var(--asp-ease);
}

.asp-reset:hover {
  background: #2f333b;
}

.asp-reset:active {
  transform: scale(0.98);
}

.asp-results {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0 0.15rem 0.85rem;
  margin-bottom: 0.15rem;
  scrollbar-width: thin;
}

.asp-results[hidden] {
  display: none;
}

.asp-result-chip {
  flex: 0 0 auto;
  max-width: 220px;
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--asp-accent);
  box-shadow: inset 0 0 0 1px var(--asp-line);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.3s var(--asp-ease), color 0.3s var(--asp-ease);
}

.asp-result-chip:hover,
.asp-result-chip.is-active {
  background: var(--asp-primary);
  color: #fff;
  box-shadow: none;
}

.asp-stage-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
}

.asp-stage {
  position: relative;
  z-index: 1;
  overflow: hidden;
  min-height: min(78vh, 820px);
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(244, 247, 247, 0.92)),
    var(--asp-surface);
  box-shadow: var(--asp-shadow);
  border: 1px solid var(--asp-line);
}

/* Trap Leaflet pane z-indexes here — not on the whole stage (that buried the sheet). */
.asp-map-stack {
  position: relative;
  z-index: 1;
  isolation: isolate;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.asp-map {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: min(78vh, 820px);
  cursor: grab;
  touch-action: none;
}

.asp-map--google {
  cursor: default;
}

.asp-map--leaflet {
  cursor: default;
  background: #eef3f3;
}

.asp-map--leaflet .asp-muted-tiles {
  filter: saturate(0.55) contrast(0.92) brightness(1.04);
  opacity: 0.88;
}

.asp-leaflet-marker {
  background: transparent !important;
  border: 0 !important;
}

/* Keep Google error dialog from covering pins if billing fails mid-load */
.asp-map--google .gm-err-container,
.asp-map--google .dismissButton {
  display: none !important;
}

.asp-map--google .gm-style-cc,
.asp-map--google a[href^="https://maps.google.com/maps"] {
  opacity: 0.28 !important;
}

.asp-stage .asp-overlay,
.asp-stage-shell .asp-overlay {
  z-index: 1200;
}

.asp-zoom-controls {
  z-index: 1100;
}

.asp-map:active {
  cursor: grabbing;
}

.asp-region {
  fill: #d9ecec;
  stroke: #ffffff;
  stroke-width: 1.4;
  transition: fill 0.45s var(--asp-ease), opacity 0.45s var(--asp-ease);
  cursor: pointer;
}

.asp-region:hover,
.asp-region.is-hot {
  fill: #bfe0e1;
}

.asp-region.is-active {
  fill: #9fd3d5;
}

.asp-region.is-dim {
  opacity: 0.35;
}

/* No CSS transform on pins — conflicts with SVG pan/zoom and causes jitter. */
.asp-pin,
.asp-cluster {
  cursor: pointer;
}

.asp-pin-hit {
  fill: transparent;
  pointer-events: all;
}

.asp-pin-core {
  stroke: #fff;
  stroke-width: 2;
  pointer-events: none;
}

.asp-pin-halo {
  opacity: 0.22;
  pointer-events: none;
}

.asp-pin.is-active .asp-pin-core {
  stroke: var(--asp-accent);
  stroke-width: 3;
}

.asp-pin.is-active .asp-pin-halo {
  opacity: 0.35;
}

.asp-pin[data-category="Costruttori e Manutentori"] .asp-pin-core,
.asp-pin[data-category="Costruttori e Manutentori"] .asp-pin-halo {
  fill: var(--asp-primary);
}

.asp-pin[data-category="Distributori e Produttori"] .asp-pin-core,
.asp-pin[data-category="Distributori e Produttori"] .asp-pin-halo {
  fill: var(--asp-secondary);
}

.asp-pin[data-category="Progettisti e Consulenti"] .asp-pin-core,
.asp-pin[data-category="Progettisti e Consulenti"] .asp-pin-halo {
  fill: var(--asp-accent);
}

.asp-cluster-halo {
  fill: rgba(43, 160, 163, 0.18);
  pointer-events: none;
}

.asp-cluster-core {
  fill: var(--asp-primary);
  stroke: #fff;
  stroke-width: 2.5;
  pointer-events: none;
}

.asp-cluster-core.is-mid {
  fill: #1f8f92;
}

.asp-cluster-core.is-heavy {
  fill: var(--asp-accent);
}

.asp-cluster-label {
  fill: #fff;
  font-family: var(--asp-font-display);
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
}

.asp-cluster:hover .asp-cluster-core {
  fill: var(--asp-primary-deep);
}

.asp-cluster:hover .asp-cluster-core.is-heavy {
  fill: #2a2e36;
}

.asp-zoom-controls {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 1100;
  display: grid;
  gap: 0.4rem;
}

.asp-zoom-controls button {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 0.85rem;
  background: rgba(255, 255, 255, 0.95);
  color: var(--asp-accent);
  box-shadow: 0 10px 28px rgba(36, 39, 45, 0.12);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.asp-zoom-controls button:hover {
  background: var(--asp-primary);
  color: #fff;
}

.asp-tooltip {
  position: absolute;
  z-index: 1050;
  padding: 0.45rem 0.7rem;
  border-radius: 0.65rem;
  background: rgba(36, 39, 45, 0.92);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  pointer-events: none;
  transform: translate(-50%, -120%);
  white-space: nowrap;
}

.asp-empty {
  position: absolute;
  inset: auto 1.25rem 1.25rem;
  z-index: 1050;
  padding: 0.9rem 1.1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--asp-line);
  color: var(--asp-muted);
  font-weight: 600;
  text-align: center;
}

.asp-overlay {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 1200;
  width: min(340px, calc(100% - 2.2rem));
  padding: 1.35rem 1.35rem 1.2rem;
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--asp-line);
  box-shadow: 0 28px 70px rgba(36, 39, 45, 0.16);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translate3d(18px, 10px, 0) scale(0.96);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.45s var(--asp-ease-out),
    transform 0.55s var(--asp-ease-out),
    visibility 0.45s;
}

.asp-overlay.is-open {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.asp-overlay[hidden] {
  display: block;
}

.asp-overlay-close {
  position: absolute;
  top: 0.75rem;
  right: 0.85rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(59, 64, 74, 0.06);
  color: var(--asp-accent);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.asp-overlay-logo {
  width: 4.25rem;
  height: 4.25rem;
  margin-bottom: 0.9rem;
  border-radius: 1.1rem;
  overflow: hidden;
  background: linear-gradient(145deg, #e7f5f5, #f3faf4);
  display: grid;
  place-items: center;
  font-family: var(--asp-font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--asp-primary-deep);
}

.asp-overlay-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asp-overlay-cat {
  margin: 0 0 0.35rem;
  color: var(--asp-primary-deep);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.asp-overlay h2 {
  margin: 0;
  padding-right: 1.5rem;
  font-family: var(--asp-font-display);
  font-size: 1.35rem;
  line-height: 1.2;
  color: var(--asp-accent);
}

.asp-overlay-meta,
.asp-overlay-address {
  margin: 0.55rem 0 0;
  color: var(--asp-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.asp-overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

.asp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.65rem;
  padding: 0 1rem;
  border-radius: 999px;
  border: 0;
  text-decoration: none;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.35s var(--asp-ease), background 0.35s var(--asp-ease);
}

.asp-btn:active {
  transform: scale(0.98);
}

.asp-btn--primary {
  background: var(--asp-primary);
  color: #fff;
}

.asp-btn--primary:hover {
  background: var(--asp-primary-deep);
}

.asp-btn--ghost {
  background: rgba(59, 64, 74, 0.06);
  color: var(--asp-accent);
}

.asp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10040;
  background: rgba(36, 39, 45, 0.28);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.28s var(--asp-ease),
    visibility 0.28s;
}

.asp-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.asp-backdrop[hidden] {
  display: none !important;
  pointer-events: none !important;
}

@keyframes asp-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes asp-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes asp-marker-in {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes asp-pin-pulse {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    transform: scale(1.14);
    filter: drop-shadow(0 0 10px rgba(43, 160, 163, 0.55));
  }
}

@keyframes asp-ring {
  0% {
    transform: scale(0.7);
    opacity: 0.55;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

.asp-header {
  animation: asp-fade-up 0.7s var(--asp-ease-out) both;
}

.asp-filters {
  animation: asp-fade-up 0.75s var(--asp-ease-out) 0.05s both;
}

.asp-stage {
  transition: box-shadow 0.5s var(--asp-ease), transform 0.6s var(--asp-ease-out);
}

.asp-stage.is-flying {
  box-shadow: 0 30px 80px rgba(43, 160, 163, 0.18);
}

.asp-stage.is-focus-associate {
  box-shadow: 0 28px 70px rgba(36, 39, 45, 0.14);
}

.asp-leaflet-marker {
  background: transparent !important;
  border: 0 !important;
}

.asp-marker-pop {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  animation: asp-marker-in 0.45s var(--asp-ease-out) both;
  transform-origin: center center;
  will-change: transform, opacity;
}

.asp-marker-pop.is-selected {
  animation: asp-pin-pulse 1.1s var(--asp-ease) infinite;
}

.asp-marker-pop.is-selected::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid var(--asp-primary);
  animation: asp-ring 1.1s var(--asp-ease-out) infinite;
  pointer-events: none;
}

.asp-result-chip {
  transition:
    transform 0.35s var(--asp-ease-out),
    background 0.35s var(--asp-ease),
    color 0.35s var(--asp-ease),
    box-shadow 0.35s var(--asp-ease);
  animation: asp-fade-up 0.4s var(--asp-ease-out) both;
}

.asp-result-chip:nth-child(1) { animation-delay: 0.02s; }
.asp-result-chip:nth-child(2) { animation-delay: 0.04s; }
.asp-result-chip:nth-child(3) { animation-delay: 0.06s; }
.asp-result-chip:nth-child(4) { animation-delay: 0.08s; }
.asp-result-chip:nth-child(5) { animation-delay: 0.1s; }
.asp-result-chip:nth-child(6) { animation-delay: 0.12s; }
.asp-result-chip:nth-child(7) { animation-delay: 0.14s; }
.asp-result-chip:nth-child(8) { animation-delay: 0.16s; }

.asp-result-chip:hover {
  transform: translateY(-2px);
}

.asp-result-chip.is-active {
  transform: translateY(-1px) scale(1.03);
}

.asp-zoom-controls button {
  transition: transform 0.3s var(--asp-ease-out), background 0.3s var(--asp-ease), color 0.3s var(--asp-ease);
}

.asp-zoom-controls button:active {
  transform: scale(0.94);
}

.asp-map--leaflet,
.asp-map--google {
  transition: filter 0.45s var(--asp-ease);
}

.asp-stage.is-flying .asp-map--leaflet .asp-muted-tiles {
  filter: saturate(0.45) contrast(0.9) brightness(1.06);
}

.asp-overlay.is-open .asp-overlay-logo {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.05s both;
}

.asp-overlay.is-open .asp-overlay-cat {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.1s both;
}

.asp-overlay.is-open h2 {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.14s both;
}

.asp-overlay.is-open .asp-overlay-meta {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.18s both;
}

.asp-overlay.is-open .asp-overlay-address {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.22s both;
}

.asp-overlay.is-open .asp-overlay-actions {
  animation: asp-rise 0.5s var(--asp-ease-out) 0.28s both;
}

@media (max-width: 860px) {
  .asp-app {
    width: min(100% - 1.25rem, 1180px);
    padding-top: 1.5rem;
  }

  .asp-header {
    flex-direction: column;
    align-items: start;
  }

  .asp-filters {
    grid-template-columns: 1fr;
  }

  .asp-overlay,
  .asp-overlay.is-open,
  .asp-overlay[hidden] {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 1.5rem 1.5rem 0 0;
    z-index: 6;
    transform: translate3d(0, 110%, 0);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #ffffff;
  }

  .asp-overlay.is-open {
    transform: translate3d(0, 0, 0);
    z-index: 10050;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: #ffffff;
  }

  .asp-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(36, 39, 45, 0.35);
  }

  .asp-backdrop.is-open {
    z-index: 10040;
  }

  .asp-stage.is-flying .asp-map--leaflet .asp-muted-tiles {
    filter: saturate(0.55) contrast(0.92) brightness(1.04);
  }

  .asp-map,
  .asp-stage {
    min-height: 62vh;
    height: 62vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asp-header,
  .asp-filters,
  .asp-marker-pop,
  .asp-marker-pop.is-selected,
  .asp-marker-pop.is-selected::after,
  .asp-result-chip,
  .asp-overlay.is-open .asp-overlay-logo,
  .asp-overlay.is-open .asp-overlay-cat,
  .asp-overlay.is-open h2,
  .asp-overlay.is-open .asp-overlay-meta,
  .asp-overlay.is-open .asp-overlay-address,
  .asp-overlay.is-open .asp-overlay-actions {
    animation: none !important;
  }

  .asp-overlay,
  .asp-backdrop,
  .asp-btn,
  .asp-count,
  .asp-stage,
  .asp-result-chip {
    transition-duration: 0.01ms !important;
  }
}
