/**
 * RGPBIO WebGIS – tema globale
 * Palette istituzionale (verde), superfici neutre, componenti compatti.
 */
@import url("https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600;700&display=swap");

:root {
  --inst-green-950: #052e16;
  --inst-green-900: #0d3320;
  --inst-green-800: #14532d;
  --inst-green-700: #166534;
  --inst-green-600: #1a7a3e;
  --inst-green-soft: rgba(22, 101, 52, 0.08);
  --inst-green-soft-hover: rgba(22, 101, 52, 0.14);
  --brand-green: var(--inst-green-900);
  --brand-red: #b91c1c;
  --bg: #eef1ee;
  --panel: #ffffff;
  --surface-muted: #f4f6f4;
  --text: #161c18;
  --muted: #5f6962;
  --border: #d1d9d3;
  --border-strong: #b8c4bb;
  --shadow-sm: 0 1px 2px rgba(15, 40, 25, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 40, 25, 0.1);
  --shadow-lg: 0 8px 28px rgba(15, 40, 25, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --fs: 0.8125rem;
  --space-1: 3px;
  --space-2: 5px;
  --space-3: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ─── Layout griglia ─── */
.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(200px, 216px) 1fr minmax(200px, 222px);
  gap: 0;
}

.panel {
  background: var(--panel);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.panel-right {
  border-right: 0;
  border-left: 1px solid var(--border);
}

.panel-section {
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  flex-shrink: 0;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.panel-section > h3 {
  margin: 0 0 var(--space-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--inst-green-800);
  cursor: default;
}

.panel-section > h3[data-collapse] {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel-section > h3[data-collapse]::before {
  content: "\25BE";
  font-size: 0.65em;
  color: var(--muted);
  font-weight: 400;
}

.panel-section.collapsed > *:not(h3) { display: none; }
.panel-section.collapsed > h3[data-collapse]::before { content: "\25B8"; }

/* Logo pannello sinistro */
#panelLogo {
  margin-top: auto;
  padding: var(--space-3) var(--space-2) var(--space-1);
  text-align: center;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, var(--surface-muted));
}

#panelLogo img {
  max-height: 64px;
  max-width: 92%;
  object-fit: contain;
  display: inline-block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.08));
}

/* ─── Mappa ─── */
.map-section { position: relative; min-width: 0; background: #dfe5e0; }
#map { position: absolute; inset: 0; }

/* OpenLayers – controlli compatti */
.map-section .ol-zoom {
  top: var(--space-3);
  left: var(--space-3);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.map-section .ol-zoom button {
  width: 30px;
  height: 30px;
  line-height: 28px;
  font-size: 1.1rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.96);
  color: var(--inst-green-900);
  transition: background 0.12s ease, color 0.12s ease;
}
.map-section .ol-zoom button:hover {
  background: var(--inst-green-700);
  color: #fff;
}
.map-section .ol-zoom-in { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.map-section .ol-zoom-out { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.map-section .ol-scale-line {
  bottom: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-xs);
  padding: 2px 6px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.map-section .ol-scale-line-inner {
  border-color: var(--inst-green-800);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
}

.map-section .ol-full-screen,
.map-section .ol-zoomslider {
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}
.map-section .ol-zoomslider { top: 5.5rem; left: var(--space-3); }

/* ─── Popup attributi ─── */
.feature-popup {
  position: absolute;
  z-index: 950;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: min(320px, 94vw);
  max-width: min(720px, 96vw);
  padding: 0;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  max-height: min(560px, 82vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: opacity 0.18s ease;
}

.feature-popup.visible { opacity: 1; }

.feature-popup::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px 7px 0;
  border-style: solid;
  border-color: var(--panel) transparent transparent transparent;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.06));
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--inst-green-800), var(--inst-green-700));
  color: #fff;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  flex-shrink: 0;
}

.popup-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.12s ease;
}
.popup-close:hover { background: rgba(255, 255, 255, 0.28); color: #fff; }

.feature-popup-content {
  padding: 10px 12px;
  overflow-y: auto;
  flex: 1;
  background: var(--surface-muted);
}

/* Tabelle attributi (popup + modale): leggibilità prioritaria */
.popup-tbl {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}
.popup-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: inherit;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: top;
  color: var(--text);
}
/* Righe a due colonne: prima cella senza colspan (es. HTML da server) */
.popup-tbl td:first-child:not([colspan]) {
  width: 38%;
  max-width: 40%;
  font-weight: 700;
  color: #2a332c;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
}
.popup-tbl tbody tr:nth-child(even) td:not([colspan]) {
  background: rgba(22, 101, 52, 0.04);
}
.popup-tbl tbody tr:nth-child(even) td.gfi-key {
  background: #e8ede9;
}
.popup-tbl tr:last-child td {
  border-bottom: none;
}
.popup-tbl th {
  padding: 10px 12px;
  font-size: inherit;
  font-weight: 700;
  text-align: left;
  color: var(--inst-green-900);
  background: var(--inst-green-soft);
  border-bottom: 1px solid var(--border-strong);
}
.popup-tbl td[colspan] {
  width: auto;
  max-width: none;
  white-space: normal;
  border-right: none;
}

.gfi-section {
  font-size: 0.76rem;
  font-weight: 700;
  margin: 6px 0 4px;
  color: var(--inst-green-800);
}
.gfi-loading {
  text-align: center;
  padding: var(--space-3);
  color: var(--muted);
  font-size: 0.74rem;
}
.gfi-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--inst-green-600);
  border-radius: 50%;
  margin-right: 6px;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}
.gfi-divider { margin: 6px 0; border: none; border-top: 1px solid var(--border); }
.gfi-iframe {
  width: 100%;
  min-height: 140px;
  max-height: 260px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-muted);
  display: block;
}
.gfi-empty { padding: 14px 12px; text-align: center; color: var(--text); font-size: 0.875rem; line-height: 1.5; }
.gfi-raw {
  margin: 0;
  padding: 6px;
  font-size: 0.68rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

/* ─── Toolbar e bottoni ─── */
.toolbar-inline {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.stack { display: grid; gap: var(--space-2); }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-xs);
  padding: 4px 9px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.76rem;
  font-family: inherit;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}
.btn:hover {
  border-color: var(--inst-green-600);
  background: var(--inst-green-soft);
  box-shadow: var(--shadow-md);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, var(--inst-green-700), var(--inst-green-800));
  color: #fff;
  border-color: var(--inst-green-800);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--inst-green-600), var(--inst-green-700));
  border-color: var(--inst-green-700);
  color: #fff;
}

.btn-manual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: var(--fs);
  font-weight: 600;
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--inst-green-800);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-manual:hover {
  background: var(--inst-green-soft);
  border-color: var(--inst-green-600);
  color: var(--inst-green-700);
}

.btn-danger {
  background: linear-gradient(180deg, #dc2626, var(--brand-red));
  color: #fff;
  border-color: #991b1b;
}
.btn-danger:hover {
  filter: brightness(1.05);
  color: #fff;
}

.btn-sm {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.btn-sm:hover {
  border-color: var(--inst-green-600);
  background: var(--inst-green-soft);
}

input, select, textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  padding: 4px 7px;
  min-height: 28px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.78rem;
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 2px var(--inst-green-soft);
}

input[type="range"] { padding: 0; min-height: auto; }

progress {
  width: 100%;
  height: 5px;
  appearance: none;
  border: none;
  background: var(--border);
  border-radius: 3px;
}
progress::-webkit-progress-bar { background: var(--border); border-radius: 3px; }
progress::-webkit-progress-value { background: var(--inst-green-700); border-radius: 3px; }

#measureResult {
  font-weight: 700;
  color: var(--brand-red);
  font-size: 0.78rem;
  min-height: 1.15em;
  margin-top: 2px;
}

/* Basemap */
.basemap-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) 0 0;
  font-size: 0.72rem;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
}
.basemap-toggle input[type="checkbox"] { margin: 0; width: 14px; height: 14px; accent-color: var(--inst-green-700); }

