/* SolarTilt – gemeinsame Gestaltung, hell und dunkel */

:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --flaeche: #ffffff;
  --flaeche-2: #f0f2f5;
  --flaeche-3: #e6e9ee;
  --text: #171a1f;
  --text-2: #5b6370;
  --text-3: #858c98;
  --rand: rgba(15, 23, 42, 0.11);
  --rand-stark: rgba(15, 23, 42, 0.2);
  --akzent: #b45309;
  --akzent-hover: #9a4708;
  --akzent-text: #ffffff;
  --akzent-weich: #fdf0dc;
  --akzent-ink: #92400e;
  --gut: #0b7a2a;
  --gut-weich: #e3f4e7;
  --warn: #8a5a00;
  --warn-weich: #fdf2d6;
  --fehler: #b4302a;
  --fehler-weich: #fbe6e4;
  --info-weich: #e4eefb;
  --info: #1b5fb0;
  --schatten: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
  /* Diagramm */
  --serie-1: #257de0;
  --serie-2: #f47230;
  --gitter: #e7e7e7;
  --achse: #c2c2c2;
  --radius: 14px;
  --radius-klein: 9px;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1014;
    --flaeche: #171a20;
    --flaeche-2: #1e2229;
    --flaeche-3: #282d36;
    --text: #e8ebf0;
    --text-2: #a0a8b6;
    --text-3: #7b8391;
    --rand: rgba(255, 255, 255, 0.09);
    --rand-stark: rgba(255, 255, 255, 0.18);
    --akzent: #f59e0b;
    --akzent-hover: #fbb33b;
    --akzent-text: #1c1200;
    --akzent-weich: #3a2a0c;
    --akzent-ink: #fbbf5a;
    --gut: #53c556;
    --gut-weich: #16301b;
    --warn: #f3c04f;
    --warn-weich: #362a0e;
    --fehler: #f07a72;
    --fehler-weich: #3a1a18;
    --info-weich: #16263b;
    --info: #7db3f2;
    --schatten: 0 1px 2px rgba(0, 0, 0, 0.4);
    --serie-1: #338ced;
    --serie-2: #e76624;
    --gitter: #2c3038;
    --achse: #474c55;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--schrift);
  min-height: 100vh;
}

a { color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.55rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 620; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0 0 0.75em; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
[hidden] { display: none !important; }

/* ------------------------------------------------ Kopf */

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--flaeche) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rand);
}
.kopf-innen {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
}
.marke {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.marke svg { width: 28px; height: 28px; flex: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none;
  color: var(--text-2);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 520;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--flaeche-2); }
.nav a[aria-current="page"] { color: var(--akzent-ink); background: var(--akzent-weich); }
.abmelden { margin-left: auto; }

@media (max-width: 640px) {
  .kopf-innen { flex-wrap: wrap; gap: 6px 10px; padding-top: 8px; padding-bottom: 6px; }
  .marke span { display: none; }
  .nav { order: 3; flex-basis: 100%; }
  .abmelden { order: 2; }
}

/* ------------------------------------------------ Inhalt */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
.seitenkopf {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.seitenkopf p { color: var(--text-2); margin: 4px 0 0; }
.zurueck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.zurueck:hover { color: var(--text); }

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 18px;
}
.karte + .karte, .stapel > * + * { margin-top: 16px; }
.karte-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.karte-kopf p { margin: 2px 0 0; color: var(--text-2); font-size: 0.88rem; }

.raster-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.raster-2 > .karte + .karte { margin-top: 0; }

.leise { color: var(--text-2); }
.klein { font-size: 0.86rem; }

/* ------------------------------------------------ Knöpfe und Felder */

