:root {
  --bg: #f4f6f8;
  --karte: #ffffff;
  --rand: #e2e6ea;
  --text: #1f2933;
  --grau: #6b7682;
  --akzent: #2f6fb0;
  --gruen: #2e8b57;
  --gruen-bg: #e6f4ec;
  --rot: #c0392b;
  --rot-bg: #fbeae8;
  --warn-bg: #fef6e0;
  --warn-rand: #f0d48a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2933;
  color: #fff;
  padding: 0.8rem 1.5rem;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar nav a {
  color: #c7d0d9;
  text-decoration: none;
  margin-left: 1.2rem;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: #fff; }
.topbar nav a.aktiv { color: #fff; border-bottom-color: var(--akzent); }

/* Layout */
.inhalt {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}
.fuss {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--grau);
  font-size: 0.85rem;
}

h1 { font-size: 1.6rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }

.kopf-zeile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.stand { color: var(--grau); font-size: 0.9rem; }
.lead { color: var(--grau); max-width: 640px; }

/* Kacheln */
.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.kachel {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.kachel-label { color: var(--grau); font-size: 0.85rem; }
.kachel-wert { font-size: 1.7rem; font-weight: 700; margin: 0.2rem 0; }
.kachel-sub { color: var(--grau); font-size: 0.8rem; }
.kachel.gruen { background: var(--gruen-bg); border-color: #bfe3cd; }
.kachel.gruen .kachel-wert { color: var(--gruen); }
.kachel.rot { background: var(--rot-bg); border-color: #f0c4bd; }
.kachel.rot .kachel-wert { color: var(--rot); }

/* Karten */
.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.karte.warn { background: var(--warn-bg); border-color: var(--warn-rand); }
.karte.risiko { background: var(--rot-bg); border-color: #f0c4bd; }
.karte.info { color: var(--grau); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--rand); }
th { color: var(--grau); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
.rechts { text-align: right; font-variant-numeric: tabular-nums; }
tr.summe td { font-weight: 700; border-top: 2px solid var(--rand); }
.pos { color: var(--gruen); }
.neg { color: var(--rot); }
.leer { color: var(--grau); font-style: italic; }
.notiz { color: var(--grau); font-size: 0.88rem; margin-top: 0.6rem; }

/* Upload */
.upload-form { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.datei-feld input { font-size: 0.95rem; }
.btn {
  background: var(--akzent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:hover { background: #265a90; }
.status-ok { color: var(--gruen); }

/* Hinweise / Flash */
.hinweise { margin-bottom: 1rem; }
.hinweis {
  background: #eaf2fb;
  border: 1px solid #c5dbf2;
  color: #1c4e80;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
}
code { background: #eef1f4; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }

/* Diagramme */
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.donut { height: 280px; }

/* Monats-Detail */
.zurueck { color: var(--akzent); text-decoration: none; font-size: 0.9rem; }
.zurueck:hover { text-decoration: underline; }
.monats-switch {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.2rem;
}
.monats-switch a {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 6px;
  padding: 0.25rem 0.6rem; font-size: 0.82rem; color: var(--grau); text-decoration: none;
}
.monats-switch a:hover { border-color: var(--akzent); color: var(--akzent); }
.monats-switch a.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }

.kat-grid {
  display: grid; grid-template-columns: minmax(260px, 1fr) 1.2fr;
  gap: 1.5rem; align-items: start;
}
.zweck { color: var(--grau); font-size: 0.85rem; }

@media (max-width: 680px) {
  .kat-grid { grid-template-columns: 1fr; }
}

/* Budget */
.hinweis-info {
  background: #eaf2fb; border: 1px solid #c5dbf2; color: #1c4e80;
  border-radius: 8px; padding: 0.6rem 0.9rem; margin-bottom: 1.2rem; font-size: 0.9rem;
}
.gruppe-summe { float: right; font-weight: 400; color: var(--grau); font-size: 0.9rem; }
.budget-zeile { padding: 0.7rem 0; border-bottom: 1px solid var(--rand); }
.budget-zeile:last-child { border-bottom: none; }
.budget-kopf { display: flex; justify-content: space-between; margin-bottom: 0.35rem; }
.budget-name { font-weight: 600; }
.budget-zahlen { font-variant-numeric: tabular-nums; }
.budget-zahlen .von { color: var(--grau); font-size: 0.88rem; }
.balken {
  height: 12px; background: #eceff2; border-radius: 6px; overflow: hidden;
}
.balken-fuell { height: 100%; border-radius: 6px; transition: width 0.3s; }
.balken-fuell.gruen { background: var(--gruen); }
.balken-fuell.gelb { background: #e0a800; }
.balken-fuell.rot { background: var(--rot); }
.balken-fuell.neutral { background: #b9c2cc; }
.budget-fuss { display: flex; justify-content: space-between; margin-top: 0.3rem; font-size: 0.85rem; }
.ampel-text { font-weight: 600; }
.ampel-text.gruen { color: var(--gruen); }
.ampel-text.gelb { color: #b8860b; }
.ampel-text.rot { color: var(--rot); }
.ampel-text.neutral { color: var(--grau); }
.rest { color: var(--grau); }
.rest.neg { color: var(--rot); font-weight: 600; }

/* Inline-Formulare / Bearbeiten */
.btn-klein { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.inline-form { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.inline-form input[type=number] {
  width: 100%; padding: 0.3rem 0.4rem; border: 1px solid var(--rand);
  border-radius: 6px; font-size: 0.85rem;
}
input, select {
  font-family: inherit;
}
.edit-tabelle input[type=number] {
  width: 110px; padding: 0.3rem 0.4rem; border: 1px solid var(--rand);
  border-radius: 6px; text-align: right;
}
.edit-tabelle input[type=text], .edit-tabelle select {
  padding: 0.3rem 0.4rem; border: 1px solid var(--rand); border-radius: 6px;
}
.neu-zeile td { border-top: 2px solid var(--rand); padding-top: 0.7rem; }
.neu-zeile input[type=text] { width: 100%; }

/* Zu-klären zuordnen */
.klaer-tabelle td { vertical-align: top; }
.klaer-form { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.klaer-form input, .klaer-form select {
  padding: 0.3rem 0.4rem; border: 1px solid var(--rand); border-radius: 6px; font-size: 0.85rem;
}
.f-muster { width: 130px; }
.f-kat { width: 140px; }
.f-bp { width: 90px; }

/* Ziel-Seite */
.ziel-hero {
  background: linear-gradient(135deg, #2f6fb0, #265a90);
  color: #fff; border-radius: 12px; padding: 1.6rem 1.4rem;
  text-align: center; margin-bottom: 1.2rem;
}
.hero-zahl { font-size: 3.4rem; font-weight: 800; line-height: 1; }
.hero-zahl.gut { font-size: 2.4rem; }
.hero-text { font-size: 1.15rem; margin-top: 0.4rem; }
.hero-text strong { color: #ffe08a; }
.hero-sub { margin-top: 0.6rem; opacity: 0.9; font-size: 0.95rem; }
.hero-sub strong { color: #ffe08a; }

.ziel-balken {
  position: relative; height: 22px; background: #eceff2;
  border-radius: 11px; overflow: hidden; display: flex;
}
.zb-fuell { height: 100%; }
.zb-fuell.gruen { background: var(--gruen); }
.zb-fuell.blau { background: var(--akzent); }
.zb-marke {
  position: absolute; top: -3px; bottom: -3px; width: 2px;
  background: #1f2933; opacity: 0.45;
}
.zb-legende {
  display: flex; justify-content: space-between;
  margin-top: 0.5rem; color: var(--grau); font-size: 0.88rem;
}

/* Antragszähler */
.zaehler-zeile { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.zaehler-wert { font-size: 2.6rem; font-weight: 800; min-width: 60px; text-align: center; }
.btn-rund {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--rand);
  background: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--text);
}
.btn-rund:hover { border-color: var(--akzent); color: var(--akzent); }
.btn-rund.plus { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.btn-rund.plus:hover { background: #256f48; }
.genau-form { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; }
.genau-form input { width: 80px; padding: 0.4rem; border: 1px solid var(--rand); border-radius: 6px; text-align: right; }

/* Ziel-Einstellungen */
.ziel-einstellungen { display: flex; flex-direction: column; gap: 0.8rem; max-width: 440px; }
.ziel-einstellungen label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--grau); }
.ziel-einstellungen .feld { display: flex; align-items: center; gap: 0.4rem; color: var(--text); }
.ziel-einstellungen input { width: 130px; padding: 0.4rem; border: 1px solid var(--rand); border-radius: 6px; text-align: right; }

/* Abmelden-Link (rechts in der Topbar abgesetzt) */
.topbar nav a.abmelden { color: #f0a9a2; margin-left: 1.6rem; }
.topbar nav a.abmelden:hover { color: #fff; }

/* Login-Seite */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-box {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 2px 12px rgba(31, 41, 51, 0.06);
}
.login-box h1 { margin: 0 0 0.2rem; }
.login-sub { color: var(--grau); margin: 0 0 1.2rem; }
.login-box label {
  display: block;
  font-size: 0.9rem;
  color: var(--grau);
  margin-bottom: 0.3rem;
}
.login-box input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rand);
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.login-box button {
  width: 100%;
  padding: 0.6rem;
  border: 0;
  border-radius: 6px;
  background: var(--akzent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.login-box button:hover { background: #285f96; }