/* Disegno */
.draw-btn { min-width: 0; padding: 4px 7px; font-size: 0.72rem; }
.draw-btn.draw-active {
  background: var(--inst-green-800);
  color: #fff;
  border-color: var(--inst-green-900);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.draw-style-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-1) 0;
  font-size: 0.7rem;
  color: var(--muted);
}
.draw-style-bar label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.draw-style-bar input[type="color"] {
  width: 24px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0;
  cursor: pointer;
}
.draw-style-bar input[type="range"] { height: 14px; cursor: pointer; accent-color: var(--inst-green-700); }
.draw-style-bar span { font-weight: 600; min-width: 28px; color: var(--text); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--inst-green-600);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  background: var(--inst-green-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.drop-zone:hover { background: var(--inst-green-soft-hover); }
.drop-zone.drag-over {
  background: rgba(22, 101, 52, 0.18);
  border-style: solid;
}

/* Overlay mappa */
#compassRose {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
  z-index: 900;
  width: 68px;
  height: 68px;
  pointer-events: none;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.22)) drop-shadow(0 1px 2px rgba(0,0,0,0.14));
}
#compassRose svg { width: 100%; height: 100%; overflow: visible; }

#mapScaleReadout {
  position: absolute;
  left: var(--space-3);
  bottom: 68px;
  z-index: 900;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--inst-green-900);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  letter-spacing: 0.02em;
}

#coordReadout {
  position: absolute;
  left: var(--space-3);
  bottom: 44px;
  z-index: 900;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-sm);
  max-width: min(420px, 55vw);
  pointer-events: none;
  line-height: 1.3;
}

/* Firma autore (obbligatoria – discreta) */
#mapAuthorSig {
  position: absolute;
  left: var(--space-3);
  bottom: 6px;
  z-index: 901;
  margin: 0;
  padding: 0;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #4a5560;
  opacity: 0.62;
  pointer-events: none;
  user-select: none;
  font-family: inherit;
}

#footerCredit {
  position: absolute;
  right: var(--space-3);
  bottom: 6px;
  z-index: 900;
  max-width: min(560px, 52vw);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 0.74rem;
  font-style: italic;
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  line-height: 1.25;
}

/* Banner errore */
.error-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: #b91c1c;
  color: #fff;
  padding: 8px 20px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
}

/* Lista WMS */
.wms-opacity-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px 0 var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-1);
}
.wms-opacity-bar label { font-size: 0.68rem; color: var(--muted); white-space: nowrap; font-weight: 600; }
.wms-opacity-bar input[type="range"] {
  flex: 1;
  min-width: 48px;
  height: 12px;
  accent-color: var(--inst-green-700);
  cursor: pointer;
}
.wms-opacity-bar span { font-size: 0.68rem; font-weight: 700; min-width: 30px; text-align: right; color: var(--inst-green-800); }

.wms-list { display: flex; flex-direction: column; gap: 2px; }

.wms-service-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}
.wms-service-bar label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}
.wms-service-select {
  width: 100%;
  font: inherit;
  padding: 5px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--panel);
}
.wms-pick-list {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.wms-row {
  display: flex;
  align-items: flex-start;   /* titoli multi-riga: controlli ancorati al top */
  gap: 7px;
  padding: 7px 4px 7px 3px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.4;
  border-radius: var(--radius-xs);
  border-bottom: 1px solid rgba(209, 217, 211, 0.55);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.wms-row:last-child { border-bottom: none; }
.wms-row:hover { background: var(--inst-green-soft); }
.wms-row:hover .wms-label { color: var(--inst-green-900); }

/* Checkbox allineato otticamente alla prima riga del titolo */
.wms-row input[type="checkbox"] {
  margin: 2px 0 0;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--inst-green-700);
  cursor: pointer;
}

/* Titolo layer — multi-riga, word-wrap abilitato, no troncamento fisso */
.wms-row .wms-label {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  color: var(--text);
}

/* Compatibilità: span generico figlio di .wms-row (vecchie righe non-advanced) */
.wms-row > span:not(.wms-status-dot):not(.wms-label) {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  color: var(--text);
}

/* Highlight occorrenze di ricerca all'interno dei titoli */
.wms-row .wms-label mark,
.wms-row > span mark,
.wms-pick-row span mark {
  background: rgba(255, 210, 0, 0.55);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
  font-weight: 600;
}

/* Riga trovata dalla ricerca — bordo verde + sfondo tenue */
.wms-row.wms-search-match {
  background: rgba(22, 101, 52, 0.06);
  border-left: 2px solid var(--inst-green-600);
  padding-left: 1px;
}

/* Messaggio vuoto "Nessun layer trovato" */
.wms-empty-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}
.wms-empty-msg svg { opacity: 0.35; }
.wms-empty-msg strong { color: var(--text); font-size: 0.82rem; }
/* Il dot di stato è un cerchio a dimensione fissa — ancorato in alto */
.wms-row .wms-status-dot {
  flex: none;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 5px;          /* allineamento ottico al centro della prima riga testo */
  min-width: 7px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.catasto-copyright {
  font-size: 0.65rem;
  color: var(--muted);
  font-style: italic;
  padding: var(--space-2) 2px 2px;
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
  line-height: 1.3;
}

/* SITAP */
.sitap-tree { display: flex; flex-direction: column; gap: var(--space-2); }
.sitap-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.sitap-group-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px var(--space-3);
  background: linear-gradient(180deg, var(--surface-muted), var(--panel));
  cursor: pointer;
  user-select: none;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--inst-green-800);
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}
.sitap-group-header:hover { background: var(--inst-green-soft); }
/* span generico nel header (checkbox, arrow): non troncare */
.sitap-group-header span { overflow: visible; white-space: normal; }
/* Titolo gruppo: testo visibile su più righe */
.sitap-group-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  word-break: break-word;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--inst-green-800);
  padding-top: 1px;
}
.sitap-count-badge {
  flex: 0 0 auto;
  background: var(--inst-green-700, #2e7d32);
  color: #fff;
  font-size: 0.63rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
  margin-top: 1px;
}
/* Freccia allineata al top quando il titolo va su più righe */
.sitap-arrow { margin-top: 2px; flex-shrink: 0; }
.sitap-group-chk { margin: 0; width: 14px; height: 14px; flex-shrink: 0; cursor: pointer; accent-color: var(--inst-green-700); }
.sitap-arrow::after { content: "\25BE"; font-size: 0.65em; color: var(--muted); }
.sitap-group.collapsed .sitap-arrow::after { content: "\25B8"; }
.sitap-group.collapsed .sitap-group-body { display: none; }
.sitap-group-body { padding: 2px 0; background: var(--panel); }
.sitap-group-body .wms-row { padding-left: 20px; font-size: 0.71rem; }
.sitap-empty { font-size: 0.7rem; color: var(--muted); padding: 4px 20px; font-style: italic; }

/* Layer vettoriali */
.layer-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  display: grid;
  gap: var(--space-2);
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
}
.layer-row { display: flex; align-items: center; gap: 6px; }
.layer-row input[type="checkbox"] {
  margin: 0;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  accent-color: var(--inst-green-700);
}
.layer-title {
  font-weight: 600;
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.layer-btns { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ── Sub-lista foto georeferenziate nel pannello layer ── */
.geoimg-photo-list {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.geoimg-photo-list-hdr {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 2px 2px 2px;
}
.geoimg-photo-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 3px 5px;
  min-height: 40px;
}
.geoimg-photo-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.geoimg-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.geoimg-photo-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.geoimg-photo-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.geoimg-photo-gps {
  font-size: 0.62rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.geoimg-photo-acts {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

/* Geocode */
.gc-item {
  padding: 4px 6px;
  cursor: pointer;
  font-size: 0.74rem;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-xs);
  transition: background 0.1s ease;
}
.gc-item:hover { background: var(--inst-green-soft); }
.gc-none { font-size: 0.72rem; color: var(--muted); padding: 4px 6px; }

/* Dialog export */
dialog {
  width: min(92vw, 500px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: var(--space-3);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 30, 20, 0.45); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); gap: var(--space-3); }
.dialog-header h3 { margin: 0; font-size: 0.95rem; color: var(--inst-green-900); }
.export-label { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Loader */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(10, 30, 18, 0.45);
  display: grid;
  place-items: center;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(2px);
}
.app-loader.is-hidden { opacity: 0; pointer-events: none; }
.loader-card {
  min-width: 260px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: var(--space-3) 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--inst-green-700);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin 0.75s linear infinite;
}
.app-loader.is-error .loader-spinner { border-top-color: var(--brand-red); }
.loader-card p { margin: 0; font-size: 0.84rem; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Layer vettoriali: pannello compatto (chiuso di default via .collapsed) ─── */
.panel-section--vectors .geojson-layer-stack { gap: 3px; }

.layer-item-on {
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 1px rgba(22, 101, 52, 0.2);
  background: linear-gradient(180deg, rgba(22, 101, 52, 0.06), var(--surface-muted));
}

.wms-row-active {
  background: var(--inst-green-soft);
  border-radius: var(--radius-xs);
}

/* ─── WMS personalizzati ─── */
.panel-section--custom-wms { padding: var(--space-2) 6px; }
.panel-section--custom-wms > h3 { margin-bottom: 4px; }

.custom-wms-form { display: flex; flex-direction: column; gap: 4px; }
.custom-wms-url {
  width: 100%;
  font-size: 0.72rem;
  min-height: 26px;
}
.custom-wms-actions { justify-content: stretch; }
.custom-wms-actions .btn { flex: 1; font-size: 0.72rem; padding: 3px 6px; }

.custom-wms-msg {
  margin: 4px 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
  min-height: 1.2em;
}
.custom-wms-msg.is-error { color: var(--brand-red); font-weight: 600; }

.custom-wms-pick-wrap.is-hidden { display: none !important; }

.custom-wms-pick-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 6px;
  padding: 3px 0;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.custom-wms-select-all {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.custom-wms-select-all input { accent-color: var(--inst-green-700); width: 13px; height: 13px; margin: 0; }
.custom-wms-pick-toolbar .btn { font-size: 0.7rem; padding: 3px 8px; }

.custom-wms-pick-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-muted);
  margin-top: 2px;
}

.custom-wms-pick-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 6px;
  font-size: 0.7rem;
  line-height: 1.25;
  cursor: pointer;
  border-bottom: 1px solid rgba(209, 217, 211, 0.6);
}
.custom-wms-pick-row:last-child { border-bottom: none; }
.custom-wms-pick-row:hover { background: var(--inst-green-soft); }
.custom-wms-pick-row input { margin-top: 2px; flex-shrink: 0; accent-color: var(--inst-green-700); width: 13px; height: 13px; }
.custom-wms-pick-row span { flex: 1; min-width: 0; word-break: break-word; }

