:root {
  --bg-page: #080e1a;
  --bg-navbar: rgba(11, 19, 34, 0.96);
  --bg-card: #0f172a;
  --bg-card-header: #0b1322;
  --border-subtle: rgba(255, 255, 255, 0.08);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --color-teal: #2dd4bf;
  --color-amber: #fbbf24;
  --color-blue: #38bdf8;
  --color-green: #10b981;
  --color-purple: #8b5cf6;
  --color-red: #ef4444;
}

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

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* NAVBAR */
.navbar { background: var(--bg-navbar); border-bottom: 1px solid var(--border-subtle); padding: 14px 28px; position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); }
.navbar-inner { max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.nav-left { display: flex; flex-direction: column; gap: 6px; }
.nav-selectors { display: flex; align-items: center; gap: 10px; }

.badge-condominio { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 12px; letter-spacing: 0.05em; }
.badge-zona { background: rgba(56, 189, 248, 0.12); color: var(--color-blue); border: 1px solid rgba(56, 189, 248, 0.3); font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 12px; }

.custom-select { background: #0d1728; color: #cbd5e1; border: 1px solid rgba(255, 255, 255, 0.15); padding: 8px 14px; border-radius: 12px; font-size: 0.88rem; font-weight: 500; outline: none; cursor: pointer; transition: border 0.2s; }
.nav-subtitle { color: var(--text-muted); font-size: 0.88rem; }
.nav-tabs { display: flex; gap: 10px; }
.tab-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.12); color: var(--text-muted); padding: 9px 18px; border-radius: 12px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.tab-btn:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.tab-btn.tab-active { background: rgba(16, 185, 129, 0.12); border-color: #10b981; color: #34d399; }

/* CONTENITORE CENTRALE */
.main-container { max-width: 1400px; margin: 36px auto; padding: 0 28px; }
.view-header { margin-bottom: 16px; }
.prospetto-tag { color: var(--color-teal); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 8px; }
.view-title { font-size: 1.7rem; font-weight: 700; color: #fff; }
.view-subtitle { font-size: 0.9rem; color: var(--text-dim); margin-top: 6px; }

/* TIMELINE ANNI */
.year-timeline { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 24px; border-bottom: 1px solid var(--border-subtle); scrollbar-width: none; }
.year-pill { padding: 6px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; transition: all 0.2s; white-space: nowrap; }
.year-pill.disabled { background: transparent; border: 1px solid rgba(255,255,255,0.05); color: rgba(255,255,255,0.2); cursor: not-allowed; }
.year-pill.has-data { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.15); color: #cbd5e1; cursor: pointer; }
.year-pill.has-data:hover { background: rgba(255,255,255,0.1); }
.year-pill.active { background: var(--color-teal); border: 1px solid var(--color-teal); color: #080e1a; font-weight: 700; }

/* CARDS */
.base-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 20px; padding: 24px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); transition: opacity 0.3s ease; }
.card-disabled { opacity: 0.4; pointer-events: none; filter: grayscale(100%); }
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 16px; }
.kpi-label { color: var(--text-dim); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 10px; }
.kpi-value { font-family: 'JetBrains Mono', monospace; font-size: 2rem; font-weight: 700; }
.kpi-subtext { color: var(--text-dim); font-size: 0.75rem; margin-top: 8px; line-height: 1.4; }
.kpi-val-teal { color: var(--color-teal); }
.kpi-val-green { color: var(--color-green); }
.kpi-val-blue { color: var(--color-blue); }
.kpi-val-nd { color: var(--text-muted); font-size: 1.5rem; }

/* BARRA ULTIMA LETTURA */
.last-reading-bar { background: rgba(16, 185, 129, 0.05); border: 1px solid rgba(16, 185, 129, 0.2); border-radius: 12px; padding: 12px 20px; margin-bottom: 32px; font-size: 0.9rem; color: #cbd5e1; display: flex; align-items: center; gap: 10px; }
.dot-pulse { width: 8px; height: 8px; background-color: #10b981; border-radius: 50%; box-shadow: 0 0 8px #10b981; }

/* GRAFICI */
.dashboard-bottom-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; }
.chart-container { position: relative; height: 320px; width: 100%; margin-top: 16px; }
.card-title { font-size: 1.1rem; font-weight: 600; color: #fff; margin-bottom: 6px; }
.card-subtitle { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 16px; line-height: 1.4; }
.chart-legend-custom { display: flex; gap: 16px; margin-top: 10px; font-size: 0.8rem; color: var(--text-muted); justify-content: center; }
.pie-chart-container { position: relative; height: 200px; width: 100%; margin-top: 20px; display: flex; justify-content: center; }

/* GIORNALIERO */
.daily-display { background: #0b1322; border: 1px solid rgba(255,255,255,0.05); border-radius: 12px; padding: 20px; margin-top: 20px; text-align: center; }
.daily-val { font-family: 'JetBrains Mono', monospace; font-size: 1.6rem; font-weight: 700; color: var(--color-purple); margin: 10px 0; }
.hourly-chart-container { height: 100px; width: 100%; margin-top: 16px; border-top: 1px dashed rgba(255,255,255,0.1); padding-top: 16px; }

/* TABELLE */
.table-wrapper { border-radius: 20px; overflow: hidden; border: 1px solid var(--border-subtle); box-shadow: 0 8px 24px rgba(0,0,0,0.25); background: var(--bg-card); margin-bottom: 24px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 800px; }
.data-table th { background: var(--bg-card-header); color: var(--text-dim); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); }
.data-table td { padding: 15px 20px; border-bottom: 1px solid var(--border-subtle); color: #e2e8f0; }
.data-table tr:hover { background: rgba(255, 255, 255, 0.02); }
.row-total { background: #0b1322 !important; border-top: 2px solid rgba(45, 212, 191, 0.3); font-weight: 700; }
.row-total td { color: #fff !important; }

/* DISCLAIMER E UTILITA' */
.disclaimer-box { background: rgba(239, 68, 68, 0.05); border-left: 4px solid var(--color-red); padding: 16px 20px; border-radius: 0 12px 12px 0; margin-bottom: 24px; font-size: 0.85rem; color: #cbd5e1; line-height: 1.5; }
.disclaimer-title { color: var(--color-red); font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.num-col { font-family: 'JetBrains Mono', monospace; color: #cbd5e1; }
.val-consumo { font-family: 'JetBrains Mono', monospace; color: var(--color-teal); font-weight: 600; }
.val-spesa { font-family: 'JetBrains Mono', monospace; color: var(--color-amber); font-weight: 600; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 auto; }
.dot-green { background: #10b981; }
.dot-amber { background: #f59e0b; }
.dot-gray { background: #64748b; }
.badge-estivo { background: rgba(251, 191, 36, 0.12); color: var(--color-amber); border: 1px solid rgba(251, 191, 36, 0.3); font-size: 0.7rem; padding: 3px 8px; border-radius: 8px; margin-left: 8px; }
.riga-estiva { background: rgba(251, 191, 36, 0.015); }
.riga-invernale { background: rgba(56, 189, 248, 0.02); }

.legenda-section { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border-subtle); }
.legenda-section h4 { color: #fff; margin-bottom: 16px; font-size: 0.95rem; }
.legenda-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; font-size: 0.85rem; color: var(--text-muted); }
.legenda-grid span { font-weight: 600; color: #cbd5e1; }
