:root {
  --ink: #1c1915;
  --ink-soft: #3f3a34;
  --muted: #6d665e;
  --line: #e4dcd2;
  --paper: #f3f0ea;
  --paper-deep: #e7e1d8;
  --white: #fffcf8;
  --green: #0f6a4e;
  --green-dark: #0b4f3a;
  --green-soft: #e5f3ed;
  --clay: #9a3b24;
  --clay-soft: #f8e6df;
  --sea: #1a5568;
  --sea-soft: #e4f1f4;
  --gold: #a9793a;
  --shadow: 0 18px 50px rgba(40, 32, 22, 0.08);
  --radius: 18px;
  --font: "Outfit", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --max: 1160px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.02rem;
  line-height: 1.55;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: var(--green-dark); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { color: var(--green); }
h1, h2, h3, .card-price, .side-price, .stats dd {
  font-family: var(--display);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
h1 { font-size: clamp(2.1rem, 4.6vw, 4.1rem); margin: 0.2rem 0 0.7rem; }
h2 { font-size: clamp(1.5rem, 2.4vw, 2rem); margin: 0; }
h3 { font-size: 1.2rem; margin: 0; }
p { margin: 0 0 0.8rem; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: #cfe7dc; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: white;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  z-index: 40;
}
.skip:focus { top: 0.6rem; }

.wrap { width: min(var(--max), calc(100% - 2rem)); margin-inline: auto; }
.narrow { width: min(760px, calc(100% - 2rem)); }
.narrow-list { width: min(820px, calc(100% - 2rem)); }
.section { padding: 1.4rem 0 2.2rem; }

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--green);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lead { color: var(--ink-soft); font-size: 1.12rem; max-width: 42rem; }
.hint { color: var(--muted); font-size: 0.92rem; }
code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92em;
  background: var(--paper-deep);
  padding: 0.05em 0.35em;
  border-radius: 6px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(243, 240, 234, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(28, 25, 21, 0.08);
}
.header-bar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  min-height: 72px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}
.logo-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--green);
}
.logo-mark svg { width: 32px; height: 32px; }
.logo-word { font-family: var(--display); font-size: 1.45rem; letter-spacing: -0.03em; }
.logo-word span { color: var(--green); }
.nav-main { display: flex; gap: 1.15rem; margin-left: 0.4rem; }
.nav-main a { color: var(--ink); text-decoration: none; font-weight: 600; }
.nav-main a:hover, .nav-main a[aria-current="page"] { color: var(--green); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.55rem; }
.icon-btn, .fav-btn, .burger {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.icon-btn svg, .fav-btn svg { width: 20px; height: 20px; }
.nav-drawer { display: none; position: relative; }
.burger { gap: 5px; align-content: center; padding: 0; }
.burger span { display: block; width: 16px; height: 2px; background: var(--ink); }
.drawer-panel, .account-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(260px, 78vw);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.55rem;
  display: grid;
  z-index: 40;
}
.drawer-panel a, .account-panel a, .drawer-panel .link, .account-panel .link {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}
.drawer-panel a:hover, .account-panel a:hover { background: var(--paper); }
.account { position: relative; }
.account summary, .burger, summary { list-style: none; cursor: pointer; }
.account summary::-webkit-details-marker, summary::-webkit-details-marker { display: none; }
.account summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  font-weight: 650;
}
.count {
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--clay);
  color: white;
  font-size: 0.75rem;
  display: inline-grid;
  place-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.65rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: white;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--green-dark); color: white; }
.btn-sm { min-height: 40px; padding: 0.4rem 0.9rem; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--white); color: var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--green-dark);
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.link-danger { color: var(--clay); }
.text-link { display: inline-block; margin-top: 0.7rem; font-weight: 650; }

.flashes { padding-top: 1rem; }
.flash {
  margin: 0 0 0.7rem;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: var(--green-soft);
  color: var(--green-dark);
}
.flash-err { background: var(--clay-soft); color: var(--clay); }
.flash ul { margin: 0; padding-left: 1.1rem; }

.hero { padding: 2.4rem 0 0.4rem; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.7fr);
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.3rem;
}
.stats, .stats-inline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7rem;
  margin: 0;
}
.stats div, .stats-inline div {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
}
.stats dt, .stats-inline dt { color: var(--muted); font-size: 0.82rem; }
.stats dd, .stats-inline dd { margin: 0.15rem 0 0; font-size: 1.7rem; }
.stats-inline { margin: 1rem 0 1.3rem; max-width: 520px; }
.stats-inline a { text-decoration: none; color: inherit; }