.custom-wms-layer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.custom-wms-active-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px 5px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--border);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.custom-wms-active-row.is-on {
  border-left-color: var(--inst-green-700);
  background: linear-gradient(90deg, var(--inst-green-soft), var(--panel));
}

.custom-wms-active-top {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.custom-wms-active-top input[type=checkbox] { flex-shrink: 0; accent-color: var(--inst-green-700); width: 13px; height: 13px; margin: 0; }
.custom-wms-active-title {
  flex: 1;
  min-width: 0;
  font-size: 0.71rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.custom-wms-remove {
  flex-shrink: 0;
  padding: 1px 5px !important;
  line-height: 1.2;
  color: var(--brand-red) !important;
  border-color: #fecaca !important;
}
.custom-wms-remove:hover { background: #fef2f2 !important; }

.custom-wms-opacity-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px dashed var(--border);
}
.custom-wms-op-label { font-size: 0.65rem; color: var(--muted); font-weight: 700; width: 42px; flex-shrink: 0; }
.custom-wms-op-slider { flex: 1; min-width: 40px; height: 10px; accent-color: var(--inst-green-700); cursor: pointer; }
.custom-wms-op-val { font-size: 0.65rem; font-weight: 700; color: var(--inst-green-800); width: 28px; text-align: right; flex-shrink: 0; }

/* ─── GFI popup enhancements ─── */

/* "Tabella" button in popup header */
.popup-attr-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  margin-right: 4px;
  transition: background 0.12s ease;
}
.popup-attr-btn:hover { background: rgba(255,255,255,0.28); }

/* Chiave attributo — colonna etichette */
.popup-tbl td.gfi-key {
  width: 38%;
  max-width: 40%;
  white-space: normal;
  word-break: break-word;
  color: #2a332c;
  font-weight: 700;
  font-size: inherit;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
}

/* Badge servizio (PCN / CATASTO / SITAP) nella sezione header */
.gfi-svc-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  vertical-align: middle;
  letter-spacing: 0.04em;
  margin-right: 4px;
  opacity: 0.95;
}
.gfi-svc-pcn     { background: #1a6b3c; color: #fff; }
.gfi-svc-catasto { background: #5d4037; color: #fff; }
.gfi-svc-sitap   { background: #1565c0; color: #fff; }
.gfi-svc-custom  { background: #546e7a; color: #fff; }

/* Conteggio feature multiple */
.gfi-feat-count {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--inst-green-800);
  padding: 6px 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
/* Intestazione singolo oggetto (JSON multi-feature) */
.gfi-feat-idx {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
  padding: 8px 4px 4px;
  margin-top: 4px;
  border-top: 1px dashed var(--border-strong);
}
.gfi-feat-idx-row { font-size: 0.8125rem; font-weight: 700; color: var(--text); }
.gfi-text-section {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--inst-green-900);
  background: var(--inst-green-soft) !important;
  padding: 8px 12px !important;
  border-bottom: 1px solid var(--border) !important;
}
.gfi-text-plain { font-size: 0.875rem; color: var(--text); font-style: italic; line-height: 1.45; }
.gfi-empty-feat { font-size: 0.875rem; color: var(--muted); font-style: italic; padding: 8px 6px; line-height: 1.45; }

/* Sezione header errore */
.gfi-section-err { color: #b71c1c !important; }
.gfi-err-row {
  font-size: 0.875rem;
  color: #b71c1c;
  padding: 6px 4px;
  line-height: 1.45;
}
.gfi-err-details {
  margin-top: 10px;
  font-size: 0.875rem;
}
.gfi-err-details summary {
  cursor: pointer;
  color: var(--inst-green-800);
  padding: 6px 0;
  font-weight: 700;
  user-select: none;
}
.gfi-err-details summary:hover { color: var(--text); }

/* Lista layer in caricamento (sostituisce il singolo .gfi-loading) */
.gfi-loading-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px 0;
}
.gfi-loading-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text);
  padding: 4px 0;
}
.gfi-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--border);
  border-top-color: var(--inst-green-600);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}
.gfi-loading-icon { font-size: 0.8rem; flex-shrink: 0; }
.gfi-loading-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gfi-loading-hint {
  font-size: 0.8125rem;
  color: var(--text);
  margin: 8px 0 4px;
  padding: 0 4px;
  font-weight: 600;
}

/* Pannelli per layer (popup) — consultazione rapida con accordion */
.gfi-layer-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  margin-bottom: 6px;
  background: var(--panel);
  overflow: hidden;
}
.gfi-layer-panel:last-child { margin-bottom: 0; }

.gfi-layer-summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--inst-green-900);
  background: var(--surface-muted);
  list-style: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  user-select: none;
}
.gfi-layer-summary::-webkit-details-marker { display: none; }
.gfi-layer-summary::before {
  content: "";
  display: inline-block;
  width: 0.28em;
  height: 0.28em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  margin-right: 2px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
  opacity: 0.75;
}
.gfi-layer-panel[open] .gfi-layer-summary::before {
  transform: rotate(45deg);
}
.gfi-layer-summary:hover {
  background: var(--inst-green-soft-hover);
}

.gfi-layer-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.gfi-layer-kind {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background: var(--inst-green-700);
  color: #fff;
  flex-shrink: 0;
}
.gfi-layer-title-txt {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* Celle attributo con valore lungo */
.gfi-cell-expand-wrap { min-width: 0; }
.gfi-cell-preview {
  display: inline;
  word-break: break-word;
}
.gfi-cell-details {
  display: inline-block;
  margin-top: 2px;
  max-width: 100%;
}
.gfi-cell-details summary.gfi-cell-more {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--inst-green-800);
  list-style: none;
  user-select: none;
  margin-top: 4px;
}
.gfi-cell-details summary.gfi-cell-more::-webkit-details-marker { display: none; }
.gfi-cell-details summary.gfi-cell-more:hover { text-decoration: underline; }
.gfi-cell-full {
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: min(360px, 55vh);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
}