.knopf {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-weight: 580;
  font-size: 0.93rem;
  line-height: 1.2;
  padding: 9px 15px;
  min-height: 40px;
  border-radius: var(--radius-klein);
  border: 1px solid var(--rand-stark);
  background: var(--flaeche);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  white-space: nowrap;
}
.knopf:hover { background: var(--flaeche-2); }
.knopf:active { transform: translateY(1px); }
.knopf:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--akzent);
  outline-offset: 2px;
}
.knopf:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.knopf.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.haupt:hover:not(:disabled) { background: var(--akzent-hover); border-color: var(--akzent-hover); }
.knopf.gefahr { color: var(--fehler); border-color: color-mix(in srgb, var(--fehler) 45%, transparent); }
.knopf.gefahr:hover:not(:disabled) { background: var(--fehler-weich); }
.knopf.gefahr.voll { background: var(--fehler); color: #fff; border-color: var(--fehler); }
.knopf.klein { min-height: 32px; padding: 5px 10px; font-size: 0.85rem; }
.knopf.gross { min-height: 52px; font-size: 1rem; padding: 12px 18px; }
.knopf svg { width: 18px; height: 18px; flex: none; }
.knopf.laedt { position: relative; color: transparent !important; pointer-events: none; }
.knopf.laedt::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid var(--text-2);
  border-right-color: transparent;
  border-radius: 50%;
  animation: drehen 0.7s linear infinite;
}
.knopf.haupt.laedt::after { border-color: var(--akzent-text); border-right-color: transparent; }
@keyframes drehen { to { transform: rotate(360deg); } }

.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.feld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.feld label, .feld .beschriftung { font-weight: 560; font-size: 0.9rem; }
.feld .hilfe { color: var(--text-2); font-size: 0.82rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="file"], textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius-klein);
  padding: 9px 11px;
  min-height: 40px;
  width: 100%;
}
input[type="file"] { padding: 7px; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 560;
  border: 1px solid var(--rand-stark); border-radius: 7px;
  background: var(--flaeche-2); color: var(--text);
  padding: 5px 10px; margin-right: 10px; cursor: pointer;
}
textarea { min-height: 72px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
.eingabe-mit-knopf { display: flex; gap: 8px; }
.eingabe-mit-knopf input { flex: 1; min-width: 0; }
.ankreuzen { display: flex; gap: 9px; align-items: flex-start; font-size: 0.92rem; cursor: pointer; margin-bottom: 14px; }
.ankreuzen input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--akzent); }

/* Umschalter (Automatik / Manuell) */
.umschalter {
  display: inline-flex;
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.umschalter button {
  appearance: none;
  font: inherit; font-weight: 580; font-size: 0.9rem;
  border: 0; background: transparent; color: var(--text-2);
  padding: 7px 16px; border-radius: 999px; cursor: pointer; min-height: 34px;
}
.umschalter button[aria-pressed="true"] { background: var(--flaeche); color: var(--text); box-shadow: var(--schatten); }
.umschalter button:disabled { cursor: not-allowed; opacity: 0.6; }

/* ------------------------------------------------ Abzeichen */

.abzeichen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 620;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--flaeche-2);
  color: var(--text-2);
  white-space: nowrap;
  line-height: 1.4;
}
.abzeichen::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.abzeichen.ohne-punkt::before { display: none; }
.abzeichen.gut { background: var(--gut-weich); color: var(--gut); }
.abzeichen.warn { background: var(--warn-weich); color: var(--warn); }
.abzeichen.fehler { background: var(--fehler-weich); color: var(--fehler); }
.abzeichen.info { background: var(--info-weich); color: var(--info); }
.abzeichen.akzent { background: var(--akzent-weich); color: var(--akzent-ink); }
.abzeichen.gut::before { box-shadow: 0 0 0 3px color-mix(in srgb, var(--gut) 25%, transparent); }

/* ------------------------------------------------ Geräteliste */

