@@ -957,37 +957,39 @@ async function loadFinance() {
const lohnt = savings _eur > 0 ;
const col = lohnt ? C . green : C . red ;
const icon = lohnt ? '✓' : '✗' ;
empfehlung = ` <div style="display:flex;align-items:center;justify-content:space-between;background:var(--surface);border:1px solid ${ col } ;border-radius:var(--radius);padding:14 px 18 px;margin-bottom:16 px">
empfehlung = ` <div style="display:flex;align-items:center;justify-content:space-between;background:var(--surface);border:1px solid ${ col } ;border-radius:var(--radius);padding:18 px 22 px;margin-bottom:24 px">
<div>
<div style="font-weight:700;font-size:15px;color: ${ col } "> ${ icon } Flexibler Tarif würde sich ${ lohnt ? 'lohnen' : 'nicht lohnen' } </div>
<div style="font-size:12px;color:var(--text-dim);margin-top:3 px">Basierend auf ${ spot _days } Tagen im Abrechnungsjahr</div>
<div style="font-size:12px;color:var(--text-dim);margin-top:5 px">Basierend auf ${ spot _days } Tagen im Abrechnungsjahr</div>
</div>
<div style="font-size:22 px;font-weight:700;color: ${ col } "> ${ lohnt ? '− ' : '+' } ${ fEur ( Math . abs ( savings _eur ) ) } </div>
<div style="font-size:26 px;font-weight:700;color: ${ col } ;margin-left:20px;white-space:nowrap ">${ lohnt ? '− ' : '+' } ${ fEur ( Math . abs ( savings _eur ) ) } </div>
</div> ` ;
}
// ── Summary-Karten ───────────────────────────────────────────
const spotCard = spot _total _eur !== null
? ` <div class="kwh-card" style="border-top:3px solid ${ C . spot } ">
<div class="kv" style="color: ${ C . spot } "> ${ fEur ( spot _total _eur ) } </div>
<div class="kl">Spot-Tarif (hypothetisch)<br><span style="opacity:.6"> ${ spot _days } Tage mit Preisdaten</span></div>
? ` <div class="kwh-card" style="border-top:3px solid ${ C . spot } ;padding:18px 10px ">
<div class="kv" style="color: ${ C . spot } ;font-size:22px ">${ fEur ( spot _total _eur ) } </div>
<div class="kl" style="font-size:11px;margin-top:6px" >Spot-Tarif (hypothetisch)<br><span style="opacity:.6"> ${ spot _days } Tage mit Preisdaten</span></div>
</div> `
: ` <div class="kwh-card"><div class="kv" style="color:var(--text-dim)">– </div><div class="kl">Spot-Tarif<br><span style="opacity:.6">Noch keine Daten</span></div></div> ` ;
: ` <div class="kwh-card" style="padding:18px 10px" ><div class="kv" style="color:var(--text-dim);font-size:22px ">– </div><div class="kl" style="font-size:11px;margin-top:6px" >Spot-Tarif<br><span style="opacity:.6">Noch keine Daten</span></div></div> ` ;
const savCard = savings _eur !== null
? ` <div class="kwh-card" style="border-top:3px solid ${ savings _eur > 0 ? C . green : C . red } ">
<div class="kv" style="color: ${ savings _eur > 0 ? C . green : C . red } "> ${ savings _eur > 0 ? '− ' : '+' } ${ fEur ( Math . abs ( savings _eur ) ) } </div>
<div class="kl"> ${ savings _eur > 0 ? 'Ersparnis mit Spot' : 'Mehrkosten mit Spot' } <br><span style="opacity:.6">gegenüber Festpreis</span></div>
? ` <div class="kwh-card" style="border-top:3px solid ${ savings _eur > 0 ? C . green : C . red } ;padding:18px 10px ">
<div class="kv" style="color: ${ savings _eur > 0 ? C . green : C . red } ;font-size:22px ">${ savings _eur > 0 ? '− ' : '+' } ${ fEur ( Math . abs ( savings _eur ) ) } </div>
<div class="kl" style="font-size:11px;margin-top:6px" > ${ savings _eur > 0 ? 'Ersparnis mit Spot' : 'Mehrkosten mit Spot' } <br><span style="opacity:.6">gegenüber Festpreis</span></div>
</div> `
: '' ;
const cards = ` <div class="energy-kwh" style="margin-bottom:20px">
<div class="kwh-card" style="border-top:3px solid ${ C . fixed } " >
<div class="kv" style="color: ${ C . fixed } "> ${ fEur ( fixed _total _eur ) } </div >
<div class="kl">Festpreis-Kosten<br><span style="opacity:.6"> ${ total _days } Tage</span></div >
</div>
${ spotCard } ${ savCard }
</div> ` ;
const cards = `
<div style="font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim);margin-bottom:10px">Kostenübersicht · Abrechnungsjahr</div >
<div class="energy-kwh" style="margin-bottom:28px;gap:12px" >
<div class="kwh-card" style="border-top:3px solid ${ C . fixed } ;padding:18px 10px" >
<div class="kv" style="color: ${ C . fixed } ;font-size:22px"> ${ fEur ( fixed _total _eur ) } </div>
<div class="kl" style="font-size:11px;margin-top:6px">Festpreis-Kosten<br><span style="opacity:.6"> ${ total _days } Tage</span></div>
</div>
${ spotCard } ${ savCard }
</div> ` ;
// ── SVG-Balkendiagramm ────────────────────────────────────────
const W = 600 , H = 180 , PL = 44 , PR = 12 , PT = 10 , PB = 28 ;
@@ -1027,13 +1029,17 @@ async function loadFinance() {
const legend = ` <text x=" ${ PL } " y=" ${ H + 18 } " font-size="10" fill=" ${ C . fixed } ">■ Festpreis</text>
<text x=" ${ PL + 70 } " y=" ${ H + 18 } " font-size="10" fill=" ${ C . spot } ">■ Spot (hypothetisch)</text> ` ;
const chart = ` <div style="margin-bottom:20px;overflow-x:auto">
<svg viewBox="0 0 ${ W } ${ H + 24 } " style="width:100%;max-width: ${ W } px;display:block ">
${ gridLines } ${ yLabels } ${ bars } ${ xLabels } ${ legend }
</svg >
</div> ` ;
const chartSection = `
<div style="border-top:1px solid var(--border);padding-top:24px;margin-top:4px ">
<div style="font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--text-dim);margin-bottom:14px">Kosten je Tag</div>
<div style="overflow-x:auto" >
<svg viewBox="0 0 ${ W } ${ H + 24 } " style="width:100%;max-width: ${ W } px;display:block">
${ gridLines } ${ yLabels } ${ bars } ${ xLabels } ${ legend }
</svg>
</div>
</div> ` ;
el . innerHTML = empfehlung + cards + chart ;
el . innerHTML = ` <div style="padding:4px 0"> ${ empfehlung } ${ cards } ${ chartSection } </div> ` ;
} catch ( e ) { el . innerHTML = '<div class="no-data">Fehler beim Laden</div>' ; console . error ( 'loadFinance:' , e ) ; }
}