.popup-tbl td.gfi-val {
  min-width: 0;
  font-weight: 500;
  color: var(--text);
}

/* ─── WMS skeleton loader ─── */
.wms-skeleton { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; }
.wms-skeleton-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  border-radius: var(--radius-xs);
  animation: skelPulse 1.4s ease-in-out infinite;
}
.wms-skeleton-chk {
  width: 14px; height: 14px; flex-shrink: 0;
  border-radius: 3px;
  background: var(--border);
}
.wms-skeleton-text {
  flex: 1;
  height: 11px;
  border-radius: 4px;
  background: var(--border);
}
@keyframes skelPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ─── SITAP icon per categoria ─── */
.sitap-group-icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ─── Attribute table modal ─── */
.wms-attr-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.52);
  z-index: 9100;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 16px;
  overflow-y: auto;
}
.wms-attr-modal.visible { display: flex; }

.wms-attr-modal-inner {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 40px);
}

.wms-attr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--inst-green-900);
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
  flex-shrink: 0;
}

.wms-attr-modal-content {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  background: var(--surface-muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.attr-modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-muted);
}

.attr-modal-filter {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--panel);
  color: var(--text);
}
.attr-modal-filter:focus {
  outline: 2px solid var(--inst-green-600);
  outline-offset: 1px;
}

.attr-modal-copy {
  flex-shrink: 0;
  font-size: 0.8125rem !important;
  padding: 7px 12px !important;
}

.attr-modal-block {
  margin-bottom: 20px;
}
.attr-modal-block:last-child { margin-bottom: 0; }

.attr-modal-section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--inst-green-900);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--inst-green-soft-hover);
}
h3.attr-modal-section-title {
  font-size: 0.9375rem;
  line-height: 1.35;
}

/* Modale: tabella ancora più leggibile del popup */
.wms-attr-modal-content .popup-tbl {
  font-size: 0.9375rem;
}
.wms-attr-modal-content .popup-tbl td {
  font-size: inherit;
  padding: 12px 14px;
  line-height: 1.5;
}
.wms-attr-modal-content .gfi-cell-full {
  font-size: 0.875rem;
  max-height: min(400px, 50vh);
}

/* ─── Altimeter ─── */
.altimeter-status {
  font-size: 0.74rem;
  color: var(--muted);
  min-height: 1.2em;
  margin-top: 4px;
  line-height: 1.4;
}

/* Modal overlay */
/* ── Modal altimetro: floating draggable panel ── */
.altimeter-modal {
  display: none;           /* semplice contenitore show/hide */
  pointer-events: none;   /* non intercetta click sul resto della mappa */
}
.altimeter-modal.visible { display: block; }

.altimeter-modal-inner {
  position: fixed;
  z-index: 9000;
  pointer-events: all;    /* il pannello stesso cattura i click */
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.18);
  width: min(700px, 96vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* posizione di default impostata via JS al primo apertura */
  top: 10vh;
  left: 50%;
  transform: translateX(-50%);
  transition: box-shadow 0.15s;
}
.altimeter-modal-inner.is-dragging {
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  transform: none;        /* durante drag rimuovi translateX */
}

.altimeter-modal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--inst-green-900);
  color: #fff;
  font-size: 0.9rem;
  flex-shrink: 0;
  cursor: move;
  user-select: none;
}
.altimeter-drag-hint {
  font-size: 0.65rem;
  opacity: 0.55;
  font-weight: 400;
  margin-left: 4px;
}

.altimeter-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.altimeter-stat {
  background: var(--surface-muted);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.altimeter-stat-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.altimeter-stat-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--inst-green-800);
}

.altimeter-chart-wrap {
  flex: 1;
  min-height: 0;
  padding: 10px 14px;
  position: relative;
}
.altimeter-chart-wrap canvas {
  width: 100% !important;
  height: 260px !important;
}

.altimeter-source-note {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: right;
  padding: 4px 14px 8px;
  flex-shrink: 0;
}
.altimeter-source-note a { color: var(--inst-green-700); }

/* ─── GeoImg Lightbox ─── */
.geoimg-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 9500;
  align-items: center;
  justify-content: center;
}
.geoimg-lightbox.visible { display: flex; }

.geoimg-lightbox-inner {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
}
.geoimg-lightbox-inner img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  display: block;
}
.geoimg-lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.geoimg-lightbox-close:hover { background: #fff; }

/* Responsive */
@media (max-width: 1050px) {
  .app-shell { grid-template-columns: minmax(188px, 200px) 1fr; }
  .panel-right {
    position: absolute;
    right: var(--space-2);
    top: var(--space-2);
    bottom: var(--space-2);
    width: min(220px, 38vw);
    z-index: 1100;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
  }
}

/* ═══════════════════════════════════════════════════
   LAYOUT STAMPA AVANZATO (EPX)
   ═══════════════════════════════════════════════════ */
dialog#exportDialog {
  width: min(96vw, 1100px);
  max-width: 96vw;
  height: min(90vh, 760px);
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  /* display is managed by the browser: none when closed, block when open.
     flex layout is applied only when the dialog is actually open. */
}
dialog#exportDialog[open] {
  display: flex;
  flex-direction: column;
}
dialog#exportDialog::backdrop {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}

/* ── Header ── */
.epx-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: linear-gradient(135deg, var(--inst-green-800), var(--inst-green-700));
  color: #fff;
  flex-shrink: 0;
  gap: 10px;
}
.epx-header > span {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.epx-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.epx-header-actions .btn {
  padding: 3px 11px;
  font-size: 0.76rem;
}
.epx-header-actions .btn-close-dialog {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: var(--radius-xs);
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  font-family: inherit;
  transition: background 0.12s;
}
.epx-header-actions .btn-close-dialog:hover { background: rgba(255,255,255,0.28); }

/* ── Body grid ── */
.epx-body {
  display: grid;
  grid-template-columns: 238px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ── */
.epx-sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--border);
  background: var(--surface-muted);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.epx-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
}
.epx-section:last-child { border-bottom: none; padding-bottom: 0; }
.epx-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--inst-green-800);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 1px;
}
.epx-section input[type=text],
.epx-section select { width: 100%; }

/* Format radios */
.epx-fmt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.epx-fmt-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 3px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 0.67rem;
  font-weight: 600;
  text-align: center;
  user-select: none;
  transition: border-color 0.1s, background 0.1s;
}
.epx-fmt-opt:has(input:checked) {
  background: linear-gradient(180deg, var(--inst-green-700), var(--inst-green-800));
  color: #fff;
  border-color: var(--inst-green-800);
}
.epx-fmt-opt input { display: none; }

/* Option checkboxes */
.epx-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 5px;
}
.epx-opts label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  cursor: pointer;
}
.epx-opts input[type=checkbox] { accent-color: var(--inst-green-700); }

/* Element list */
.epx-element-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.epx-element-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  cursor: pointer;
  padding: 2px 3px;
  border-radius: var(--radius-xs);
  transition: background 0.1s;
}
.epx-element-row:hover { background: var(--inst-green-soft); }
.epx-element-row input[type=checkbox] { accent-color: var(--inst-green-700); margin: 0; flex-shrink: 0; }

/* Logo slots */
.epx-logo-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.epx-logo-slot {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xs);
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background: var(--panel);
  transition: border-color 0.12s, background 0.12s;
}
.epx-logo-slot:hover { border-color: var(--inst-green-600); background: var(--inst-green-soft); }
.epx-logo-slot.drag-over { border-style: solid; border-color: var(--inst-green-600); background: var(--inst-green-soft); }
.epx-logo-preview { max-height: 40px; max-width: 100%; object-fit: contain; display: block; }
.epx-logo-hint {
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
}
.epx-logo-clear {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.48);
  color: #fff;
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.epx-logo-clear:hover { background: rgba(180,0,0,0.7); }

