.map-container {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.map-controls-topright {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 6px;
  width: max-content;
  min-width: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: var(--shadow-md);
}

.map-controls-stack {
  position: absolute;
  top: 10px;
  right: 10px;
  bottom: 30px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.map-controls-stack .map-controls-topright {
  position: static;
  top: auto;
  right: auto;
  max-height: 100%;
}

.map-nav-window {
  min-width: 260px;
  width: 260px;
  max-width: 260px;
  padding: 6px 6px 5px;
}

#surfaceGroupNavWindow {
  min-width: 350px;
  width: 350px;
  max-width: 350px;
}

#surfaceGroupNavWindow .nav-window-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#surfaceGroupNavWindow .perizie-layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 3fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
}

#surfaceGroupNavWindow .perizie-layout-left,
#surfaceGroupNavWindow .perizie-layout-right {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#surfaceGroupNavWindow .perizie-layout-right {
  border-left: 1px solid var(--border);
  padding-left: 10px;
  gap: 6px;
  align-items: stretch;
}

#surfaceGroupNavWindow .perizie-list-title {
  color: var(--text-main);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  margin: 0;
  margin-top: 6px;
}

#surfaceGroupNavWindow .nav-group-list {
  max-height: none;
  height: auto;
  flex: 1 1 auto;
  overflow-y: auto;
  margin-top: 0;
  padding-bottom: 0;
  padding-right: 4px;
  transform: none;
  min-height: 0;
}

#surfaceGroupNavWindow.nav-editor-open .nav-group-list {
  transform: none;
}

#surfaceGroupNavWindow .perizie-layout-right .surface-group-link {
  background: transparent;
  border: none;
  padding: 1px 0;
  border-radius: 0;
  font-size: 13px;
  text-decoration: underline;
  line-height: 1.2;
  color: #111827;
}

#surfaceGroupNavWindow .perizie-layout-right .surface-group-sep {
  display: none !important;
}

#surfaceGroupNavWindow .perizie-layout-right #surfaceGroupsList {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#surfaceGroupNavWindow .perizie-layout-right .surface-group-link.active {
  color: var(--interactive);
  font-weight: 600;
  background: transparent;
}

#surfaceGroupNavWindow .toggle-switch {
  width: 40px;
  height: 22px;
}

#surfaceGroupNavWindow .toggle-slider:before {
  width: 18px;
  height: 18px;
}

#surfaceGroupNavWindow .toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(18px);
}

.nav-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.nav-window-toggle {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
}

.map-nav-window .section-triangle {
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.map-nav-window.nav-collapsed .section-triangle {
  transform: rotate(0deg);
}

.nav-window-title {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  color: var(--text-main);
}

.nav-window-body {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.25s ease, opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.map-nav-window.nav-collapsed .nav-window-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.map-nav-window.nav-full-height {
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.map-nav-window.nav-full-height .nav-window-body {
  flex: 1 1 auto;
  max-height: none;
  height: auto;
}

.map-nav-window.nav-full-height.nav-collapsed {
  height: auto;
  max-height: none;
  min-height: 0;
}

.map-nav-window.nav-full-height.nav-collapsed .nav-window-body {
  max-height: 0;
  height: 0;
}

.nav-window-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.nav-window-label {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
}

.nav-window-row .toggle-switch {
  margin-left: auto;
  flex: 0 0 auto;
}

.nav-window-action-btn {
  height: 22px;
  min-width: 44px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  cursor: pointer;
}

.perizia-code-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.perizia-code-row .nav-window-label {
  font-size: 14px;
  font-weight: 700;
}

.perizia-inline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

.perizia-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.perizia-meta-row select {
  min-width: 140px;
}

.perizia-code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.perizia-code-actions input {
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 600;
  min-width: 120px;
}

.perizia-save-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--interactive);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.15s ease;
}

.perizia-save-btn:hover {
  background: var(--interactive-light);
}

.perizia-save-btn svg {
  width: 16px;
  height: 16px;
}

.perizia-delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='3,6 21,6'/><line x1='8' y1='6' x2='8' y2='4'/><line x1='16' y1='6' x2='16' y2='4'/><rect x='6' y='6' width='12' height='14' rx='2'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

.perizia-delete-btn svg {
  width: 16px;
  height: 16px;
}

.surface-group-editor {
  display: none;
  width: 100%;
  margin-top: 6px;
  overflow-y: auto;
  padding-right: 4px;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
}

.map-nav-window.nav-editor-open .surface-group-editor {
  display: block;
}

.nav-group-list {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  transition: transform 0.25s ease;
  margin-top: 6px;
  padding-bottom: 25px;
  flex: 0 0 auto;
}

.nav-window-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.map-nav-window.nav-editor-open .nav-group-list {
  transform: translateY(6px);
}

.surface-group-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.surface-group-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.surface-group-link.active {
  border-color: var(--interactive);
  background: var(--interactive-light);
}

.surface-groups-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 40;
}