.search, .panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.search { padding: 0.85rem; }
.search-grid, .form-grid, .duo {
  display: grid;
  gap: 0.75rem;
}
.search-grid { grid-template-columns: 1.4fr 1fr 1fr auto; align-items: end; margin-top: 0.75rem; }
.form-grid { grid-template-columns: 1fr 1fr; }
.duo { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: 1 / -1; }
.map-find { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.map-find .indirizzo-wrap { flex: 1 1 240px; }
.indirizzo-wrap { position: relative; z-index: 5; }
.indirizzi-lista {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 6;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-height: 260px;
  overflow: auto;
}
.indirizzi-lista button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
}
.indirizzi-lista button:hover,
.indirizzi-lista button.is-on { background: var(--paper); }
#mappa-posizione {
  position: relative;
  z-index: 0;
  height: 400px;
  width: 100%;
  margin-top: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #d9d3c8;
}
#mappa-posizione img,
#mappa-posizione .leaflet-tile {
  max-width: none;
  mix-blend-mode: normal;
}
#mappa-posizione.map-manca { outline: 3px solid var(--clay); }

.segment {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--paper);
  border-radius: 999px;
}
.segment label { position: relative; display: block; font-weight: 700; }
.segment input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.segment span { display: block; padding: 0.45rem 0.95rem; border-radius: 999px; }
.segment input:checked + span { background: var(--green); color: white; }
.segment input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