/* Legend drag handle */
.epx-drag-handle {
  cursor: grab;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0 1px;
  flex-shrink: 0;
  user-select: none;
}
.epx-drag-handle:active { cursor: grabbing; }
.epx-legend-dragging { opacity: 0.38; }
.epx-legend-over { outline: 2px solid var(--inst-green-600); outline-offset: -1px; }

/* Legend editor (reused across old/new) */
.export-legend-editor {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 130px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 4px;
  background: var(--panel);
  scrollbar-width: thin;
}
.export-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 3px;
  background: var(--surface-muted);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}
.export-legend-item input[type=checkbox] { flex-shrink: 0; accent-color: var(--inst-green-700); width: 13px; height: 13px; margin: 0; }
.export-legend-swatch {
  width: 14px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.18);
  flex-shrink: 0;
}
.export-legend-item input[type=text] {
  flex: 1;
  padding: 1px 4px;
  min-height: 18px;
  font-size: 0.7rem;
  border-color: var(--border);
}
.export-legend-empty { font-size: 0.7rem; color: var(--muted); padding: 6px; text-align: center; font-style: italic; }

/* ── Canvas area ── */
.epx-canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;       /* center canvas horizontally */
  justify-content: flex-start;
  overflow: auto;            /* scroll if canvas exceeds space (rare) */
  background: #8a9e90;
  padding: 10px 12px;
  gap: 7px;
  min-height: 0;
  min-width: 0;
}
.epx-canvas-label {
  font-size: 0.67rem;
  color: rgba(255,255,255,0.88);
  text-align: center;
  font-style: italic;
  flex-shrink: 0;
  width: 100%;
}
.epx-layout-canvas {
  /* Width + height set by JS to match page aspect ratio.
     flex: none prevents flex from overriding our explicit dimensions. */
  flex: none;
  background: #fff;
  box-shadow: 0 3px 16px rgba(0,0,0,0.38);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

/* Canvas dot-grid overlay */
.epx-canvas-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right,  rgba(0,0,0,0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0,0,0,0.06) 1px, transparent 1px);
  background-size: 5% 5%;
  pointer-events: none;
  z-index: 0;
}

