/* feld.energy Cloud – angelehnt an den Auftritt von feld.energy:
   dunkles Waldgrün, helles Lindgrün als Markierung, fast weißer Grund */
:root {
  --bg: #F7F9F4;
  --card: #FFFFFF;
  --ink: #12301C;
  --muted: #4E6153;
  --line: #DDE5D8;
  --line-soft: #EEF3EA;
  --accent: #12301C;
  --accent-soft: #E3F7D0;
  --mint: #E3F7D0;
  --sun: #12301C;
  --ok: #1F7A4D;
  --warn: #8A5A0B;
  --err: #B42318;
  --radius: 14px;
  font-family: "Figtree", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
a:hover { color: #0A1F11; }
:focus-visible { outline: 3px solid #9BD27A; outline-offset: 2px; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92em; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Gerüst */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 256px; flex-shrink: 0; background: #FCFDFB; border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 14px; padding: 4px 8px 22px; }
.logo { flex-shrink: 0; width: 30px; height: 30px; }
.brand-name { font-family: "DM Mono", ui-monospace, "SF Mono", monospace; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; }
.brand-text { display: flex; flex-direction: column; align-items: center; gap: 6px; line-height: 1.2; }
.brand-sub { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.08em; }
.nav-label { padding: 8px 10px 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.plant, .nav { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 15px; }
.plant:hover, .nav:hover { background: var(--line-soft); color: var(--ink); }
.plant.active, .nav.active { background: var(--accent-soft); font-weight: 600; }
.plant .grow { flex-grow: 1; }
.plant-state { font-size: 12px; color: var(--muted); font-weight: 400; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-button { width: 100%; border: none; background: none; font: inherit; text-align: left; cursor: pointer; }
.main { flex-grow: 1; min-width: 0; padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 18px; max-width: 1400px; }

/* Kopf */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.crumb { display: inline-block; font-size: 14px; font-weight: 500; color: var(--mint); background: var(--ink); padding: 4px 10px; margin-bottom: 0; }
.title-row { display: flex; align-items: center; gap: 12px; }
h1 { font-family: "Prompt", "Figtree", sans-serif; font-size: 32px; font-weight: 700; letter-spacing: -0.01em;
  line-height: 1.15; background: var(--mint); padding: 8px 16px 6px; }
.auth-card h1, .card h1 { background: none; padding: 0; }
.sub { color: var(--muted); margin-top: 4px; }
.day-nav { display: flex; gap: 8px; }

/* Buttons & Badges */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid #C5D2BF; border-radius: 10px; background: var(--card); color: var(--ink); font: inherit;
  font-weight: 500; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--line-soft); color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #FFFFFF; font-weight: 600; box-shadow: 0 0 0 3px var(--mint); }
.btn.primary:hover { background: #0A1F11; color: #FFFFFF; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--err); border-color: #E7B7B2; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 4px; font-size: 12.5px; font-weight: 600; }
.badge.ok { background: #E3F2EA; color: var(--ok); }
.badge.warn { background: #FCF1DF; color: var(--warn); }
.badge.sample { background: var(--ink); color: var(--mint); }
.badge.err { background: #FBE9E7; color: var(--err); }

/* Meldungen */
.flash { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); }
.flash.ok { background: #E3F2EA; }
.flash.error { background: #FBE9E7; color: #7A1A12; }

/* Datenstatus */
.status { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); }
.status.warn { border-color: #EBC98F; background: #FFF8EC; }
.status.off { border-style: dashed; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: #A6B1BB; }
.dot.ok { background: #2E9960; }
.dot.warn { background: #D98A12; }

/* Kennzahlen: eine durchgehende Leiste statt einzelner Kacheln */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
.kpi { padding: 16px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.kpi:last-child { border-right: none; }
.kpi-label { font-size: 14px; color: var(--muted); font-weight: 500; }
.kpi-value { font-family: "Prompt", "Figtree", sans-serif; font-size: 34px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value .unit { font-size: 15px; font-weight: 400; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.kpi-note { font-size: 13px; color: var(--muted); }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.card.narrow { max-width: 520px; }
.card.empty { padding: 28px; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
h2 { font-family: "Prompt", "Figtree", sans-serif; font-size: 18px; font-weight: 600; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.facts { margin: 0; display: grid; grid-template-columns: minmax(160px, 38%) 1fr; gap: 8px 16px; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Diagramm */
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.key.irr { background: var(--sun); }
.key.temp { background: repeating-linear-gradient(90deg, #7A8C7E 0 4px, transparent 4px 7px); margin-left: 10px; }
.chart { width: 100%; height: 300px; display: block; }
.chart .grid { stroke: #E7EEE2; stroke-width: 1; }
.chart .axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .irr-fill { fill: #BFE8A0; fill-opacity: 0.55; }
.chart .irr-line { fill: none; stroke: var(--sun); stroke-width: 2.5; stroke-linejoin: round; }
.chart .irr-dot { fill: #FFFFFF; stroke: var(--sun); stroke-width: 2.5; }
.chart .temp-line { fill: none; stroke: #7A8C7E; stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .now { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.raw { margin: 0; padding: 14px; background: #F7F9F4; border: 1px solid var(--line-soft); border-radius: 6px;
  overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; line-height: 1.5; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-size: 14px; font-weight: 500; margin-top: 8px; }
.form input, .form select { min-height: 44px; padding: 0 12px; border: 1px solid #C5D2BF; border-radius: 10px;
  font: inherit; background: #FFFFFF; color: var(--ink); }
.form .btn { margin-top: 14px; }
.code-input { font-size: 22px; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }

/* Login-Seiten */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 30px 30px; display: flex; flex-direction: column; gap: 12px; }
.brand-auth { padding: 0 0 6px; }
.auth-card h1 { font-size: 24px; }
.lead { color: var(--muted); }
.hint { font-size: 14px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.qr { align-self: center; width: 220px; height: 220px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #FFFFFF; }
.qr svg { width: 100%; height: 100%; display: block; }
.manual summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.manual p { margin-top: 8px; font-size: 14px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--line); }
  .two-col { grid-template-columns: 1fr; }
}

/* Passwort anzeigen */
.pw-field { position: relative; display: flex; }
.pw-field input { flex-grow: 1; padding-right: 52px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 40px;
  border: none; background: none; color: var(--muted); cursor: pointer; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; }
.pw-toggle:hover { color: var(--ink); background: var(--line-soft); }
.pw-toggle .eye-off { display: none; }
.pw-toggle.shown .eye-off { display: inline; }

/* Login-Seiten im feld.energy-Grün */
body.auth { background: var(--ink); }
body.auth .auth-card { border: none; box-shadow: 0 0 0 6px var(--mint); }
body.auth .auth-card h1 { background: var(--mint); padding: 6px 12px 4px; align-self: flex-start; font-family: "Prompt", "Figtree", sans-serif; }

.divider { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0 -4px; }

/* ================================================================
   Leitwarte: Übersicht, Anlagen, Alarme
   ================================================================ */
.grow { flex-grow: 1; }
.nav-top { display: flex; flex-direction: column; gap: 2px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.plant-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav .count, .count { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px;
  padding: 0 7px; border-radius: 11px; background: var(--err); color: #FFFFFF; font-size: 12.5px; font-weight: 700;
  text-decoration: none; font-variant-numeric: tabular-nums; }
a.count:hover { color: #FFFFFF; background: #8F1C13; }
.crumb a { color: inherit; text-decoration: none; }
.crumb a:hover { text-decoration: underline; color: inherit; }

/* Status: Punkte und Beschriftung */
.dot.none, .dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px #A6B1BB; }
.dot.err { background: var(--err); }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; white-space: nowrap; }
.state.none { color: var(--muted); }
.state.warn { color: var(--warn); font-weight: 600; }
.state.err { color: var(--err); font-weight: 600; }
.nodata { color: #8C9A8F; font-size: 13.5px; }
.kpis .kpi-value.nodata, .kpis.six .kpi-value.nodata { font-family: inherit; font-size: 17px; font-weight: 500; letter-spacing: 0; color: #8C9A8F; padding: 10px 0 6px; }
.badge.none { background: var(--line-soft); color: var(--muted); }

/* Zusammenfassung oben: eine Zeile Zahlen, wie eine Anzeigetafel */
.tally { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--ink); color: #FFFFFF;
  border-radius: var(--radius); overflow: hidden; }
.tally.three { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 720px; }
.tally-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 20px 16px; border-right: 1px solid rgba(227, 247, 208, 0.16);
  color: #FFFFFF; text-decoration: none; }
.tally-item:last-child { border-right: none; }
.tally-item.link:hover { background: #1B4029; color: #FFFFFF; }
.tally-item.hot { background: var(--mint); color: var(--ink); }
.tally-item.hot .tally-label { color: var(--ink); }
.tally-item.link.hot:hover { background: #D3F0B8; color: var(--ink); }
.tally-value { display: flex; align-items: center; gap: 10px; font-family: "Prompt", "Figtree", sans-serif; font-size: 32px;
  font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tally-value .unit { font-family: "Figtree", sans-serif; font-size: 15px; font-weight: 400; margin-left: 4px; letter-spacing: 0; opacity: 0.8; }
.tally-value .dot { width: 11px; height: 11px; }
.tally-value .dot.none { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6); }
.tally-label { font-size: 13.5px; color: rgba(255, 255, 255, 0.72); }

/* Anlagentabelle */
.card.flush { padding: 0; overflow: hidden; }
.scroll { overflow-x: auto; }
.fleet { font-size: 14.5px; }
.fleet th { padding: 12px 12px; background: #FCFDFB; white-space: nowrap; }
.fleet td { padding: 12px 12px; }
.fleet tbody tr:hover { background: #FAFCF8; }
.fleet tr.unlinked .plant-link { color: var(--muted); }
.th-note { font-weight: 400; color: #8C9A8F; margin-left: 4px; }
.plant-link { display: block; font-weight: 600; font-size: 15.5px; color: var(--ink); text-decoration: none; }
.plant-link:hover { text-decoration: underline; color: var(--ink); }
.cell-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
.fleet .badge { margin-left: 6px; }
.table-foot { padding: 10px 14px 12px; font-size: 13.5px; border-top: 1px solid var(--line-soft); }
.spark-cell { width: 170px; }
.spark { display: block; width: 150px; height: 34px; }
.spark-base { stroke: #C5D2BF; stroke-width: 1; stroke-dasharray: 2 3; }
.unlinked .spark-base { stroke: #DDE5D8; }
.spark-fill { fill: #BFE8A0; fill-opacity: 0.6; }
.spark-line { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spark-now { stroke: #9BD27A; stroke-width: 1; }
.nowrap { white-space: nowrap; }

/* Anlagendetail */
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpis.six .kpi-value { font-size: 30px; }
.chart-empty { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 20px; border: 1.5px dashed var(--line); border-radius: 10px; color: var(--muted);
  background: repeating-linear-gradient(0deg, transparent 0 47px, var(--line-soft) 47px 48px); }
.chart-empty.short { min-height: 110px; }
.card.flush .chart-empty { margin: 16px; }
details.settings summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details.settings summary::-webkit-details-marker { display: none; }
details.settings summary::before { content: "+"; font-size: 20px; width: 20px; color: var(--muted); }
details.settings[open] summary::before { content: "−"; }
details.settings[open] summary { margin-bottom: 8px; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.grid-form > div { display: flex; flex-direction: column; gap: 6px; }
.grid-form input { width: 100%; }
.grid-form .btn, .form .form-end .btn { margin-top: 0; }

/* Alarme */
.sev { display: inline-block; padding: 3px 9px; border-radius: 4px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.sev.err { background: var(--err); color: #FFFFFF; }
.sev.warn { background: #FCE7C2; color: #6B4508; }
.sev.info { background: var(--line-soft); color: var(--muted); }
.sev-mark { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.sev-mark.err { background: #F0776B; }
.sev-mark.warn { background: #F2C46D; }
.sev-mark.info { background: rgba(255, 255, 255, 0.45); }
.tally-item.hot .sev-mark.err { background: var(--err); }
.alarm-list { list-style: none; margin: 0; padding: 0; }
.alarm-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft); }
.alarm-item:last-child { border-bottom: none; }
.alarm-item.closed { opacity: 0.6; }
.alarm-time { font-size: 13px; white-space: nowrap; }
.table.alarms tr.closed td { color: var(--muted); }
.table.alarms tr.closed .sev { opacity: 0.55; }
.table.alarms th:first-child, .table.alarms td:first-child { padding-left: 20px; }
.segmented { display: inline-flex; border: 1px solid #C5D2BF; border-radius: 10px; padding: 3px; background: var(--card); }
.seg { min-height: 38px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 7px; color: var(--ink); text-decoration: none; font-weight: 500; }
.seg:hover { background: var(--line-soft); color: var(--ink); }
.seg.on { background: var(--ink); color: #FFFFFF; }

@media (max-width: 1280px) {
  .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.six .kpi { border-bottom: 1px solid var(--line); }
  .tally { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tally-item { border-bottom: 1px solid rgba(227, 247, 208, 0.16); }
  .grid-form { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.facts.tight { grid-template-columns: max-content 1fr; align-items: center; }

/* Logo als Bild (Omega + Schriftzug) */
.brand { flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 10px 22px; }
.wordmark { display: block; width: 188px; height: auto; }
.brand-sub { letter-spacing: 0.02em; font-size: 12px; padding-left: 1px; }
.brand-auth { padding: 0 0 10px; }
.brand-auth .wordmark { width: 220px; }

/* Anlage anlegen / löschen */
.nav.add { color: var(--muted); font-size: 14px; }
.nav.add:hover { color: var(--ink); }
.new-plant { max-width: 980px; gap: 8px; }
.new-plant h2.spaced { margin-top: 18px; }
.grid-form.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-form.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-form.two { grid-template-columns: minmax(0, 320px) auto; justify-content: start; }
.new-plant .actions { margin-top: 18px; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); gap: 8px; }
@media (max-width: 1100px) { .grid-form.five { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Leistung, Verzeichnisse */
.key.pow { background: #2E7D4F; }
.key.kwp { background: repeating-linear-gradient(90deg, #B42318 0 4px, transparent 4px 7px); margin-left: 10px; }
.chart.power { height: 240px; }
.chart .pow-fill { fill: #9FD6B4; fill-opacity: 0.5; }
.chart .pow-line { fill: none; stroke: #2E7D4F; stroke-width: 2.2; stroke-linejoin: round; }
.chart .kwp-line { stroke: #B42318; stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.6; }
.settings .grid-form { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-hint { margin-top: 10px; font-size: 13.5px; max-width: 760px; }

/* Diagramme rund um die Uhr: gleichmäßig skaliert, feineres Raster */
.chart, .chart.power { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #EEF3EA; stroke-width: 1; }
.chart .grid.major { stroke: #D6E0D0; }
.chart .vgrid { stroke: #F1F5EE; stroke-width: 1; }
.chart .vgrid.major { stroke: #DDE5D8; }
.chart .axis { font-size: 11px; }
.chart .axis.strong { fill: var(--ink); font-weight: 600; }
.chart .axis.unit-label { font-size: 10.5px; font-style: italic; }
.chart .temp-axis { fill: #5E7263; }
.chart .temp-tick { stroke: #7A8C7E; stroke-width: 1; }

/* Schaltbare Legende im Diagramm Einstrahlung und Temperatur */
.legend.chart-toggles .series-toggle { background: none; border: 0; padding: 2px 6px; margin-left: 6px; font: inherit; color: inherit; cursor: pointer; border-radius: 6px; }
.legend.chart-toggles .series-toggle:hover { background: rgba(0, 0, 0, .05); }
.legend.chart-toggles .series-toggle.off { opacity: .35; text-decoration: line-through; }
.legend.chart-toggles .key { margin-left: 0; margin-right: 6px; }

/* Werte-Anzeige beim Überfahren des Diagramms Einstrahlung und Temperatur */
.chart-tip { position: fixed; z-index: 1000; pointer-events: none; background: #fff; border: 1px solid rgba(0, 0, 0, .12); border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); padding: 10px 12px; font-size: 14px; min-width: 240px; }
.chart-tip strong { display: block; margin-bottom: 6px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.chart-tip .tip-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chart-tip .tip-lab { flex: 1; }
.chart-tip .tip-val { font-weight: 600; white-space: nowrap; }

/* Datenexport */
.export-form { display: grid; gap: 20px; }
.export-form .ef-row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: start; }
.export-form .ef-label { font-weight: 600; padding-top: 7px; }
.export-form select, .export-form input[type=date] { font: inherit; padding: 6px 10px; border: 1px solid rgba(0, 0, 0, .18); border-radius: 8px; background: #fff; }
.export-form .ef-range { display: flex; gap: 18px; flex-wrap: wrap; }
.export-form .ef-quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.export-form .ef-quick button, .ef-btn { font: inherit; padding: 6px 12px; border: 1px solid rgba(0, 0, 0, .18); border-radius: 8px; background: #fff; color: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
.export-form .ef-quick button:hover { background: rgba(0, 0, 0, .04); }
.export-form .ef-opt { display: block; margin: 5px 0; }
.ef-btn.primary { background: #1f3d2b; border-color: #1f3d2b; color: #fff; font-weight: 600; }
.export-msg.ok { border-left: 4px solid #2E7D4F; }
.export-msg.err { border-left: 4px solid #B42318; }

/* Zoom in den Diagrammen */
button[hidden] { display: none !important; }
.chart { -webkit-user-select: none; user-select: none; }
.zoom-tools { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.zoom-hint { font-size: 12px; color: var(--muted); }
.mon-hint { margin: 6px 0 0; }

/* Komponenten */
.table.comp td { vertical-align: middle; }
tr.comp-edit[hidden] { display: none; }
tr.comp-edit td { background: #F7F9F5; }
.comp-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; padding: 10px 2px; }
.comp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.comp-form input, .comp-form select { font: inherit; color: var(--ink); padding: 6px 8px; border: 1px solid rgba(0, 0, 0, .18); border-radius: 8px; background: #fff; }
.comp-form input[readonly] { background: #F1F4EE; color: var(--muted); }
.comp-form .wide { grid-column: span 2; }
.comp-form .full { grid-column: 1 / -1; }
.comp-form .actions { grid-column: 1 / -1; display: flex; gap: 10px; }
.comp-delete { margin: 0 2px 10px; }
.ef-btn.danger { color: #B42318; border-color: rgba(180, 35, 24, .4); }
@media (max-width: 900px) { .comp-form { grid-template-columns: 1fr 1fr; } }

.plant-pick { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.plant-pick select { font: inherit; font-weight: 400; padding: 7px 12px; min-width: 220px; border: 1px solid rgba(0, 0, 0, .18); border-radius: 8px; background: #fff; }

/* Rechte je Benutzer */
.rights-form fieldset.rights-group { border: 1px solid var(--line, #dfe3dc); border-radius: 10px; padding: 10px 14px 12px; margin: 14px 0 0; }
.rights-form legend { font-weight: 600; padding: 0 6px; }
.rights-form label.check { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; font-weight: normal; }
.rights-form label.check input { width: auto; margin: 0; }
.rights-form .btn { margin-top: 14px; }

/* Auswertung */
.warn-text { color: #b5452f; }
.page-links { margin: 0 0 12px; }
.report-nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 14px; }
.report-nav .seg { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line, #dfe3dc); text-decoration: none; color: inherit; }
.report-nav .seg.on { background: #1f3d2b; color: #fff; border-color: #1f3d2b; }
.chart.bars rect.bar { fill: #3fa34d; }
.chart.bars rect.bar.today { fill: #8cc995; }
.chart.bars text { font-size: 12px; fill: #5b6660; }
.chart.bars line.grid { stroke: #e6e9e3; }

/* Tickets */
.prio, .tstatus { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85em; background: #eef1ec; }
.prio.hoch { background: #fbe3c8; } .prio.kritisch { background: #f6c9c0; color: #7a1d0e; } .prio.niedrig { color: #6b746e; }
.tstatus.neu { background: #dbe8f6; } .tstatus.bearbeitung { background: #fff0c2; } .tstatus.wartet { background: #ece2f6; } .tstatus.erledigt { background: #d8efd9; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.facts dt { color: #6b746e; } .facts dd { margin: 0; white-space: pre-wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid #dfe3dc; padding: .2rem 0 .6rem .8rem; }
.timeline li.kommentar { border-color: #3fa34d; } .timeline li.verlust { border-color: #e0a800; }
.timeline li p { margin: .15rem 0 0; white-space: pre-wrap; }
.device-pick { border: 1px solid #dfe3dc; border-radius: 10px; padding: 8px 14px; }
.device-pick label.check { display: flex; gap: 8px; align-items: baseline; font-weight: normal; margin: 4px 0; }
.device-pick label.check input { width: auto; margin: 0; }
.span2 { grid-column: 1 / -1; }
textarea { width: 100%; font: inherit; }

/* Lebenszeitakte */
.akte-group .grid-form { margin-top: 4px; }
.inline-form { display: inline; }
.timeline li .inline-form .btn { margin-top: 4px; }
.timeline li.firmware { border-color: #2F6FB5; } .timeline li.ticket { border-color: #7A4FB5; }
.timeline li.geraetetausch, .timeline li.neues_geraet { border-color: #2F9C9C; } .timeline li.alarm { border-color: #b5452f; }
.card-head .segmented { flex-wrap: wrap; }

/* Kalender */
.cal-filter { display: inline-flex; gap: .4rem; margin-left: auto; }
.cal-filter select { width: auto; }
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 760px; }
table.cal th { padding: 8px; text-align: left; font-weight: 600; border-bottom: 1px solid #dfe3dc; }
table.cal td { vertical-align: top; border: 1px solid #eef0ec; padding: 4px; position: relative; }
table.cal.monat td { height: 110px; }
table.cal.woche td { height: 320px; }
table.cal td.other { background: #f7f8f6; color: #9aa39d; }
table.cal td.today { background: #f1f8f1; }
.cal-day { font-size: .85em; color: #6b746e; }
.cal-item { display: block; margin: 3px 0; padding: 3px 6px; border-radius: 6px; font-size: .82em; text-decoration: none; color: #1f2933;
            border-left: 4px solid #3fa34d; background: #eef6ef; overflow: hidden; }
.cal-item.legend { display: inline-block; margin: 0 2px; }
.cal-item.inspektion { border-color: #2F6FB5; background: #e8f0f9; } .cal-item.reinigung { border-color: #2F9C9C; background: #e6f4f4; }
.cal-item.einsatz { border-color: #b5452f; background: #f9ebe7; } .cal-item.sonstiges { border-color: #7A8C7E; background: #f0f2ef; }
.cal-item.erledigt, .cal-item.abgesagt { opacity: .55; text-decoration: line-through; }
.cal-item.overdue { outline: 2px solid #b5452f; }
.cal-sub { display: block; color: #6b746e; font-size: .9em; }
.cal-add { position: absolute; top: 2px; right: 6px; text-decoration: none; color: #9aa39d; font-weight: 700; opacity: 0; }
table.cal td:hover .cal-add { opacity: 1; }
.time-range { display: flex; gap: .4rem; align-items: center; }
.btn-row { display: flex; gap: .5rem; margin-top: 8px; }

/* Eigene Kennzahlen */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.formula-row { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.formula-row input, .formula-row select { width: auto; }
.formula-row input[name=formula] { flex: 1 1 260px; }
.formula-row .short { width: 80px; } .formula-row .tiny { width: 64px; }
.formula-help { margin-top: 12px; font-size: .9em; color: #4d5852; }
.formula-help code { background: #eef1ec; padding: 0 .3em; border-radius: 4px; }

/* Budget */
.good-text { color: #2f7d3a; }
.chart.bars rect.bar.budget { fill: #cfd8d1; }
.chart.bars polyline.cum { fill: none; stroke: #7A4FB5; stroke-width: 2; }
.chart.bars polyline.cum.budget { stroke-dasharray: 6 4; stroke: #9a86b8; }
.key.budget-key { background: #cfd8d1; }
.budget-months { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; margin-top: 10px; }
.budget-months .form-end { grid-column: 1 / -1; }
tr.sum td { border-top: 2px solid #1f3d2b; }

/* Wetter */
.weather-now { display: flex; flex-wrap: wrap; gap: 1.5rem 2.5rem; align-items: center; }
.weather-main { display: flex; align-items: center; gap: .8rem; }
.weather-sign { font-size: 2.6rem; line-height: 1; }
.weather-temp { font-size: 1.8rem; font-weight: 600; }
.weather-facts { flex: 1 1 320px; grid-template-columns: max-content 1fr max-content 1fr; }
.weather-h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.weather-src { font-size: .85em; margin-top: .6rem; }
@media (max-width: 700px) { .weather-facts { grid-template-columns: max-content 1fr; } }

/* Anlagenseite: Wetter oben rechts */
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.weather-mini { background: var(--card, #fff); border: 1px solid var(--line, #dfe3dc); border-radius: 12px; padding: 10px 14px; min-width: 260px; max-width: 360px; }
.weather-mini .wm-head { display: flex; gap: 10px; align-items: center; }
.weather-mini .weather-sign { font-size: 2rem; }
.weather-mini .wm-temp { font-size: 1.15rem; font-weight: 600; }
.weather-mini .wm-temp .muted { font-size: .85rem; font-weight: 400; }
.weather-mini .wm-line { font-size: .85rem; }
.weather-mini .wm-alert { margin: 8px 0 0; padding: 6px 8px; border-radius: 6px; background: #fbe9d4; color: #7a3d0e; font-size: .85rem; }
.weather-mini .wm-details summary { cursor: pointer; font-size: .85rem; color: var(--muted, #6b746e); margin-top: 6px; }
.weather-mini .wm-details .facts { font-size: .85rem; margin-top: 6px; }
.weather-mini .wm-alert-full, .weather-mini .wm-src { font-size: .8rem; margin: 6px 0 0; }
@media (max-width: 800px) { .head-side { align-items: stretch; } .weather-mini { max-width: none; } }

/* Zurück-Knopf */
.back-row { margin: 0 0 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line, #dfe3dc);
             text-decoration: none; color: inherit; font-size: 14px; background: var(--card, #fff); }
.back-link:hover { background: #f1f4ef; }

/* Klappbare Abschnitte auf der Anlagenseite */
.fold-toggle { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; }
.fold-toggle::before { content: "−"; font-size: 20px; width: 20px; color: var(--muted); font-family: "Figtree", sans-serif; }
.fold-toggle[aria-expanded="false"]::before { content: "+"; }
.fold-toggle:focus-visible { outline: 3px solid #9BD27A; outline-offset: 2px; border-radius: 4px; }
.card.folded > :not(.card-head), .card.folded .card-head > :not(h2) { display: none; }
.card.folded .card-head { margin-bottom: 0; }
.two-col > .card.folded { align-self: start; }

/* ================================================================
   Menü in Gruppen
   ================================================================ */
.sidebar { overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; }
.sidebar .nav-label { padding: 10px 12px 3px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar .nav, .sidebar .plant { min-height: 38px; }
.plant-list { flex-shrink: 0; max-height: 40vh; padding-bottom: 6px; }
.theme-toggle { color: var(--ink); }
.theme-icon { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%); flex-shrink: 0; }

/* ================================================================
   Leitwarte als Tabelle
   ================================================================ */
.lw-summary { display: flex; flex-wrap: wrap; gap: 10px; }
.lw-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; font-size: 14.5px; }
.lw-table th { padding: 0; }
.sort-btn { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 12px; cursor: pointer; white-space: nowrap; }
.lw-table th.num .sort-btn { text-align: right; }
.sort-btn:hover { color: var(--ink); }
.sort-btn:focus-visible { outline: 3px solid #9BD27A; outline-offset: -3px; }
.lw-table th[aria-sort="ascending"] .sort-btn::after { content: " ↑"; color: var(--ink); }
.lw-table th[aria-sort="descending"] .sort-btn::after { content: " ↓"; color: var(--ink); }
.lw-table td.soll.good { background: #DDF3E5; }
.lw-table td.soll.mid { background: #FCF1DF; }
.lw-table td.soll.bad { background: #FBE9E7; }
.lw-alarm { font-size: 13.5px; }
.lw-alarm.err { color: var(--err); }
.lw-alarm.warn { color: var(--warn); }

/* ================================================================
   Dunkles Design (Schalter unten im Menü, Wahl bleibt im Browser)
   ================================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181A;
  --card: #1D2224;
  --ink: #E6ECE7;
  --muted: #9AA8A0;
  --line: #2E3638;
  --line-soft: #262C2E;
  --accent: #9BD27A;
  --accent-soft: #263A2C;
  --mint: #263A2C;
  --sun: #E6ECE7;
  --ok: #4CC38A;
  --warn: #E5A93B;
  --err: #F07167;
}
:root[data-theme="dark"] a:hover { color: #C3E8A9; }
:root[data-theme="dark"] .sidebar { background: #181C1E; }
:root[data-theme="dark"] .wordmark { filter: invert(1) hue-rotate(180deg) brightness(1.3); }
:root[data-theme="dark"] .crumb { color: #C3E8A9; background: #263A2C; }
:root[data-theme="dark"] .btn { border-color: var(--line); }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .btn.primary:hover { background: #9BD27A; border-color: #9BD27A; color: #12301C; box-shadow: none; }
:root[data-theme="dark"] .btn.danger { border-color: rgba(240, 113, 103, .45); }
:root[data-theme="dark"] .badge.ok, :root[data-theme="dark"] .flash.ok { background: rgba(76, 195, 138, .15); }
:root[data-theme="dark"] .badge.warn, :root[data-theme="dark"] .status.warn { background: rgba(229, 169, 59, .12); border-color: rgba(229, 169, 59, .4); }
:root[data-theme="dark"] .badge.err, :root[data-theme="dark"] .flash.error { background: rgba(240, 113, 103, .15); color: #F7B4AD; }
:root[data-theme="dark"] .count { color: #14181A; }
:root[data-theme="dark"] a.count:hover { background: #F7B4AD; color: #14181A; }
:root[data-theme="dark"] .dot { background: #5F6B66; }
:root[data-theme="dark"] .dot.ok { background: var(--ok); }
:root[data-theme="dark"] .dot.warn { background: var(--warn); }
:root[data-theme="dark"] .dot.err { background: var(--err); }
:root[data-theme="dark"] .dot.none, :root[data-theme="dark"] .dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px #6F7C76; }
:root[data-theme="dark"] .nodata, :root[data-theme="dark"] .th-note, :root[data-theme="dark"] .kpis .kpi-value.nodata { color: #7D8A84; }
:root[data-theme="dark"] .tally { background: #1F3326; }
:root[data-theme="dark"] .tally-item.link:hover { background: #294430; }
:root[data-theme="dark"] .fleet th { background: #1A1F21; }
:root[data-theme="dark"] .fleet tbody tr:hover { background: #222829; }
:root[data-theme="dark"] .sev.warn { background: rgba(229, 169, 59, .2); color: #F2D59A; }
:root[data-theme="dark"] .sev.err { color: #14181A; }
:root[data-theme="dark"] .segmented { border-color: var(--line); }
:root[data-theme="dark"] .seg.on, :root[data-theme="dark"] .report-nav .seg.on { background: #9BD27A; border-color: #9BD27A; color: #12301C; }
:root[data-theme="dark"] .raw { background: #181C1E; }
:root[data-theme="dark"] .form input, :root[data-theme="dark"] .form select, :root[data-theme="dark"] .form textarea,
:root[data-theme="dark"] .export-form select, :root[data-theme="dark"] .export-form input[type=date],
:root[data-theme="dark"] .export-form .ef-quick button, :root[data-theme="dark"] .ef-btn,
:root[data-theme="dark"] .comp-form input, :root[data-theme="dark"] .comp-form select,
:root[data-theme="dark"] .plant-pick select, :root[data-theme="dark"] .mail-form textarea, :root[data-theme="dark"] .mail-form button,
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea {
  background: #181C1E; color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"] .ef-btn.primary, :root[data-theme="dark"] .mail-form button.primary { background: #9BD27A; border-color: #9BD27A; color: #12301C; }
:root[data-theme="dark"] .comp-form input[readonly], :root[data-theme="dark"] tr.comp-edit td { background: #222829; }
:root[data-theme="dark"] .chart-tip { background: var(--card); border-color: var(--line); color: var(--ink); }
:root[data-theme="dark"] .chart .grid, :root[data-theme="dark"] .chart .vgrid, :root[data-theme="dark"] .chart.bars line.grid { stroke: #262C2E; }
:root[data-theme="dark"] .chart .grid.major, :root[data-theme="dark"] .chart .vgrid.major { stroke: #353D3F; }
:root[data-theme="dark"] .chart .irr-fill, :root[data-theme="dark"] .spark-fill { fill: #3F6B32; }
:root[data-theme="dark"] .chart .irr-dot { fill: var(--card); }
:root[data-theme="dark"] .chart .pow-fill { fill: #2E5A41; }
:root[data-theme="dark"] .chart .pow-line, :root[data-theme="dark"] .key.pow { stroke: #4CC38A; background: #4CC38A; }
:root[data-theme="dark"] .chart .temp-axis, :root[data-theme="dark"] .chart.bars text { fill: var(--muted); }
:root[data-theme="dark"] .spark-base { stroke: #3A4345; }
:root[data-theme="dark"] .prio, :root[data-theme="dark"] .tstatus, :root[data-theme="dark"] .formula-help code { background: #2A3133; }
:root[data-theme="dark"] .prio.hoch { background: rgba(229, 169, 59, .22); }
:root[data-theme="dark"] .prio.kritisch { background: rgba(240, 113, 103, .25); color: #F7B4AD; }
:root[data-theme="dark"] .tstatus.neu { background: rgba(110, 160, 220, .22); }
:root[data-theme="dark"] .tstatus.bearbeitung { background: rgba(229, 169, 59, .22); }
:root[data-theme="dark"] .tstatus.wartet { background: rgba(160, 120, 210, .22); }
:root[data-theme="dark"] .tstatus.erledigt { background: rgba(76, 195, 138, .2); }
:root[data-theme="dark"] .facts dt, :root[data-theme="dark"] .cal-day, :root[data-theme="dark"] .cal-sub, :root[data-theme="dark"] .formula-help, :root[data-theme="dark"] .mail-hint { color: var(--muted); }
:root[data-theme="dark"] .timeline li, :root[data-theme="dark"] .device-pick, :root[data-theme="dark"] table.cal th, :root[data-theme="dark"] table.cal td { border-color: var(--line); }
:root[data-theme="dark"] table.cal td.other { background: #181C1E; color: #6F7C76; }
:root[data-theme="dark"] table.cal td.today { background: #1F3326; }
:root[data-theme="dark"] .cal-item { color: var(--ink); background: #232A2C; }
:root[data-theme="dark"] .weather-mini .wm-alert { background: rgba(229, 169, 59, .15); color: #F2D59A; }
:root[data-theme="dark"] .back-link:hover, :root[data-theme="dark"] .legend.chart-toggles .series-toggle:hover { background: #262C2E; }
:root[data-theme="dark"] .warn-text { color: #F28B6E; }
:root[data-theme="dark"] .good-text { color: var(--ok); }
:root[data-theme="dark"] tr.sum td { border-top-color: var(--ink); }
:root[data-theme="dark"] .lw-table td.soll.good { background: rgba(76, 195, 138, .18); }
:root[data-theme="dark"] .lw-table td.soll.mid { background: rgba(229, 169, 59, .16); }
:root[data-theme="dark"] .lw-table td.soll.bad { background: rgba(240, 113, 103, .18); }

/* Logo oben links: Klick aktualisiert die Seite */
.brand-link { text-decoration: none; color: inherit; border-radius: 10px; }
.brand-link:hover { background: var(--line-soft); color: inherit; }
.brand-link.refreshing .wordmark { animation: brand-pulse .6s ease-in-out infinite alternate; }
@keyframes brand-pulse { from { opacity: 1; } to { opacity: .45; } }
