/* Entwurf A · Hell & klar — weiße Flächen, blauer Akzent, linke Seitenleiste.
   Farben ausschließlich über CSS-Variablen; dunkles Thema über [data-theme="dark"]. */
:root {
  --bg: #f6f8fb;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f1f4f8;
  --text: #1c2433;
  --text-muted: #667085;
  --border: #e3e7ee;
  --akzent: #1a56db;
  --akzent-text: #ffffff;
  --akzent-bg: #e8f0fe;
  --fehler: #b3261e;
  --fehler-bg: #fdecea;
  --erfolg: #146c2e;
  --erfolg-bg: #e6f4ea;
  --warnung: #7a5b00;
  --warnung-bg: #fff3cd;
  --schatten: 0 1px 2px rgba(16, 24, 40, 0.06);
  --einnahmen: #1a56db;
  --ausgaben: #f59e0b;
  --gewinn-linie: #111827;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --bg-card: #141c30;
    --bg-sidebar: #0e1626;
    --bg-hover: #1b2540;
    --text: #e6e9f0;
    --text-muted: #9aa4b8;
    --border: #243150;
    --akzent: #5b9bff;
    --akzent-text: #0b1220;
    --akzent-bg: #1e2a44;
    --fehler: #f2b8b5;
    --fehler-bg: #3a1f1e;
    --erfolg: #9bd8ac;
    --erfolg-bg: #163420;
    --warnung: #f5d68a;
    --warnung-bg: #3a2f10;
    --schatten: 0 1px 3px rgba(0, 0, 0, 0.4);
    --einnahmen: #5b9bff;
    --ausgaben: #f5a742;
    --gewinn-linie: #e6e9f0;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-card: #141c30;
  --bg-sidebar: #0e1626;
  --bg-hover: #1b2540;
  --text: #e6e9f0;
  --text-muted: #9aa4b8;
  --border: #243150;
  --akzent: #5b9bff;
  --akzent-text: #0b1220;
  --akzent-bg: #1e2a44;
  --fehler: #f2b8b5;
  --fehler-bg: #3a1f1e;
  --erfolg: #9bd8ac;
  --erfolg-bg: #163420;
  --warnung: #f5d68a;
  --warnung-bg: #3a2f10;
  --schatten: 0 1px 3px rgba(0, 0, 0, 0.4);
  --einnahmen: #5b9bff;
  --ausgaben: #f5a742;
  --gewinn-linie: #e6e9f0;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-size: 15px;
  line-height: 1.45;
}
a { color: var(--akzent); }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; }

/* -- Layout: Seitenleiste + Inhalt -------------------------------------- */
.app-layout { display: flex; min-height: 100vh; width: 100%; }

.seitenleiste {
  width: 232px; flex-shrink: 0; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  padding: 1.1rem 0.9rem; display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.seitenleiste .marke { font-weight: 700; font-size: 1.05rem; padding: 0.3rem 0.6rem 1.1rem; }
.seitenleiste nav { display: flex; flex-direction: column; gap: 2px; }
.seitenleiste nav a {
  display: block; padding: 0.55rem 0.7rem; border-radius: 8px; color: var(--text);
  text-decoration: none; font-size: 0.93rem;
}
.seitenleiste nav a:hover { background: var(--bg-hover); }
.seitenleiste nav a.aktiv { background: var(--akzent-bg); color: var(--akzent); font-weight: 600; }

.seitenleiste-fuss {
  margin-top: auto; padding-top: 0.8rem; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.3rem;
}
.theme-umschalter {
  display: flex; align-items: center; gap: 0.55rem; background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 0.88rem; padding: 0.5rem 0.7rem; border-radius: 8px; text-align: left;
}
.theme-umschalter:hover { background: var(--bg-hover); }
.theme-umschalter .symbol-dunkel { display: none; }
:root[data-theme="dark"] .theme-umschalter .symbol-hell { display: none; }
:root[data-theme="dark"] .theme-umschalter .symbol-dunkel { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-umschalter .symbol-hell { display: none; }
  :root:not([data-theme="light"]) .theme-umschalter .symbol-dunkel { display: inline-block; }
}
.abmelden { padding: 0.5rem 0.7rem; border-radius: 8px; }
.abmelden:hover { background: var(--bg-hover); }

.menu-umschalter {
  display: none; position: fixed; top: 0.7rem; left: 0.7rem; z-index: 40; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 0.45rem; color: var(--text); cursor: pointer;
}
.menu-hintergrund { display: none; }

.inhaltsbereich { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.inhalt { flex: 1; padding: 1.6rem 1.8rem; max-width: 1180px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.inhalt-ohne-anmeldung { max-width: 480px; padding: 3rem 1.5rem; }
footer { text-align: center; color: var(--text-muted); font-size: 0.8rem; padding: 1rem; }

/* -- Karten / Kacheln ----------------------------------------------------- */
.karte {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--schatten); overflow-x: auto;
}
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; }
.kachel { text-align: left; }
.kachel .zahl { font-size: 1.7rem; font-weight: 700; }
.kachel .zahl a { color: inherit; text-decoration: none; }
.kachel .zahl a:hover { text-decoration: underline; }
.kachel .label { color: var(--text-muted); font-size: 0.86rem; margin-top: 0.15rem; }

.kpi-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.2rem; box-shadow: var(--schatten); }
.kpi .kpi-label { color: var(--text-muted); font-size: 0.82rem; display: block; margin-bottom: 0.3rem; }
.kpi .kpi-wert { font-size: 1.5rem; font-weight: 700; }
.kpi .kpi-wert a { color: inherit; text-decoration: none; }
.kpi .kpi-wert a:hover { text-decoration: underline; }

