/* FF Karlstetten — Markenfarben wie auf der Vereins-Website
   (Rot = Feuerwehr, Schwarz/Weiß = Gemeindefarben, Gold = verbindender Akzent) */
:root {
  --rot: #E2001A;
  --rot-dunkel: #B00014;
  --gold: #F7C600;
  --schwarz: #141414;
  --text: #1c1c1c;
  --muted: #6b6b6b;
  --bg: #f7f6f4;
  --card: #ffffff;
  --border: #e2ddd6;
  --gruen: #2e7d32;
  --warnung: #b45309;
  --gefahr: #B00014;
}

* { box-sizing: border-box; }

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

.banner {
  background: #fff3cd;
  color: #664d03;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  text-align: center;
  border-bottom: 1px solid #ffe08a;
}

.layout {
  display: flex;
  min-height: 100vh;
}

nav {
  width: 230px;
  background: var(--schwarz);
  color: #eee;
  padding: 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.9rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--gold);
}
.brand img {
  width: 44px;
  height: auto;
}
.brand strong {
  display: block;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.2;
}
.brand span {
  display: block;
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

nav ul { list-style: none; padding: 0; margin: 0; }
nav li { margin-bottom: 0.25rem; }
nav a {
  color: #ccc;
  text-decoration: none;
  display: block;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}
nav a:hover { background: #333; color: #fff; }
nav a.aktiv { background: var(--rot); color: #fff; }

.nav-trenner {
  margin-top: 1rem;
  padding: 0.4rem 0.5rem 0.2rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
}

.nav-benutzer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #333;
  font-size: 0.8rem;
  color: #aaa;
}
.nav-benutzer a { color: var(--gold); }

main {
  flex: 1;
  min-width: 0; /* verhindert, dass breite Inhalte (Tabellen) das Flex-Layout sprengen */
  padding: 1.5rem 2rem;
  max-width: 1100px;
}

h2 {
  margin-top: 0;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--rot);
  display: inline-block;
}

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--card);
  margin-bottom: 1.5rem;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-size: 0.9rem;
}
th { background: #efece7; }
tr.negativ { color: var(--gefahr); font-weight: bold; }
tr.warnung td { background: #fff8e6; }

/* Status-Einfärbung ganzer Buchungszeilen (leichte Ampelfarbe). Zwei Schattierungen
   je Status über :nth-child ergeben eine Zebra-Optik, damit gleichfarbige Zeilen
   direkt hintereinander unterscheidbar bleiben. Hintergrund liegt auf den Zellen. */
tr.zeile-vollstaendig > td            { background: #eefaf2; }
tr.zeile-vollstaendig:nth-child(even) > td { background: #d8efe0; }
tr.zeile-beleg-fehlt > td             { background: #fefce8; }
tr.zeile-beleg-fehlt:nth-child(even) > td  { background: #f8ecb9; }
tr.zeile-zu-pruefen > td              { background: #eff5ff; }
tr.zeile-zu-pruefen:nth-child(even) > td   { background: #d6e6fc; }
tr.zeile-storniert > td               { background: #f5f5f6; color: var(--muted); }
tr.zeile-storniert:nth-child(even) > td    { background: #e6e6e9; }

.karten { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.karte {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--rot);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  min-width: 200px;
}
.karte h3 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--muted); }
.karte .betrag { font-size: 1.4rem; font-weight: bold; }
.karte .betrag.negativ { color: var(--gefahr); }

/* ===== Dashboard (Übersicht) ===== */
.db-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

/* Hero: Gesamtvermögen, dunkel mit Gold-Akzent */
.db-hero {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #1c1c1c 0%, #2a2a2a 100%);
  border-radius: 12px;
  border-left: 5px solid var(--gold);
  padding: 1.5rem 1.75rem;
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}
.db-hero .label { color: var(--gold); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.db-hero .summe { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin-top: 0.15rem; }
.db-hero .aufteilung { display: flex; flex-wrap: wrap; gap: 0.9rem 1.75rem; }
.db-hero .aufteilung .k { color: #b9b4ab; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.db-hero .aufteilung .v { font-size: 1.3rem; font-weight: 700; }
/* Auf dem dunklen Hero hellere Grün-/Rot-Töne für ausreichenden Kontrast */
.db-hero .betrag-ein { color: #4ade80; }
.db-hero .betrag-aus { color: #ff6b6b; }

/* Konto-Kacheln je Kassenkreis */
.db-kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--rot);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.db-kpi.deaktiviert { border-top-color: var(--muted); opacity: 0.75; }
.db-kpi h3 { margin: 0 0 0.6rem; font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; }
.db-kpi .gesamt { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.01em; }
.db-kpi .zeile { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; }
.db-kpi .zeile .betrag { color: var(--text); font-weight: 600; }

/* Arbeitsvorrat-Kacheln (klickbar) */
.db-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.db-stat {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.12s, transform 0.12s;
}
.db-stat:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.08); transform: translateY(-1px); }
.db-stat .zahl { font-size: 2rem; font-weight: 800; line-height: 1; }
.db-stat .titel { color: var(--muted); font-size: 0.85rem; margin-top: 0.35rem; }
.db-stat.gut .zahl { color: var(--gruen); }
.db-stat.offen .zahl { color: var(--warnung); }
.db-stat.info .zahl { color: var(--rot); }

/* Fortschrittsbalken „vollständig" */
.db-fortschritt { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.2rem; margin-bottom: 1.75rem; }
.db-fortschritt .kopf { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.5rem; }
.db-fortschritt .balken { height: 14px; background: #eee; border-radius: 999px; overflow: hidden; }
.db-fortschritt .balken > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gruen), #43a047); border-radius: 999px; }

/* Kontrollen als Ampel-Karten */
.db-kontrollen { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 0.8rem; }
.db-check {
  display: flex; align-items: flex-start; gap: 0.7rem;
  background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--gruen);
  border-radius: 8px; padding: 0.8rem 1rem;
}
.db-check.warn { border-left-color: var(--warnung); background: #fffdf5; }
.db-check .ampel { font-size: 1.2rem; line-height: 1.3; }
.db-check .titel { font-size: 0.85rem; color: var(--muted); }
.db-check .wert { font-weight: 700; }

form { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1.5rem; max-width: 640px; }
label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; }
label span { display: block; margin-bottom: 0.25rem; color: var(--muted); }
input, select, textarea { width: 100%; padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.9rem; }

button, .btn {
  background: var(--rot);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--rot-dunkel); }
.btn.sekundaer { background: #6b6b6b; }
.btn.sekundaer:hover { background: #4d4d4d; }
button.sekundaer { background: #6b6b6b; }
button.sekundaer:hover { background: #4d4d4d; }

/* Beträge: Eingänge grün, Ausgänge rot (systemweit), nie umbrechen */
.betrag { white-space: nowrap; }
.betrag-ein { color: #1b7f3b; white-space: nowrap; }
.betrag-aus { color: var(--rot); white-space: nowrap; }

/* Import-/Erfassungszeitpunkt als Mouseover direkt am Datum (dezent markiert) */
.datum-hinweis { cursor: help; border-bottom: 1px dotted var(--muted); }

/* Kassenkreis-Tabs (Buchungsübersicht) */
.kk-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  border-bottom: 2px solid var(--rot);
  margin-bottom: 1rem;
}
.kk-tabs a {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--rot);
  border-radius: 6px 6px 0 0;
  background: #efece7;
  color: #141414;
  text-decoration: none;
  font-weight: 600;
  margin-bottom: -2px;
}
.kk-tabs a:hover { background: #e4e0d8; }
.kk-tabs a.aktiv {
  background: var(--rot);
  color: #fff;
  border-color: var(--rot);
}
.kk-tabs a .hinweis { color: inherit; opacity: 0.8; font-weight: 400; }

/* Kommentar/Notiz zu einer Buchung — sichtbar hervorgehoben */
.kommentar {
  margin-top: 0.25rem;
  padding: 0.2rem 0.45rem;
  background: #fff8dc;
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  font-size: 0.88em;
}
.badge.kommentar-tag { background: var(--gold); color: #141414; }

/* Kompakte Inline-Bearbeitung in Listen (Buchungsübersicht) */
table select.inline, table input.inline {
  padding: 0.25rem 0.35rem;
  font-size: 0.88em;
  width: auto;
  margin: 0;
}
table button.inline {
  padding: 0.25rem 0.5rem;
  font-size: 0.85em;
  white-space: nowrap;
}

/* Zeilen-Speichern erscheint erst, wenn in der Zeile etwas geändert wurde
   (JS entfernt „schlafend"); ohne JavaScript bleibt er sichtbar. */
button.zeile-speichern.schlafend { visibility: hidden; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: bold; }
.badge.neu { background: #dbeafe; color: #1e40af; }
.badge.bekannt { background: #e5e7eb; color: #374151; }
.badge.verdaechtig { background: #fee2e2; color: #991b1b; }
.badge.fehlerhaft { background: #fef3c7; color: #92400e; }
.badge.status-vollstaendig { background: #dcfce7; color: #166534; }
.badge.status-offen { background: #fef3c7; color: #92400e; }

.flash { padding: 0.6rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.info { background: #e0f2fe; color: #075985; }
.flash.erfolg { background: #dcfce7; color: #166534; }
.flash.warnung { background: #fef3c7; color: #92400e; }
.flash.fehler { background: #fee2e2; color: #991b1b; }

.hinweis { color: var(--muted); font-size: 0.85rem; }

/* Abschnitts-Überschrift je Kassenkreis — Kassenkreise werden nie in einer Tabelle vermischt */
h4.kreis-titel {
  margin: 1.75rem 0 0.5rem;
  padding-left: 0.5rem;
  border-left: 4px solid var(--rot);
  font-size: 1rem;
}

/* Mobil/Smartphone: Seitenleiste wird zur oberen Leiste, Inhalt darunter über volle Breite.
   Wichtig, weil Belege künftig direkt am Handy fotografiert/gescannt werden. */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  nav {
    width: auto;
    padding: 0.75rem 1rem;
  }
  nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  nav li { margin-bottom: 0; }
  nav a { padding: 0.35rem 0.6rem; }
  .nav-trenner { width: 100%; margin-top: 0.5rem; padding-top: 0; }
  .nav-benutzer { width: 100%; margin-top: 0.75rem; padding-top: 0.75rem; }
  main { padding: 1rem; max-width: 100%; }
  /* Tabellen dürfen quer scrollen statt das Layout zu sprengen */
  main { overflow-x: hidden; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