.surface-groups-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, 92vw);
  max-height: 82vh;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 41;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 16px;
}

.surface-groups-popup-title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.surface-groups-popup-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.surface-groups-popup-actions button {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.surface-groups-popup-table-wrap {
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  scrollbar-gutter: stable;
}

.surface-groups-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.catasto-address-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 42;
}

.catasto-address-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 43;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
}

.catasto-address-popup-title {
  font-weight: 600;
  color: #111827;
  cursor: move;
  user-select: none;
}

.catasto-address-popup-text {
  font-size: 13px;
  color: #475569;
}

.catasto-address-popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.catasto-address-popup-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.catasto-duplicate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
}

.catasto-duplicate-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.catasto-duplicate-item:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.catasto-duplicate-item .title {
  font-weight: 600;
  color: #111827;
}

.catasto-duplicate-item .meta {
  font-size: 12px;
  color: #64748b;
}

.fastmap-job-toast {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 12;
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  max-width: 280px;
  white-space: pre-line;
}

.fastmap-job-toast[data-state="running"] {
  border-color: var(--interactive);
  background: var(--interactive-light);
}

.fastmap-job-toast[data-state="ok"] {
  border-color: #16a34a;
}

.fastmap-job-toast[data-state="error"] {
  border-color: #dc2626;
  background: #fef2f2;
}

.fastmap-job-backdrop {
  position: absolute;
  inset: 0;
  z-index: 11;
  background: transparent;
}

.fastmap-job-popup {
  position: absolute;
  left: 16px;
  bottom: 60px;
  z-index: 12;
  width: 320px;
  max-width: calc(100% - 32px);
  padding: 10px 12px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
}

.fastmap-job-popup-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.fastmap-job-popup-status {
  margin-bottom: 6px;
  white-space: pre-line;
}

.fastmap-job-popup-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.fastmap-job-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  color: var(--text-muted);
}

.fastmap-job-close:hover {
  color: var(--text-main);
}

.map-controls-topright label {
  font-size: 12px;
  margin-bottom: 2px;
}

.map-controls-topright select {
  width: 100%;
  max-width: 100%;
  margin-bottom: 6px;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}

.zoom-row input[type="range"] {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.zoom-row label,
.zoom-row .zoom-value {
  flex: 0 0 auto;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid var(--interactive);
  box-shadow: var(--shadow-xs);
  margin-top: -5px;
}

input[type="range"]::-moz-range-thumb {
  height: 16px;
  width: 16px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 2px solid var(--interactive);
  box-shadow: var(--shadow-xs);
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.layer-slider::-webkit-slider-thumb {
  border-color: #2563eb;
}

.layer-slider::-moz-range-thumb {
  border-color: #2563eb;
}

.zoom-row .zoom-value {
  font-size: 13px;
  min-width: 24px;
  text-align: right;
}

.coords-row {
  font-size: 13px;
  margin-top: 4px;
  color: var(--text-muted);
}

.coords-row span.value {
  font-weight: 600;
  color: var(--text-main);
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-row h2 {
  margin: 0;
}

.section-eye-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 6px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

.section-eye-btn svg {
  width: 14px;
  height: 14px;
  stroke: var(--interactive);
  stroke-width: 2;
  fill: none;
}

.section-eye-btn.is-off svg {
  stroke: #9ca3af;
}

.section-eye-btn.is-off::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 2px;
  background: #9ca3af;
  transform: rotate(-45deg);
}

.section-toggle {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-left: auto;
}

.section-triangle {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--text-muted);
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.inspire-section.collapsed .section-triangle,
.collapsible-section.collapsed .section-triangle {
  transform: rotate(0deg);
}

.section-body {
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.25s ease, opacity 0.25s ease;
}

.inspire-section.collapsed .section-body,
.collapsible-section.collapsed .section-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
