:root, :root[data-theme="light"] {
  color-scheme: light;
  --seite: #f7f6f3;
  --karte: #ffffff;
  --flaeche: #efedE8;
  --text: #141414;
  --leise: #5f5d58;
  --linie: #dfdcd5;
  --eingabe-rand: #a9a69f;
  --akzent: #141414;
  --akzent-text: #ffffff;
  --fokus: #0b6e99;
  --marker: #d9480f;
  --gruen: #1c7c54; --gruen-hell: #dff3e9; --gruen-text: #135a3c;
  --gelb: #8a5a00;  --gelb-hell: #fdf0d3;
  --rot: #b3261e;
  --schatten: 0 1px 2px rgba(20, 20, 20, .08), 0 8px 24px rgba(20, 20, 20, .06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --seite: #111111;
  --karte: #1b1b1b;
  --flaeche: #262626;
  --text: #f1efea;
  --leise: #aaa7a0;
  --linie: #333333;
  --eingabe-rand: #5c5a56;
  --akzent: #f1efea;
  --akzent-text: #141414;
  --fokus: #6fc3e6;
  --marker: #ff8a50;
  --gruen: #66d3a4; --gruen-hell: #1a3429; --gruen-text: #b4efd3;
  --gelb: #f3c969;  --gelb-hell: #3a2e12;
  --rot: #ff8a80;
  --schatten: 0 1px 2px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--seite);
  color: var(--text);
  font: 17px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
.leise { color: var(--leise); }
.klein { font-size: .9rem; }
:focus-visible { outline: 3px solid var(--fokus); outline-offset: 2px; }

/* Kopfzeile */
.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px max(16px, calc((100vw - 1120px) / 2));
  background: var(--karte); border-bottom: 1px solid var(--linie);
}
.logo {
  font-size: clamp(1.55rem, 5vw, 2.2rem); font-weight: 800; letter-spacing: .16em;
  line-height: 1; color: var(--text); text-decoration: none; white-space: nowrap;
}
.kopf-rechts { display: flex; align-items: center; gap: 8px; }

/* Knöpfe */
button {
  font: inherit; font-size: .95rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 8px; min-height: 44px;
  border: 1px solid var(--eingabe-rand); background: var(--karte); color: var(--text);
}
button:hover { background: var(--flaeche); }
button.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 600; }
button.haupt:hover { opacity: .86; background: var(--akzent); }
button.gut { background: var(--gruen); border-color: var(--gruen); color: var(--karte); font-weight: 600; }
button.gut:hover { opacity: .88; background: var(--gruen); }
button.schlicht { border-color: transparent; background: transparent; color: var(--leise); }
button.schlicht:hover { color: var(--text); background: var(--flaeche); }
button.warnung { border-color: var(--rot); color: var(--rot); background: transparent; }
button.warnung:hover { background: var(--flaeche); }
button:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1120px; margin: 0 auto; padding: 32px 16px 80px; }


/* ---------- Berichtsportal ---------- */
.zahl, .tabelle td { font-variant-numeric: tabular-nums; }
.gruss { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 8px; }
.einleitung { max-width: 62ch; color: var(--leise); }

/* Aufbau: Archiv links, Bericht rechts */
.portal { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; align-items: start; margin-top: 28px; }
.archiv { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 6px; }
.archiv h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--leise); margin-bottom: 6px; }
.archiv-eintrag { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; min-height: 0; border-radius: 10px; border: 1px solid transparent; background: transparent; }
.archiv-eintrag:hover { background: var(--flaeche); }
.archiv-eintrag.aktiv { background: var(--karte); border-color: var(--linie); box-shadow: var(--schatten); }
.archiv-zeit { font-weight: 700; font-variant-numeric: tabular-nums; }
.archiv-titel { font-size: .88rem; color: var(--leise); line-height: 1.3; }
.archiv-leer { color: var(--leise); font-size: .95rem; }

