:root {
  /* Brand palette — sampled from the SapereComune.it logo */
  --navy: #1E3A5F;          /* wordmark "SAPERE", tower, book */
  --gold: #C2A063;          /* wordmark "COMUNE", side houses */
  --accent: var(--navy);    /* primary interactive colour (links, active fills) */
  --ink: #1b2733;
  --muted: #5a6e80;         /* muted blue-grey (motto), AA on white */
  --line: #dce2e9;
  --bg-soft: #f2f5f8;

  /* Section framing tokens (issue #28) */
  --radius: 8px;            /* shared card/panel corner radius */
  --card-shadow: 0 1px 3px rgba(30, 58, 95, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  background: #fff;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1040px; margin: 0 auto; padding: 0 1rem; }

/* Header / footer */
.site-header {
  background: #fff;
  color: var(--ink);
  border-bottom: 2px solid var(--gold);
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  min-height: 64px;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
.site-header .brand {
  display: inline-flex;
  align-items: center;
}
.site-header .brand img {
  height: 44px;
  width: auto;
}
.site-nav {
  /* Secondary tier: always wraps to its own full-width row beneath the search. */
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.25rem;
  margin-top: 0.3rem;
}
.site-nav > a,
.nav-menu > summary {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}
.site-nav > a:hover {
  color: var(--navy);
  text-decoration: none;
}

/* "Strumenti" disclosure menu */
.nav-menu {
  position: relative;
}
.nav-menu > summary {
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after {
  content: "";
  display: inline-block;
  margin-left: 0.35rem;
  border: 0.3rem solid transparent;
  border-top-color: currentColor;
  border-bottom: 0;
  vertical-align: middle;
}
.nav-menu > summary:hover { color: var(--navy); }
.nav-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  min-width: 190px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(30, 58, 95, 0.16);
  padding: 0.35rem;
  display: grid;
  gap: 0.05rem;
  z-index: 60;
}
.nav-menu-panel a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav-menu-panel a:hover {
  background: var(--bg-soft);
  color: var(--navy);
  text-decoration: none;
}

@media (max-width: 560px) {
  .site-search { flex-basis: 100%; max-width: none; margin-left: 0; margin-top: 0.5rem; }
  .nav-menu-panel { right: auto; left: 0; }
}
.site-footer {
  margin-top: 3rem;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .container { padding-top: 1rem; padding-bottom: 1rem; }
.site-footer p { margin: 0.3rem 0; }
.site-footer .footer-tagline { color: var(--ink); }
.site-footer .footer-sources { font-size: 0.8rem; }
.site-footer .footer-links { margin-top: 0.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; font-size: 0.8rem; }

/* "Segnala un errore" footer trigger — a link-styled button among the footer links. */
.footer-report {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}
.footer-report:hover { text-decoration: underline; }
.footer-report .icn { width: 0.95em; height: 0.95em; }

/* Page-correction dialog. */
.report-dialog {
  width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(30, 58, 95, 0.25);
  color: var(--ink);
}
.report-dialog::backdrop { background: rgba(27, 39, 51, 0.45); }
.report-form { padding: 1.25rem 1.4rem 1.4rem; margin: 0; }
.report-form h2 {
  margin: 0 0 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  font-size: 1.15rem;
}
.report-intro { margin: 0 0 1rem; color: var(--muted); font-size: 0.9rem; }
.report-form label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.9rem; }
.report-optional { font-weight: 400; color: var(--muted); }
.report-form textarea,
.report-form input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.report-form textarea { resize: vertical; margin-bottom: 1rem; }
.report-form input[type="email"] { margin-bottom: 0.3rem; }
.report-hint { margin: 0 0 1rem; color: var(--muted); font-size: 0.8rem; }
.report-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.report-status { margin: 0 0 0.8rem; font-size: 0.88rem; }
.report-status.is-error { color: #b3261e; }
.report-status.is-success { color: #1b6e2f; }
.report-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.report-cancel {
  padding: 0.45rem 0.9rem;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.report-cancel:hover { border-color: var(--muted); }
.report-submit {
  padding: 0.45rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.report-submit:disabled { opacity: 0.6; cursor: default; }

main.container { padding-top: 1.5rem; padding-bottom: 2rem; }

/* Typography */
h1 { font-size: 1.7rem; margin: 0.2rem 0 0.6rem; }
h1::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.4rem;
  background: var(--gold);
  border-radius: 2px;
}
h2 {
  font-size: 1.2rem;
  margin: 1.6rem 0 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--line);
  background: linear-gradient(var(--gold), var(--gold)) left bottom / 2.5rem 2px no-repeat;
}
.lead { color: var(--muted); margin-top: 0; }
.muted { color: var(--muted); font-size: 0.88rem; }

/* Explanations beside source abbreviations. */
.source-abbr { display: inline-flex; align-items: baseline; gap: 0.2em; white-space: nowrap; }
.source-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25em; height: 1.25em; padding: 0;
  border: 1px solid currentColor; border-radius: 50%;
  background: transparent; color: inherit; font: inherit;
  font-size: 0.85em; font-weight: 600; line-height: 1; cursor: help;
}
.source-help:hover { color: var(--accent); background: var(--bg-soft); }
.source-help:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.source-tooltip {
  position: fixed;
  box-sizing: border-box; width: max-content; max-width: min(20rem, calc(100vw - 2rem));
  padding: 0.65rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); box-shadow: 0 3px 12px rgba(30, 58, 95, 0.15);
  font-size: 0.85rem; font-weight: 400; line-height: 1.5; white-space: normal;
}
@supports (position-area: bottom) {
  .source-tooltip {
    inset: auto; margin: 0.4rem;
    position-area: bottom;
    position-try-fallbacks: flip-block;
  }
}
/* Older browsers can read the explanation inline. */
@supports not selector(:popover-open) {
  .source-abbr { display: inline; white-space: normal; }
  .source-help { display: none; }
  .source-tooltip {
    position: static; padding: 0; margin-left: 0.3em;
    border: 0; background: transparent; color: inherit; box-shadow: none;
  }
}

/* Consistent section/card framing (issue #28) — shared soft shadow so the
   bordered cards used across comune/province/region/statistics pages read as
   one family rather than a set of one-off styles. */
.stat-card,
.school,
.school-kind,
.index-chart-grid section,
.map-list li,
.it-map-frame,
.context-locator {
  box-shadow: var(--card-shadow);
}

/* Breadcrumb */
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.8rem; }
.breadcrumb a { color: var(--muted); }

/* Lists */
.grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.5rem;
}
.grid li {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.7rem;
}
.grid li a { font-weight: 600; }
.grid li .muted { display: block; }

.cols {
  list-style: none; padding: 0; margin: 0;
  columns: 4; column-gap: 1.2rem; font-size: 0.92rem;
}
.cols li { break-inside: avoid; padding: 0.1rem 0; }

@media (max-width: 720px) {
  .cols { columns: 2; }
}

/* Comune header */
.comune-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.comune-head h1 { margin: 0; }
.stemma { width: 64px; height: 80px; object-fit: contain; }
.stemma-head { width: 69px; height: 86px; }

.fuel-brand-logo { width: 20px; height: 20px; object-fit: contain; vertical-align: -5px; }

/* Inline icons (monochrome, inherit text colour) */
.icn { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.18em; }
.icn-danger { color: #c0392b; }
.icn-ext { width: 0.8em; height: 0.8em; margin-left: 0.12em; vertical-align: -0.05em; }
h2 .icn, h2 span { vertical-align: middle; }
h2 .icn { margin-right: 0.4rem; }

/* Tables */
.infobox, .data { border-collapse: collapse; width: 100%; margin: 0.6rem 0; font-size: 0.93rem; }
.infobox th, .infobox td, .data th, .data td {
  border: 1px solid var(--line); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top;
}
.infobox th { background: var(--bg-soft); width: 220px; }
.gemellaggio { white-space: nowrap; cursor: default; }
.gemellaggio a { cursor: pointer; }
.gemellaggio + .gemellaggio { margin-left: 0.55rem; }
.data th { background: var(--bg-soft); }
.data tr:nth-child(even) td { background: #fbfcfd; }
/* The row of a reference table (zone climatiche, sismiche) that applies to this comune. */
.data tr.is-current th, .data tr.is-current td { background: var(--bg-soft); font-weight: 600; }
/* The case sparse gloss would otherwise widen the Località column enough to wrap every other
   column; capping it keeps the gloss inside its own row, which just grows taller. */
.frazioni-nota { display: block; max-width: 24rem; }
.inline-list {
  margin: 0;
  padding-left: 1.1rem;
}
.inline-list li {
  margin: 0.08rem 0;
}

/* Population pyramids */
.pyramid svg { display: block; width: 100%; height: auto; }

/* Demographic index trends */
.index-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.8rem;
  margin: 0.8rem 0 1.4rem;
}
.index-chart-grid section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}
.index-chart-grid h3 { margin: 0; font-size: 1rem; }
.index-chart-grid svg { display: block; width: 100%; height: auto; }

/* HTML chart legend — kept outside the SVG so its text does not shrink with the viewBox */
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem;
  margin: 0.5rem 0 0.35rem; font-size: 0.85rem; color: #555;
}
.chart-legend i {
  display: inline-block; width: 15px; height: 3px; border-radius: 2px;
  margin-right: 0.4rem; vertical-align: middle;
}

