/* Aussehen der Hausserver-Oberflaeche von hahn.
   Farben und Masse nach den iOS-Werten der Groupware (ios-sign.css), hell und
   dunkel folgen der Einstellung des Geraets. Zuerst fuers Handy gebaut. */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;
  --karte: #fff;
  --karte-2: #f2f2f7;
  --text: #000;
  --text-2: rgba(60, 60, 67, .6);
  --text-3: rgba(60, 60, 67, .3);
  --linie: rgba(60, 60, 67, .18);
  --fuell: rgba(120, 120, 128, .12);
  --blau: #007aff;
  --gruen: #34c759;
  --rot: #ff3b30;
  --orange: #ff9500;
  --lila: #af52de;
  --tuerkis: #30b0c7;
  --sonne: #ff9f0a;
  --glas: rgba(249, 249, 249, .86);
  --segment-an: #fff;
  --schatten: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --radius: 18px;
  --radius-s: 12px;
  --rand: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --karte: #1c1c1e;
    --karte-2: #2c2c2e;
    --text: #fff;
    --text-2: rgba(235, 235, 245, .6);
    --text-3: rgba(235, 235, 245, .3);
    --linie: rgba(84, 84, 88, .55);
    --fuell: rgba(120, 120, 128, .24);
    --blau: #0a84ff;
    --gruen: #30d158;
    --rot: #ff453a;
    --orange: #ff9f0a;
    --lila: #bf5af2;
    --tuerkis: #40c8e0;
    --sonne: #ffb340;
    --glas: rgba(22, 22, 24, .86);
    --segment-an: #636366;
    --schatten: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Grundschrift 17 px wie auf dem iPhone (106,25 % der ueblichen 16 px, eine groessere
   Browsereinstellung wirkt mit). Auf iPhone/iPad setzt das Kopfskript die Textgroesse. */
html { -webkit-text-size-adjust: 100%; font-size: 106.25%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blau); text-decoration: none; }
code { font-size: .9em; }
.zahl, .wert, .zahlen b { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ------------------------------------------------ Rahmen */
.inhalt {
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) var(--rand) calc(96px + env(safe-area-inset-bottom));
}
.inhalt > * { animation: auf .35s ease both; }
@keyframes auf { from { opacity: 0; transform: translateY(6px); } }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glas);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--linie);
}
.tabs a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px;
  color: var(--text-2);
  font-size: 11px; font-weight: 500;
}
.tabs a svg { width: 26px; height: 26px; }
.tabs a.aktiv { color: var(--blau); }