/* Draggable blocks */
.epx-block {
  position: absolute;
  border: 1.5px dashed rgba(0,0,0,0.28);
  border-radius: 2px;
  cursor: move;
  user-select: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  overflow: hidden;
  transition: box-shadow 0.1s;
}
.epx-block:hover {
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 2px rgba(22,101,52,0.18);
  z-index: 2;
}
.epx-block--selected {
  border: 2px solid var(--inst-green-600) !important;
  box-shadow: 0 0 0 3px rgba(22,101,52,0.22) !important;
  z-index: 3;
}
.epx-block--dragging {
  opacity: 0.82;
  box-shadow: 0 4px 18px rgba(0,0,0,0.28) !important;
  z-index: 10;
}
/* Block colors by type */
.epx-block--map      { background: rgba(190,218,238,0.5); border-color: #5c94b8; }
.epx-block--header   { background: rgba(46,125,50,0.22);  border-color: #2e7d32; }
.epx-block--footer   { background: rgba(90,90,90,0.1);    border-color: #999; }
.epx-block--scalebar { background: rgba(255,255,255,0.72); border-color: #888; }
.epx-block--north    { background: rgba(255,255,255,0.72); border-color: #888; }
.epx-block--legend   { background: rgba(255,255,244,0.82); border-color: #9c9c5e; }
.epx-block--logo     { background: rgba(235,235,255,0.75); border-color: #8080c0; }

/* Block label */
.epx-block-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: rgba(0,0,0,0.52);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
  text-align: center;
  padding: 2px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Property panel below canvas */
.epx-elem-props {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.94);
  border-radius: var(--radius-xs);
  padding: 5px 8px;
  font-size: 0.7rem;
  border: 1px solid var(--border-strong);
  flex-wrap: wrap;
}
.epx-prop-name {
  font-weight: 700;
  color: var(--inst-green-800);
  margin-right: 4px;
  min-width: 72px;
}
.epx-elem-props label {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.epx-elem-props input[type=number] {
  width: 52px;
  padding: 2px 4px;
  font-size: 0.68rem;
}

/* ─── Preset bar ─── */
.epx-preset-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 5px;
}
.epx-preset-btn {
  flex: 1;
  padding: 4px 2px;
  font-size: 0.69rem;
  font-weight: 600;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.epx-preset-btn:hover {
  background: var(--inst-green-soft);
  border-color: var(--inst-green-600);
  color: var(--inst-green-700);
}
.epx-preset-btn.active {
  background: var(--inst-green-700);
  border-color: var(--inst-green-700);
  color: #fff;
}
.epx-reset-btn {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.69rem;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.epx-reset-btn:hover {
  background: rgba(180, 0, 0, 0.06);
  color: var(--brand-red);
  border-color: var(--brand-red);
}

/* ─── Margin guide row ─── */
.epx-margin-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.epx-margin-label {
  flex: 1;
  font-size: 0.73rem;
  color: var(--muted);
  white-space: nowrap;
}
.epx-margin-unit {
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.7;
}
.epx-margin-input {
  width: 52px;
  padding: 2px 4px;
  font-size: 0.73rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--panel);
}

/* ─── 8-point resize handles ─── */
.epx-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1.5px solid var(--inst-green-700);
  border-radius: 2px;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  pointer-events: all;
  /* Individual positioning via JS — see HANDLE_DEFS */
}
.epx-handle--nw { top: -4px;  left: -4px;  cursor: nw-resize; }
.epx-handle--n  { top: -4px;  left: calc(50% - 4px); cursor: n-resize; }
.epx-handle--ne { top: -4px;  right: -4px; cursor: ne-resize; }
.epx-handle--e  { top: calc(50% - 4px); right: -4px; cursor: e-resize; }
.epx-handle--se { bottom: -4px; right: -4px; cursor: se-resize; }
.epx-handle--s  { bottom: -4px; left: calc(50% - 4px); cursor: s-resize; }
.epx-handle--sw { bottom: -4px; left: -4px;  cursor: sw-resize; }
.epx-handle--w  { top: calc(50% - 4px); left: -4px;  cursor: w-resize; }

/* hide handles when block is not selected */
.epx-block:not(.epx-block--selected) .epx-handle {
  display: none;
}

/* ─── Block resizing state ─── */
.epx-block--resizing {
  outline: 2px dashed var(--inst-green-600) !important;
  outline-offset: 1px;
  opacity: 0.88;
  cursor: crosshair;
}

/* ─── Alignment snap guides ─── */
.epx-snap-guide {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  background: rgba(220, 50, 50, 0.75);
}
.epx-snap-guide--v {
  top: 0;
  bottom: 0;
  width: 1px;
}
.epx-snap-guide--h {
  left: 0;
  right: 0;
  height: 1px;
}

/* ─── Margin guide overlay ─── */
.epx-margin-guide {
  position: absolute;
  border: 1px dashed rgba(100, 100, 200, 0.55);
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
  box-shadow: inset 0 0 0 1px rgba(100,100,200,0.1);
}

/* ═══════════════════════════════════════════════════
   LAYER PANEL ENHANCED
   ═══════════════════════════════════════════════════ */
.layer-item { overflow: hidden; }

.layer-row { min-width: 0; }

.layer-color-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.2);
  flex-shrink: 0;
  display: inline-block;
}

.layer-geom-icon {
  font-size: 0.65rem;
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.8;
  line-height: 1;
}

.layer-feat-badge {
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 4px;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.5;
}

.layer-title-editable {
  cursor: text;
  border-radius: 2px;
  padding: 0 2px;
  transition: background 0.1s;
}
.layer-title-editable:focus {
  outline: 1px solid var(--inst-green-600);
  background: var(--panel);
  cursor: text;
}

.layer-opacity-row {
  display: none;
  align-items: center;
  gap: 5px;
  padding-top: 2px;
}
.layer-opacity-row.open { display: flex; }
.layer-op-label { font-size: 0.62rem; color: var(--muted); font-weight: 700; width: 38px; flex-shrink: 0; }
.layer-op-slider { flex: 1; min-width: 40px; height: 10px; accent-color: var(--inst-green-700); cursor: pointer; }
.layer-op-val { font-size: 0.62rem; font-weight: 700; color: var(--inst-green-800); width: 28px; text-align: right; flex-shrink: 0; }

.btn-opacity-toggle {
  border: none;
  background: transparent;
  padding: 0 3px;
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}
.btn-opacity-toggle:hover { color: var(--inst-green-700); background: var(--inst-green-soft); }
.btn-opacity-toggle.active { color: var(--inst-green-700); }

/* ═══════════════════════════════════════════════════
   GEOPROCESSING SECTION
   ═══════════════════════════════════════════════════ */
.geoproc-select-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.geoproc-select-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  width: 18px;
  flex-shrink: 0;
  text-align: center;
}
.geoproc-select-row select { flex: 1; min-width: 0; font-size: 0.72rem; min-height: 24px; }
.geoproc-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  margin-top: 4px;
}
.geoproc-btns .btn { font-size: 0.71rem; padding: 3px 6px; text-align: center; }
#geoprocResult {
  font-size: 0.72rem;
  color: var(--inst-green-700);
  min-height: 1.1em;
  margin-top: 3px;
  font-weight: 600;
}
#geoprocResult.err { color: var(--brand-red); }
.geoproc-refresh { margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════
   FOTO GEOREFERENZIATE
   ═══════════════════════════════════════════════════ */
.geoimg-status {
  font-size: 0.72rem;
  color: var(--inst-green-700);
  min-height: 1em;
  font-weight: 600;
  margin-top: 2px;
}
.geoimg-manual-row {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.geoimg-manual-row input[type=file] { flex: 1; min-width: 0; font-size: 0.68rem; }
.geoimg-count {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Geo image popup */
.geoimg-popup { display: flex; flex-direction: column; gap: 6px; }
.geoimg-popup-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  display: block;
}
.geoimg-popup-meta { display: flex; flex-direction: column; gap: 4px; }
.geoimg-meta-gps {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}
.geoimg-popup-actions { display: flex; gap: 4px; }
.btn-danger-sm {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: var(--brand-red);
  border-radius: var(--radius-xs);
  padding: 2px 7px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.1s;
}
.btn-danger-sm:hover { background: #fee2e2; }

/* ═══════════════════════════════════════════════════
   WMS REGIONALI & ENTI — lista piatta con sezioni
   ═══════════════════════════════════════════════════ */

/* Container */
.wr-list {
  display: flex;
  flex-direction: column;
}

/* ── Intestazione sezione (Regioni / ISPRA / Bacini) ── */
.wr-section-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 4px;
  margin-top: 6px;
  background: var(--inst-green-900);
  color: #fff;
  border-radius: var(--radius-xs);
  position: sticky;
  top: 0;
  z-index: 2;
}
.wr-section-hdr:first-child { margin-top: 0; }
.wr-section-icon { font-size: 0.9rem; }
.wr-section-title {
  flex: 1;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wr-section-count {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 0 7px;
  min-width: 20px;
  text-align: center;
}

/* ── Lista servizi per sezione ── */
.wr-section-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
  overflow: hidden;
  margin-bottom: 2px;
}

/* ── Riga singolo servizio ── */
.wr-row {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.wr-row:last-child { border-bottom: none; }

.wr-row-hdr {
  display: grid;
  grid-template-columns: 5px 1fr auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.wr-row-hdr:hover { background: var(--inst-green-soft); }
.wr-row--open > .wr-row-hdr {
  background: var(--inst-green-soft);
  border-bottom: 1px solid var(--border);
}

/* Dot colorato — la "barra" laterale */
.wr-dot {
  width: 5px;
  border-radius: 3px;
  align-self: stretch;
  flex-shrink: 0;
  min-height: 20px;
}

/* Testi nome + dominio */
.wr-row-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  min-width: 0;
}
.wr-row-title {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.wr-row-meta {
  font-size: 0.62rem;
  color: var(--muted);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

/* Link geoportale */
.wr-row-link {
  font-size: 0.78rem;
  color: var(--inst-green-600);
  text-decoration: none;
  flex-shrink: 0;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
  transition: background 0.1s;
}
.wr-row-link:hover { background: var(--inst-green-soft-hover); }

/* Badge stato */
.wr-badge {
  font-size: 0.63rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.wr-badge-idle    { background: var(--surface-muted); color: var(--muted); border: 1px solid var(--border); }
.wr-badge-loading { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; animation: skelPulse 1.2s ease infinite; }
.wr-badge-ok      { background: #f0fdf4; color: var(--inst-green-700); border: 1px solid #bbf7d0; }
.wr-badge-err     { background: #fef2f2; color: var(--brand-red); border: 1px solid #fecaca; }
.wr-badge-warn    { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* Freccia expand */
.wr-row-arrow {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  position: relative;
}
.wr-row-arrow::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg) translate(-2px, 2px);
  transition: transform 0.18s;
  transform-origin: center;
}
.wr-row--open .wr-row-arrow::before {
  transform: rotate(45deg);
}

/* Body collassato / espanso */
.wr-row-body {
  border-top: 1px solid var(--border);
  padding: 6px 8px 8px 16px;
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.wr-row-body.collapsed {
  display: none;
}

/* Nota servizio */
.wr-row-note {
  font-size: 0.67rem;
  color: var(--muted);
  font-style: italic;
  padding: 3px 5px 5px;
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius-xs);
  margin-bottom: 3px;
  line-height: 1.35;
}

/* Riga "Tutti i layer" */
.wr-group-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px 5px;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 2px;
}
.wr-group-chk { accent-color: var(--inst-green-700); }
.wr-group-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
}

/* Empty state */
.wr-empty {
  font-size: 0.72rem;
  color: var(--muted);
  font-style: italic;
  padding: 6px 4px;
  text-align: center;
}

/* Nota fallback (servizio non raggiungibile) */
.wr-fallback-note {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-xs);
  padding: 5px 7px;
  font-size: 0.68rem;
  color: #92400e;
  margin-bottom: 4px;
  line-height: 1.3;
}
.wr-fallback-icon { flex-shrink: 0; font-size: 0.75rem; }

/* ── Barra di ricerca ── */
.wr-search-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  margin-bottom: 4px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.wr-search-wrap:focus-within {
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 2px var(--inst-green-soft);
}
.wr-search-ico   { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }
.wr-search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 0.76rem; font-family: inherit; color: var(--text);
  padding: 1px 0; min-width: 0;
}
.wr-search-input::placeholder { color: var(--muted); }
.wr-search-input::-webkit-search-cancel-button { display: none; }
.wr-search-reset {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 0.7rem; padding: 0 2px;
  border-radius: 3px; display: flex; align-items: center;
  transition: color 0.1s;
}
.wr-search-reset:hover { color: var(--brand-red); }

/* ── Intestazione sotto-servizio nella riga regione espansa ── */
.wr-svc-subtitle {
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 10px 2px 10px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  background: var(--surface-muted, #f8faf8);
  display: flex;
  align-items: center;
  gap: 4px;
}
.wr-svc-subtitle:first-child { border-top: none; margin-top: 0; }

/* icona warning per servizi fallback/irraggiungibili */
.wr-svc-warn { color: #b45309; }

/* ── Nota servizio ── */
.wr-svc-note {
  font-size: 0.64rem;
  color: var(--muted);
  font-style: italic;
  padding: 0 10px 4px 10px;
  background: var(--surface-muted, #f8faf8);
}

/* ─── Profilo altimetrico — barra export ─── */
/* .altimeter-modal-header è già definito sopra, aggiungiamo solo le parti nuove */
.altimeter-modal-header > span:first-child {
  flex: 1;
  color: #fff;
  font-weight: 700;
}
.altimeter-export-bar {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.alt-export-btn {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.alt-export-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.5);
}
.alt-export-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.alt-export-pdf {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.4);
  font-weight: 700;
}
.alt-export-pdf:hover:not(:disabled) {
  background: rgba(255,255,255,0.32);
}

/* ══════════════════════════════════════════════════
   EDITOR TESTI PDF ALTIMETRICO
   ══════════════════════════════════════════════════ */
.alt-pdf-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 3200;
  background: rgba(5, 20, 10, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: altEditorFadeIn 0.18s ease;
}
@keyframes altEditorFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.alt-pdf-editor-box {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,0.08);
  width: 480px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: altEditorSlideUp 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes altEditorSlideUp {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Header */
.alt-pdf-editor-hdr {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  background: var(--inst-green-900);
  color: #fff;
  gap: 8px;
  flex-shrink: 0;
}
.alt-pdf-editor-hdr-title {
  flex: 1;
  font-weight: 700;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
}
.alt-pdf-editor-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  transition: color 0.15s, background 0.15s;
}
.alt-pdf-editor-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

/* Body */
.alt-pdf-editor-body {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow-y: auto;
  max-height: calc(80vh - 120px);
}

.alt-pdf-editor-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.alt-pdf-editor-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.alt-pdf-editor-input,
.alt-pdf-editor-textarea {
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 9px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  resize: vertical;
}
.alt-pdf-editor-input:focus,
.alt-pdf-editor-textarea:focus {
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 2px rgba(26, 122, 62, 0.18);
  background: #fff;
}
.alt-pdf-editor-textarea {
  min-height: 58px;
  resize: vertical;
}

/* Anteprima mini */
.alt-pdf-editor-preview {
  margin-top: 2px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  border: 1px solid var(--border);
}
.alt-pdf-editor-preview-inner {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--inst-green-900);
  padding: 5px 10px;
}
.alt-pdf-editor-preview-bar {
  display: none;
}
.alt-pdf-editor-preview-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

/* Footer */
.alt-pdf-editor-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  flex-shrink: 0;
}

.alt-pdf-editor-btn-cancel,
.alt-pdf-editor-btn-gen {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.alt-pdf-editor-btn-cancel {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
}
.alt-pdf-editor-btn-cancel:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
  color: var(--text);
}
.alt-pdf-editor-btn-gen {
  background: var(--inst-green-800);
  color: #fff;
  border-color: var(--inst-green-700);
}
.alt-pdf-editor-btn-gen:hover {
  background: var(--inst-green-700);
}

/* ── Altimetro — gruppi input (disegna / da layer) ── */
.alt-input-group {
  margin-bottom: 5px;
}
.alt-input-group + .alt-input-group {
  padding-top: 5px;
  border-top: 1px dashed var(--border);
}
.alt-input-group-label {
  margin: 0 0 3px;
  font-size: 0.69rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Altimetro — cursore hover sul grafico mostra dot sulla mappa ── */
#altimeterChart { cursor: crosshair; }

/* ═══════════════════════════════════════════════════════
   LOGO IN MAPPA — overlay posizionabile
   ═══════════════════════════════════════════════════════ */
#mapLogoOverlay {
  position: absolute;
  z-index: 200;
  pointer-events: none;
  padding: 5px;
  transition: opacity 0.2s;
}
#mapLogoOverlay img {
  display: block;
  max-width: 140px;
  max-height: 62px;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.45));
  border-radius: 3px;
  background: rgba(255,255,255,0.85);
  padding: 2px 4px;
}
#mapLogoOverlay.pos-top-left     { top: 50px;   left: 8px;   bottom: auto; right: auto; }
#mapLogoOverlay.pos-top-right    { top: 50px;   right: 8px;  bottom: auto; left: auto; }
#mapLogoOverlay.pos-bottom-left  { bottom: 52px; left: 8px;   top: auto;   right: auto; }
#mapLogoOverlay.pos-bottom-right { bottom: 52px; right: 8px;  top: auto;   left: auto; }

/* ═══════════════════════════════════════════════════════
   RICERCA WMS — barra di filtro
   ═══════════════════════════════════════════════════════ */
.wms-search-bar {
  margin: 0 0 4px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  padding: 4px 0 2px;
}
.wms-search-input {
  width: 100%;
  padding: 6px 30px 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wms-search-input:focus {
  outline: none;
  border-color: var(--inst-green-600);
  box-shadow: 0 0 0 3px rgba(22,101,52,0.13);
  background: #fff;
}
.wms-search-input::placeholder { color: var(--muted); font-style: italic; }

/* Icona lente sempre verde, posizionata nell'input */
.wms-search-bar::before {
  content: "⌕";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--inst-green-600);
  font-size: 1rem;
  pointer-events: none;
}

/* Badge risultati: normale → verde attivo → rosso nessun risultato */
.wms-search-count {
  font-size: 0.67rem;
  color: var(--muted);
  text-align: right;
  margin: 0 0 4px;
  min-height: 14px;
  line-height: 14px;
  transition: color 0.15s;
}
.wms-search-count.has-results  { color: var(--inst-green-700); font-weight: 600; }
.wms-search-count.no-results   { color: #b91c1c; font-weight: 600; }

/* Highlight risultati ricerca */
mark {
  background: rgba(255, 210, 0, 0.45);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════
   WMS ROW AVANZATA — opacità + legenda per layer
   ═══════════════════════════════════════════════════════ */
.wms-row-wrap {
  border-bottom: 1px solid var(--border);
}
.wms-row-wrap:last-child { border-bottom: none; }
.wms-row-wrap .wms-row  { border-bottom: none; }

.wms-row-detail-btn {
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;   /* ancorato in alto con il titolo multi-riga */
  margin-top: 1px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1;
  transition: background 0.1s;
}
.wms-row-detail-btn:hover { background: var(--border); color: var(--text); }
.wms-row-detail-btn.is-open { color: var(--inst-green-700); }

.wms-layer-detail {
  display: none;
  padding: 4px 6px 6px 22px;
  background: var(--surface-muted);
  border-top: 1px dashed var(--border);
}
.wms-layer-detail.open { display: block; }

/* slider opacità nel detail */
.wms-detail-opacity {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.69rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.wms-detail-opacity > span:first-child { white-space: nowrap; }
.wms-detail-opacity input[type=range] {
  flex: 1;
  height: 3px;
  accent-color: var(--inst-green-700);
  cursor: pointer;
}
.wms-detail-opacity .wms-op-val {
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* legenda nel detail */
.wms-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.69rem;
  color: var(--inst-green-700);
  cursor: pointer;
  user-select: none;
}
.wms-legend-toggle:hover { text-decoration: underline; }

.wms-legend-img-wrap { margin-top: 4px; display: none; }
.wms-legend-img-wrap.open { display: block; }
.wms-legend-img-wrap img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: block;
}
.wms-legend-loading { font-size: 0.67rem; color: var(--muted); font-style: italic; padding: 3px 0; }
.wms-legend-err     { font-size: 0.67rem; color: var(--brand-red); padding: 3px 0; }

/* ── Indicatore stato tile WMS (dot colorato per ogni layer) ── */
.wms-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 4px 0 0;
  vertical-align: middle;
  cursor: help;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}
.wms-dot-off     { background: var(--border-strong); }
.wms-dot-loading {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.28);
  animation: wms-dot-pulse 1s ease-in-out infinite;
}
.wms-dot-ok      { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.22); }
.wms-dot-warn    { background: #f97316; box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.28); }
.wms-dot-error   { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.28); }