/* Sub-navigation pills */
.subnav { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.subnav a, .subnav .active, .subnav-link-inline {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.3rem 0.85rem; font-size: 0.88rem;
}
.subnav .active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.subnav-link-inline {
  display: inline-block; padding: 0 0.45rem;
  font-size: inherit; line-height: 1.3; white-space: nowrap;
}

/* Stat cards (used by the stat-hero topic template) */
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.65rem 0.75rem;
}
.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.stat-card strong {
  display: block;
  margin-top: 0.08rem;
  font-size: 1.25rem;
  line-height: 1.15;
}

/* Six-slot stat-topic template: hero numbers, lede sentence, source line, hub topic cards */
.stat-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.6rem;
  margin: 1rem 0 1.1rem;
}
.stat-hero .stat-card { box-shadow: var(--card-shadow); }
.stat-lede {
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0.6rem 0 1.1rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--gold);
  color: var(--ink);
}
.stat-source { color: var(--muted); font-size: 0.82rem; margin: 0.5rem 0 0; }
.topic-grid {
  list-style: none; padding: 0; margin: 1.2rem 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem;
}
.topic-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.7rem 0.85rem; box-shadow: var(--card-shadow);
}
.topic-card a { font-weight: 600; }
.topic-card p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }
.province-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}
.compact-table {
  font-size: 0.9rem;
}
.rank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0.6rem 0 1.4rem;
}
.rank-grid h3 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}
.ranking {
  list-style-position: inside;
  margin: 0;
  padding: 0;
}
.ranking li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--line);
}
.ranking a {
  overflow-wrap: anywhere;
  font-weight: 600;
}
.ranking span {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.86rem;
}

