:root {
  --bg: #1d1f21;
  --bg-elev: #2b3137;
  --bg-footer: #161a1d;
  --text: #f5f7fa;
  --muted: #c5ced6;
  --accent: #4da3ff;
  --line: rgba(255, 255, 255, 0.08);
  --danger: #ffb4b4;
  --ok: #b7f0cf;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  --max: 1080px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Montserrat", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(77, 163, 255, 0.14), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(77, 163, 255, 0.08), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  letter-spacing: 0.01em;
}

h1, h2, h3 { font-weight: 600; line-height: 1.25; letter-spacing: -0.02em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* Rollover leggero su tutte le immagini del sito (esclusi logo hero/brand gestiti a parte). */
.block img,
.page img:not(.hero-logo),
.gallery img,
.energy-mark,
.certs img,
.tesla-gallery img,
.te-card img,
.te-hero-visual img,
.te-photo-trigger img,
.admin-list img,
.request-card img {
  transition:
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.55s ease,
    box-shadow 0.55s ease,
    opacity 0.45s ease;
}

.block img:hover,
.page img:not(.hero-logo):hover,
.gallery img:hover,
.energy-mark:hover,
.certs a:hover img,
.tesla-gallery img:hover,
.te-card:hover img,
.te-hero-visual:hover img,
.te-photo-trigger:hover img,
.admin-list img:hover {
  transform: scale(1.04) translateY(-3px);
  filter: brightness(1.06) contrast(1.03);
}

.container {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(22, 26, 29, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar {
  background: #121518;
  font-size: 0.82rem;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 6px 0;
}

.topbar a { color: var(--muted); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.brand img {
  height: 52px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
  opacity: 0.82;
  filter: brightness(0.88);
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease,
    filter 0.35s ease;
}

.brand:hover img {
  transform: scale(1.06);
  opacity: 1;
  filter: brightness(1);
  text-decoration: none;
}

.brand:hover { text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-links a { color: white; text-decoration: none; }

.nav-toggle {
  display: none;
  background: transparent;
  color: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #000;
  padding: 96px 20px 48px;
}

.hero-bg,
.hero-night,
.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Foto a colori pieni: solo sorvolo (transform). Luminosità = velo nero sopra. */
.hero-bg {
  inset: -12% -8% -8%;
  background: url("img/wp.jpeg") center 38% / cover no-repeat;
  transform: scale(1.28) translate3d(0, 7%, 0);
  transform-origin: 50% 42%;
  will-change: transform;
  animation: romeFlyover 3.8s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.hero-night {
  background: #000;
  opacity: 1;
  will-change: opacity;
  animation: romeLightsOn 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Leggibilità testo: appare in parallelo, senza scatti. */
.hero-scrim {
  background:
    radial-gradient(ellipse 85% 60% at 50% 80%, rgba(255, 170, 90, 0.1), transparent 60%),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.35) 0%,
      rgba(0, 0, 0, 0.22) 45%,
      rgba(0, 0, 0, 0.48) 100%
    );
  opacity: 0;
  animation: romeScrimIn 3.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 860px;
  animation: fadeUp 1s 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-logo-link {
  display: inline-block;
  text-decoration: none;
  margin: 0 auto 4px;
}

.hero-logo {
  width: min(100%, 392px); /* ~70% di 560px */
  height: auto;
  margin: 0 auto;
  opacity: 0.62;
  filter:
    brightness(0.72)
    contrast(0.92)
    drop-shadow(0 0 10px rgba(0, 0, 0, 0.45));
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    filter 0.4s ease;
}

.hero-logo-link:hover .hero-logo,
.hero-logo-link:focus-visible .hero-logo {
  transform: scale(1.07);
  opacity: 0.95;
  filter:
    brightness(0.95)
    contrast(1)
    drop-shadow(0 0 16px rgba(200, 210, 220, 0.35));
}

.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;
}

.energy-mark {
  display: block;
  width: min(100%, 420px);
  height: auto;
  margin: 0 auto 8px;
}

.tesla-block { margin-top: 36px; }
.tesla-block h2 { text-align: center; }

.tesla-gallery figure { margin: 0; }
.tesla-gallery figcaption {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 2px 0;
  text-align: left;
}
.tesla-gallery figcaption span { color: var(--muted); font-size: 0.92rem; }

.hero h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 5vw, 3rem);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

.payoff { font-size: 1.15rem; margin: 0 auto 12px; max-width: 720px; }
.settori { letter-spacing: 0.3px; color: #e8eef5; }

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.block, .page {
  width: min(var(--max), calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0;
}

.block h2, .page h1 { text-align: center; font-size: 2rem; margin-bottom: 28px; }

.block p, .lead {
  text-align: center;
  max-width: 780px;
  margin: 0 auto 22px;
  font-size: 1.05rem;
  color: var(--muted);
}

.block p strong, .lead { color: var(--text); }
.block p strong { color: white; }

.center { text-align: center; }

.page.narrow { max-width: 560px; }

.service-grid {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.service-grid li {
  background: var(--bg-elev);
  border-radius: 10px;
  padding: 22px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.35s ease;
  border: 1px solid transparent;
}

.service-grid li:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  border-color: rgba(77, 163, 255, 0.25);
}

.gallery {
  margin-top: 12px;
  display: grid;
  gap: 25px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.gallery img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
}

.gallery img:hover {
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
}

.contact-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.contact-box, .form-card, .request-card {
  background: var(--bg-elev);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.35s ease;
}

.contact-box:hover {
  transform: translateY(-3px);
  border-color: rgba(77, 163, 255, 0.28);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
}

.contact-box strong {
  display: block;
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.contact-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.45;
}

.contact-lines li {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.contact-box p { margin: 0; text-align: left; color: var(--text); max-width: none; }

.form-card { margin-top: 28px; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}

.wide { grid-column: 1 / -1; }

.opt { color: var(--muted); font-weight: 400; }

input, select, textarea {
  font: inherit;
  color: white;
  background: #15181b;
  border: 1px solid #3d4650;
  border-radius: 8px;
  padding: 10px 12px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

textarea { resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.35s ease,
    border-color 0.35s ease,
    box-shadow 0.4s ease,
    background-color 0.35s ease;
}

.btn-primary {
  background: var(--accent);
  color: #07131f;
  box-shadow: 0 8px 20px rgba(77, 163, 255, 0.28);
}
.btn-primary:hover {
  filter: brightness(1.08);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(77, 163, 255, 0.38);
}
.btn-ghost { background: transparent; color: white; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { text-decoration: none; border-color: white; transform: translateY(-2px); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.privacy { color: var(--muted); font-size: 0.85rem; text-align: left; margin: 8px 0 16px; }

.form-errors { color: var(--danger); margin: 8px 0 0; padding-left: 18px; }
p.form-errors { padding-left: 0; }

.success {
  background: #143026;
  border-radius: 10px;
  padding: 8px 4px;
  color: var(--ok);
}

.success h3, .success p { color: var(--ok); text-align: left; }

.hp {
  position: absolute;
  left: -10000px;
  height: 0;
  overflow: hidden;
}

.site-footer {
  background: var(--bg-footer);
  text-align: center;
  padding: 48px 16px 32px;
  margin-top: 20px;
}

.certs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.certs img {
  height: 110px;
  margin: 12px;
  object-fit: contain;
}

.legal { color: var(--muted); font-size: 0.9rem; }

.admin-head, .filters, .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-head { justify-content: space-between; }
.admin-head h1 { margin: 0; text-align: left; }

.filters { margin: 18px 0; }

.request-card { margin-bottom: 14px; }
.request-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.request-card p { text-align: left; margin: 6px 0; max-width: none; color: var(--text); }
.message { white-space: pre-wrap; }
.tag, .protocol {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  background: #15181b;
  font-size: 0.8rem;
  margin-right: 8px;
}
.muted { color: var(--muted); font-size: 0.85rem; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.check-row input { width: auto; }

.ok-msg {
  color: var(--ok);
  margin: 8px 0 0;
}

.sopralluogo-extra {
  margin-top: 28px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.sopralluogo-extra h3 {
  margin: 22px 0 8px;
  font-size: 1.15rem;
}

.sopralluogo-map-wrap { margin: 12px 0 8px; }

.map-search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.geo-suggest {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15181b;
  max-height: 160px;
  overflow: auto;
}

.geo-suggest li { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.geo-suggest li:last-child { border-bottom: none; }

.map-search input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.agenda-note {
  grid-column: 1 / -1;
  text-align: left;
  margin: 0 0 4px;
}

.confirm-box {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #15181b;
}

.confirm-box .fields { margin-top: 10px; margin-bottom: 10px; }

.pagamento-stub { margin-top: 1.5rem; }

.sagi-map-seg-label {
  background: #c62828 !important;
  color: #fff !important;
  border: 1px solid #8e0000 !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font: 800 0.72rem/1.2 "Montserrat", sans-serif !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.stato-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #243040;
  margin-left: 6px;
}

.stato-nuovo { background: #1b4f72; }
.stato-presoincarico { background: #7d6608; }
.stato-pianificato { background: #1a5276; }
.stato-approvato { background: #196f3d; }
.stato-annullato { background: #7b241c; }
.stato-chiuso { background: #4d5656; }

.stato-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.filtro-stati {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 8px 0 16px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border-radius: 10px;
  border: 1px solid var(--line);
}

.filtro-stati label.check-row { margin: 0; font-size: 0.88rem; }

.tariffa-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(77, 163, 255, 0.35);
  background: #15181b;
}

.tariffa-prezzo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.map-hint { text-align: left; margin: 0 0 10px; max-width: none; }

.sopralluogo-map,
.admin-mini-map {
  height: 360px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  z-index: 1;
}

.admin-mini-map { height: 220px; margin: 8px 0 12px; }

.sopralluogo-map[data-mode="circle"],
.sopralluogo-map[data-mode="rectangle"] {
  cursor: crosshair;
}

.sagi-map-label {
  background: #c62828 !important;
  color: #fff !important;
  border: 1px solid #8e0000 !important;
  border-radius: 6px !important;
  padding: 4px 9px !important;
  font: 800 0.82rem/1.3 "Montserrat", sans-serif !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}

.leaflet-div-icon.sagi-map-label,
.leaflet-div-icon.sagi-map-seg-label {
  background: transparent !important;
  border: none !important;
}

.sagi-compass {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #c62828;
  background: #fff;
  color: #c62828;
  font: 800 0.95rem/1 "Montserrat", sans-serif;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.allegati-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.file-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.allegati-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.allegati-list li {
  background: #15181b;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.allegato-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.allegati-admin ul {
  margin: 6px 0 12px;
  padding-left: 1.1rem;
}

.allegati-admin li { margin: 4px 0; }

.linkish {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.allegato-nota { color: var(--muted); }

#blazor-error-ui {
  background: #3a1d1d;
  color: white;
  bottom: 0;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}

/* Sorvolo dall'alto: solo transform (fluido, GPU). */
@keyframes romeFlyover {
  from { transform: scale(1.28) translate3d(0, 7%, 0); }
  to   { transform: scale(1.06) translate3d(0, 0, 0); }
}

/* Da nero a luci: solo opacity del velo nero (graduale 0→100). */
@keyframes romeLightsOn {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes romeScrimIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.block h2,
.page h1 {
  animation: fadeUp 0.95s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.nav-links a {
  transition: color 0.3s ease, opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-links a:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-bg {
    animation: none;
    transform: scale(1.06) translate3d(0, 0, 0);
  }
  .hero-night { animation: none; opacity: 0; }
  .hero-scrim { animation: none; opacity: 1; }
  .hero-content { animation: none; opacity: 1; }
}

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px 18px;
    background: #161a1d;
    border-bottom: 1px solid var(--line);
  }
  .nav-links.open { display: flex; }
  .fields { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .hero { min-height: 88svh; }
  .hero-logo { width: min(88%, 300px); }
}
