:root {
  --bg: #f4f5f7;
  --paper: #ffffff;
  --ink: #16202b;
  --muted: #5f6b7a;
  --line: #e3e6ea;
  --navy: #0f2740;
  --accent: #c8741a;
  --accent-soft: #fdf1e3;
  --green: #1f7a4d;
  --red: #b23a3a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 39, 64, .06), 0 6px 18px rgba(15, 39, 64, .06);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--navy); }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .4em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.15rem; margin-top: 1.6em; color: var(--navy); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.top { background: var(--navy); color: #fff; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-family: Fraunces, Georgia, serif; font-size: 1.5rem; color: #fff; text-decoration: none; font-weight: 600; }
.brand span { color: #f0b36b; }
.top nav a { color: #d7dee7; text-decoration: none; margin-left: 20px; font-weight: 500; }
.top nav a:hover { color: #fff; }

.hero { padding: 28px 0 8px; }
.hero .sub { color: var(--muted); margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0 10px; box-shadow: var(--shadow); }
.filters label { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: 4px; font-weight: 500; }
.filters label.chk { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; }
.filters select, .filters input[type=search], .filters input[type=text] { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 120px; color: var(--ink); }
.filters input[type=search] { min-width: 220px; }
.filters button { font: inherit; font-weight: 600; background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; cursor: pointer; }
.filters .reset { font-size: .85rem; color: var(--muted); padding-bottom: 8px; }
.count { color: var(--muted); margin: 6px 2px 14px; font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card { display: block; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; border-top: 4px solid var(--navy); }
.card .card-body { padding: 12px 16px 14px; }
.cover { position: relative; aspect-ratio: 16 / 10; background: #dfe4ea center / cover no-repeat; }
.cover.nophoto { background: linear-gradient(135deg, #e9edf2, #d3dae3); }
.nophoto-label { position: absolute; top: 10px; left: 12px; font-size: .72rem; color: #5f6b7a; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.overlay { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 26px 12px 9px; background: linear-gradient(to top, rgba(10, 20, 35, .92), rgba(10, 20, 35, .55) 60%, transparent); color: #fff; }
.overlay .k { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.overlay .v { display: block; font-weight: 700; font-size: .86rem; overflow-wrap: anywhere; }
.overlay .v small { font-weight: 500; font-size: .72rem; opacity: .9; }
.score { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); border: 2px solid rgba(255,255,255,.85); }
.s1, .s2, .s3 { background: #b23a3a; }
.s4, .s5 { background: #d97706; }
.s6, .s7 { background: #6b8e23; }
.s8, .s9, .s10 { background: #1f7a4d; }
.card .sintesi { margin: 8px 0 0; font-size: .82rem; color: #3b4652; line-height: 1.4; }
.badge.occ { background: #e7f0fb; color: #2b5b9c; }
.badge.warn { background: #fff4d6; color: #8a5a00; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(15, 39, 64, .12); }
.card.type-casa { border-top-color: #1f7a4d; }
.card.type-appartamento { border-top-color: #2b6cb0; }
.card.type-commerciale { border-top-color: #7b4bb3; }
.card.type-terreno { border-top-color: #8a8f2a; }
.card.type-posteggio { border-top-color: #8c8c8c; }
.card h3 { font-size: 1.15rem; margin: 8px 0 2px; }
.card .addr { margin: 0; color: var(--muted); font-size: .88rem; min-height: 1.3em; }
.card .when { margin: 8px 0 0; font-weight: 600; color: var(--accent); font-size: .92rem; }
.card .meta { margin: 8px 0 0; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: .7rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: #eef1f4; color: var(--muted); }
.badge.type { background: var(--navy); color: #fff; }
.badge.canton { background: var(--accent-soft); color: var(--accent); }
.badge.share { background: #f3eefa; color: #6a3fa0; }
.badge.ppp { background: #eef4fa; color: #2f5d8a; }
.badge.days { background: #e8f3ec; color: var(--green); }
.badge.days.soon { background: #fde8e8; color: var(--red); }
.badge.status-annullata, .badge.status-sostituita { background: #fde8e8; color: var(--red); }
.badge.status-rinviata { background: #fff4d6; color: #8a5a00; }
.badge.status-conclusa { background: #e9e9e9; color: #555; }

.kv { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); }
.kv div { min-width: 0; }
.kv dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-size: .82rem; overflow-wrap: anywhere; }
.kv dd small { font-weight: 500; color: var(--muted); font-size: .72rem; }

.pager { display: flex; justify-content: center; gap: 18px; margin: 26px 0; color: var(--muted); }
.empty { grid-column: 1 / -1; color: var(--muted); padding: 30px; text-align: center; }

.crumb { margin: 18px 0 6px; font-size: .9rem; }
.head { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.head h1 { margin: 10px 0 2px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.score-big { flex: 0 0 auto; text-align: center; color: #fff; border-radius: 14px; padding: 10px 16px; min-width: 110px; }
.score-big .n { display: block; font-size: 2.4rem; font-weight: 800; line-height: 1; }
.score-big .l { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; opacity: .9; margin-top: 4px; }
.gallery-wrap { margin: 14px 0 4px; }
.gallery { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; }
.gallery a { flex: 0 0 auto; scroll-snap-align: start; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.gallery img { height: 280px; width: auto; display: block; }
.gallery a:first-child { outline: 3px solid var(--accent); }
.analysis { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px 18px; box-shadow: var(--shadow); margin: 14px 0; }
.an-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.an-head form { margin: 0; }
.an-head button { font: inherit; font-weight: 600; background: var(--navy); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.an-head button[disabled] { opacity: .5; cursor: default; }
.analysis .lead { font-size: 1.05rem; line-height: 1.5; margin: 6px 0 8px; }
.analysis .motiv { color: #3b4652; margin: 0 0 12px; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.an-grid .fact.hi { background: var(--accent-soft); border-color: #f1d9b8; }
.an-grid .fact dd.txtv { font-weight: 500; font-size: .9rem; }
.procontro { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.procontro > div { border-radius: 10px; padding: 8px 14px; }
.procontro .pro { background: #e8f3ec; }
.procontro .contro { background: #fde8e8; }
.procontro h3, .an-cols h3 { font-family: Inter, system-ui, sans-serif; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin: 6px 0 4px; }
.procontro ul, .an-cols ul { margin: 0 0 6px; padding-left: 18px; font-size: .9rem; line-height: 1.45; }
.an-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 20px; margin-top: 14px; }
.conclusione { margin: 14px 0 4px; padding: 10px 14px; background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 6px; }
.docs { list-style: none; padding: 0; margin: 0; }
.docs li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.docs li a { font-weight: 600; }
.docs li small { display: block; color: var(--muted); }
.dk { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 4px; background: #eef1f4; color: var(--muted); margin-right: 6px; }
.dk-perizia { background: #e7f0fb; color: #2b5b9c; }
.dk-condizioni { background: #fff4d6; color: #8a5a00; }
.dk-oneri { background: #f3eefa; color: #6a3fa0; }
.addr.big { color: var(--muted); font-size: 1.05rem; margin: 0; }
.alert { margin-top: 14px; padding: 10px 14px; background: #fde8e8; border-left: 4px solid var(--red); border-radius: 6px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.fact { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.fact.main { grid-column: 1 / -1; background: var(--accent-soft); border-color: #f1d9b8; }
.fact dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fact dd { margin: 2px 0 0; font-weight: 700; font-size: 1.15rem; }
.fact dd.small { font-weight: 400; font-size: .9rem; color: var(--muted); }
.fact dd.ctx { font-weight: 400; font-size: .75rem; color: var(--muted); margin-top: 4px; }

.cols { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; margin: 10px 0 40px; }
.col { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px 22px; box-shadow: var(--shadow); }
.txt { white-space: pre-wrap; font: inherit; margin: 0 0 8px; line-height: 1.5; }
.txt.small, .small { font-size: .82rem; color: var(--muted); }
.links, .plain { padding-left: 18px; margin: 0; }
.links li, .plain li { margin: 4px 0; }
.amounts { width: 100%; border-collapse: collapse; font-size: .82rem; }
.amounts td { padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.amounts td.v { white-space: nowrap; font-weight: 600; }
.amounts td.c { color: var(--muted); }
.amounts td.c .bar + * { white-space: nowrap; }
.stats-row td.c { white-space: nowrap; }
.bar { display: inline-block; height: 10px; background: var(--navy); border-radius: 3px; vertical-align: middle; margin-right: 6px; }

.foot { color: var(--muted); font-size: .78rem; padding: 20px 20px 40px; border-top: 1px solid var(--line); margin-top: 20px; }

@media (max-width: 800px) {
  .cols { grid-template-columns: 1fr; }
  .procontro { grid-template-columns: 1fr; }
  .gallery img { height: 200px; }
  .top nav a { margin-left: 12px; }
  h1 { font-size: 1.5rem; }
}

/* lightbox foto */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 14, 22, .94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 96vw; max-height: 96vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox img { max-width: 96vw; max-height: 88vh; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.6); cursor: pointer; background: #111; }
.lightbox figcaption { color: #cfd6de; font-size: .85rem; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; font-size: 2.6rem; line-height: 1; width: 56px; height: 72px; border-radius: 10px; cursor: pointer; }
.lightbox button:hover { background: rgba(255,255,255,.28); }
.lightbox .lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-close { top: 12px; right: 14px; width: 48px; height: 48px; font-size: 2rem; }
@media (max-width: 800px) { .lightbox button { width: 40px; height: 56px; font-size: 2rem; } .lightbox .lb-prev { left: 4px; } .lightbox .lb-next { right: 4px; } }

/* deposito: dove e quanto pagare */
.alert.warn { background: #fff4d6; border-left-color: #d29a00; }
.deposit { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 22px 16px; box-shadow: var(--shadow); margin: 14px 0; border-top: 4px solid var(--accent); scroll-margin-top: 12px; }
.dep-grid { display: grid; grid-template-columns: minmax(240px, 2fr) 3fr; gap: 18px; }
.dep-amount { background: var(--accent-soft); border: 1px solid #f1d9b8; border-radius: 10px; padding: 12px 14px; }
.dep-amount .k { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dep-amount .big { display: block; font-size: 1.9rem; font-weight: 800; color: var(--navy); margin: 2px 0 8px; }
.dep-calc { width: 100%; border-collapse: collapse; font-size: .88rem; margin-bottom: 8px; }
.dep-calc td { padding: 4px 0; border-bottom: 1px solid #f1d9b8; vertical-align: top; }
.dep-calc td.v { text-align: right; white-space: nowrap; font-weight: 600; padding-left: 10px; }
.dep-calc tr.tot td { font-weight: 700; border-bottom: 0; }
.dep-pay h3, .dep-source h3 { font-family: Inter, system-ui, sans-serif; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 6px; color: var(--navy); }
.dep-txt { margin: 4px 0; font-size: .92rem; line-height: 1.45; }
.bank { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; font-size: .92rem; }
.bank dt { color: var(--muted); font-size: .8rem; padding-top: 2px; }
.bank dd { margin: 0; overflow-wrap: anywhere; }
code.iban { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.05rem; font-weight: 700; letter-spacing: .03em; background: #eef4fa; padding: 2px 6px; border-radius: 5px; }
.copy { font: inherit; font-size: .75rem; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 2px 8px; cursor: pointer; margin-left: 4px; }
.chk-row { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: .78rem; }
.chk { font-size: .8rem; margin: 4px 0; }
.ok { color: var(--green); font-weight: 600; }
.ko { color: var(--red); font-weight: 700; }
.warn { color: #8a5a00; }
.pill { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; background: #eef1f4; color: var(--muted); vertical-align: 1px; margin-left: 4px; }
.pill.ok { background: #e8f3ec; color: var(--green); }
.pill.ko { background: #fde8e8; color: var(--red); }
.dep-source { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 4px; }
.dep-source p { margin: 4px 0; font-size: .9rem; }
.quote { margin: 8px 0 4px; padding: 8px 12px; border-left: 3px solid var(--line); background: #f8f9fb; font-size: .85rem; color: #3b4652; white-space: pre-wrap; }
.dep-notes { margin-top: 10px; padding: 8px 12px; background: #fff4d6; border-radius: 6px; font-size: .88rem; }
.dep-notes p { margin: 4px 0; }
.badge.revoca { background: #fde8e8; color: var(--red); }
@media (max-width: 800px) { .dep-grid { grid-template-columns: 1fr; } .bank { grid-template-columns: 1fr; } .bank dt { padding-top: 6px; } }