/* Administrative SVG maps */
.map-browse {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(280px, 1.1fr);
  gap: 1rem;
  align-items: start;
  margin: 1rem 0 1.5rem;
}
.it-map-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 0.75rem;
}
.it-svg-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: 620px;
}
.it-svg-map path {
  fill: #e8f2ed;
  stroke: var(--navy);
  stroke-width: 0.45;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill 0.12s ease-out, stroke 0.12s ease-out;
}
.it-svg-map-comuni path {
  stroke-width: 0.25;
}
.it-svg-map-comuni a.pop-bin-0 path { fill: #edf7ef; }
.it-svg-map-comuni a.pop-bin-1 path { fill: #d8eddc; }
.it-svg-map-comuni a.pop-bin-2 path { fill: #bfe1c8; }
.it-svg-map-comuni a.pop-bin-3 path { fill: #93c9a4; }
.it-svg-map-comuni a.pop-bin-4 path { fill: #58a97b; }
.it-svg-map-comuni a.pop-bin-5 path { fill: #2f8d63; }
.it-svg-map-comuni a.pop-bin-6 path { fill: #1f764f; }
.it-svg-map-comuni a.pop-bin-7 path { fill: #155e3d; }
.it-svg-map-comuni a.pop-bin-8 path { fill: #0f472e; }
.it-svg-map-comuni a.pop-bin-9 path { fill: #0a2f20; }
/* Marks the current comune's position on locator maps (issue #44). Not
   interactive: clicks must fall through to the province link underneath. */
.it-svg-map .map-city-dot {
  fill: #d3342c;
  stroke: #fff;
  stroke-width: 1.4;
  pointer-events: none;
}
.it-svg-map a {
  cursor: pointer;
  outline: none;
}
.it-svg-map a:hover path,
.it-svg-map a:focus path,
.it-svg-map a.is-active path {
  fill: #f7c96b;
  stroke: #9f5f10;
}
.it-svg-map-comuni a:hover path,
.it-svg-map-comuni a:focus path,
.it-svg-map-comuni a.is-active path {
  fill: #f7c96b;
  stroke: #9f5f10;
}
.map-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 240px;
  padding: 0.45rem 0.55rem;
  border-radius: 4px;
  background: #1b1f23;
  color: #fff;
  box-shadow: 0 8px 24px rgba(27, 31, 35, 0.22);
  font-size: 0.86rem;
  line-height: 1.25;
}
.map-tooltip strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
}
.map-tooltip span {
  display: block;
  color: #d7dde3;
}
.chart-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: #1b1f23;
  color: #fff;
  box-shadow: 0 8px 24px rgba(27, 31, 35, 0.22);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  /* pre-line: single-line labels stay one line, multi-series labels break at \n */
  white-space: pre-line;
}
.chart-tooltip strong {
  font-weight: 700;
}
svg.trend {
  /* Let a horizontal finger drag scrub the chart readout while a vertical drag
     still scrolls the page; without this touch-action the browser eats every
     drag as a scroll and the tooltip never tracks the finger on mobile. */
  touch-action: pan-y;
}
svg.trend .hb {
  cursor: crosshair;
}
.map-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.45rem;
}
.map-list li {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition: background 0.12s ease-out, border-color 0.12s ease-out;
}
.map-list li.is-active {
  border-color: #d08a22;
  background: #fff7df;
}
.map-list li a {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  font-weight: 600;
}
.map-list li .muted {
  display: block;
}
.territory-section {
  margin: 1rem 0 1.5rem;
}
.territory-map-frame {
  max-width: 760px;
  margin-bottom: 1rem;
}
.territory-index {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.25rem 0.8rem;
  font-size: 0.92rem;
}
.territory-index li {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.28rem 0.45rem;
  border-radius: 4px;
}
.territory-index li.is-active {
  background: #fff7df;
}
.territory-index a {
  overflow-wrap: anywhere;
  font-weight: 600;
}
.territory-index .muted {
  white-space: nowrap;
  font-size: 0.82rem;
}

/* Alphabetical comuni index (region-level list page) */
.letter-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 1rem 0; }
.letter-nav a {
  min-width: 1.9rem; text-align: center;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0.2rem 0.35rem; font-weight: 600; font-size: 0.9rem;
}
.letter-nav a:hover { border-color: var(--accent); }
.letter-head { margin-bottom: 0.4rem; }
:target { scroll-margin-top: 1rem; }

/* Contextual page shell: persistent sidebar + body */
.page-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 1.6rem;
  align-items: start;
}
.context-sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  font-size: 0.9rem;
}
.page-body { min-width: 0; }

.context-locator {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  padding: 0.5rem;
  margin-bottom: 0.9rem;
}
.context-locator .it-svg-map { max-height: 320px; }

.context-nav .group-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.9rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.context-nav .group-title .icn { width: 1em; height: 1em; }
.context-nav ul { list-style: none; margin: 0; padding: 0; }
.context-nav li { margin: 0; }
.context-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.34rem 0.6rem;
  border-radius: 5px;
  color: var(--ink);
  line-height: 1.25;
}
.context-nav a .icn { color: var(--muted); }
.context-nav a:hover { background: var(--bg-soft); text-decoration: none; }
.context-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.context-nav a.active .icn { color: #fff; }

/* Mobile-only quick-links strip near the top of the comune page. The full
   context rail is alongside the content on desktop but reflows to the page
   bottom at <=860px, so on mobile we surface the hottest sections up top. */
.quick-nav { display: none; }
@media (max-width: 860px) {
  .quick-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 0 1.1rem;
  }
  .quick-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
  }
  .quick-nav a .icn { width: 1em; height: 1em; color: var(--muted); }
  .quick-nav a:hover { border-color: var(--accent); text-decoration: none; }
}

/* Comune data card: infobox + contatti in the left column, at-a-glance
   cards in the aside. The two-row template lets the contatti block fill
   the space under the infobox instead of leaving a gap when the aside
   runs taller. */
.comune-card.has-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 256px;
  /* auto 1fr keeps the infobox row at its natural height, so a taller aside
     pushes leftover space below the contatti block, not between the two. */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "info aside"
    "contatti aside";
  gap: 1.2rem;
  align-items: start;
}
.comune-card.has-aside > .infobox { grid-area: info; }
.comune-card.has-aside > .comune-aside { grid-area: aside; }
.comune-card.has-aside > .comune-contatti { grid-area: contatti; min-width: 0; }
.comune-contatti h2:first-child { margin-top: 0; }
.comune-card .infobox { margin-top: 0; }
.comune-aside { display: flex; flex-direction: column; gap: 0.8rem; }

