@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
}

:root {
  --bg: #ffffff;
  --bg2: #f5f5f5;
  --card: #ffffff;
  --border: #53006c;
  --border-light: #d0bada;
  --text: #53006c;
  --muted: #7a3a8a;
  --accent: #53006c;
  --accent-dark: #35004a;
  --radius: 0px;
  --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0 !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─── */
header {
  padding: 0 32px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
}

.logo span {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  display: block;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

header .spacer { flex: 1; }
.basemap-switcher {
  z-index: 9999 !important;
  pointer-events: auto;
}
.badge {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* ─── LAYOUT ─── */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  align-items: start;
}

/* ─── SIDEBAR ─── */
.sidebar {
  background: var(--bg);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); }

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-section h3 {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* City info */
.city-info {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  background: var(--bg);
}

.city-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.city-meta { font-size: 10px; color: var(--muted); margin-top: 2px; }

.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.score-ring-wrap canvas { width: 64px !important; height: 64px !important; }
.score-val { font-size: 18px; font-weight: 700; color: var(--text); }
.score-label { font-size: 9px; color: var(--muted); text-align: center; letter-spacing: 0.08em; text-transform: uppercase; }

/* Category selector */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cat-btn {
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 10px 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s;
  color: var(--text);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.cat-btn:hover {
  border-color: var(--border);
  background: var(--bg2);
}

.cat-btn.active {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: var(--bg);
}

.cat-btn.active svg path,
.cat-btn.active svg rect,
.cat-btn.active svg circle,
.cat-btn.active svg line,
.cat-btn.active svg polyline,
.cat-btn.active svg polygon {
  stroke: #ffffff;
  fill: none;
}

.cat-btn.active svg .fill-black {
  fill: #ffffff;
  stroke: none;
}

.cat-icon-svg { width: 22px; height: 22px; display: block; }

/* Legend */
.legend-bar {
  height: 8px;
  background: linear-gradient(90deg, #22c55e, #86efac, #fbbf24, #f97316, #ef4444);
  border: 1px solid var(--border-light);
}
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── MAIN ─── */
.main-content {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

#map {
  width: 100%;
  height: calc(85vh - 52px);
  flex-shrink: 0;
  position: relative;
}

/* ─── CHARTS PANEL ─── */
.charts-panel {
  border-top: 2px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  height: 480px;
  min-height: 480px;
  flex-shrink: 0;
}

.charts-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.charts-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.charts-subtitle { font-size: 10px; color: var(--muted); }
.spacer { flex: 1; }

.charts-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0;
  overflow: hidden;
}

.chart-card {
  padding: 12px 14px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}

.chart-card:nth-child(2),
.chart-card:nth-child(4) { border-right: none; }
.chart-card:nth-child(3),
.chart-card:nth-child(4) { border-bottom: none; }

.chart-card-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  flex-shrink: 0;
}

.chart-card canvas {
  flex: 1;
  min-height: 0;
}

.stat-row {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.stat-chip {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  padding: 4px 8px;
  font-size: 10px;
  flex: 1;
  text-align: center;
}

.stat-chip .val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  display: block;
}

.stat-chip .lbl { color: var(--muted); font-size: 9px; letter-spacing: 0.05em; }

.empty-charts {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 14px;
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-light);
  border-top-color: var(--border);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 12px; color: var(--muted); letter-spacing: 0.05em; }

.leaflet-container { background: #f0f0f0 !important; }

/* ─── BASEMAP SWITCHER ─── */
.basemap-switcher {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1001;
}

.basemap-btn {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0 var(--border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.basemap-btn:hover { background: var(--bg2); }

.basemap-dropdown {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  background: #ffffff;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border-light);
  min-width: 160px;
  z-index: 1002;
}

.basemap-dropdown.open { display: block; }

.basemap-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  user-select: none;
  transition: background 0.1s;
}

.basemap-option:last-child { border-bottom: none; }
.basemap-option:hover { background: var(--bg2); }
.basemap-option.active { background: var(--accent-dark); color: #fff; }
.basemap-option.active .basemap-thumb { border-color: rgba(255,255,255,0.5); }

.basemap-thumb {
  width: 28px;
  height: 20px;
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.basemap-thumb-light {
  background: linear-gradient(135deg, #e8e8e8 0%, #f5f5f5 40%, #d0d0d0 100%);
}

.basemap-thumb-ortofoto {
  background: linear-gradient(135deg, #4a6741 0%, #3d5c38 30%, #8a7a5a 55%, #6b6b5a 80%, #a09080 100%);
  position: relative;
  overflow: hidden;
}
.basemap-thumb-ortofoto::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,0.04) 2px, rgba(255,255,255,0.04) 4px),
    repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(0,0,0,0.05) 3px, rgba(0,0,0,0.05) 5px);
}

/* ─── POI PANEL nel dropdown basemap ─── */
.basemap-section-title {
  padding: 6px 12px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--border-light);
  margin-top: 2px;
  user-select: none;
}

.poi-layer-list {
  max-height: 280px;
  overflow-y: auto;
}

.poi-layer-list::-webkit-scrollbar { width: 3px; }
.poi-layer-list::-webkit-scrollbar-thumb { background: var(--border-light); }

.poi-layer-row {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  cursor: default;
}

.poi-layer-row:last-child { border-bottom: none; }

.poi-layer-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  border-right: 1px solid var(--border-light);
}

.poi-layer-check input[type=checkbox] {
  width: 12px;
  height: 12px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  border-radius: 0 !important;
}

.poi-layer-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  margin: 0 6px 0 8px;
}