.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.2rem; align-items: start; }

.liste-info { list-style: none; margin: 0; padding: 0; }
.liste-info li {
  display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.55rem 0; font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.liste-info li:last-child { border-bottom: none; }
.liste-info a { text-decoration: none; color: var(--text); }
.liste-info a:hover { color: var(--akzent); }
.liste-info .betrag { font-weight: 600; white-space: nowrap; }

/* -- Tabellen -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 0.83rem; }
tr:hover td { background: var(--bg-hover); }

/* -- Formulare -------------------------------------------------------------- */
label { display: block; margin: 0.7rem 0 0.25rem; font-size: 0.88rem; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 0.95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }
textarea { min-height: 4rem; }
.feld-reihe { display: flex; gap: 1rem; flex-wrap: wrap; }
.feld-reihe > * { flex: 1; min-width: 160px; }

button, .knopf {
  display: inline-block; padding: 0.55rem 1.1rem; border-radius: 8px; border: none;
  background: var(--akzent); color: var(--akzent-text); font-size: 0.95rem; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
button:hover, .knopf:hover { filter: brightness(1.06); }
button.sekundaer, .knopf.sekundaer { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.gefahr, .knopf.gefahr { background: var(--fehler); color: #fff; }
.link-button { background: none; border: none; color: var(--akzent); cursor: pointer; padding: 0; font-size: 0.95rem; font-family: inherit; }
form.inline { display: inline; }

ul.meldungen { list-style: none; padding: 0; margin: 0 0 1rem; }
.meldung { padding: 0.6rem 0.9rem; border-radius: 8px; margin-bottom: 0.5rem; }
.meldung.fehler { background: var(--fehler-bg); color: var(--fehler); }
.meldung.erfolg { background: var(--erfolg-bg); color: var(--erfolg); }

.status { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; }
.status.offen { background: var(--warnung-bg); color: var(--warnung); }
.status.teilbezahlt { background: var(--warnung-bg); color: var(--warnung); }
.status.bezahlt { background: var(--erfolg-bg); color: var(--erfolg); }
.status.ueberfaellig { background: var(--fehler-bg); color: var(--fehler); }
.status.entwurf { background: var(--bg-hover); color: var(--text-muted); }
.status.storniert, .status.storno { background: var(--bg-hover); color: var(--text-muted); }

.aktionen { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0; }
.hinweistext { color: var(--text-muted); font-size: 0.9rem; }
.suche { margin-bottom: 1rem; }

/* -- Diagramm "Einnahmen & Ausgaben" ---------------------------------------- */
.diagramm-karte { padding-bottom: 0.8rem; }
.diagramm-kopf { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.9rem; }
.diagramm-kopf h2 { margin: 0; }
.diagramm-steuerung { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.diagramm-steuerung select {
  width: auto; padding: 0.35rem 0.55rem; font-size: 0.85rem; border-radius: 8px;
}
.segment { display: flex; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segment-btn {
  background: none; border: none; color: var(--text); font-size: 0.82rem; padding: 0.38rem 0.7rem; cursor: pointer;
  border-radius: 0;
}
.segment-btn:hover { background: rgba(127, 127, 127, 0.12); }
.segment-btn.aktiv { background: var(--akzent); color: var(--akzent-text); }

#dg-svg-wrap { position: relative; }
#dg-svg-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.dg-balken-einnahmen { fill: var(--einnahmen); }
.dg-balken-ausgaben { fill: var(--ausgaben); }
.dg-linie-gewinn { fill: none; stroke: var(--gewinn-linie); stroke-width: 2.2; }
.dg-punkt-gewinn { fill: var(--gewinn-linie); }
.dg-achse { stroke: var(--border); stroke-width: 1; }
.dg-achse-text { fill: var(--text-muted); font-size: 10px; }
.dg-monat-text { fill: var(--text-muted); font-size: 10.5px; }

.dg-tooltip {
  position: absolute; pointer-events: none; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem 0.7rem; font-size: 0.8rem; box-shadow: var(--schatten);
  white-space: nowrap; z-index: 5; transform: translate(-50%, -100%); margin-top: -10px; visibility: hidden;
}
.dg-tooltip strong { display: block; margin-bottom: 0.2rem; }
.dg-tooltip .dg-tooltip-zeile { display: flex; justify-content: space-between; gap: 0.8rem; }

.diagramm-legende { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-muted); margin-top: 0.6rem; }
.diagramm-legende span { display: flex; align-items: center; gap: 0.4rem; }
.legende-punkt { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legende-punkt.farbe-einnahmen { background: var(--einnahmen); }
.legende-punkt.farbe-ausgaben { background: var(--ausgaben); }
.legende-linie { width: 14px; height: 2px; background: var(--gewinn-linie); display: inline-block; }

/* -- Mobil (<760px): Seitenleiste als ausklappbares Menü -------------------- */
@media (max-width: 760px) {
  .menu-umschalter { display: inline-flex; align-items: center; justify-content: center; }
  .seitenleiste {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 50; width: 250px;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  body.menue-offen .seitenleiste { transform: translateX(0); }
  body.menue-offen .menu-hintergrund {
    display: block; position: fixed; inset: 0; background: rgba(10, 14, 25, 0.45); z-index: 45;
  }
  .inhalt { padding: 3.6rem 1rem 1.5rem; }
  .kpi-reihe { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .diagramm-steuerung { width: 100%; }
}
