/* Casa Campagna — "fuoco e pietra": la scheda della stufa prende il colore del suo stato,
   tutto il resto resta sobrio su un grigio nebbia freddo. */

@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2-variations"), url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #e9edf1;
  --panel: #ffffff;
  --fg: #142230;
  --muted: #5d6b7a;
  --line: #d6dde4;
  --brace: #e8590c;
  --fiamma: #f59f00;
  --acqua: #2b78c5;
  --foglia: #23875a;
  --ambra: #c77700;
  --allarme: #d42a2a;
  /* alias usati dal grafico */
  --ok: var(--foglia);
  --warn: var(--ambra);
  --bad: var(--allarme);
  --info: var(--acqua);
  --accent: var(--brace);
  --primary-bg: #142230;
  --primary-fg: #ffffff;
  --r-hero: 26px;
  --r-card: 20px;
  --r-chip: 14px;
  --ombra: 0 1px 0 rgba(20, 34, 48, .04), 0 10px 26px -16px rgba(20, 34, 48, .28);
  --display: "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1620;
    --panel: #16212c;
    --fg: #e6ecf2;
    --muted: #93a1af;
    --line: #253341;
    --brace: #ff7a3d;
    --fiamma: #ffb627;
    --acqua: #5fa3e8;
    --foglia: #4cc38a;
    --ambra: #f0a43a;
    --allarme: #ff6b6b;
    --primary-bg: #e6ecf2;
    --primary-fg: #0d1620;
    --ombra: none;
  }
  .card { border-color: var(--line); }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(84px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--acqua); }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; display: block; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.top { margin: 6px 2px 16px; }
.top h1 { font-family: var(--display); font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; margin: 0; }
.top .sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.ok { color: var(--foglia); }
.err { color: var(--allarme); }

