:root {
  color-scheme: light;
  --seite: #f9f9f7;
  --flaeche: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-leise: #898781;
  --gitter: #e1e0d9;
  --achse: #c3c2b7;
  --rand: rgba(11, 11, 11, 0.10);
  --serie-1: #2a78d6;   /* Mittelwert */
  --serie-2: #eb6834;   /* DHT22 Nr. 1 */
  --serie-3: #1baf7a;   /* DHT22 Nr. 2 */
  --gut: #0ca30c;
  --warnung: #fab219;
  --akzent: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --seite: #0d0d0d;
    --flaeche: #1a1a19;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-leise: #898781;
    --gitter: #2c2c2a;
    --achse: #383835;
    --rand: rgba(255, 255, 255, 0.10);
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-3: #199e70;
    --akzent: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --seite: #0d0d0d;
  --flaeche: #1a1a19;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-leise: #898781;
  --gitter: #2c2c2a;
  --achse: #383835;
  --rand: rgba(255, 255, 255, 0.10);
  --serie-1: #3987e5;
  --serie-2: #d95926;
  --serie-3: #199e70;
  --akzent: #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--seite);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
}

.seite {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1, h2 { margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 0.95rem; font-weight: 600; }
.untertitel { margin: 4px 0 0; color: var(--text-2); }

/* Kopf + Status ---------------------------------------------------------- */
.kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--rand);
  background: var(--flaeche);
  font-size: 0.9rem;
  color: var(--text-2);
}
.status__icon {
  width: 16px; height: 16px;
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff;
  background: var(--text-leise);
}
.status--live .status__icon { background: var(--gut); }
.status--live .status__icon::before { content: "✓"; }
.status--alt .status__icon { background: var(--warnung); color: #0b0b0b; }
.status--alt .status__icon::before { content: "!"; }
.status--unbekannt .status__icon::before { content: "?"; }

/* Kacheln ---------------------------------------------------------------- */
.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kachel, .karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
}
.kachel { padding: 16px; }
.kachel h2 { color: var(--text-2); font-weight: 500; }
.kachel__wert { margin: 6px 0 2px; font-size: 2.6rem; font-weight: 600; letter-spacing: -0.02em; }
.kachel__wert--klein { font-size: 1.6rem; padding: 0.4rem 0; }
.einheit { font-size: 1.1rem; font-weight: 500; color: var(--text-2); margin-left: 4px; }
.kachel__detail { margin: 0; color: var(--text-2); font-size: 0.9rem; }

/* Filter ----------------------------------------------------------------- */
.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 16px;
}
.segment {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--flaeche);
  padding: 3px;
  gap: 2px;
}
.segment button, .knopf {
  font: inherit;
  font-size: 0.9rem;
  border: 0;
  border-radius: 7px;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.segment button:hover { background: var(--gitter); color: var(--text); }
.segment button[aria-pressed="true"] { background: var(--akzent); color: #fff; font-weight: 600; }
.knopf { background: var(--akzent); color: #fff; font-weight: 600; }
.schalter { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.9rem; cursor: pointer; }
.eigen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: 100%; }
.eigen[hidden] { display: none; }
.eigen label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--text-2); }
.eigen input {
  font: inherit; font-size: 0.9rem;
  padding: 5px 8px;
  border: 1px solid var(--rand);
  border-radius: 7px;
  background: var(--flaeche);
  color: var(--text);
}
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* Diagramm-Karten -------------------------------------------------------- */
.karte { padding: 16px; margin-bottom: 16px; }
.karte__kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-bottom: 8px;
}
.karte__kopf h2 { font-size: 1.05rem; }
.einheit-klein { font-weight: 400; color: var(--text-leise); font-size: 0.85rem; }
.statistik { margin: 0; font-size: 0.85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.diagramm { position: relative; height: 300px; }
.hinweis { color: var(--text-leise); font-size: 0.85rem; margin: 0 0 16px; }

/* Tabelle ---------------------------------------------------------------- */
.tabelle summary { cursor: pointer; font-weight: 600; }
.tabelle__rahmen { overflow-x: auto; margin-top: 12px; max-height: 420px; overflow-y: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--gitter); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; background: var(--flaeche); color: var(--text-2); font-weight: 600; }

@media (max-width: 560px) {
  .kachel__wert { font-size: 2.1rem; }
  .diagramm { height: 240px; }
}
