:root {
  --bg: #eef0ec;
  --card: #ffffff;
  --ink: #17201c;
  --muted: #4f5b55;
  --line: #d6dbd6;
  --soft: #f6f7f4;
  --sun: #f2b52a;
  --sun-ink: #3a2a00;
  --yield: #1f7a45;
  --volt: #c2410c;
  --temp: #7c3aed;
  --soll: #2f6fa8;
  --off: #c9cfca;
  --shadow: 0 1px 2px rgba(18,25,22,.06), 0 8px 24px rgba(18,25,22,.06);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 Archivo, "Segoe UI", system-ui, sans-serif;
}
a { color: var(--ink); }
a:hover { color: #8a5a00; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 3px solid var(--soll); outline-offset: 2px; }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Hero: Anlagenfoto ueber die obere Haelfte */
.hero { position: relative; min-height: min(46vh, 420px); background: #dfe3dd; display: flex; overflow: hidden; }
.hero-photo { position: absolute; inset: 0; background-size: cover; background-position: center; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(10,14,12,.35) 0, rgba(10,14,12,0) 30%, rgba(10,14,12,0) 45%, rgba(10,14,12,.72) 100%); }
.hero-body { position: relative; width: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; padding-top: 16px; padding-bottom: 50px; color: #fff; }
.hero h1 { margin: 0; font-size: clamp(30px, 5vw, 48px); font-weight: 800; letter-spacing: -.025em; line-height: 1.05; text-wrap: balance; }
.hero p { margin: 6px 0 0; font-size: 16px; color: rgba(255,255,255,.9); }
.back { align-self: flex-start; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.92); color: var(--ink); text-decoration: none; font-weight: 600; }
.status { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.92); color: var(--ink); font-size: 13px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, #7a857f); }
.hero.no-photo { min-height: 0; background: var(--card); border-bottom: 1px solid var(--line); }
.hero.no-photo .hero-shade { display: none; }
.hero.no-photo .hero-body { color: var(--ink); }
.hero.no-photo p { color: var(--muted); }
.hero.no-photo .back, .hero.no-photo .status { background: var(--soft); border: 1px solid var(--line); }
.hero-body { flex-wrap: wrap; }

/* Umschalter */
.switch { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: -30px; position: relative; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.tab { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; min-width: 112px; min-height: 58px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; cursor: pointer; text-align: left; }
.tab b { font-size: 16px; }
.tab small { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--sun); color: #121916; box-shadow: 0 2px 8px rgba(18,25,22,.18); }
.tab[aria-selected="true"] small { color: var(--sun-ink); }
.pager { display: flex; align-items: center; gap: 6px; padding: 6px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); }
.pager button { width: 46px; height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); font-size: 24px; line-height: 1; cursor: pointer; }
.pager button:disabled { opacity: .35; cursor: default; }
.pager span { min-width: 130px; text-align: center; font-family: var(--mono); font-weight: 500; }
.pager[hidden] { display: none; }

main { display: flex; flex-direction: column; gap: 20px; padding-top: 22px; padding-bottom: 40px; }
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card h2 { margin: 0; font-size: 19px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }

/* Kennzahlen */
.summary { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: center; }
.big { flex: 999 1 320px; display: flex; flex-direction: column; gap: 2px; }
.big .label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.big .value { font-size: clamp(48px, 8vw, 72px); font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.big .value small { font-size: 26px; font-weight: 600; letter-spacing: 0; color: var(--muted); }
.ringbox { flex: 1 1 280px; display: flex; align-items: center; gap: 20px; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring strong { font-size: 26px; letter-spacing: -.02em; }
.ring span { font-size: 12px; color: var(--muted); }
dl.facts { margin: 0; display: grid; grid-template-columns: auto auto; gap: 6px 16px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; font-family: var(--mono); white-space: nowrap; }
.now { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.now div { background: var(--soft); border-radius: 12px; padding: 10px 14px; }
.now span { display: block; font-size: 12px; color: var(--muted); }
.now b { font-family: var(--mono); font-size: 17px; }

/* Schalter */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; padding: 10px 12px; background: var(--soft); border-radius: 12px; margin: 14px 0 6px; }
.tools .grp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tools .grp > span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid #c7cec9; background: var(--card); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, #7a857f); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Diagramm */
.chart { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 0 8px; margin-top: 10px; }
.chart .plot { position: relative; height: 300px; border-bottom: 1px solid #c7cec9; }
.chart .plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart .ax { position: relative; height: 300px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chart .ax span { position: absolute; transform: translateY(-50%); white-space: nowrap; }
.chart .ax.l span { right: 0; }
.chart .ax.r span { left: 0; }
.chart .xl { grid-column: 2; position: relative; height: 22px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chart .xl span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.grid-line { position: absolute; left: 0; right: 0; border-top: 1px solid #eceeea; }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 4px; }
.bar { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; cursor: pointer; border: 0; padding: 0; background: none; }
.bar > b { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: var(--sun); }
.bar.under > b { background: var(--off); }
.bar > s { position: absolute; left: -2px; right: -2px; border-top: 2px solid var(--soll); }
.bar:hover > b { filter: brightness(.92); }
.peak.flip { transform: translate(calc(-100% - 10px), -50%); }
#dayplot { touch-action: pan-y; }
.peak { position: absolute; padding: 3px 8px; border-radius: 8px; background: var(--card); border: 1px solid #c7cec9; font-size: 12px; font-weight: 600; white-space: nowrap; transform: translate(10px, -50%); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 10px; border-radius: 3px; background: var(--c); }
.legend i.line { height: 0; border-top: 2px solid var(--c); background: none; border-radius: 0; }
.tip { position: absolute; pointer-events: none; padding: 6px 10px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%); }
.empty { padding: 50px 0; text-align: center; color: var(--muted); }

/* Tabellen */
.tablebox { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid #c7cec9; white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid #eceeea; }
td.n, th.n { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr.sum td { font-weight: 700; }
.neg { color: #b30000; }
td a { font-weight: 600; }

/* Wechselrichter-Karten */
.wrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.wr { display: flex; flex-direction: column; gap: 8px; }
.wr header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.wr .kwh { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.wr .share { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.wr .share b { display: block; height: 100%; border-radius: 999px; background: var(--c, var(--sun)); }

/* Anlageninfo */
.info { display: grid; grid-template-columns: minmax(150px, auto) minmax(0, 1fr); gap: 10px 24px; margin: 14px 0 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; }

/* Ereignisse */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filters select { min-height: 42px; min-width: 170px; padding: 0 10px; border-radius: 10px; border: 1px solid #c7cec9; background: var(--card); font: inherit; color: var(--ink); }
.filters button { align-self: flex-end; min-height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid #c7cec9; background: var(--soft); cursor: pointer; }
.wrdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c); }
.code { font-family: var(--mono); color: var(--muted); margin-right: 6px; }
.err { color: #b30000; font-weight: 600; }

.foot { padding-bottom: 32px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px; }

@media (max-width: 640px) {
  .switch { margin-top: -22px; }
  .tab { min-width: 0; flex: 1 1 30%; padding: 0 12px; }
  .tabs { width: 100%; }
  .pager { width: 100%; justify-content: space-between; }
  /* Schalter: Gruppenname als Zeile darueber; Wechselrichter als wischbare Zeile, Anzeigen umbrechend */
  .tools { flex-direction: column; align-items: stretch; gap: 10px; padding: 10px; margin-left: -6px; margin-right: -6px; }
  .tools .grp > span { width: 100%; margin: 0; font-size: 11px; }
  .tools, .tools .grp, main > * { min-width: 0; max-width: 100%; }
  .tools .grp[aria-label="Wechselrichter"] { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 24px; }
  .tools .grp[aria-label="Wechselrichter"] > span { display: none; }
  .tools .grp[aria-label="Wechselrichter"]::-webkit-scrollbar { display: none; }
  .chip { flex: none; scroll-snap-align: start; min-height: 40px; padding: 0 12px; font-size: 13px; gap: 6px; }
  .chip i { width: 8px; height: 8px; }
  .ring { width: 104px; height: 104px; }
  .ring svg { width: 104px; height: 104px; }
  .ring strong { font-size: 21px; }
  .ringbox { gap: 14px; }
  dl.facts { gap: 6px 10px; font-size: 13px; }
  /* Diagramm: volle Breite, Achsenbeschriftung liegt ueber den Gitterlinien */
  .chart { grid-template-columns: minmax(0, 1fr); margin-top: 22px; }
  .chart .plot, .chart .ax { height: 240px; }
  .chart .ax.l { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; }
  .chart .ax.l span { right: auto; left: 2px; transform: translateY(-115%); background: rgba(255,255,255,.85); padding: 0 3px; border-radius: 4px; }
  .chart .ax.r { display: none; }
  .chart .xl { grid-column: 1; font-size: 10px; }
  .chart .xl span.minor { display: none; }
  .chart .xl span:first-child { transform: none; }
  .chart .xl span:last-child { transform: translateX(-100%); }
  .bars { gap: 2px; }
  .bar > b { border-radius: 3px 3px 1px 1px; }
  .legend { font-size: 12px; gap: 6px 14px; }
  .card { padding: 16px; }
  .info { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .info dd { margin-bottom: 10px; }
  /* Touch-Ziele: Links in Tabellen, Anlageninfo und Fusszeile mindestens 44 px hoch */
  td a, .info a, .foot a { display: inline-block; padding: 12px 0; }
}