.seitenleiste { display: none; }
@media (min-width: 900px) {
  body { padding-left: 250px; }
  .tabs { display: none; }
  .inhalt { padding: 34px 40px 56px; }
  .seitenleiste {
    position: fixed; top: 0; bottom: 0; left: 0; width: 250px; z-index: 30;
    display: flex; flex-direction: column;
    padding: 22px 12px 18px;
    overflow-y: auto;
    background: var(--karte);
    border-right: .5px solid var(--linie);
  }
  .seitenleiste .marke { display: flex; align-items: center; gap: 12px; padding: 0 10px 20px; color: var(--text); }
  .seitenleiste .marke img { width: 40px; height: 40px; border-radius: 10px; }
  .seitenleiste .marke b { display: block; font-size: 1.2353rem; line-height: 1.1; letter-spacing: -.02em; }
  .seitenleiste .marke b span { color: var(--sonne); }
  .seitenleiste .marke small { color: var(--text-2); font-size: 0.7059rem; }
  .seitenleiste a:not(.marke) {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 10px; margin: 1px 0;
    border-radius: 10px;
    color: var(--text); font-size: 0.8824rem; font-weight: 500;
  }
  .seitenleiste a svg { width: 20px; height: 20px; color: var(--blau); flex: none; }
  .seitenleiste a:not(.marke):hover { background: var(--fuell); }
  .seitenleiste a.aktiv, .seitenleiste a.aktiv:hover { background: var(--blau); color: #fff; }
  .seitenleiste a.aktiv svg { color: #fff; }
  .seitenleiste a.extern::after { content: "↗"; margin-left: auto; color: var(--text-3); font-size: 0.7647rem; }
  .seitenleiste .gruppe {
    margin: 18px 10px 6px;
    font-size: 0.7059rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-2);
  }
  .seitenleiste .schub { margin-top: auto; }
}

/* ------------------------------------------------ Kopf */
.kopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.kopf h1 { margin: 0; font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.ueber { margin: 0 0 3px; font-size: 0.7647rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--text-2); }
.unter { margin: 4px 0 0; color: var(--text-2); font-size: 0.8824rem; }
.live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--karte);
  box-shadow: var(--schatten);
  color: var(--text-2); font-size: 0.7647rem; white-space: nowrap;
}
.punkt { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.punkt.gut { background: var(--gruen); }
.punkt.warn { background: var(--orange); }
.punkt.schlecht { background: var(--rot); }
.live .punkt.gut { animation: puls 2.4s ease-in-out infinite; }
@keyframes puls { 50% { opacity: .35; } }

.abschnitt {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 30px 4px 10px;
  font-size: 1.2941rem; font-weight: 700; letter-spacing: -.01em;
}
.abschnitt a, .abschnitt small { font-size: 0.8824rem; font-weight: 400; }
.abschnitt small { color: var(--text-2); }

/* ------------------------------------------------ Karten und Raster */
.karte {
  background: var(--karte);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--schatten);
}
.karte + .karte, .karte + .raster, .raster + .karte, .raster + .raster { margin-top: 12px; }
.raster > .karte, .gitter > .karte { margin-top: 0; }
.karte h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 600; }
.karte p { margin: 0; }
a.karte { display: block; color: var(--text); }
.raster { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) {
  .raster.vier { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .raster.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .raster.breit { grid-template-columns: 3fr 2fr; }
}
.raster.eins { grid-template-columns: minmax(0, 1fr); }

.kachel .titel { display: flex; align-items: center; gap: 6px; font-size: 0.8824rem; font-weight: 600; color: var(--text-2); }
.kachel .titel svg { width: 19px; height: 19px; flex: none; }
.kachel .wert { margin-top: 8px; font-size: 1.7647rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kachel .wert small { margin-left: 3px; font-size: 1rem; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.kachel .zusatz { margin-top: 5px; font-size: 0.8235rem; color: var(--text-2); }
.f-sonne { color: var(--sonne); }
.f-haus { color: var(--blau); }
.f-batterie { color: var(--gruen); }
.f-netz { color: var(--lila); }
.f-rot { color: var(--rot); }

.balken { height: 8px; margin-top: 10px; border-radius: 4px; background: var(--fuell); overflow: hidden; }
.balken i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--gruen); transition: width .8s ease; }

.zahlen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
@media (min-width: 760px) { .zahlen.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.zahlen span { display: block; font-size: 0.7647rem; color: var(--text-2); }
.zahlen b { font-size: 1.2353rem; font-weight: 700; letter-spacing: -.01em; }
.zahlen b small { margin-left: 2px; font-size: 0.8235rem; font-weight: 500; color: var(--text-2); }

/* Ringe (Autarkie, Ladestand) */
.ringe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.ring { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.ring-bild { position: relative; width: 116px; height: 116px; }
.ring-bild.gross { width: 170px; height: 170px; }
.ring-bild svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bild .spur { stroke: var(--fuell); }
.ring-bild .bogen { stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring-bild b {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.ring-bild.gross b { font-size: 38px; }
.ring > span { margin-top: 8px; font-size: 0.8824rem; font-weight: 600; }
.ring > small { font-size: 0.7647rem; color: var(--text-2); max-width: 170px; overflow-wrap: anywhere; }
@media (max-width: 370px) { .ring-bild { width: 100px; height: 100px; } .ring-bild b { font-size: 22px; } }

/* ------------------------------------------------ Energiefluss */
.fluss svg { display: block; width: 100%; max-width: 500px; height: auto; margin: 0 auto; }
.fluss .leitung { fill: none; stroke: var(--fuell); stroke-width: 5; stroke-linecap: round; }
.fluss .strom {
  fill: none; stroke-width: 5; stroke-linecap: round; stroke-dasharray: .1 13;
  opacity: 0; transition: opacity .5s;
  animation: fliessen 1s linear infinite;
}
.fluss .strom.an { opacity: 1; }
.fluss .strom.rueck { animation-direction: reverse; }
@keyframes fliessen { to { stroke-dashoffset: -13.1; } }
.fluss .knoten circle { stroke-width: 2.5; }
.fluss .mitte { fill: var(--text-3); }
.fluss text { fill: var(--text); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fluss text.klein { fill: var(--text-2); font-size: 12.5px; font-weight: 500; }
@media (prefers-reduced-motion: reduce) {
  .fluss .strom { animation: none; stroke-dasharray: none; }
  .inhalt > * { animation: none; }
}

/* ------------------------------------------------ Bedienelemente */
.segment { display: flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fuell); }
.segment button {
  flex: 1; padding: 8px 0;
  border: 0; border-radius: 8px; background: none; cursor: pointer;
  color: var(--text); font: inherit; font-size: 0.8824rem; font-weight: 500;
}
/* Tippflaeche mindestens 44 px hoch (Apple-Richtlinie), ohne die Knoepfe sichtbar zu vergroessern */
.segment button, .chips button { position: relative; }
.segment button::after, .chips button::after { content: ""; position: absolute; inset: -4px 0; }
.segment button.aktiv { background: var(--segment-an); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }

.blaettern { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.blaettern .titel { flex: 1; text-align: center; font-size: 1rem; font-weight: 600; line-height: 1.25; }
.blaettern .titel small { display: block; font-size: 0.7647rem; font-weight: 400; color: var(--text-2); }
.rund {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--karte); color: var(--blau); box-shadow: var(--schatten);
}
.rund svg { width: 22px; height: 22px; }
.rund[disabled] { color: var(--text-3); cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips button {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--fuell); color: var(--text-2);
  font: inherit; font-size: 0.8235rem; font-weight: 500;
}
.chips button i { width: 10px; height: 10px; border-radius: 3px; background: currentColor; opacity: .35; }
.chips button.an { background: var(--karte-2); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--linie); }
.chips button.an i { opacity: 1; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 50px; padding: 0 16px;
  border: 0; border-radius: 13px; cursor: pointer;
  background: var(--fuell); color: var(--blau);
  font: inherit; font-size: 1rem; font-weight: 600;
  transition: transform .1s, background-color .2s, color .2s;
}
.knopf:active { transform: scale(.97); }
.knopf.primaer { background: var(--blau); color: #fff; }
.knopf.gefahr { color: var(--rot); }
.knopf.scharf { background: var(--orange); color: #fff; }
.knopf[disabled] { opacity: .45; cursor: default; transform: none; }

.diagramm { position: relative; height: 270px; }
.diagramm.klein { height: 150px; }
@media (min-width: 760px) { .diagramm { height: 330px; } .diagramm.klein { height: 170px; } }

.hinweis {
  margin-bottom: 12px; padding: 12px 14px;
  border-radius: var(--radius-s);
  background: var(--karte);
  background: color-mix(in srgb, var(--orange) 16%, var(--karte));
  font-size: 0.8824rem;
}
.fehler-text { color: var(--rot); font-size: 0.8235rem; margin-top: 8px; }
.leise { color: var(--text-2); font-size: 0.8235rem; }

/* ------------------------------------------------ Listen (Mehr, Server) */
.liste { background: var(--karte); border-radius: var(--radius); overflow: hidden; box-shadow: var(--schatten); }
.liste + .liste { margin-top: 12px; }
.liste > a, .liste > div {
  position: relative;
  display: flex; align-items: center; gap: 13px;
  min-height: 54px; padding: 11px 16px;
  color: var(--text);
}
.liste > * + *::before { content: ""; position: absolute; top: 0; right: 0; left: 61px; border-top: .5px solid var(--linie); }
.liste.schlicht > * + *::before { left: 16px; }
.liste .symbol { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 8px; color: #fff; }
.liste .symbol svg { width: 19px; height: 19px; }
.liste .text { flex: 1; min-width: 0; }
.liste .text small { display: block; font-size: 0.7647rem; color: var(--text-2); }
.liste .rechts { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 0.8824rem; text-align: right; }
.liste .pfeil { width: 17px; height: 17px; color: var(--text-3); flex: none; }
.liste a:active { background: var(--fuell); }

/* ------------------------------------------------ Geld: gespart, Einspeiseverguetung, zusammen (Start, Verlauf) */
.geld {
  margin-top: 18px; padding: 12px 14px;
  border-radius: var(--radius-s);
  background: var(--karte-2);
  background: color-mix(in srgb, var(--gruen) 14%, var(--karte));
}
.geld h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; }
.gzeile { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.gzeile div { flex: 1; min-width: 0; }
.gzeile div b { display: block; font-size: 0.9412rem; font-weight: 600; }
.gzeile div small { display: block; font-size: 0.7647rem; color: var(--text-2); line-height: 1.3; }
.gzeile > b { flex: none; font-size: 1.1765rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.gzeile.summe { margin-top: 2px; border-top: .5px solid var(--linie); }
.gzeile.summe > b { font-size: 1.4706rem; letter-spacing: -.02em; }