/* Bericht */
.bericht { display: flex; flex-direction: column; gap: 44px; min-width: 0; }
.b-kopf { display: flex; flex-direction: column; gap: 10px; }
.b-zeitraum { display: inline-flex; align-self: flex-start; gap: 8px; align-items: center; font-size: .82rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--leise); }
.b-kopf h1 { font-size: clamp(1.7rem, 4.4vw, 2.6rem); letter-spacing: -.01em; text-wrap: balance; }
.b-kern { font-size: clamp(1.08rem, 2.2vw, 1.3rem); line-height: 1.5; max-width: 62ch; border-left: 3px solid var(--marker); padding-left: 16px; }
.b-sektion { display: flex; flex-direction: column; gap: 16px; }
.b-sektion > h2 { font-size: 1.3rem; text-wrap: balance; }
.b-sektion > h2 .leise { font-weight: 400; }
.b-text { max-width: 66ch; }
.kacheln { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr)); }
.kennzahl { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.kennzahl-wert { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kennzahl-name { font-weight: 600; }
.kennzahl-hinweis { color: var(--leise); font-size: .88rem; line-height: 1.35; }
.mini-zahlen { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.mini { border-top: 1px solid var(--linie); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.mini .wert { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini .name { color: var(--leise); font-size: .88rem; }
.nv { font-style: italic; font-weight: 500 !important; color: var(--leise); font-size: 1rem !important; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 20px; min-width: 0; }
.karte h3 { font-size: 1.05rem; margin-bottom: 6px; }
.karte.luecke { border-style: dashed; background: transparent; }

/* Diagramm */
.diagramm { position: relative; margin-top: 12px; }
.diagramm svg { display: block; width: 100%; height: auto; }
.legende { display: flex; flex-wrap: wrap; gap: 16px; font-size: .88rem; color: var(--leise); margin-top: 6px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.farbe { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.farbe.markiert { background: var(--marker); }
.farbe.normal { background: var(--eingabe-rand); }
.tip { position: absolute; pointer-events: none; background: var(--karte); border: 1px solid var(--linie); border-radius: 8px; box-shadow: var(--schatten); padding: 6px 10px; font-size: .85rem; white-space: nowrap; }
.tip .leise { display: block; }

/* Tabelle */
.tabellenbox { overflow-x: auto; }
.tabelle { border-collapse: collapse; width: 100%; font-size: .95rem; }
.tabelle th, .tabelle td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--linie); white-space: nowrap; }
.tabelle th { font-size: .82rem; color: var(--leise); font-weight: 600; }
.tabelle th:nth-child(-n+2), .tabelle td:nth-child(-n+2) { text-align: left; }
.tabelle td:nth-child(2) { white-space: normal; min-width: 10rem; }
.tabelle tr.hervor td { background: var(--gruen-hell); }

/* Beste und schwächste */
.highlights { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.highlight { display: flex; flex-direction: column; gap: 6px; }
.highlight .etikett { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--gruen); }
.highlight.schwach .etikett { color: var(--gelb); }
.highlight .kennzahl-wert { font-size: 2rem; }

/* Listen */
.punkte { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.punkte li { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: 4px 16px; line-height: 1.45; }
.punkte .wann { font-weight: 700; }
.ableitung { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 10px; max-width: 70ch; line-height: 1.5; }
.ableitung b { font-weight: 700; }
.zwei { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.zwei .punkte li { grid-template-columns: minmax(0, 1fr); gap: 0; }
details.begriffe { border-top: 1px solid var(--linie); padding-top: 16px; }
details.begriffe summary { cursor: pointer; font-weight: 600; }
details.begriffe dl { display: grid; gap: 10px; margin: 14px 0 0; max-width: 70ch; }
details.begriffe dt { font-weight: 600; }
details.begriffe dd { margin: 0; color: var(--leise); line-height: 1.5; }

/* Fragen */
.fragen { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.frage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; padding: 12px; border-radius: 8px; background: var(--flaeche); }
.frage.ohne-haken { grid-template-columns: minmax(0, 1fr); }
.frage.erledigt { opacity: .6; }
.frage-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.frage-fuss { color: var(--leise); font-size: .85rem; }
.haken { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--gruen); cursor: pointer; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
textarea { font: inherit; width: 100%; min-height: 96px; resize: vertical; display: block; padding: 10px; border-radius: 8px; border: 1px solid var(--eingabe-rand); background: var(--karte); color: var(--text); margin-bottom: 10px; }
.fehler { color: var(--rot); margin-top: 8px; font-size: .95rem; }
.fehler:empty { display: none; }
.ok-meldung { color: var(--gruen); font-weight: 600; }

/* Inhaber */
.verwaltung { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--flaeche); }
.status { display: inline-block; font-size: .82rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; background: var(--flaeche); color: var(--leise); white-space: nowrap; }
.status.frei { background: var(--gruen-hell); color: var(--gruen-text); }
.status.entwurf { background: var(--gelb-hell); color: var(--gelb); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 28px 0 8px; }
.kpi { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 16px; }
.kpi-wert { font-size: 1.8rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-name { color: var(--leise); font-size: .9rem; margin-top: 4px; }
.kpi.gelb .kpi-wert { color: var(--gelb); }
.abschnitt-titel { font-size: 1.25rem; margin: 40px 0 16px; }
.kundenliste { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.kundenkarte { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 18px; box-shadow: var(--schatten); display: flex; flex-direction: column; gap: 12px; }
.kundenkarte h3 { font-size: 1.15rem; }
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.zugang { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .9rem; color: var(--leise); }
.zugang button { min-height: 34px; padding: 2px 10px; font-size: .85rem; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo li { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: var(--flaeche); }
.protokoll { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
.mitte { max-width: 520px; margin: 15vh auto; padding: 0 16px; text-align: center; }
.mitte .logo { display: inline-block; margin-bottom: 20px; }
.zurueck { margin-bottom: 8px; }

@media (max-width: 860px) {
  main { padding-top: 20px; }
  .portal { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .archiv { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .archiv h2 { display: none; }
  .archiv-eintrag { flex: 0 0 auto; border-color: var(--linie); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .punkte li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .bericht { animation: rein .35s ease-out; }
  @keyframes rein { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
