/* SolarDiagnose: ruhiges Arbeitswerkzeug. Farben tragen Bedeutung (Status, Energieflüsse), sonst Zurückhaltung.
   Nur Systemschriften: keine Schriftdateien von fremden Servern (DSGVO). */
:root {
  color-scheme: light;
  --paper: #eef2f4;
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #5a6875;
  --line: #d5dde3;
  --accent: #1d5c8a;
  --accent-ink: #ffffff;
  --ok: #2e7d4f;
  --warn: #a86a12;
  --fault: #b42318;
  --manual: #8794a1;
  --c-pv: #d99a00;
  --c-load: #1d5c8a;
  --c-grid: #8b4fae;
  --c-soc: #2e7d4f;
  --c-feed: #d99a00;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0f161c;
    --surface: #17212a;
    --ink: #e4ebf0;
    --muted: #96a4b1;
    --line: #2a3843;
    --accent: #6aaee0;
    --accent-ink: #0f161c;
    --ok: #5cc28a;
    --warn: #e0a548;
    --fault: #f06a5c;
    --manual: #6f7d8a;
    --c-pv: #f2b929;
    --c-load: #6aaee0;
    --c-grid: #c08ae0;
    --c-soc: #5cc28a;
    --c-feed: #f2b929;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
code { font-size: .9em; background: var(--paper); padding: .1em .35em; border-radius: 4px; }
code.copy { display: inline-block; margin-top: .35rem; user-select: all; word-break: break-all; }
.muted { color: var(--muted); }

/* Kopfzeile */
.top {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .75rem clamp(1rem, 3vw, 2rem); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.top nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.top nav a { padding: .35rem .7rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.top nav a:hover { background: var(--paper); }
.top nav a[aria-current="page"] { background: var(--paper); font-weight: 600; }
.logout { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 1em; background: var(--fault); color: #fff; font-size: .8rem; text-align: center; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem clamp(1rem, 3vw, 2rem) 4rem; }
.narrow { max-width: 640px; }
.login { margin: 12vh auto 0; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.lead { margin: 0; color: var(--muted); max-width: 70ch; }
.lead strong { color: var(--fault); }
.crumb { margin: 0 0 .25rem; font-size: .9rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }

/* Meldungen oben */
.flash { padding: .7rem 1rem; border-radius: var(--radius); border-left: 4px solid var(--ok); background: var(--surface); margin: 0 0 1rem; }
.flash-warn { border-color: var(--warn); }
.flash-err { border-color: var(--fault); }

/* Anlagenliste */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
.plants { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.plants tbody tr { box-shadow: inset 4px 0 0 var(--state); }
.plants td:first-child { white-space: nowrap; padding-left: 1rem; font-size: .9rem; }
.plants a { font-weight: 600; text-decoration: none; }
.plants a:hover { text-decoration: underline; }
.sub { font-size: .85rem; color: var(--muted); }
.sub.alarm { color: var(--fault); }
.sub.warn { color: var(--warn); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--state); margin-right: .45rem; }
.state-ok { --state: var(--ok); }
.state-warn { --state: var(--warn); }
.state-fault { --state: var(--fault); }
.state-manual { --state: var(--manual); }
.spark { width: 120px; height: 28px; display: block; }
.spark polygon { fill: var(--c-pv); opacity: .22; }
.spark polyline { fill: none; stroke: var(--c-pv); stroke-width: 1.5; }
.spark line { stroke: var(--line); }
#filter { min-width: 16rem; }
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Momentanwerte und Kennzahlen */
.now { display: flex; flex-wrap: wrap; gap: 2.5rem; align-items: flex-end; margin: 0 0 1rem; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.now div, .figures div { display: flex; flex-direction: column; }
.now .k, .figures .k { font-size: .85rem; color: var(--muted); }
.now .v { font-size: 1.9rem; font-weight: 650; line-height: 1.1; }
.now p { margin: 0 0 0 auto; font-size: .85rem; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin: 0 0 1.25rem; }
.figures .v { font-size: 1.4rem; font-weight: 650; }

/* Diagramme */
.chart { width: 100%; margin: .5rem 0 1rem; }
.chart svg { display: block; overflow: visible; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; background: var(--c); }
.axis text { font-size: 11px; fill: var(--muted); }
.axis .grid { stroke: var(--line); stroke-width: 1; }
.axis .zero { stroke: var(--muted); stroke-width: 1; }
.stroke { fill: none; stroke: var(--c); stroke-width: 1.75; stroke-linejoin: round; }
.area { fill: var(--c); opacity: .15; stroke: none; }
.bar { fill: var(--c); }
.s-pv { --c: var(--c-pv); }
.s-load { --c: var(--c-load); }
.s-grid { --c: var(--c-grid); }
.s-soc { --c: var(--c-soc); }
.s-feed { --c: var(--c-feed); }
.tip line { stroke: var(--muted); stroke-dasharray: 3 3; }
.tip text { font-size: 12px; fill: var(--ink); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: .9rem; }
.form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .9rem 1.25rem; margin-bottom: 1rem; }
.form.inline, form.inline { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; font-weight: 500; }
label[hidden] { display: none; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: .55rem .7rem; width: 100%;
}
input[type="checkbox"] { width: auto; }
input[type="file"] { padding: .4rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: .9rem; }
legend { font-weight: 600; padding: 0 .35rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }
.actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer; display: inline-block; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: .55rem 1rem;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.small { padding: .25rem .6rem; font-size: .85rem; }
button.danger { background: transparent; color: var(--fault); border-color: var(--fault); }
.danger-zone { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.source { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1.5rem; align-items: start; }
.or { color: var(--muted); margin: 2rem 0 0; }
@media (max-width: 720px) {
  .source { grid-template-columns: 1fr; gap: .5rem; }
  .or { margin: 0; }
  .row { grid-template-columns: 1fr; }
  .now { gap: 1.25rem; }
  .now p { margin: 0; flex-basis: 100%; }
}

/* Meldungsliste */
.alarms { list-style: none; margin: 0; padding: 0; }
.alarms li { padding: .7rem 0 .7rem 1rem; border-bottom: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--fault); }
.alarms li.closed { box-shadow: inset 3px 0 0 var(--line); color: var(--muted); }
.alarms .when { font-size: .85rem; color: var(--muted); margin-right: .5rem; }
.alarms form { margin-top: .4rem; }

/* Bericht Speicheranalyse */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.25rem, 3vw, 2rem); }
.report-head { border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; padding-bottom: .75rem; }
.report-head p { margin: 0; }
.report h2 { margin-top: 2rem; }
.verdict { border-left: 4px solid var(--accent); padding: .25rem 0 .25rem 1rem; margin: 0 0 1rem; max-width: 75ch; }
.verdict p { margin: 0; }
tr.best td { background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 600; }
.fineprint { font-size: .8rem; color: var(--muted); max-width: 80ch; margin-top: 2rem; }

@media print {
  :root { color-scheme: light; --paper: #fff; --surface: #fff; --ink: #000; --muted: #444; --line: #ccc; }
  .top, .no-print, main > .flash { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; }
  .chart, table { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