.geraeteraster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: 16px;
}
.geraetekarte {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 16px 16px 14px;
  transition: border-color 0.15s, transform 0.15s;
}
.geraetekarte:hover { border-color: var(--rand-stark); transform: translateY(-1px); }
.geraetekarte.offline .kennzahlen { opacity: 0.6; }
.gk-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.gk-name { font-weight: 650; font-size: 1.05rem; overflow-wrap: anywhere; }
.gk-id { color: var(--text-3); font-family: var(--mono); font-size: 0.78rem; }
.kennzahlen { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kennzahl { background: var(--flaeche-2); border-radius: var(--radius-klein); padding: 8px 10px; min-width: 0; }
.kennzahl .bez { font-size: 0.74rem; color: var(--text-2); font-weight: 560; text-transform: uppercase; letter-spacing: 0.04em; }
.kennzahl .wert { font-size: 1.12rem; font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kennzahl .wert small { font-size: 0.75rem; font-weight: 520; color: var(--text-2); margin-left: 2px; }
.gk-fuss {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--text-2);
  border-top: 1px solid var(--rand); padding-top: 10px;
}

.leer {
  text-align: center;
  padding: 48px 20px;
  border: 1px dashed var(--rand-stark);
  border-radius: var(--radius);
  color: var(--text-2);
}
.leer svg { width: 48px; height: 48px; margin-bottom: 8px; color: var(--akzent); }
.leer h2 { color: var(--text); margin-bottom: 6px; }

/* ------------------------------------------------ Gerät-Detail */

.live {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.live .kennzahl { padding: 10px 12px; }
.live .kennzahl .wert { font-size: 1.25rem; }

.steuerkreuz { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.steuerkreuz .knopf { flex-direction: column; gap: 4px; min-height: 64px; }
.steuerkreuz .knopf svg { width: 22px; height: 22px; }
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--rand); }
.zeile:first-of-type { border-top: 0; }
.zeile .titel { font-weight: 580; }
.zeile .titel small { display: block; font-weight: 400; color: var(--text-2); font-size: 0.83rem; }
.schwelle { display: flex; gap: 8px; align-items: center; }
.schwelle input { width: 90px; }

.hinweis {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius-klein);
  background: var(--info-weich); color: var(--text); font-size: 0.9rem; margin-bottom: 14px;
}
.hinweis svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--info); }
.hinweis.warn { background: var(--warn-weich); }
.hinweis.warn svg { color: var(--warn); }
.hinweis.fehler { background: var(--fehler-weich); }
.hinweis.fehler svg { color: var(--fehler); }
.hinweis.gut { background: var(--gut-weich); }
.hinweis.gut svg { color: var(--gut); }
.hinweis p:last-child { margin-bottom: 0; }

