*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f8f8f6;
  --bg2:       #ffffff;
  --border:    rgba(0,0,0,0.1);
  --text:      #1a1a18;
  --text2:     #6b6b67;
  --text3:     #9b9b95;
  --blue:      #185FA5;
  --blue-light:#E6F1FB;
  --green:     #1D9E75;
  --green-light:#EAF3DE;
  --amber:     #BA7517;
  --amber-light:#FAEEDA;
  --red:       #A32D2D;
  --red-light: #FCEBEB;
  --radius:    8px;
  --radius-lg: 12px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; padding-top: 40px; }

/* Google Translate banner */
.goog-te-banner-frame { position: fixed !important; top: 0 !important; height: 40px !important; z-index: 99 !important; }

/* Navbar a due righe — fixed */
.navbar {
  width: 100%;
  background-color: #ffffff !important;
  border-bottom: 0.5px solid var(--border);
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  z-index: 9999;
  padding: 10px 20px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);

}

/* Copertura sopra navbar */
.navbar::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  height: 40px;
  background: #ffffff;
  z-index: 9999;
}

/* Riga 1: brand centrato */
.navbar-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-bottom: 8px;
}

.nav-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: inherit;
}
.nav-brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
}
.nav-call { font-size: 12px; color: var(--text2); font-weight: 400; }

.nav-solar {
  display: none;
}
.solar-pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; background: var(--bg); border: 0.5px solid var(--border); color: var(--text2); }
.solar-pill.good { background: var(--green-light); color: #27500A; }
.solar-pill.warn { background: var(--amber-light); color: var(--amber); }
.solar-pill.bad  { background: var(--red-light); color: var(--red); }

/* Hamburger */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  cursor: pointer;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.nav-hamburger span { display: block; height: 2px; background: var(--text2); border-radius: 2px; transition: all .25s; }
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Riga 2: solar centrato */
.navbar-solar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 0 6px;
  border-top: 0.5px solid var(--border);
}

/* Riga 3: link centrati */
.navbar-bottom {
  display: flex;
  justify-content: center;
  width: 100%;
  border-top: 0.5px solid var(--border);
  padding: 4px 0;
}

.nav-links { display: flex; gap: 2px; list-style: none; flex-wrap: wrap; justify-content: center; }
.nav-links a { padding: 4px 10px; border-radius: var(--radius); color: var(--text2); text-decoration: none; font-size: 13px; transition: background .15s; white-space: nowrap; }
.nav-links a:hover { background: var(--bg); color: var(--text); }
.nav-links a.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }

/* Menu mobile */
.nav-mobile {
  display: none;
  position: fixed;
  top: 377px;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-bottom: 0.5px solid var(--border);
  z-index: 9998;
  padding: 8px 16px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.nav-mobile.open { display: block; }
.nav-mobile ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-mobile ul li a { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--text2); text-decoration: none; font-size: 14px; transition: background .15s; }
.nav-mobile ul li a:hover { background: var(--bg); color: var(--text); }
.nav-mobile ul li a.active { background: var(--blue-light); color: var(--blue); font-weight: 500; }
.nav-mobile-solar { display: flex; gap: 6px; padding: 8px 12px 4px; border-top: 0.5px solid var(--border); margin-top: 6px; align-items: center; flex-wrap: wrap; }

/* Layout — margin-top compensa navbar fixed (40px banner + 297px navbar) */
.main-content { padding: 20px; max-width: 1400px; margin: 400px auto 0; }
.page-title { font-size: 18px; font-weight: 500; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 1200px) { .grid-5 { grid-template-columns: repeat(3, 1fr); } }

/* Cards */
.card { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; position: relative; z-index: 0; }
.card-title { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; font-weight: 500; }
.metric-val { font-size: 28px; font-weight: 500; line-height: 1; }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* Tabelle */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 7px 10px; text-align: left; font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; border-bottom: 0.5px solid var(--border); font-weight: 500; background: var(--bg); }
.data-table td { padding: 7px 10px; border-bottom: 0.5px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* Badge */
.badge { display: inline-block; font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 500; }
.badge-blue   { background: var(--blue-light); color: var(--blue); }
.badge-green  { background: var(--green-light); color: #0F6E56; }
.badge-amber  { background: var(--amber-light); color: var(--amber); }
.badge-gray   { background: var(--bg); color: var(--text2); border: 0.5px solid var(--border); }

/* Barra attività */
.act-bar { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.act-fill { height: 100%; border-radius: 3px; }

/* Mappa */
#main-map { height: 400px; border-radius: var(--radius); overflow: hidden; }
.leaflet-pane { z-index: 1 !important; }
.leaflet-top, .leaflet-bottom { z-index: 2 !important; }
.leaflet-control { z-index: 2 !important; }
.leaflet-container { z-index: 1 !important; }

/* Responsive */
@media (max-width: 1100px) {
  .navbar-bottom .nav-links { display: none; }
  .nav-solar { display: none !important; }
  .nav-hamburger { display: flex; }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }
}