/* At-a-glance "operational" cards (pronto soccorso, cheapest fuel) */
.quick-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0.7rem 0.8rem;
  box-shadow: var(--card-shadow);
}
.quick-emergency { border-left: 3px solid #c0392b; }
.quick-pharmacy { border-left: 3px solid #2e7d32; }
.quick-fuel { border-left: 3px solid var(--accent); }
.quick-flag { border-left: 3px solid #1565c0; }
.icn-blue { color: #1565c0; }
.icn-green { color: #2e7d32; }
.quick-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.quick-line {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.3rem 0;
  font-size: 0.9rem;
}
.quick-line + .quick-line { border-top: 1px solid var(--line); }
.quick-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.quick-fuel .quick-line { flex-direction: row; align-items: baseline; justify-content: space-between; }
.quick-fuel .quick-val strong { font-size: 1.05rem; }
.quick-note { margin: 0.4rem 0 0; font-size: 0.82rem; }
.quick-more { display: inline-block; margin-top: 0.5rem; font-size: 0.85rem; font-weight: 600; }

/* Redditi IRPEF: income-bracket distribution bars */
.fasce { margin: 0.6rem 0 0.4rem; max-width: 640px; }
.fascia-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 130px;
  gap: 0.6rem;
  align-items: center;
  padding: 0.18rem 0;
  font-size: 0.9rem;
}
.fascia-label { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.fascia-bar { background: var(--bg-soft); border-radius: 4px; height: 14px; overflow: hidden; }
.fascia-bar i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.fascia-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) {
  .fascia-row { grid-template-columns: 96px minmax(0, 1fr) 116px; font-size: 0.82rem; }
}

/* Bandiera Blu pages */
.bb-years { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.4rem; }
.bb-year {
  display: inline-block; padding: 0.25rem 0.6rem; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  background: #fff; color: var(--accent); text-decoration: none;
}
.bb-year:hover { background: #f0f6ff; }
.bb-year.is-current { background: #1565c0; border-color: #1565c0; color: #fff; }
.bb-regione { display: flex; align-items: center; gap: 0.4rem; margin: 1.6rem 0 0.4rem; }
.bb-provincia { margin: 0.9rem 0 0.3rem; font-size: 1rem; color: var(--muted); }
.bb-comuni { margin: 0 0 0.6rem; padding-left: 1.2rem; columns: 2; column-gap: 2rem; }
.bb-comuni li { margin: 0.15rem 0; break-inside: avoid; }
.bb-spiagge { color: var(--muted); font-size: 0.88rem; }
.bb-spiagge::before { content: " — "; }
@media (max-width: 600px) { .bb-comuni { columns: 1; } }
.bb-pin {
  width: 18px; height: 18px; border-radius: 50%;
  background: #1565c0; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.bb-map-note { margin: 0.4rem 0 1.2rem; }

/* Reti di comuni */
.rc-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem; margin: 1.2rem 0;
}
.rc-card {
  display: flex; flex-direction: column; gap: 0.3rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; box-shadow: var(--card-shadow);
  padding: 0.8rem 0.9rem; text-decoration: none; color: inherit;
}
.rc-card:hover { border-color: var(--accent); }
.rc-card-title { font-weight: 700; color: var(--accent); }
/* Emoji render taller than the surrounding text; nudge them back onto the baseline. */
.rete-emoji { font-size: 0.95em; line-height: 1; }
.rc-card-count { font-size: 0.88rem; font-weight: 600; }
.rc-card-desc { font-size: 0.88rem; color: var(--muted); }
.rete-badge {
  display: inline-block; padding: 0.1rem 0.55rem; margin: 0.1rem 0.15rem 0.1rem 0;
  border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: #f6f9f6; text-decoration: none;
}
.rete-badge:hover { border-color: var(--accent); }
.rc-scheda { max-width: 640px; }
.rc-filtri { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0 0.8rem; }
.rc-filtro {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 0.88rem; font-weight: 600; cursor: pointer;
  user-select: none;
}
.rc-filtro:hover { border-color: var(--accent); }
.rc-filtro:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.rc-filtro:has(input:not(:checked)) { opacity: 0.45; }
.rc-filtro input { position: absolute; opacity: 0; pointer-events: none; }
.rc-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.15);
}
.rc-filtro-n { color: var(--muted); font-weight: 400; }
.rc-premiati {
  list-style: none; padding: 0; margin: 1rem 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.6rem;
}
.rc-premiato {
  display: flex; flex-direction: column; gap: 0.15rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.55rem 0.7rem; box-shadow: var(--card-shadow);
}
.rc-premiato-nome { font-weight: 600; }
.rc-premiato-reg { font-size: 0.85rem; }
.rc-premiato-badges { margin-top: 0.1rem; }
.rc-mini-badge { font-size: 0.95rem; margin-right: 0.2rem; cursor: default; }
.rc-scroll { overflow-x: auto; }
.rc-matrix td, .rc-matrix th { text-align: center; white-space: nowrap; }
.rc-matrix thead th { white-space: normal; min-width: 5.5rem; }
.rc-matrix th[scope="row"], .rc-matrix thead th:first-child { text-align: left; }
.rc-matrix thead th a { text-decoration: none; }
.rc-matrix-tot td, .rc-matrix-tot th { border-top: 2px solid var(--muted); }

/* Calendario scolastico */
.cs-years { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1.4rem; }
.cs-year {
  display: inline-block; padding: 0.25rem 0.6rem; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  background: #fff; color: var(--accent); text-decoration: none;
}
.cs-year:hover { background: #f0f6ff; }
.cs-year.is-current { background: #1565c0; border-color: #1565c0; color: #fff; }
.cs-table th[scope="row"] { text-align: left; }
.cs-nota { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); margin-top: 0.15rem; }
.cs-sospensioni, .cs-festivita { margin: 0; padding-left: 1.1rem; }
.cs-sospensioni li, .cs-festivita li { margin: 0.1rem 0; }
.cs-sospensioni { font-size: 0.88rem; }
.quick-calendario .cs-mini { margin: 0.3rem 0 0; font-size: 0.9rem; }
.quick-calendario .cs-mini dt { font-weight: 600; color: var(--muted); }
.quick-calendario .cs-mini dd { margin: 0 0 0.35rem; }

/* Visual month-grid calendar component */
.cs-cal { margin: 0 0 1.6rem; }
.cs-cal-controls { margin: 0 0 0.4rem; }
.cs-cal-pick { font-weight: 600; }
.cs-cal-pick select { margin-left: 0.4rem; font: inherit; padding: 0.2rem 0.4rem; border: 1px solid var(--line); border-radius: var(--radius); }
.cs-cal-only { font-weight: 700; margin: 0; }
.cs-cal-summary p { margin: 0.2rem 0 0.6rem; }
.cs-cal-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 0 0 1rem; font-size: 0.85rem; color: var(--muted); }
.cs-leg { display: inline-flex; align-items: center; gap: 0.35rem; }
.cs-sw { width: 0.85rem; height: 0.85rem; border-radius: 3px; display: inline-block; border: 1px solid rgba(0,0,0,.12); }
.cs-cal-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.cs-month-name { font-weight: 700; font-size: 0.95rem; margin: 0 0 0.35rem; }
.cs-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cs-dow { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--muted); padding-bottom: 2px; }
.cs-day {
  text-align: center; font-size: 0.78rem; line-height: 1.9; border-radius: 3px;
  border: 1px solid rgba(0,0,0,.06);
}
.cs-blank { border: 0; }
/* Day-type colors (also used as legend swatches) */
.cs-lez  { background: #eef4ff; color: #1a3a5c; }
.cs-fest { background: #ffd6d6; color: #8a1f1f; font-weight: 600; }
.cs-nat  { background: #e3dbff; color: #3a2a6b; }
.cs-pas  { background: #d7f0de; color: #1d5a32; }
.cs-sosp { background: #ffe3c2; color: #8a4b12; }
.cs-we   { background: #f1f1f1; color: #aaa; }
.cs-out  { background: #fff; color: #ccc; border-color: rgba(0,0,0,.03); }
.cs-start, .cs-end { background: #1565c0; color: #fff; font-weight: 700; border-color: #1565c0; }
/* Keep each day's category color visible inside today's teal outline. */
.cs-today { box-shadow: inset 0 0 0 2px #00796b, inset 0 0 0 3px #fff; font-weight: 700; }
i.cs-sw.cs-lez, i.cs-sw.cs-fest, i.cs-sw.cs-nat, i.cs-sw.cs-pas, i.cs-sw.cs-sosp, i.cs-sw.cs-we { line-height: 0; }
@media (max-width: 520px) { .cs-cal-months { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }

/* Desktop: keep sidebar visually on the left even though it follows the
   content in source order (so mobile shows content first). */
.context-sidebar { order: -1; }

@media (max-width: 860px) {
  .page-shell { grid-template-columns: 1fr; }
  .context-sidebar { position: static; order: 0; }
  .context-locator { max-width: 340px; }
}
@media (max-width: 640px) {
  .comune-card.has-aside {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-template-areas: "info" "aside" "contatti";
  }
}

/* Map */
#map { height: 460px; border: 1px solid var(--line); border-radius: var(--radius); }

/* School cards on comune scuole page */
h2 .count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.school-heading {
  display: flex; align-items: center; gap: 0.5rem;
}
.school-heading .school-kind-icon {
  width: 24px; height: 24px; flex: 0 0 auto;
}
.school-kind-section {
  margin: 1rem 0 0.35rem; color: var(--muted);
  font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0;
}
.school-kind-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.7rem; margin: 0.7rem 0 1.4rem;
}
.school-kind {
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  padding: 0.75rem 0.9rem; display: grid; align-items: center;
  grid-template-columns: 28px 1fr auto; gap: 0.7rem;
}
.school-kind-icon {
  width: 28px; height: 28px; color: var(--accent);
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.school-kind span { overflow-wrap: anywhere; }
.school-kind strong { color: var(--muted); font-size: 0.9rem; }
.school-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 0.8rem; margin: 0.6rem 0 1.4rem;
}
.school {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; background: #fff;
}
.school h3 { margin: 0 0 0.3rem; font-size: 1.0rem; line-height: 1.3; }
.school p { margin: 0.25rem 0; font-size: 0.88rem; }
.school .addr { color: var(--ink); }
.school .parent { color: var(--muted); font-size: 0.85rem; }
.school .meta { color: var(--muted); font-size: 0.82rem; }
.school .meta code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; }
.school .contacts { font-size: 0.82rem; word-break: break-word; }
.school .contacts .sep { color: var(--line); margin: 0 4px; }

.bank-heading { margin: 1.3rem 0 0.5rem; font-size: 1.05rem; }
.bank-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.8rem; margin: 0.5rem 0 1.2rem;
}
.bank {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.7rem 0.9rem; background: #fff;
}
.bank p { margin: 0.2rem 0; font-size: 0.88rem; }
.bank .addr { color: var(--ink); }
.bank .loc { color: var(--muted); font-size: 0.85rem; }
.bank .meta { color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.bank .meta code { background: var(--bg-soft); padding: 1px 6px; border-radius: 3px; }
.bank .meta .tipo { text-transform: capitalize; }

@media (max-width: 720px) {
  .map-browse { grid-template-columns: 1fr; }
  .province-grid,
  .rank-grid { grid-template-columns: 1fr; }
  .territory-index { grid-template-columns: 1fr; }
}

/* Visually-hidden labels */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header search */
.site-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 320px;
  max-width: 620px;
  margin-left: 1.75rem;
}
.site-search input[type="search"] {
  width: 100%;
  padding: 0.62rem 0.9rem 0.62rem 2.4rem;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235a6e80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 0.8rem center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.site-search input[type="search"]:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.12);
}
.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(30, 58, 95, 0.16);
  padding: 0.25rem;
  z-index: 70;
  max-height: 70vh;
  overflow-y: auto;
}
.search-result {
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  color: var(--ink);
}
.search-result:hover,
.search-result.is-active {
  background: var(--bg-soft);
  text-decoration: none;
}
.search-result-title { font-weight: 600; color: var(--navy); }
.search-result-subtitle { font-size: 0.8rem; color: var(--muted); }


/* /cerca results page */
.cerca-page {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}
.cerca-page input[type="search"] {
  flex: 1 1 auto;
  padding: 0.5rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cerca-page button {
  padding: 0.5rem 1.1rem;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.cerca-results { list-style: none; padding: 0; margin: 0; }
.cerca-results li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.cerca-results li .muted { display: block; }

/* Codici catastali */
.cc-table { max-width: 720px; }
.cc-hint {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 0.7rem 0.85rem;
  margin: 1.2rem 0 1.6rem;
}

/* Homepage entry points */
.home-stats { display: grid; gap: 1.5rem; grid-template-columns: 2fr 1fr; align-items: start; margin: 1.2rem 0 0; }
.home-stats h3 { margin: 0 0 0.45rem; font-size: 1rem; }
.home-stats .trend svg { width: 100%; height: auto; }
.ranking { margin: 0; padding-left: 1.4rem; }
.ranking li { margin: 0.2rem 0; }
.ranking li .muted { margin-left: 0.4rem; }
.entry-points {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.entry-points a {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.entry-points a:hover { background: #fff; border-color: var(--navy); text-decoration: none; }

/* Homepage hero: proposition + comune search on the left, region map on the right,
   so the page's promise ("comuni") is answered in the first viewport. */
.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 380px);
  gap: 1.5rem;
  align-items: start;
  margin: 0.4rem 0 1.6rem;
}
.home-hero-intro h1 { font-size: 1.9rem; }
.home-hero-map {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.home-hero-map .it-svg-map { width: 100%; max-height: 500px; }
.hero-regioni-title { margin: 1.3rem 0 0.7rem; font-size: 1rem; }
.hero-search {
  margin: 1rem 0 0;
  max-width: 560px;
  flex: none;
  gap: 0.5rem;
}
.hero-search input[type="search"] {
  flex: 1 1 auto;
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  font-size: 1.1rem;
}
.hero-search button {
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
.hero-examples { margin-top: 0.8rem; }
.hero-examples a { padding: 0.3rem 0.8rem; font-size: 0.9rem; }

/* Homepage "Oggi in Italia": daily-refreshed utilities (pharmacies, fuel, ER). */
.today-date {
  margin-left: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}
.today-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0.6rem 0 1.8rem;
}
.today-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--card-shadow);
  color: var(--ink);
}
.today-card:hover { border-color: var(--navy); text-decoration: none; }
.today-pharmacy { border-left-color: #2e7d32; }
.today-fuel { border-left-color: var(--accent); }
.today-emergency { border-left-color: #c0392b; }
.today-school { border-left-color: var(--gold); }
.today-icon { flex: 0 0 auto; font-size: 20px; line-height: 1.4; }
.today-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.today-body strong { color: var(--navy); font-size: 0.95rem; }
.today-body .muted { font-size: 0.82rem; }

.region-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.4rem;
}
.region-links li {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  transition: background 0.12s ease-out, border-color 0.12s ease-out;
}
.region-links li.is-active { border-color: #d08a22; background: #fff7df; }
.region-links li a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}
.region-links li .muted { font-size: 0.78rem; }

@media (max-width: 760px) {
  /* Mobile: search stays the hero; the map yields to the region pills below. */
  .home-hero { grid-template-columns: 1fr; }
  .home-hero-map { display: none; }
}

/* Homepage feature cards (timely content) */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin: 0.6rem 0 1.8rem;
}
.feature-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: var(--card-shadow);
  color: var(--ink);
}
.feature-card:hover { background: #fff; border-left-color: var(--navy); text-decoration: none; }
.feature-body { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.feature-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 24px;
  line-height: 1;
}
.feature-icon-flag { background: #e3f0fb; }
.feature-icon-school { background: #fbf0db; }
.feature-icon-fuel { background: #fbe4e4; }
.feature-icon-emergency { background: #fdeee0; }
.feature-icon-tin { background: #e6f4ea; }
.feature-kicker {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.feature-card strong { color: var(--navy); font-size: 1.05rem; }

/* Homepage demographic superlatives */
.superlatives {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0.6rem 0 1.8rem;
}
.superlative-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  color: var(--ink);
}
.superlative-card:hover { border-color: var(--navy); text-decoration: none; }
.superlative-card strong { color: var(--navy); }
.superlative-value { font-size: 1.15rem; font-weight: 700; color: var(--ink); }

/* Homepage "Esplora per tema": grouped directory of the site's hub pages */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem 1.2rem;
  margin: 0.6rem 0 1.6rem;
}
.theme-group h3 {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.theme-group ul { list-style: none; margin: 0; padding: 0; }
.theme-group li { margin: 0; }
.theme-group a {
  display: block;
  padding: 0.28rem 0;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.home-fonti {
  margin: 1.6rem 0 0;
  padding-left: 0.85rem;
  border-left: 3px solid var(--gold);
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .today-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .home-stats { grid-template-columns: 1fr; }
  .feature-cards,
  .superlatives { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .today-strip { grid-template-columns: 1fr; }
  .hero-search button { display: none; }
}

/* Comuni limitrofi page: generated lead, local adjacency map, confinanti
   comparison table, reference-centre cards, nearby chips. */
.lm-lead { max-width: 65ch; font-size: 1.02rem; margin: 0.9rem 0 1.2rem; }

.lm-map {
  margin: 1rem 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 0.6rem;
  background: #fff;
}
.lm-map svg { display: block; width: 100%; height: auto; max-height: 520px; margin: 0 auto; }
.lm-map figcaption {
  display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem;
  padding: 0.5rem 0.3rem 0; font-size: 0.82rem; color: var(--muted);
}
.lm-lg { display: inline-flex; align-items: center; gap: 0.35rem; }
.lm-sw { width: 0.85rem; height: 0.85rem; border-radius: 3px; border: 1px solid #8fa3b8; }
.lm-sw-self { background: var(--gold); }
.lm-sw-conf { background: #c8d7e8; }
.lm-sw-ctx { background: #eef2f6; }
.lm-map path.lm-ctx  { fill: #eef2f6; stroke: #8fa3b8; stroke-width: 0.7; }
.lm-map path.lm-conf { fill: #c8d7e8; stroke: #8fa3b8; stroke-width: 0.8; }
.lm-map path.lm-self { fill: var(--gold); stroke: var(--navy); stroke-width: 1.2; }
.lm-map path.lm-conf:hover { fill: #a9c1dc; }
.lm-map path.lm-ctx:hover  { fill: #c8d7e8; }
.lm-map text {
  font-family: inherit; fill: var(--ink);
  paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round;
  text-anchor: middle; pointer-events: none;
}
.lm-lbl-self { font-size: 15px; font-weight: 700; }
.lm-lbl-conf { font-size: 11.5px; }
.lm-lbl-centro { font-size: 13px; font-weight: 700; fill: var(--navy); }
.lm-dot { fill: var(--navy); stroke: #fff; stroke-width: 1.5; pointer-events: none; }

.lm-tbl { overflow-x: auto; }
.lm-confinanti td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lm-confinanti td:first-child a { font-weight: 600; }

.lm-centri {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.6rem; margin: 0.8rem 0 0.5rem;
}
.lm-centro {
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 0.6rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.15rem;
}
.lm-ruolo {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); font-weight: 600;
}
.lm-centro-nome { font-size: 1.12rem; font-weight: 700; }
.lm-centro-dist { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.45rem; }
.lm-chip {
  font-size: 0.68rem; padding: 0.06rem 0.45rem; border-radius: 999px;
  font-weight: 600; border: 1px solid var(--gold); color: var(--gold);
}
.lm-vicini { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.7rem 0; }
.lm-vicino {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.22rem 0.75rem; font-size: 0.88rem; font-weight: 600;
}
.lm-vicino span { color: var(--muted); font-weight: 400; margin-left: 0.45rem; font-size: 0.8rem; }
.lm-vicino:hover { border-color: var(--gold); text-decoration: none; }
.lm-metodo { margin-top: 1.6rem; }