.fortschritt { height: 8px; background: var(--flaeche-3); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.fortschritt > div { height: 100%; background: var(--akzent); border-radius: 999px; width: 0; transition: width 0.4s; }

/* Tabellen */
.tabelle-huelle { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
th, td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--rand); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
td .mono { word-break: break-all; }
.aktionen { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------ Diagramm */

.diagramm { position: relative; margin-top: 4px; }
.diagramm + .diagramm { margin-top: 22px; }
.diagramm-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.legende { display: flex; gap: 14px; font-size: 0.82rem; color: var(--text-2); flex-wrap: wrap; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legende i.serie-1, .tipp i.serie-1 { background: var(--serie-1); }
.legende i.serie-2, .tipp i.serie-2 { background: var(--serie-2); }
.diagramm svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.diagramm .gitter { stroke: var(--gitter); stroke-width: 1; }
.diagramm .grundlinie { stroke: var(--achse); stroke-width: 1; }
.diagramm .achse { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.diagramm .endwert { fill: var(--text); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.diagramm .linie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.diagramm .flaeche { stroke: none; opacity: 0.1; }
.diagramm .serie-1 { stroke: var(--serie-1); }
.diagramm .serie-2 { stroke: var(--serie-2); }
.diagramm .flaeche.serie-1 { fill: var(--serie-1); }
.diagramm .punkt { stroke: var(--flaeche); stroke-width: 2; }
.diagramm .punkt.serie-1 { fill: var(--serie-1); }
.diagramm .punkt.serie-2 { fill: var(--serie-2); }
.diagramm .fadenkreuz { stroke: var(--achse); stroke-width: 1; }
.diagramm .leer-text { fill: var(--text-2); font-size: 13px; }
.tipp {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--flaeche); border: 1px solid var(--rand-stark); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  padding: 7px 10px; font-size: 0.82rem; white-space: nowrap;
}
.tipp .zeit { color: var(--text-2); margin-bottom: 3px; }
.tipp div { display: flex; align-items: center; gap: 7px; }
.tipp i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tipp b { font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; }
details.tabellenansicht { margin-top: 10px; font-size: 0.88rem; }
details.tabellenansicht summary { cursor: pointer; color: var(--text-2); }
details.tabellenansicht .tabelle-huelle { max-height: 260px; overflow-y: auto; margin-top: 8px; }

/* ------------------------------------------------ Einrichtung */

.schritte { counter-reset: schritt; display: flex; flex-direction: column; gap: 14px; }
.schritt { position: relative; padding-left: 58px; }
.schritt::before {
  counter-increment: schritt;
  content: counter(schritt);
  position: absolute; left: 18px; top: 18px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.9rem;
  background: var(--flaeche-3); color: var(--text-2);
}
.schritt.aktiv::before { background: var(--akzent); color: var(--akzent-text); }
.schritt.erledigt::before { content: "✓"; background: var(--gut); color: var(--flaeche); }
.schritt.gesperrt { opacity: 0.55; }
.schritt.gesperrt :is(button, input) { pointer-events: none; }
.schritt h2 { margin-bottom: 4px; }
.schritt > p.leise { margin-bottom: 14px; }
.infoliste { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 0.9rem; margin: 12px 0 0; }
.infoliste dt { color: var(--text-2); }
.infoliste dd { margin: 0; overflow-wrap: anywhere; }
.verlaufsliste { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.verlaufsliste li { display: flex; gap: 10px; align-items: baseline; }
.verlaufsliste time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 0.82rem; flex: none; }
.maschine {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--akzent); animation: pulsieren 1.2s ease-in-out infinite; margin-right: 4px;
}
@keyframes pulsieren { 50% { opacity: 0.3; } }

/* ------------------------------------------------ Anmeldung */

.anmelde-seite { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.anmelde-karte { width: 100%; max-width: 380px; }
.anmelde-karte .marke { justify-content: center; margin-bottom: 18px; font-size: 1.25rem; }
.anmelde-karte .marke svg { width: 38px; height: 38px; }
.anmelde-karte .knopf { width: 100%; }

/* ------------------------------------------------ Dialoge und Meldungen */

dialog {
  border: 1px solid var(--rand-stark);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
  padding: 20px;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(10, 12, 16, 0.5); backdrop-filter: blur(2px); }
dialog h2 { margin-bottom: 8px; }
dialog .knopfreihe { justify-content: flex-end; margin-top: 18px; }
.token-feld {
  font-family: var(--mono); font-size: 0.88rem; word-break: break-all;
  background: var(--flaeche-2); border: 1px solid var(--rand); border-radius: var(--radius-klein);
  padding: 10px 12px; margin: 10px 0; user-select: all;
}

.meldungen { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.meldung {
  background: var(--text); color: var(--bg);
  padding: 11px 15px; border-radius: 10px; font-size: 0.9rem; font-weight: 520;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  animation: einblenden 0.2s ease-out;
}
.meldung.fehler { background: var(--fehler); color: #fff; }
@keyframes einblenden { from { opacity: 0; transform: translateY(8px); } }

.skelett { background: var(--flaeche-2); border-radius: var(--radius); min-height: 190px; animation: pulsieren 1.4s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}

.abstand { margin-top: 16px; }
.schritte > .karte + .karte { margin-top: 0; }

@media (max-width: 480px) {
  .karte { padding: 16px; }
  .schritt { padding-left: 16px; }
  .schritt::before { position: static; margin-bottom: 8px; }
  .tabelle-huelle { margin: 0 -16px; padding: 0 16px; }
}