@keyframes wms-dot-pulse {
  0%, 100% { opacity: 1;    transform: scale(1);    }
  50%       { opacity: 0.45; transform: scale(0.78); }
}

/* ── Overlay progresso export PDF / PNG ── */
#exportProgressOverlay {
  position: absolute;
  inset: 0;
  z-index: 980;
  background: rgba(0, 0, 0, 0.36);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
#exportProgressOverlay.active {
  opacity: 1;
  pointer-events: auto;
}
.export-progress-badge {
  background: rgba(255, 255, 255, 0.97);
  border-radius: var(--radius);
  padding: 14px 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--inst-green-900);
  user-select: none;
}
.export-progress-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--inst-green-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .panel {
    position: absolute;
    z-index: 1000;
    max-height: 38%;
    left: var(--space-2);
    right: var(--space-2);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
  }
  .panel-left { top: var(--space-2); }
  .panel-right { bottom: var(--space-2); top: auto; width: auto; }
  #panelLogo img { max-height: 48px; }
  #footerCredit { font-size: 0.68rem; max-width: 90vw; }
  #coordReadout { max-width: 90vw; font-size: 0.65rem; }
  #mapScaleReadout { font-size: 0.62rem; }
  .altimeter-modal-inner { width: 96vw; max-height: 90vh; }
}