/* ---------- la stufa: scheda che cambia colore con lo stato ---------- */
.hero {
  --h-bg: linear-gradient(150deg, #3b4b5c 0%, #1c2631 100%);
  --h-ombra: rgba(28, 38, 49, .45);
  position: relative;
  color: #fff;
  background: var(--h-bg);
  border-radius: var(--r-hero);
  padding: 18px 16px 16px;
  margin-bottom: 14px;
  box-shadow: 0 20px 38px -24px var(--h-ombra);
  overflow: hidden;
  transition: box-shadow .4s;
}
.hero.lavoro {
  --h-bg: radial-gradient(90% 120% at 8% 0%, rgba(255, 182, 39, .8) 0%, rgba(255, 182, 39, 0) 58%),
          linear-gradient(150deg, #c2410c 0%, #8a240b 55%, #561409 100%);
  --h-ombra: rgba(194, 65, 12, .75);
}
.hero.accensione {
  --h-bg: radial-gradient(90% 120% at 8% 0%, rgba(255, 210, 120, .55) 0%, rgba(255, 210, 120, 0) 58%),
          linear-gradient(150deg, #a86300 0%, #6b3f00 100%);
  --h-ombra: rgba(168, 99, 0, .6);
}
.hero.allarme { --h-bg: linear-gradient(150deg, #c92a2a 0%, #6e1111 100%); --h-ombra: rgba(201, 42, 42, .7); }
.hero.pulizia, .hero.finale { --h-bg: linear-gradient(150deg, #2f6db0 0%, #173a63 100%); --h-ombra: rgba(47, 109, 176, .55); }
.hero.standby { --h-bg: linear-gradient(150deg, #4a5d70 0%, #26333f 100%); }

.hero-top { display: flex; align-items: center; gap: 14px; }
.fiamma {
  width: 56px; height: 56px; border-radius: 18px; flex: none;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .75);
}
.fiamma .ic { width: 30px; height: 30px; }
.fiamma.lavoro { color: #ffd27a; background: rgba(255, 255, 255, .18); }
.fiamma.lavoro .ic { transform-origin: 50% 90%; animation: guizzo 2.6s ease-in-out infinite; }
.fiamma.accensione .ic { animation: respiro 1.6s ease-in-out infinite; }
@keyframes guizzo {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50% { transform: scale(1.07) rotate(2deg); }
}
@keyframes respiro { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.hero-stato { flex: 1; min-width: 0; }
.hero-nome { font-size: .8rem; opacity: .82; }
.hero .nome { font-family: var(--display); font-size: 2.1rem; font-weight: 700; line-height: 1.02; letter-spacing: -.03em; }
.hero .da { font-size: .85rem; opacity: .85; margin-top: 2px; }
.pill {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  color: #fff; text-decoration: none; font-size: .82rem; font-weight: 600;
  background: rgba(255, 255, 255, .16); padding: 7px 12px 7px 10px; border-radius: 999px;
}
.pill .ic { width: 16px; height: 16px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; gap: 10px; align-items: flex-start; background: rgba(255, 255, 255, .12); border-radius: var(--r-chip); padding: 10px 12px; }
.stat > .ic { width: 19px; height: 19px; opacity: .85; margin-top: 2px; }
.stat .l { font-size: .74rem; opacity: .82; }
.stat .v { font-family: var(--display); font-size: 1.4rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .8rem; font-weight: 500; opacity: .75; }
.barre { display: flex; gap: 3px; margin-top: 6px; }
.barre b { width: 13px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); }
.barre b.on { background: #fff; }
.hero .hint { border-left-color: rgba(255, 255, 255, .55); }
.hero .hint.warn { border-left-color: #ffd27a; }
.allarme-riga { margin: 12px 0 0; padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .25); font-weight: 600; font-size: .9rem; }

/* ---------- schede ---------- */
.card { background: var(--panel); border: 1px solid transparent; border-radius: var(--r-card); box-shadow: var(--ombra); padding: 16px 16px 18px; margin-bottom: 14px; }
.card h2 { font-size: 1rem; font-weight: 650; margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 .link { font-size: .85rem; font-weight: 600; text-decoration: none; }
.tit { display: inline-flex; align-items: center; gap: 9px; }
.tit .ic { width: 18px; height: 18px; color: var(--muted); }
.card.allarmi { border-color: color-mix(in srgb, var(--allarme) 40%, transparent); }
.card.allarmi .tit .ic { color: var(--allarme); }

.hint { border-left: 3px solid var(--acqua); padding: 10px 12px; background: var(--bg); border-radius: 0 12px 12px 0; font-size: .88rem; margin-top: 12px; }
.hint.warn { border-left-color: var(--ambra); background: color-mix(in srgb, var(--ambra) 11%, var(--panel)); }
.hint.bad { border-left-color: var(--allarme); background: color-mix(in srgb, var(--allarme) 11%, var(--panel)); }
/* dentro la scheda colorata della stufa il suggerimento resta scuro e leggibile */
.hero .hint, .hero .hint.warn, .hero .hint.bad { background: rgba(0, 0, 0, .22); color: #fff; }

/* ---------- pellet ---------- */
.pellet { display: grid; grid-template-columns: 128px 1fr; gap: 18px; align-items: center; margin-bottom: 12px; }
.autonomia .l { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .82rem; }
.autonomia .l .ic { width: 15px; height: 15px; }
.autonomia .v { font-family: var(--display); font-size: 1.9rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.anello { position: relative; width: 128px; height: 128px; }
.anello svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.anello circle { fill: none; stroke-width: 12; }
.anello .fondo { stroke: var(--bg); }
.anello .valore { stroke: var(--foglia); stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset .9s ease, stroke .3s; }
.anello .valore.basso { stroke: var(--ambra); }
.anello .valore.vuoto { stroke: var(--allarme); }
.centro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.kg { font-family: var(--display); font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.righe { list-style: none; margin: 0; padding: 0; }
.righe li { display: grid; grid-template-columns: 18px 1fr auto; gap: 9px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: .85rem; }
.righe .ic { width: 16px; height: 16px; color: var(--muted); }
.righe span { color: var(--muted); }
.righe b { font-family: var(--display); font-size: 1rem; font-weight: 650; font-variant-numeric: tabular-nums; }
#pl-nota { margin: 12px 0 0; }
#b-pieno { margin-top: 14px; }

/* ---------- in arrivo ---------- */
.prossimi { list-style: none; margin: 0; padding: 0; }
.prossimi li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.prossimi li:first-child { border-top: 0; padding-top: 0; }
.prossimi b { display: block; font-size: .93rem; }
.prossimi span:not(.chip) { display: block; font-size: .8rem; color: var(--muted); }
.chip { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; flex: none; }
.c-acqua { background: color-mix(in srgb, var(--acqua) 14%, transparent); color: var(--acqua); }
.c-foglia { background: color-mix(in srgb, var(--foglia) 14%, transparent); color: var(--foglia); }
.c-sole { background: color-mix(in srgb, var(--fiamma) 18%, transparent); color: var(--ambra); }

/* ---------- allarmi e liste ---------- */
.avviso { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.avviso:first-child { border-top: 0; padding-top: 0; }
.avviso > .ic { width: 22px; height: 22px; margin-top: 1px; }
.avviso .t { font-weight: 650; }
.avviso.critico > .ic, .avviso.critico .t { color: var(--allarme); }
.avviso.attenzione > .ic, .avviso.attenzione .t { color: var(--ambra); }
.avviso.chiuso { opacity: .65; }
.avviso .azione { margin-top: 10px; min-height: 42px; }
.avviso.chiuso > .ic, .avviso.chiuso .t { color: var(--muted); }

.list .item { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.list .item:first-child { border-top: 0; }
.list .item > .ic { width: 18px; height: 18px; color: var(--muted); }
.list .item .sx { flex: 1; min-width: 0; }

/* ---------- pulsanti e comandi ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  border-radius: var(--r-chip); padding: 0 16px; min-height: 48px;
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn .ic { width: 18px; height: 18px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary-bg); border-color: transparent; color: var(--primary-fg); }
.btn.fuoco { background: linear-gradient(140deg, #f76707, #c2410c); border-color: transparent; color: #fff; }
.btn.danger { color: var(--allarme); }
.btn.full { width: 100%; }
.btn:focus-visible, a:focus-visible, input:focus-visible, .linkbtn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--acqua) 65%, transparent); outline-offset: 2px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }
.row.compatta { flex: 0 1 auto; }
.row.compatta > .btn { flex: 0 0 auto; }
.linkbtn { background: none; border: 0; color: var(--acqua); padding: 8px 0; cursor: pointer; font-weight: 600; }
.linkbtn.con-icona { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.linkbtn .ic { width: 16px; height: 16px; }

.ctrl { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--line); }
.card h2 + .ctrl { border-top: 0; padding-top: 2px; }
.ctrl .lbl { font-weight: 650; }
.ctrl .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.stepper { display: flex; align-items: center; gap: 8px; }
.btn.tondo { width: 46px; min-height: 46px; padding: 0; border-radius: 50%; }
.btn.invia { padding: 0 14px; }
.val-box { min-width: 72px; display: flex; flex-direction: column; align-items: center; }
.val { font-family: var(--display); font-size: 1.65rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.val-box .barre b { background: var(--line); }
.val-box .barre b.on { background: var(--brace); }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; padding: 12px 14px; border-radius: var(--r-chip); border: 1px solid var(--line); background: var(--bg); min-height: 48px;
}
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--ambra); border-radius: var(--r-chip); margin: 12px 0; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--brace); }

/* ---------- grafico ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ---------- barra in basso ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { position: relative; text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px; font-size: .72rem; font-weight: 500; }
.tab-ic { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .2s, color .2s; }
.tab-ic .ic { width: 22px; height: 22px; }
.tabs a.on { color: var(--fg); font-weight: 650; }
.tabs a.on .tab-ic { background: color-mix(in srgb, var(--brace) 16%, transparent); color: var(--brace); }
.tabs .badge { position: absolute; top: 4px; left: calc(50% + 10px); background: var(--allarme); color: #fff; border-radius: 9px; font-size: .65rem; font-weight: 700; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; }

/* ---------- finestre e messaggi ---------- */
.modal { position: fixed; inset: 0; background: rgba(8, 14, 20, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding: 12px; }
.sheet { background: var(--panel); border-radius: 24px; width: 100%; max-width: 520px; padding: 20px 18px 18px; margin-bottom: env(safe-area-inset-bottom); animation: sale .22s ease-out; }
.sheet h3 { font-family: var(--display); font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 8px; }
@keyframes sale { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); background: var(--fg); color: var(--bg); padding: 11px 16px; border-radius: var(--r-chip); font-size: .9rem; z-index: 30; max-width: 90vw; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); }
.toast.err { background: var(--allarme); color: #fff; }

.login { max-width: 420px; margin: 8vh auto 0; }
.login .logo { width: 68px; height: 68px; border-radius: 20px; display: block; margin: 0 auto 14px; }
.login h1 { font-family: var(--display); font-size: 1.9rem; letter-spacing: -.025em; text-align: center; margin: 0 0 4px; }
.login p.muted { text-align: center; margin: 0 0 18px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- fotovoltaico ---------- */
.hero.sole {
  --h-bg: radial-gradient(90% 120% at 8% 0%, rgba(255, 224, 130, .85) 0%, rgba(255, 224, 130, 0) 60%),
          linear-gradient(150deg, #d98a00 0%, #a35a00 55%, #6b3a00 100%);
  --h-ombra: rgba(217, 138, 0, .6);
}
.hero.notte { --h-bg: linear-gradient(150deg, #24365a 0%, #111b30 100%); --h-ombra: rgba(36, 54, 90, .55); }
.hero.sole .fiamma { color: #fff3c4; background: rgba(255, 255, 255, .2); }
.hero.sole .fiamma .ic { animation: gira 24s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.fv-griglia { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 10px; }
@media (min-width: 560px) { .fv-griglia { grid-template-columns: repeat(4, 1fr); } }
.fv-t { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fv-t .l { font-size: .76rem; color: var(--muted); }
.fv-t .v { font-family: var(--display); font-size: 1.2rem; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fv-t .v small { font-size: .75rem; font-weight: 500; color: var(--muted); }
.c-rete { background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); }
.chip.preleva { background: color-mix(in srgb, var(--allarme) 13%, transparent); color: var(--allarme); }
.chip.cede, .chip.carica { background: color-mix(in srgb, var(--foglia) 14%, transparent); color: var(--foglia); }
.chip.scarica { background: color-mix(in srgb, var(--ambra) 16%, transparent); color: var(--ambra); }
.fv-frase { margin: 14px 0 4px; }
#cf-oggi { margin: 0; }
.tabella { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.tabella th { text-align: right; font-weight: 600; color: var(--muted); font-size: .74rem; padding: 0 0 6px 6px; }
.tabella th:first-child, .tabella td:first-child { text-align: left; padding-left: 0; }
.tabella td { text-align: right; padding: 7px 0 7px 6px; border-top: 1px solid var(--line); }
#fv-grafico-soc { margin-top: 10px; }

/* ---------- casa a riquadri: un riquadro per aspetto, toccandolo si apre il dettaglio ---------- */
.tabs { grid-template-columns: repeat(3, 1fr); }
.gruppo { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 4px 9px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 1px; min-width: 0; min-height: 138px;
  padding: 12px 13px 13px; border-radius: var(--r-card); background: var(--panel); border: 1px solid transparent;
  box-shadow: var(--ombra); color: var(--fg); text-decoration: none; overflow: hidden; transition: transform .12s;
}
a.tile:active { transform: scale(.98); }
.t-testa { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.t-ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--bg); color: var(--muted); }
.t-ic .ic { width: 20px; height: 20px; }
.t-freccia { width: 18px; height: 18px; color: var(--muted); opacity: .6; }
.t-nome { font-size: .78rem; font-weight: 600; color: var(--muted); }
.t-val { font-family: var(--display); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.12; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.t-sub { font-size: .78rem; color: var(--muted); line-height: 1.3; margin-top: 2px; }
.t-barra { margin-top: auto; height: 5px; border-radius: 3px; background: var(--bg); overflow: hidden; }
.t-sub + .t-barra { margin-top: auto; }
.tile .t-barra { position: relative; top: 6px; }
.t-barra b { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--foglia); transition: width .7s ease; }
.t-barra b.basso { background: var(--ambra); }
.t-barra b.vuoto { background: var(--allarme); }

/* tinte dell'icona */
.t-ic.sole { background: color-mix(in srgb, var(--fiamma) 18%, transparent); color: var(--ambra); }
.t-ic.acqua { background: color-mix(in srgb, var(--acqua) 14%, transparent); color: var(--acqua); }
.t-ic.foglia { background: color-mix(in srgb, var(--foglia) 14%, transparent); color: var(--foglia); }
.t-ic.ambra { background: color-mix(in srgb, var(--ambra) 16%, transparent); color: var(--ambra); }
.t-ic.rosso { background: color-mix(in srgb, var(--allarme) 14%, transparent); color: var(--allarme); }

/* stati del riquadro */
.tile.attenzione { border-color: color-mix(in srgb, var(--ambra) 55%, transparent); }
.tile.attenzione .t-sub { color: var(--ambra); }
.tile.allarme { border-color: color-mix(in srgb, var(--allarme) 60%, transparent); background: color-mix(in srgb, var(--allarme) 7%, var(--panel)); }
.tile.allarme .t-val, .tile.allarme .t-sub { color: var(--allarme); }
.tile.caldo, .tile.accensione, .tile.sole { color: #fff; border-color: transparent; }
.tile.caldo { background: radial-gradient(110% 120% at 0% 0%, rgba(255, 182, 39, .75) 0%, rgba(255, 182, 39, 0) 60%), linear-gradient(150deg, #c2410c 0%, #7a1f0a 100%); }
.tile.accensione { background: linear-gradient(150deg, #a86300 0%, #6b3f00 100%); }
.tile.sole { background: radial-gradient(110% 120% at 0% 0%, rgba(255, 224, 130, .85) 0%, rgba(255, 224, 130, 0) 62%), linear-gradient(150deg, #d98a00 0%, #8a4b00 100%); }
.tile.caldo .t-nome, .tile.caldo .t-sub, .tile.accensione .t-nome, .tile.accensione .t-sub,
.tile.sole .t-nome, .tile.sole .t-sub, .tile.caldo .t-freccia, .tile.accensione .t-freccia, .tile.sole .t-freccia { color: rgba(255, 255, 255, .88); opacity: 1; }
.tile.caldo .t-ic, .tile.accensione .t-ic, .tile.sole .t-ic { background: rgba(255, 255, 255, .2); color: #fff3c4; }
.tile.caldo .t-ic .ic { transform-origin: 50% 90%; animation: guizzo 2.6s ease-in-out infinite; }
.tile.futuro { background: transparent; box-shadow: none; border: 1.5px dashed var(--line); }
.tile.futuro .t-val { font-size: 1.1rem; color: var(--muted); }

/* riquadro largo degli allarmi */
.tile.largo { flex-direction: row; align-items: center; gap: 12px; min-height: 0; padding: 13px 14px; }
.tile.largo .t-corpo { flex: 1; min-width: 0; }
.tile.largo .t-val { font-size: 1.2rem; }
.tile.largo .t-ic { width: 42px; height: 42px; border-radius: 14px; }

.indietro { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 6px -6px; padding: 4px 6px; font-size: .92rem; font-weight: 600; color: var(--acqua); text-decoration: none; }
.indietro .ic { width: 18px; height: 18px; }
.card.analisi { margin-top: 22px; }
@media (prefers-color-scheme: dark) { .tile:not(.caldo):not(.accensione):not(.sole):not(.futuro):not(.attenzione):not(.allarme) { border-color: var(--line); } }
/* su telefono l'ultimo riquadro dispari prende tutta la riga */
@media (max-width: 639px) { .tiles > .tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; } }
.t-val small.muto { font-family: system-ui, -apple-system, sans-serif; font-size: .78rem; font-weight: 500; letter-spacing: 0; opacity: .75; }
.tiles.aree .tile { min-height: 150px; }
#pc-val { margin-bottom: 4px; }
/* ---------- stanze ---------- */
.stanza { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.stanza:first-child { border-top: 0; padding-top: 2px; }
.stanza .sx { flex: 1; min-width: 0; }
.stanza .nome { font-weight: 650; font-size: .95rem; }
.stanza .gradi { font-family: var(--display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stanza.futura { opacity: .6; }
.stanza.futura .gradi { font-family: inherit; font-size: .85rem; font-weight: 500; color: var(--muted); }
.stanza .stato { font-size: .78rem; font-weight: 600; }
.stanza .stato.ok { color: var(--foglia); }
.stanza .stato.freddo { color: var(--acqua); }
.stanza .stato.caldo { color: var(--ambra); }
.stanza .stato.offline { color: var(--allarme); }
/* ---------- consigli di Claude ---------- */
#t-analisi { margin-top: 10px; }
#t-analisi .t-val { font-size: 1.05rem; line-height: 1.25; }
.tile.largo + .tiles { margin-top: 10px; }
.analisi-testo p { margin: 0 0 10px; font-size: .92rem; }
.consiglio { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.consiglio:first-child { border-top: 0; }
.consiglio > .ic { width: 18px; height: 18px; color: var(--foglia); margin-top: 2px; }
.consiglio .t { font-weight: 650; font-size: .92rem; }
.consiglio .risparmio { display: inline-block; margin-top: 4px; font-size: .74rem; font-weight: 700; color: var(--foglia); background: color-mix(in srgb, var(--foglia) 12%, transparent); padding: 2px 8px; border-radius: 999px; }
.vecchia { padding: 9px 0; border-top: 1px solid var(--line); font-size: .88rem; }
.vecchia:first-child { border-top: 0; }
.vecchia summary { cursor: pointer; font-weight: 600; }
/* ---------- la casa in 3D ---------- */
.casa3d { margin-top: 10px; padding-bottom: 12px; overflow: hidden; }
.casa3d h2 { flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; font-size: .78rem; font-weight: 600; color: var(--muted); padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--fg); box-shadow: 0 1px 3px rgba(20, 34, 48, .18); }
.c3d-box { margin: 0 -14px; position: relative; }
.c3d-meteo { position: absolute; right: 14px; bottom: 2px; display: flex; align-items: center; gap: 7px; text-align: right; pointer-events: none; }
.c3d-meteo .ic { width: 24px; height: 24px; color: var(--muted); order: 2; }
.c3d-meteo .t { font-family: var(--display); font-size: 1.2rem; font-weight: 700; line-height: 1; }
.c3d-meteo .s { font-size: .7rem; font-weight: 600; color: var(--muted); }
.c3d { display: block; width: 100%; height: auto; overflow: visible; }
.c3d-legenda { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .74rem; color: var(--muted); margin-top: 6px; }
.c3d-legenda span { display: inline-flex; align-items: center; gap: 5px; }
.c3d-legenda i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.c3d-nota { font-size: .74rem; color: var(--muted); margin: 6px 0 0; }

.c3d {
  --muro-sopra: #fbf7f1; --muro-sud: #efe4d6; --muro-ovest: #dfcfbc;
  --pietra-sopra: #ece7dc; --pietra-sud: #d9d0c0; --pietra-ovest: #c3b8a4;
  --zoccolo-sud: #cfc6b8; --zoccolo-ovest: #bbb1a2;
  --vicino-sopra: #e7eaee; --vicino-sud: #d9dde2; --vicino-ovest: #c9ced5;
  --pav-ok: #cdeedd; --pav-freddo: #cfe2f7; --pav-caldo: #fbe1bb; --pav-nd: #eceff2; --pav-off: #f6d2d2;
  --prato: #d7ecca; --vialetto: #ece6da;
  --tetto-sopra: #c46a4b; --tetto-sud: #a3533a; --tetto-ovest: #8e4632;
  --pannello: #22374f; --pannello-riga: #4d6d92;
  --casotto-sopra: #f1f3f5; --casotto-sud: #dfe4e9; --casotto-ovest: #cdd4dc;
  --scuro: #39434e; --linea: rgba(20, 34, 48, .16);
  --eti-bg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  .c3d {
    --muro-sopra: #3a4552; --muro-sud: #2f3944; --muro-ovest: #27303a;
    --pietra-sopra: #45474a; --pietra-sud: #393b3e; --pietra-ovest: #2f3134;
    --zoccolo-sud: #252c33; --zoccolo-ovest: #1f252b;
    --vicino-sopra: #2a323b; --vicino-sud: #232a32; --vicino-ovest: #1d232a;
    --pav-ok: #1f4a36; --pav-freddo: #1d3b5c; --pav-caldo: #5a4220; --pav-nd: #2a333d; --pav-off: #552a2a;
    --prato: #1b2e22; --vialetto: #2a2f35;
    --tetto-sopra: #7a3f2c; --tetto-sud: #643323; --tetto-ovest: #552b1e;
    --pannello: #142538; --pannello-riga: #35587d;
    --casotto-sopra: #3a4350; --casotto-sud: #313945; --casotto-ovest: #29303a;
    --scuro: #0f151b; --linea: rgba(0, 0, 0, .35);
    --eti-bg: #1d2935;
  }
}
.c3d > path { stroke: var(--linea); stroke-width: .6; stroke-linejoin: round; }
.c3d .prato { fill: var(--prato); stroke: none; }
.c3d .vialetto { fill: var(--vialetto); stroke: none; }
.c3d .mattoni.f-sopra, .c3d .casotto.f-sopra { fill: var(--muro-sopra); }
.c3d .mattoni.f-sud { fill: var(--muro-sud); }
.c3d .mattoni.f-ovest { fill: var(--muro-ovest); }
.c3d .pietra.f-sopra { fill: var(--pietra-sopra); }
.c3d .pietra.f-sud { fill: var(--pietra-sud); }
.c3d .pietra.f-ovest { fill: var(--pietra-ovest); }
.c3d .zoccolo.f-sopra { fill: var(--pietra-sopra); }
.c3d .zoccolo.f-sud { fill: var(--zoccolo-sud); }
.c3d .zoccolo.f-ovest { fill: var(--zoccolo-ovest); }
.c3d .pieno.f-sopra { fill: var(--muro-sopra); }
.c3d .pietra.pieno.f-sopra { fill: var(--pietra-sopra); }
.c3d .vicino.f-sopra { fill: var(--vicino-sopra); }
.c3d .vicino.f-sud { fill: var(--vicino-sud); }
.c3d .vicino.f-ovest { fill: var(--vicino-ovest); }
.c3d .casotto.f-sud { fill: var(--casotto-sud); }
.c3d .casotto.f-ovest { fill: var(--casotto-ovest); }
.c3d .casotto.f-sopra { fill: var(--casotto-sopra); }
.c3d .tetto.f-sopra { fill: var(--tetto-sopra); }
.c3d .tetto.f-sud { fill: var(--tetto-sud); }
.c3d .tetto.f-ovest { fill: var(--tetto-ovest); }
.c3d .pannello { fill: var(--pannello); stroke: var(--pannello-riga); stroke-width: .8; }
.c3d .pav { stroke: none; transition: fill .6s; }
.c3d .pav.ok { fill: var(--pav-ok); }
.c3d .pav.freddo { fill: var(--pav-freddo); }
.c3d .pav.caldo { fill: var(--pav-caldo); }
.c3d .pav.nd { fill: var(--pav-nd); }
.c3d .pav.off { fill: var(--pav-off); }
.c3d .veranda.f-sopra { fill: var(--pietra-sopra); }
.c3d .veranda.f-sud, .c3d .veranda.f-ovest { fill: var(--pietra-ovest); }
.c3d .ringhiera { fill: var(--scuro); fill-opacity: .25; stroke: none; }
.c3d .pedana.f-sopra { fill: #c0573a; }
.c3d .pedana.f-sud, .c3d .pedana.f-ovest { fill: #96402a; }
.c3d .stufa.f-sopra { fill: #f5efe4; }
.c3d .stufa.f-sud { fill: #e9dfcf; }
.c3d .stufa.f-ovest { fill: #d6c9b5; }
.c3d .focolare { fill: #2b2f33; stroke: none; }
.c3d .focolare.lavoro { fill: #ff8a1f; animation: c3d-brace 1.8s ease-in-out infinite alternate; }
.c3d .focolare.accensione { fill: #f5b031; animation: c3d-brace .9s ease-in-out infinite alternate; }
.c3d .focolare.allarme { fill: #d42a2a; }
.c3d .tubo { fill: #6b7581; stroke: none; }
.c3d .onda { fill: none; stroke: #ff8a1f; stroke-width: 1.6; stroke-linecap: round; opacity: 0; animation: c3d-sale 2.4s ease-in infinite; }
.c3d .onda.o1 { animation-delay: .8s; }
.c3d .onda.o2 { animation-delay: 1.6s; }
.c3d .termo.f-sopra, .c3d .termo.f-sud, .c3d .termo.f-ovest { stroke: none; }
.c3d .termo.freddo.f-sopra { fill: #e6eaee; } .c3d .termo.freddo.f-sud { fill: #cfd6dd; } .c3d .termo.freddo.f-ovest { fill: #bcc5ce; }
.c3d .termo.caldo.f-sopra { fill: #ffb08a; } .c3d .termo.caldo.f-sud { fill: #f0784a; } .c3d .termo.caldo.f-ovest { fill: #d65a2c; }
.c3d .inverter { fill: #eef1f4; stroke: #8a96a3; }
.c3d .batteria.f-sopra { fill: #59636e; } .c3d .batteria.f-sud { fill: #3d4651; } .c3d .batteria.f-ovest { fill: #2f3740; }
.c3d .palo { fill: #8a7a66; stroke: none; }
.c3d .cavo { fill: none; stroke: #6b7581; stroke-width: 1; }
.c3d .scavo { fill: none; stroke: #b9ab94; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.c3d .traccia { fill: none; stroke-width: 3.2; stroke-linecap: round; opacity: .22; }
.c3d .flusso { fill: none; stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 1.5 7.5; animation: c3d-flusso 1.2s linear infinite; }
.c3d .flusso.inv { animation-direction: reverse; }
.c3d > .sole { stroke: #f2b100; }
.c3d > .batt { stroke: #23a36a; }
.c3d > .rete { stroke: #7a8796; }
.c3d > .casa { stroke: #2b78c5; }

.c3d .eti-box { fill: var(--eti-bg); stroke: var(--linea); stroke-width: .8; filter: drop-shadow(0 2px 4px rgba(20, 34, 48, .16)); }
.c3d .eti-coda { fill: var(--eti-bg); stroke: none; }
.c3d .eti-t { font-size: 10px; font-weight: 600; fill: var(--muted); }
.c3d .eti-v { font-family: var(--display); font-size: 13.5px; font-weight: 700; fill: var(--fg); font-variant-numeric: tabular-nums; }
.c3d .eti-e { font-family: system-ui, -apple-system, sans-serif; font-size: 10.5px; font-weight: 600; fill: var(--muted); }
.c3d .eti-ic { color: var(--muted); }
.c3d .eti.stanza.ok .eti-v { fill: var(--foglia); }
.c3d .eti.stanza.freddo .eti-v { fill: var(--acqua); }
.c3d .eti.stanza.caldo .eti-v { fill: var(--ambra); }
.c3d .eti.stanza.off .eti-v { fill: var(--allarme); }
.c3d .eti.stanza.nd .eti-v { fill: var(--muted); font-size: 11px; font-weight: 600; font-family: system-ui, -apple-system, sans-serif; }
.c3d .eti.umido .eti-e { fill: var(--ambra); }
.c3d .eti.stufa .eti-ic { color: var(--muted); }
.c3d .eti.stufa.lavoro .eti-ic, .c3d .eti.stufa.lavoro .eti-v { color: var(--brace); fill: var(--brace); }
.c3d .eti.stufa.accensione .eti-ic, .c3d .eti.stufa.accensione .eti-v { color: var(--ambra); fill: var(--ambra); }
.c3d .eti.stufa.allarme .eti-ic, .c3d .eti.stufa.allarme .eti-v { color: var(--allarme); fill: var(--allarme); }
.c3d .eti.sole .eti-ic { color: #e0a000; }
.c3d .eti.batt .eti-ic { color: #23a36a; }
.c3d .eti.rete.prelievo .eti-ic { color: var(--allarme); }
.c3d .eti.casa .eti-ic { color: var(--acqua); }
.c3d .meteo-t { font-family: var(--display); font-size: 20px; font-weight: 700; fill: var(--fg); }
.c3d .meteo-s { font-size: 10px; font-weight: 600; fill: var(--muted); }
.c3d .meteo .eti-ic { color: var(--muted); }
.c3d a { cursor: pointer; }
.c3d .pav-nome { font-size: 10px; font-weight: 700; fill: var(--muted); }
.c3d .pav-sub { font-size: 8.5px; font-weight: 500; }

@keyframes c3d-flusso { to { stroke-dashoffset: -18; } }
@keyframes c3d-brace { from { fill-opacity: .75; } to { fill-opacity: 1; } }
@keyframes c3d-sale { 0% { opacity: 0; transform: translateY(4px); } 30% { opacity: .9; } 100% { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) {
  .c3d .flusso, .c3d .onda, .c3d .focolare { animation: none; }
  .c3d .onda { opacity: .6; }
}
