/* Green Imperium – Gestaltung
   Farbwelt: tiefes Petrol, Waldgrün, Schiefergrau, warmes Weiß; Gold für Erfolge,
   Himmelsblau für Energie/Wetter, Orange für Warnungen, abgestuftes Rot für Kritisches. */
:root {
  --petrol: #0f4c5c; --petrol-d: #0a3540; --petrol-l: #1d6a7d;
  --forest: #2d6a4f; --forest-l: #3f9a6d; --slate: #3d4a52; --slate-l: #66757e;
  --paper: #f7f3ea; --paper-2: #efe8d9; --white: #fffdf8; --ink: #1f2a30; --muted: #66757e;
  --gold: #c9a227; --sky: #4aa3df; --orange: #e07a1f; --red: #b8402f; --green-ok: #2f8a5b;
  --line: #ddd3bf; --shadow: 0 6px 24px rgba(15, 40, 50, .12); --radius: 14px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --s-pv: #e7a91c; --s-load: #0f4c5c; --s-export: #4aa3df; --s-import: #b8402f; --s-self: #2d6a4f; --s-discharge: #8e6bbf; --s-soc: #8e6bbf;
  --topbar-h: 60px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.55 var(--font-ui); color: var(--ink); background: var(--paper); }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.2; color: var(--petrol-d); margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--petrol-l); }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--white); padding: .5em 1em; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .neg { color: var(--red); } .pos { color: var(--green-ok); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

/* ---------- Buttons & Formulare ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; min-height: 44px; padding: .55em 1.1em; border-radius: 10px;
  border: 1px solid var(--line); background: var(--white); color: var(--petrol-d); font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s, box-shadow .15s; }
.btn:hover:not(:disabled) { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--forest-l); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-link { background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 36px; padding: .3em .5em; font-weight: 500; }
.btn-lg { font-size: 1.06rem; padding: .75em 1.4em; }
.btn-sm { min-height: 34px; padding: .3em .8em; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6em; margin-top: 1em; } .btn-row.end { justify-content: flex-end; }
.btn-col { display: flex; flex-direction: column; gap: .6em; margin-top: 1em; }
.icon-btn { border: 0; background: transparent; font-size: 1.4rem; line-height: 1; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; color: inherit; }
.icon-btn:hover { background: rgba(0,0,0,.06); }
.linkish { background: none; border: 0; padding: 0; text-align: left; color: var(--petrol-l); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.input, .form input[type=text], .form input[type=email], .form input[type=password], .form input[type=search], .form select {
  width: 100%; min-height: 44px; padding: .55em .8em; border: 1px solid #cfc4ad; border-radius: 10px; background: #fff; }
.stack > * + * { margin-top: .7em; }
.check-row, .range-row { display: flex; align-items: center; gap: .6em; min-height: 40px; }
.range-row input { flex: 1; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.segmented button { border: 0; background: #fff; padding: .55em 1em; min-height: 44px; cursor: pointer; }
.segmented button.on { background: var(--petrol); color: #fff; }

/* ---------- Karten & Raster ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2em 1.3em; box-shadow: var(--shadow); margin-bottom: 1.2em; }
.card-highlight { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.25), var(--shadow); }
.card-error { border-color: var(--red); }
.card-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5em; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 1.2em; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 1.2em; }
.grid-2 > *, .grid-3 > *, .home-layout > *, .planner-layout > *, .mail-layout > * { min-width: 0; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; } .grid-2, .grid-3 { margin-bottom: 1.2em; }
.page-head { margin: .2em 0 1.2em; } .lead { font-size: 1.06rem; color: var(--slate); max-width: 70ch; }
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: .35em 1em; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat { display: flex; flex-direction: column; gap: .2em; } .stat strong { font-size: 1.6rem; font-family: var(--font-head); }
.callout { padding: .8em 1em; border-radius: 10px; background: #e8f1f4; border-left: 4px solid var(--sky); margin: .6em 0; }
.callout-ok { background: #e6f3ec; border-color: var(--green-ok); } .callout-warn { background: #fdf1e4; border-color: var(--orange); }
.tag { display: inline-block; padding: .15em .6em; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--paper-2); color: var(--slate); }
.tag-premium { background: #f6ecc9; color: #7a5d00; } .tag-budget { background: #e8eef0; } .tag-standard { background: #e1efe7; color: var(--forest); }
.tag-real { background: var(--forest); color: #fff; } .tag-practice { background: var(--sky); color: #fff; }
.table { width: 100%; border-collapse: collapse; } .table td, .table th { padding: .45em .5em; border-bottom: 1px solid var(--line); text-align: left; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { max-height: 420px; overflow: auto; }
.progress { height: 12px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--forest), var(--forest-l)); transition: width .6s; }
.checklist { list-style: none; padding: 0; margin: 0; } .checklist li { padding: .35em 0; display: flex; gap: .5em; }
.checklist li.done { color: var(--muted); } .checklist .check { color: var(--forest); font-weight: 700; width: 1.2em; }
.action-list { list-style: none; padding: 0; margin: 0; } .action-list li { padding: .6em 0; border-bottom: 1px dashed var(--line); }
.action-list .linkish { display: flex; flex-direction: column; text-decoration: none; } .action-list .linkish span { color: var(--slate); font-size: .92rem; }
.npc-tip { display: flex; gap: .8em; align-items: flex-start; background: #f4f0e4; border-radius: 12px; padding: .8em; margin: .5em 0 1em; }
.npc-tip p { margin: 0; }
.loading { display: flex; align-items: center; gap: .7em; padding: 3em; color: var(--muted); justify-content: center; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--forest); border-radius: 50%; animation: spin .9s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Porträts ---------- */
.portrait { border-radius: 50%; object-fit: cover; flex: none; background: var(--paper-2); }
.portrait-xs { width: 34px; height: 34px; } .portrait-sm { width: 48px; height: 48px; } .portrait-md { width: 72px; height: 72px; }
.portrait-initials { display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .85em; }

/* ---------- Spiel-Layout ---------- */
body.game { padding-top: var(--topbar-h); }
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30; display: flex; align-items: center; gap: .8em; padding: 0 1em;
  background: linear-gradient(90deg, var(--petrol-d), var(--petrol)); color: #eef5f3; box-shadow: 0 2px 12px rgba(0,0,0,.25); }
.topbar .brand { display: flex; align-items: center; gap: .5em; color: #fff; text-decoration: none; font-family: var(--font-head); font-size: 1.1rem; white-space: nowrap; }
.topbar .brand img { width: 36px; height: 36px; }
.topbar .who { display: flex; flex-direction: column; line-height: 1.15; font-size: .92rem; min-width: 0; }
.topbar .who .muted { color: #b9d0cb; }
.topbar .stats { display: flex; gap: 1em; margin-left: auto; align-items: center; font-variant-numeric: tabular-nums; font-size: .92rem; }
.topbar .stat-item { display: flex; align-items: center; gap: .35em; white-space: nowrap; }
.topbar .muted { color: #b9d0cb; }
.topbar .neg { color: #ffb3a6; }
.topbar .icon { width: 20px; height: 20px; color: var(--gold); }
.topbar .icon-wx { width: 24px; height: 24px; }
.topbar .msg-btn { position: relative; color: #fff; display: inline-flex; padding: .4em; border-radius: 8px; }
.topbar .msg-btn .icon { color: #fff; width: 24px; height: 24px; }
.topbar .badge-dot { position: absolute; top: 0; right: -2px; background: var(--orange); color: #fff; border-radius: 999px; font-size: .72rem; min-width: 18px; padding: 0 5px; text-align: center; font-weight: 700; }
.topbar .avatar-link img { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--gold); display: block; }
.topbar form { margin: 0; }
.topbar .logout { color: #cfe3de; background: none; border: 0; cursor: pointer; text-decoration: underline; font-size: .85rem; }
#nav-toggle { display: none; color: #fff; }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
#sidebar { background: #ece5d5; border-right: 1px solid var(--line); padding: 1em .6em; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow: auto; }
#sidebar ul { list-style: none; margin: 0; padding: 0; }
#sidebar a, #sidebar .nav-locked { display: flex; align-items: center; gap: .65em; padding: .55em .75em; border-radius: 10px; color: var(--slate); text-decoration: none; min-height: 44px; }
#sidebar a:hover { background: rgba(255,255,255,.6); }
#sidebar a[aria-current] { background: var(--petrol); color: #fff; }
#sidebar .icon { width: 20px; height: 20px; flex: none; }
#sidebar .nav-locked { opacity: .55; flex-wrap: wrap; } #sidebar .nav-locked small, .nav-preview small { width: 100%; padding-left: 28px; font-size: .75rem; }
#sidebar .badge { margin-left: auto; background: var(--orange); color: #fff; border-radius: 999px; padding: 0 .5em; font-size: .78rem; font-weight: 700; }
.nav-preview { margin-top: 1em; } .nav-preview summary { cursor: pointer; padding: .5em .75em; color: var(--muted); font-size: .9rem; }
.nav-preview li { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; padding: .35em .75em; color: var(--muted); font-size: .9rem; }
main { padding: 1.4em clamp(1em, 3vw, 2.4em) calc(var(--tut-h, 0px) + 3em); max-width: 1400px; width: 100%; outline: none; }

/* ---------- Tutorial ---------- */
#tutorial { position: fixed; right: 18px; bottom: 18px; width: min(400px, calc(100vw - 24px)); z-index: 40; background: var(--white);
  border: 2px solid var(--gold); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
#tutorial .tut-head { display: flex; align-items: center; gap: .7em; padding: .75em .9em; border-bottom: 1px solid var(--line); }
#tutorial .tut-head > div { flex: 1; display: flex; flex-direction: column; line-height: 1.25; } #tutorial small { color: var(--muted); }
#tutorial .tut-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--petrol); color: #fff; display: grid; place-items: center; }
#tutorial .tut-icon .icon { width: 22px; height: 22px; }
#tutorial .tut-body { padding: .8em 1em 1em; } #tutorial.minimized .tut-body { display: none; }
#tutorial.minimized { width: min(340px, calc(100vw - 24px)); }
#tutorial.minimized .tut-head { border-bottom: 0; padding: .5em .8em; cursor: pointer; }
#tutorial .tut-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5em; }
#tutorial .tut-wait { display: flex; gap: .6em; align-items: center; color: var(--slate); font-size: .92rem; margin-bottom: .6em; }
.tut-highlight { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(201,162,39,.65); } 50% { box-shadow: 0 0 0 8px rgba(201,162,39,0); } }
polygon.tut-highlight, g.tut-highlight rect { animation: svgpulse 1.6s ease-in-out infinite; }
@keyframes svgpulse { 0%, 100% { stroke: rgba(240,200,60,.95); stroke-width: 6; } 50% { stroke: rgba(240,200,60,.2); stroke-width: 14; } }

/* ---------- Modale Dialoge & Toasts ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10,25,30,.55); display: grid; place-items: center; padding: 1em; }
.modal { background: var(--white); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 2em); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1em 1.2em .4em; } .modal-head h2 { margin: 0; }
.modal-body { padding: .4em 1.2em 1em; } .modal-actions { display: flex; justify-content: flex-end; gap: .6em; padding: 0 1.2em 1.2em; flex-wrap: wrap; }
.call-line { display: flex; gap: 1em; align-items: flex-start; min-height: 110px; } .call-line.me { flex-direction: row-reverse; text-align: right; }
.call-line p { background: #f2efe6; padding: .8em 1em; border-radius: 14px; margin: .3em 0 0; }
.call-line.me p { background: #e3eef1; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: .5em; align-items: center; pointer-events: none; }
.toast { background: var(--petrol-d); color: #fff; padding: .7em 1.1em; border-radius: 10px; box-shadow: var(--shadow); max-width: 92vw; transition: opacity .5s, transform .5s; }
.toast-success { background: var(--forest); } .toast-error { background: var(--red); } .toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Szenen (Haus, Büro) ---------- */
.scene { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #222; margin: 0 0 1.2em; aspect-ratio: 1344 / 768; }
.scene > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.scene-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-tint { position: absolute; inset: 0; pointer-events: none; transition: background 1.5s; }
.phase-morning .scene-tint { background: linear-gradient(180deg, rgba(255,190,120,.18), rgba(255,220,170,.05)); }
.phase-evening .scene-tint { background: linear-gradient(180deg, rgba(255,120,60,.28), rgba(90,40,80,.22)); }
.phase-night .scene-tint { background: linear-gradient(180deg, rgba(5,15,45,.62), rgba(10,20,50,.42)); }
.phase-night.scene-home .scene-tint::after { content: ""; position: absolute; left: 33%; top: 66%; width: 44%; height: 8%; background: radial-gradient(ellipse at center, rgba(255,200,110,.35), transparent 70%); }
.scene-home.cloudy .scene-tint { box-shadow: inset 0 0 0 2000px rgba(90,100,110,.18); }
.precip { position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image: repeating-linear-gradient(105deg, transparent 0 14px, rgba(200,215,230,.6) 14px 15px); background-size: 60px 60px; animation: rain .5s linear infinite; }
.precip-2 { background-image: radial-gradient(circle, rgba(255,255,255,.9) 1.5px, transparent 2px); background-size: 28px 28px; animation: snow 4s linear infinite; }
@keyframes rain { to { background-position: -20px 60px; } } @keyframes snow { to { background-position: 10px 112px; } }
.hot-roof { fill: rgba(255,255,255,0); stroke: rgba(255,255,255,0); stroke-width: 3; cursor: pointer; transition: fill .2s; }
.hot-roof:hover, .hot-roof:focus { fill: rgba(255,240,180,.16); stroke: rgba(255,230,150,.85); outline: none; }
.module { stroke: #8fa9c9; stroke-width: 1.4; }
.modules.building .module { opacity: .55; }
.scaffold line { stroke: #b58b4a; stroke-width: 5; opacity: .75; }
.hot-meter { cursor: pointer; } .meter-box { fill: #d9d6cf; stroke: #6b6b6b; stroke-width: 2; } .meter-display { fill: #2b3a2f; } .meter-dial { fill: none; stroke: #444; stroke-width: 2; }
.hot-meter:hover .meter-box, .hot-meter:focus .meter-box { fill: #fff3c4; } .hot-meter:focus { outline: none; }
.battery-body { fill: #e9ecef; stroke: #4b5a63; stroke-width: 2.5; } .battery-level { fill: var(--forest-l); } .battery.building { opacity: .6; }
.home-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: 1.2em; align-items: start; }
.scene-info h2 { margin-bottom: .6em; } .scene-info .icon-wx { width: 20px; height: 20px; vertical-align: -4px; }
.progress-block { margin-top: 1em; }
.hotspot { position: absolute; border: 2px solid transparent; border-radius: 12px; background: transparent; cursor: pointer; padding: 0; transition: background .2s, border-color .2s; }
.hotspot:hover, .hotspot:focus-visible { background: rgba(255,240,190,.16); border-color: rgba(255,225,140,.9); }
.hotspot.locked { cursor: not-allowed; } .hotspot.locked:hover { background: rgba(0,0,0,.15); border-color: rgba(255,255,255,.3); }
.hotspot-label { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -4px); background: rgba(10,30,35,.88); color: #fff; padding: .25em .6em; border-radius: 8px;
  font-size: .82rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s; }
.hotspot:hover .hotspot-label, .hotspot:focus-visible .hotspot-label, .hotspot.tut-highlight .hotspot-label { opacity: 1; }
.hotspot .badge { background: var(--orange); border-radius: 999px; padding: 0 .4em; margin-left: .4em; }
.office-list ul { display: flex; flex-wrap: wrap; gap: .4em 1.4em; list-style: none; padding: 0; margin: 0; }

/* ---------- Rechnung / Briefe ---------- */
.paper { background: #fffef9; border: 1px solid #e6dcc6; border-radius: 6px; padding: 1.6em 1.8em; box-shadow: 0 1px 0 #e9e1cf, 0 10px 30px rgba(60,45,20,.12); margin-bottom: 1.2em; }
.invoice header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--petrol); padding-bottom: .6em; margin-bottom: 1em; }
.invoice-sender { color: var(--muted); font-size: .9rem; } .invoice-title { font-family: var(--font-head); font-weight: 700; color: var(--petrol); }
.invoice-table { width: 100%; border-collapse: collapse; } .invoice-table td { padding: .5em .2em; border-bottom: 1px dotted #d8ccb2; }
.invoice-table tr.total td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 0; font-size: 1.08rem; }
.letter { position: relative; font-family: var(--font-head); font-size: 1.05rem; line-height: 1.7; }
.handwritten { background: #fdf8ea; transform: rotate(-.4deg); }
.letter-photo { float: right; width: 140px; margin: 0 0 1em 1.2em; border: 6px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.2); transform: rotate(2deg); }
.signature { font-style: italic; margin-top: 1.4em; }

/* ---------- Angebote & Quiz ---------- */
.offer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr)); gap: 1.2em; margin-bottom: 1.2em; }
.offer { display: flex; flex-direction: column; margin: 0; } .offer .btn { margin-top: auto; }
.offer.selected { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(45,106,79,.25), var(--shadow); }
.offer .pro { color: var(--forest); margin: .6em 0 .2em; } .offer .con { color: var(--red); }
.quiz-options { display: flex; flex-wrap: wrap; gap: .6em; margin: .4em 0 .8em; }
.quiz-options .btn.chosen { border-color: var(--slate); } .quiz-options .btn.correct { border-color: var(--forest); background: #e6f3ec; opacity: 1; }

/* ---------- Minispiel Solardach ---------- */
.planner-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 1.2em; align-items: start; }
.planner-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
.roof-face header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4em 1em; } .roof-face h2 { margin: 0; }
.compass, .yield-hint { color: var(--muted); font-size: .9rem; }
.roof-wrap { margin-top: .8em; padding: 14px; border-radius: 10px; background: linear-gradient(180deg, #8f3d2a, #a24a33); box-shadow: inset 0 6px 14px rgba(0,0,0,.3); }
.roof-back { background: linear-gradient(180deg, #7c3424, #8f3f2b); }
.roof-grid { display: grid; gap: 4px; touch-action: none; user-select: none; }
.roof-cell { aspect-ratio: 1.13 / 1.72; border: 1px solid rgba(0,0,0,.25); border-radius: 3px; cursor: pointer; padding: 0; min-width: 0;
  background: repeating-linear-gradient(0deg, #b4563a 0 9px, #9d4732 9px 11px); color: #fff; font-size: 1.1rem; position: relative; }
.roof-cell:hover:not(:disabled) { filter: brightness(1.15); }
.roof-cell.shade-1::after, .roof-cell.shade-2::after { content: ""; position: absolute; inset: 0; border-radius: 3px; pointer-events: none;
  background: repeating-linear-gradient(45deg, rgba(20,30,40,.35) 0 4px, transparent 4px 9px); }
.roof-cell.shade-2::after { background: repeating-linear-gradient(45deg, rgba(10,20,30,.6) 0 5px, transparent 5px 8px); }
.roof-cell.on { background: linear-gradient(135deg, #2c4a73, #16263f 60%, #3b5f8f); border-color: #9fb8d8;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); background-size: 100% 100%; }
.roof-cell.on::before { content: ""; position: absolute; inset: 3px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(90deg, transparent 32%, rgba(160,190,230,.35) 33%, transparent 34%, transparent 65%, rgba(160,190,230,.35) 66%, transparent 67%),
    linear-gradient(0deg, transparent 24%, rgba(160,190,230,.3) 25%, transparent 26%, transparent 49%, rgba(160,190,230,.3) 50%, transparent 51%, transparent 74%, rgba(160,190,230,.3) 75%, transparent 76%); }
.roof-cell.blocked { background: #6b6b6b; cursor: not-allowed; opacity: .9; }
.planner-stats.pending { opacity: .7; }
.planner-mini { display: none; }
.score { display: flex; align-items: baseline; gap: .4em; } .score-num { font-family: var(--font-head); font-size: 2.6rem; font-weight: 700; color: var(--forest); }
.score.big .score-num { font-size: 3.6rem; }
.score-parts { list-style: none; padding: 0; margin: .4em 0 1em; } .score-parts li { display: grid; grid-template-columns: 1fr 100px 2.5em; align-items: center; gap: .5em; font-size: .92rem; }
.score-parts meter { width: 100%; }

/* ---------- Diagramme ---------- */
.chart-wrap { margin: .4em 0 0; } .chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e7dfcd; } .chart .axis { font-size: 11px; fill: var(--muted); }
.chart .line { fill: none; stroke-width: 2.4; } .chart .area { opacity: .28; }
.s-pv { stroke: var(--s-pv); fill: var(--s-pv); background: var(--s-pv); } .s-load { stroke: var(--s-load); fill: var(--s-load); background: var(--s-load); }
.s-export { stroke: var(--s-export); fill: var(--s-export); background: var(--s-export); } .s-import { stroke: var(--s-import); fill: var(--s-import); background: var(--s-import); }
.s-self { stroke: var(--s-self); fill: var(--s-self); background: var(--s-self); } .s-discharge, .s-soc { stroke: var(--s-discharge); fill: var(--s-discharge); background: var(--s-discharge); }
.chart .line.s-load { fill: none; } .chart .line.s-pv, .chart .line.s-soc { fill: none; } .chart .line.s-export, .chart .line.s-import, .chart .line.s-self { fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: .3em 1.2em; list-style: none; padding: 0; margin: .4em 0 0; font-size: .88rem; color: var(--slate); }
.swatch { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: .4em; vertical-align: 0; }
.rings { display: flex; justify-content: space-around; gap: .5em; flex-wrap: wrap; }
.ring { position: relative; width: 112px; text-align: center; } .ring svg { width: 112px; height: 112px; }
.ring-bg { fill: none; stroke: var(--paper-2); stroke-width: 10; } .ring-fg { fill: none; stroke: var(--forest); stroke-width: 10; stroke-linecap: round; transition: stroke-dasharray .8s; }
.ring-label { position: absolute; inset: 0 0 auto 0; height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.ring-label strong { font-size: 1.2rem; } .ring-label span { font-size: .7rem; color: var(--muted); max-width: 80px; }
.flow-svg { width: 100%; height: auto; } .flow-node circle { fill: var(--paper); stroke: var(--petrol); stroke-width: 2; }
.flow-icon { font-size: 18px; fill: var(--petrol); } .flow-node-label { font-size: 11px; fill: var(--slate); }
.flow { stroke-width: 3; } .f-self { stroke: var(--s-self); } .f-export { stroke: var(--s-export); } .f-import { stroke: var(--s-import); } .f-charge, .f-discharge { stroke: var(--s-discharge); }
.flow-label { font-size: 10.5px; font-weight: 700; fill: var(--ink); paint-order: stroke; stroke: #fff; stroke-width: 3px; } .arrowhead { fill: var(--slate); }
.forecast-strip { display: flex; gap: .5em; overflow-x: auto; padding-bottom: .3em; }
.fc { flex: none; min-width: 76px; display: flex; flex-direction: column; align-items: center; gap: .2em; background: var(--paper); border-radius: 10px; padding: .5em; font-size: .85rem; }
.icon-wx { width: 30px; height: 30px; } .icon-xl { width: 72px; height: 72px; } .wx-now { align-items: center; text-align: center; }
.demo-sky { position: relative; height: 150px; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #7ec3ee, #d8eefa); transition: background 1s; --sun-x: 10%; --sun-y: 85%; }
.demo-sky.night { background: linear-gradient(180deg, #0d1a3a, #283b63); }
.demo-sun { position: absolute; left: var(--sun-x); top: var(--sun-y); width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: radial-gradient(circle, #fff6c8, #f2b632 60%, rgba(242,182,50,0) 72%); transition: left .4s linear, top .4s linear; }
.demo-clock { font-family: var(--font-head); font-size: 1.4rem; margin: .5em 0; } .demo-kv { margin-bottom: .5em; }

/* ---------- Nachrichten ---------- */
.mail-layout { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 1.2em; align-items: start; }
.mail-list { list-style: none; padding: .4em; margin: 0; max-height: 70vh; overflow: auto; }
.mail-item { display: flex; gap: .7em; align-items: center; width: 100%; padding: .6em; border: 0; background: transparent; text-align: left; border-radius: 10px; cursor: pointer; }
.mail-item:hover { background: var(--paper); } .mail-item.active { background: #e3eef1; }
.mail-item.unread strong { color: var(--petrol-d); } .mail-item:not(.unread) strong { font-weight: 500; }
.mail-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; } .mail-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-meta small { color: var(--muted); } .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); flex: none; }
.mail-head { display: flex; gap: 1em; align-items: center; margin-bottom: 1em; } .mail-head h2 { margin: 0; }
.pad { padding: 1em; }

/* ---------- Erfolge & Chronik ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8em; list-style: none; padding: 0; margin: 0; }
.badge-card { display: flex; flex-direction: column; gap: .2em; padding: .9em; border-radius: 12px; background: var(--paper); border: 1px solid var(--line); }
.badge-card.locked { opacity: .55; } .medal { font-size: 1.8rem; line-height: 1; }
.tier-gold .medal { color: var(--gold); } .tier-silver .medal { color: #8c9aa3; } .tier-bronze .medal { color: #b07a45; }
.chronicle { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--gold); }
.chronicle li { display: flex; gap: 1em; padding: .6em 0 1.2em 1.2em; position: relative; }
.chronicle li::before { content: ""; position: absolute; left: -9px; top: 1em; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 3px solid var(--paper); }
.chronicle img { width: 150px; border-radius: 10px; flex: none; object-fit: cover; aspect-ratio: 16/10; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { display: flex; gap: .6em; padding: .5em 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.steps li.done { color: var(--muted); } .steps li.current { font-weight: 700; } .steps .check { width: 1.3em; color: var(--forest); }
.help summary { cursor: pointer; list-style: none; } .help summary h2 { display: inline; } .help summary::-webkit-details-marker { display: none; }
.help summary::after { content: " ▾"; color: var(--muted); } details[open].help summary::after { content: " ▴"; }
.avatar-pick { display: flex; flex-wrap: wrap; gap: .5em; } .avatar-pick button { padding: 2px; border: 3px solid transparent; border-radius: 50%; background: none; cursor: pointer; }
.avatar-pick button.on { border-color: var(--forest); } .avatar-pick img { border-radius: 50%; display: block; }

/* ---------- Öffentliche Seiten ---------- */
.site-header { display: flex; align-items: center; justify-content: space-between; padding: .8em clamp(1em, 4vw, 3em); background: var(--petrol-d); color: #fff; }
.site-header a { color: #fff; } .site-header .brand { display: flex; align-items: center; gap: .6em; text-decoration: none; font-family: var(--font-head); font-size: 1.25rem; }
.site-header .brand img { width: 40px; height: 40px; } .site-header nav { display: flex; gap: .8em; align-items: center; }
.site-main { max-width: 1100px; margin: 0 auto; padding: 2em clamp(1em, 4vw, 2em) 4em; }
.site-footer { text-align: center; color: var(--muted); padding: 2em 1em; font-size: .88rem; border-top: 1px solid var(--line); }
.site-footer a { margin: 0 .5em; }
.hero { position: relative; min-height: 70vh; display: grid; align-items: end; color: #fff; background: #123 center/cover no-repeat; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,25,30,.15) 30%, rgba(5,25,30,.85)); }
.hero-inner { position: relative; max-width: 1100px; margin: 0 auto; padding: 3em clamp(1em, 4vw, 2em); width: 100%; }
.hero h1 { color: #fff; font-size: clamp(2.2rem, 5vw, 3.6rem); margin-bottom: .2em; } .hero p { font-size: 1.2rem; max-width: 60ch; color: #e8f1ee; }
.hero .btn-row .btn:not(.btn-primary) { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.2em; margin: 2em 0; }
.city-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1em; }
.city-card { position: relative; border-radius: 12px; overflow: hidden; background: #000; color: #fff; display: block; }
.city-card img { display: block; aspect-ratio: 16/10; object-fit: cover; width: 100%; opacity: .9; }
.city-card .cap { position: absolute; inset: auto 0 0 0; padding: .6em .8em; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.city-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: .8em; }
.city-pick label { cursor: pointer; display: block; border: 3px solid transparent; border-radius: 14px; overflow: hidden; background: var(--white); box-shadow: var(--shadow); }
.city-pick input { position: absolute; opacity: 0; } .city-pick input:checked + .city-opt { outline: 3px solid var(--forest); outline-offset: -3px; }
.city-pick input:focus-visible + .city-opt { outline: 3px solid var(--sky); outline-offset: -3px; }
.city-opt img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; } .city-opt div { padding: .6em .8em; font-size: .88rem; }
.city-opt strong { display: block; font-size: 1.05rem; } .city-opt .pro { color: var(--forest); } .city-opt .con { color: var(--red); }
.avatar-radio { display: flex; flex-wrap: wrap; gap: .5em; } .avatar-radio label { cursor: pointer; } .avatar-radio input { position: absolute; opacity: 0; }
.avatar-radio img { width: 64px; height: 64px; border-radius: 50%; border: 3px solid transparent; display: block; }
.avatar-radio input:checked + img { border-color: var(--forest); } .avatar-radio input:focus-visible + img { border-color: var(--sky); }
.form { display: grid; gap: 1em; } .form label > span { display: block; font-weight: 600; margin-bottom: .25em; }
.form .hint { color: var(--muted); font-size: .85rem; } .form .error { color: var(--red); font-size: .9rem; } .form .hp { position: absolute; left: -5000px; }
.auth-card { max-width: 460px; margin: 2em auto; } .auth-wide { max-width: 1000px; }
.alert { padding: .8em 1em; border-radius: 10px; margin-bottom: 1em; } .alert-error { background: #fbe9e5; color: #7c2416; } .alert-ok { background: #e6f3ec; color: #1c5a3b; }

/* ---------- Administration ---------- */
body.admin .site-main { max-width: 1300px; } .admin-nav { display: flex; flex-wrap: wrap; gap: .4em; margin-bottom: 1.2em; }
.admin-nav a { padding: .45em .9em; border-radius: 8px; background: var(--white); border: 1px solid var(--line); text-decoration: none; }
.admin-nav a.on { background: var(--petrol); color: #fff; } pre.log { background: #1d2529; color: #d5e2e6; padding: 1em; border-radius: 10px; overflow: auto; max-height: 520px; font-size: .82rem; }
.inline-form { display: inline-flex; gap: .4em; align-items: center; flex-wrap: wrap; } .inline-form input, .inline-form select { min-height: 36px; padding: .3em .5em; border: 1px solid #cfc4ad; border-radius: 8px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .home-layout, .planner-layout { grid-template-columns: 1fr; } .planner-side { position: static; }
  .planner-mini { display: flex; justify-content: space-between; gap: .6em; position: sticky; top: calc(var(--topbar-h) + 6px); z-index: 5;
    background: var(--petrol-d); color: #fff; padding: .55em .9em; border-radius: 12px; margin-bottom: .8em; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; font-size: .92rem; }
  .planner-mini .neg { color: #ffb3a6; }
  .topbar .hide-sm { display: none; }
}
@media (max-width: 860px) {
  :root { --topbar-h: 56px; }
  #nav-toggle { display: inline-grid; place-items: center; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  #sidebar { position: fixed; z-index: 35; top: var(--topbar-h); left: 0; bottom: 0; width: 270px; transform: translateX(-105%); transition: transform .25s; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  body.nav-open #sidebar { transform: none; }
  .topbar .who, .topbar .brand span { display: none; }
  .topbar .stats { gap: .6em; font-size: .85rem; } #hdr-time span:not(:first-of-type) { display: none; }
  .mail-layout { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr 1fr; }
  #tutorial { right: 8px; left: 8px; bottom: 8px; width: auto; }
  .chronicle img { width: 90px; }
  .letter-photo { width: 100px; }
}
@media (max-width: 520px) {
  #hdr-power { display: none; }
  .card { padding: 1em; }
  .roof-wrap { padding: 8px; } .roof-grid { gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