/* ═══════════════════════════════════════════════════
   SCREEN CAPTURE v2  —  overlay professionale
   ═══════════════════════════════════════════════════ */

/* Schermo intero semitrasparente */
.epx-sc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 28, 16, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

/* Card centrale */
.epx-sc-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.42);
  padding: 32px 36px 28px;
  max-width: 480px;
  width: 90vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.epx-sc-icon {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.18));
}

.epx-sc-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--inst-green-800);
  letter-spacing: 0.01em;
}

/* Step list */
.epx-sc-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.epx-sc-step {
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 0.86rem;
  line-height: 1.45;
  border: 1.5px solid transparent;
  transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}

.epx-sc-step.active {
  background: linear-gradient(135deg, var(--inst-green-800), var(--inst-green-700));
  color: #fff;
  border-color: var(--inst-green-700);
  font-weight: 600;
}
.epx-sc-step.active strong { color: #fff; }

.epx-sc-step.done {
  background: var(--inst-green-soft);
  color: var(--inst-green-700);
  border-color: rgba(22,101,52,0.22);
  opacity: 0.75;
}
.epx-sc-step.done::before { content: "✓  "; }

.epx-sc-step.pending {
  background: var(--surface-muted);
  color: var(--muted);
  border-color: var(--border);
  opacity: 0.55;
}

/* Spinner tre punti pulsanti */
.epx-sc-spinner {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  height: 20px;
}
.epx-sc-spinner i {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--inst-green-700);
  animation: epxScPulse 1.2s ease-in-out infinite;
  font-style: normal;
}
.epx-sc-spinner i:nth-child(2) { animation-delay: 0.2s; }
.epx-sc-spinner i:nth-child(3) { animation-delay: 0.4s; }

@keyframes epxScPulse {
  0%, 80%, 100% { transform: scale(0.55); opacity: 0.35; }
  40%           { transform: scale(1);    opacity: 1;    }
}

.epx-sc-hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
}

/* ─────────────────────────────────────────────────────
   SCREEN CAPTURE — dialog di conferma pre-cattura
   Mostrato PRIMA di chiamare getDisplayMedia per
   informare l'utente di cosa sta per accadere.
   ───────────────────────────────────────────────────── */

.epx-sc-preflight {
  position: fixed;
  inset: 0;
  background: rgba(10, 28, 16, 0.70);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  animation: epxPfIn 0.18s ease;
}

@keyframes epxPfIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.epx-sc-preflight-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.44);
  padding: 28px 32px 24px;
  max-width: 420px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: epxPfSlide 0.20s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes epxPfSlide {
  from { transform: translateY(12px) scale(0.97); }
  to   { transform: translateY(0)    scale(1);    }
}

.epx-sc-preflight-icon {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.14));
}

.epx-sc-preflight-title {
  margin: 0;
  font-size: 1.10rem;
  font-weight: 700;
  color: var(--inst-green-800);
  letter-spacing: 0.01em;
}

.epx-sc-preflight-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.55;
}

.epx-sc-preflight-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-muted, #f3f4f6);
  border: 1px solid var(--border, #d1d9d3);
  border-radius: 7px;
  padding: 9px 13px;
  line-height: 1.45;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.epx-sc-preflight-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.epx-sc-preflight-actions .btn {
  flex: 1;
  max-width: 170px;
  font-size: 0.88rem;
}

/* ─────────────────────────────────────────────────────
   SCREEN CAPTURE — modal di errore / blocco
   Mostrato quando getDisplayMedia fallisce (permesso
   negato, timeout, policy intranet, ecc.).
   Offre: Riprova | Snapshot canvas | Annulla
   ───────────────────────────────────────────────────── */

.epx-sc-blocked {
  position: fixed;
  inset: 0;
  background: rgba(80, 10, 10, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  animation: epxPfIn 0.18s ease;   /* riusa keyframe del preflight */
}

.epx-sc-blocked-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.44);
  border-top: 4px solid #b91c1c;
  padding: 26px 30px 22px;
  max-width: 440px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  animation: epxPfSlide 0.20s cubic-bezier(0.34,1.56,0.64,1);
}

.epx-sc-blocked-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.epx-sc-blocked-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #b91c1c;
  letter-spacing: 0.01em;
}

.epx-sc-blocked-body {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.55;
  text-align: left;
  width: 100%;
}

.epx-sc-blocked-body p {
  margin: 0 0 8px;
}
.epx-sc-blocked-body p:last-child {
  margin-bottom: 0;
}

.epx-sc-blocked-causes {
  background: var(--surface-muted, #f3f4f6);
  border: 1px solid var(--border, #d1d9d3);
  border-radius: 7px;
  padding: 9px 13px;
  font-size: 0.80rem;
  line-height: 1.5;
}

.epx-sc-blocked-causes code {
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 0.78rem;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

.epx-sc-blocked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

.epx-sc-blocked-actions .btn {
  flex: 1 1 120px;
  max-width: 160px;
  font-size: 0.84rem;
  white-space: nowrap;
}

/* Pulsante Riprova — verde primario */
.epx-sc-bl-retry {
  background: var(--inst-green-700, #15803d);
  color: #fff;
  border-color: var(--inst-green-700, #15803d);
}
.epx-sc-bl-retry:hover {
  background: var(--inst-green-800, #166534);
  border-color: var(--inst-green-800, #166534);
}

/* Pulsante Snapshot — tono neutro */
.epx-sc-bl-snapshot {
  background: var(--surface-muted, #f3f4f6);
  color: var(--text);
  border-color: var(--border, #d1d9d3);
}
.epx-sc-bl-snapshot:hover {
  background: var(--border, #d1d9d3);
}

/* ═══════════════════════════════════════════════════
   MAP PREVIEW  —  miniatura live nel blocco mappa
   ═══════════════════════════════════════════════════ */

/* Il blocco mappa: sfondo placeholder + contenitore per il canvas preview */
.epx-block--map {
  background-color: #c0d4c0; /* placeholder verde tenue (visibile prima del render) */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* overflow: hidden già impostato da .epx-block */
}

/* Canvas display-only iniettato da updateMapPreview (tentativo 2) */
.epx-preview-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
  border-radius: 1px;
  /* Nessuna transizione — aggiornamento istantaneo */
}

/* Label e handles rimangono sopra il canvas preview */
.epx-block--map .epx-block-label {
  position: relative;
  z-index: 2;
  background: rgba(255,255,255,0.78);
  padding: 2px 8px;
  border-radius: 3px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.22);
  text-shadow: none;
}

/* Gli 8 handles restano sempre sopra */
.epx-block--map .epx-handle {
  z-index: 21;
}

/* ═══════════════════════════════════════════════════
   CATTURA SCHERMATA  —  label prominente nel dialog
   ═══════════════════════════════════════════════════ */

/* Label cattura schermata occupa tutta la larghezza */
.epx-sc-capture-label {
  grid-column: 1 / -1 !important;  /* full width nella grid epx-opts */
  display: flex !important;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem !important;
  background: linear-gradient(135deg, rgba(20,83,45,0.08), rgba(20,83,45,0.04));
  border: 1px solid rgba(20,83,45,0.22);
  border-radius: 5px;
  padding: 5px 8px !important;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
  margin-top: 2px;
}
.epx-sc-capture-label:hover {
  background: linear-gradient(135deg, rgba(20,83,45,0.14), rgba(20,83,45,0.08));
  border-color: var(--inst-green-600);
}
.epx-sc-capture-label input[type=checkbox] {
  accent-color: var(--inst-green-700);
  flex-shrink: 0;
}
.epx-sc-badge {
  margin-left: auto;
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--inst-green-700);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Bottone "Cattura" nell'header del dialog */
.epx-header-actions .epx-sc-btn {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.50);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 0.13s, border-color 0.13s, transform 0.1s;
}
.epx-header-actions .epx-sc-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.32);
  border-color: rgba(255,255,255,0.8);
  transform: translateY(-1px);
}
.epx-header-actions .epx-sc-btn:active:not(:disabled) {
  transform: translateY(0);
}