.poi-layer-label {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  padding: 0 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 32px;
}

.poi-layer-row.current-cat .poi-layer-label {
  font-weight: 700;
}

.poi-layer-expand {
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  border-left: 1px solid var(--border-light);
  color: var(--muted);
  font-size: 10px;
  transition: transform 0.15s;
  user-select: none;
}

.poi-layer-expand.open { transform: rotate(180deg); }

.poi-subtype-list {
  display: none;
  background: var(--bg2);
  border-bottom: 1px solid var(--border-light);
}

.poi-subtype-list.open { display: block; }

.poi-subtype-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 36px;
  border-bottom: 1px solid rgba(208,186,218,0.4);
  cursor: pointer;
}

.poi-subtype-row:last-child { border-bottom: none; }

.poi-subtype-row:hover { background: rgba(83,0,108,0.06); }

.poi-subtype-row input[type=checkbox] {
  width: 11px;
  height: 11px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.poi-subtype-label {
  font-size: 10px;
  color: var(--muted);
  flex: 1;
}

/* ─── POI SECTION ─── */
.poi-section {
  border-top: 1px solid var(--border-light);
  margin-top: 0;
  background: var(--bg);
  flex-shrink: 0;
}

.poi-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
}

.poi-info-bar {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}

.poi-stat {
  flex: 1;
  padding: 10px 16px;
  border-right: 1px solid var(--border-light);
}
.poi-stat:last-child { border-right: none; }
.poi-stat .val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.poi-stat .lbl {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 3px;
}

.poi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 220px 220px;
  border-top: none;
}

/* POI alphabetical list */
.poi-alpha-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  font-size: 10px;
}

.poi-alpha-list::-webkit-scrollbar { width: 3px; }
.poi-alpha-list::-webkit-scrollbar-thumb { background: var(--border-light); }

.poi-alpha-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg2);
  line-height: 1.3;
}

.poi-alpha-item:last-child { border-bottom: none; }

.poi-alpha-name {
  flex: 1;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poi-alpha-type {
  color: var(--muted);
  font-size: 9px;
  flex-shrink: 0;
}

.map-tooltip {
  background: #fff !important;
  border: 1px solid #000 !important;
  color: #000 !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 11px !important;
  padding: 10px 14px !important;
  box-shadow: 2px 2px 0 #000 !important;
}