form label:not(.check) {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
}
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.65rem 0.8rem;
  border: 1px solid #d9d1c6;
  border-radius: 12px;
  background: var(--white);
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--green);
  border-color: var(--green);
}
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem 0.8rem; margin: 0.4rem 0 0.8rem; }
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 550;
}
.check input { width: 1.05rem; min-height: 0; height: 1.05rem; }
.check-solo { margin-top: 0.8rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.chip span { color: var(--muted); }
.chip:hover, .chip-on { background: var(--green-soft); border-color: transparent; color: var(--green-dark); }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card:hover { box-shadow: var(--shadow); }
.card-media { position: relative; background: var(--paper-deep); }
.card-media img, .gallery-main { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.card-body { padding: 0.9rem 1rem 1rem; display: grid; gap: 0.25rem; }
.card-price { margin: 0; font-size: 1.45rem; display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.card-price a { color: var(--ink); text-decoration: none; }
.card-price span, .card-by, .card-where { color: var(--muted); font-family: var(--font); font-size: 0.92rem; letter-spacing: 0; font-weight: 500; }
.card-title { font-size: 1.12rem; margin: 0.15rem 0; }
.card-title a { color: var(--ink); text-decoration: none; }
.card-title a:hover { color: var(--green-dark); }
.card-where, .detail-where { display: flex; align-items: center; gap: 0.3rem; margin: 0; }
.card-where svg, .detail-where svg { width: 16px; height: 16px; flex: none; }
.card-specs { display: flex; flex-wrap: wrap; gap: 0.55rem 0.8rem; list-style: none; margin: 0.45rem 0 0; padding: 0; color: var(--ink-soft); font-size: 0.9rem; }
.card-specs li { display: inline-flex; align-items: center; gap: 0.25rem; }
.card-specs svg { width: 16px; height: 16px; }
.card-by { margin: 0.35rem 0 0; }
.pill {
  display: inline-flex;
  width: fit-content;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.card-media .pill { position: absolute; top: 12px; left: 12px; }
.fav { position: absolute; top: 10px; right: 10px; margin: 0; }
.fav-btn.is-on { color: var(--clay); background: white; }
.fav-btn.is-on svg path { fill: currentColor; }
.pill-vendita { background: var(--clay-soft); color: var(--clay); }
.pill-affitto { background: var(--sea-soft); color: var(--sea); }

.cities { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.city {
  display: grid;
  gap: 0.15rem;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-decoration: none;
  color: var(--ink);
}
.city span { color: var(--muted); font-size: 0.9rem; }
.city:hover { border-color: var(--green); }
.band {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  border-radius: 24px;
  background: #12352c;
  color: #f4efe6;
}
.band h2, .band p { color: inherit; }
.band p { margin: 0.4rem 0 0; max-width: 40rem; }
.band .btn { background: #f4efe6; color: #12352c; }
.band .btn:hover { background: white; color: #12352c; }

.site-footer { background: #1c1915; color: #f3f0ea; padding: 2.4rem 0 1.2rem; margin-top: 1rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 1.5rem; }
.site-footer a { color: #f3f0ea; text-decoration: none; display: block; margin: 0.35rem 0; }
.site-footer h2 { font-family: var(--font); font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.6rem; }
.logo-on-dark { color: #f4efe6; }
.logo-on-dark .logo-word span { color: #8dceba; }
.footer-base { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid rgba(243, 240, 234, 0.15); color: #b7b0a6; }

.results-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.3rem; align-items: start; margin-top: 1rem; }
.filters > summary { font-weight: 750; margin-bottom: 0.6rem; }
.filters-body, .auth, .side-card { padding: 1rem; display: grid; gap: 0.75rem; }
.results-bar { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: 0.9rem; }
.results-bar .chips { margin: 0; flex: 1; }
.sort { min-width: 180px; }
.results-count { color: var(--muted); margin-top: -0.2rem; }
.pager { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.2rem; }
.pager-link, .pager-gap {
  min-width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--white);
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
}
.pager-link.is-current, .pager-link[aria-current="page"] { background: var(--green); color: white; border-color: var(--green); }
.empty { padding: 1.4rem; }
.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; color: var(--muted); font-size: 0.92rem; margin-bottom: 0.8rem; }
.crumbs a { color: var(--muted); }

.detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.4rem; align-items: start; }
.detail h1 { font-size: clamp(1.8rem, 3vw, 2.7rem); }
.detail-side { position: sticky; top: 88px; display: grid; gap: 0.8rem; }
.gallery-main { border-radius: 20px; background: var(--paper-deep); }
.thumbs { display: flex; gap: 0.45rem; overflow-x: auto; margin-top: 0.55rem; }
.thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; background: none; cursor: pointer; }
.thumbs img { width: 92px; height: 64px; object-fit: cover; border-radius: 8px; }
.thumbs .is-on { border-color: var(--green); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; list-style: none; padding: 0; margin: 1rem 0; }
.facts li { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.8rem; }
.facts span { display: block; color: var(--muted); font-size: 0.82rem; }
.facts-soft li { background: transparent; }
.prose { max-width: 68ch; }
.prose-page h2 { margin: 1.4rem 0 0.5rem; }
.feature-list { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; padding: 0; }
.feature-list li { background: var(--green-soft); color: var(--green-dark); border-radius: 999px; padding: 0.3rem 0.7rem; font-weight: 650; font-size: 0.92rem; }
.energy { display: flex; align-items: center; gap: 0.5rem; }
.classe { display: inline-grid; place-items: center; min-width: 2.4rem; height: 2.4rem; border-radius: 10px; color: white; }
.classe-a { background: #1f8a4c; }
.classe-b { background: #6aaa2f; }
.classe-c { background: #c6b12a; color: #1c1915; }
.classe-d { background: #d89a2b; }
.classe-e { background: #d46a2a; }
.classe-f { background: #c44b32; }
.classe-g { background: #a33b24; }
.map-frame { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--white); }
.map-frame iframe { width: 100%; height: 280px; border: 0; }
.side-price { font-size: 2rem; margin: 0.3rem 0; }
.side-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.side-actions form { margin: 0; }
.advertiser { border-top: 1px solid var(--line); padding-top: 0.7rem; }
.owner-bar { margin: 0; }
.note { padding: 0.9rem 1rem; background: #fff6df; border-color: #ead7a4; }

.photo-edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin: 1rem 0; }
.photo-edit figure { margin: 0; }
.photo-edit img { width: 100%; height: 110px; object-fit: cover; border-radius: 12px; }
.preview { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.preview img { width: 92px; height: 70px; object-fit: cover; border-radius: 10px; }
fieldset { border: 0; margin: 0 0 1.2rem; padding: 0; }
legend { font-family: var(--display); font-size: 1.35rem; margin-bottom: 0.7rem; }
.form-annuncio { padding: 1.1rem 1.15rem 1.3rem; }

.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: 18px; }
.list-table { width: 100%; border-collapse: collapse; }
.list-table th, .list-table td { text-align: left; padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.list-table th { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.list-table .hint { display: block; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }
.badge { display: inline-flex; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700; background: var(--paper-deep); }
.badge-attivo { background: var(--green-soft); color: var(--green-dark); }
.badge-bozza { background: #fff6df; color: #7a5b16; }
.badge-sospeso { background: var(--clay-soft); color: var(--clay); }
.stack { display: grid; gap: 0.8rem; }
.message { padding: 1rem 1.05rem; }
.message.is-new { box-shadow: inset 3px 0 0 var(--green); }
.message h2, .message h3 { margin-bottom: 0.35rem; }

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media (max-width: 980px) {
  .nav-main, .account, .header-actions .btn-ghost { display: none; }
  .nav-drawer { display: block; }
  .hero-grid, .results-layout, .detail, .footer-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .grid, .cities { grid-template-columns: 1fr 1fr; }
  .search-grid { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .grid, .cities, .form-grid, .check-grid, .photo-edit, .stats, .stats-inline, .facts { grid-template-columns: 1fr; }
  .band, .section-head, .results-bar { flex-direction: column; align-items: stretch; }
  .header-bar { min-height: 64px; }
  h1 { font-size: 2rem; }
}
