:root {
  --bg: #f2f5f7;
  --karte: #ffffff;
  --rand: #e2e8ee;
  --text: #1b2733;
  --text2: #5c6b7a;
  --akzent: #0e7c66;
  --akzent-dunkel: #0a5f4e;
  --akzent-hell: #e6f4f1;
  --gefahr: #c0392b;
  --gefahr-hell: #fdecea;
  --ok-hell: #e8f6ec;
  --ok-text: #1e7c3c;
  --sidebar-bg: #13232e;
  --sidebar-text: #b9c6d0;
}

* { box-sizing: border-box; }

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

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }

/* --- Layout ----------------------------------------------------------- */

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  padding: 0 1.25rem 1.25rem;
  letter-spacing: -0.02em;
}
.logo span { color: #3ecfae; }
.logo:hover { text-decoration: none; }
.logo-gross { font-size: 1.8rem; padding: 0; text-align: center; color: var(--text); }
.logo-gross span { color: var(--akzent); }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 .75rem; }
.sidebar nav a {
  color: var(--sidebar-text);
  padding: .55rem .75rem;
  border-radius: 8px;
  font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.sidebar nav a.aktiv { background: var(--akzent); color: #fff; }

.sidebar-fuss {
  margin-top: auto;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
}
.sidebar-fuss a { color: var(--sidebar-text); }

.inhalt {
  flex: 1;
  padding: 1.75rem 2.25rem 3rem;
  max-width: 1200px;
}

/* --- Seitenkopf -------------------------------------------------------- */

.seitenkopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 0 0 1.25rem;
}
.seitenkopf:not(:first-child) { margin-top: 2rem; }
.untertitel { color: var(--text2); margin: .25rem 0 0; }
.aktionen { display: flex; gap: .5rem; flex-shrink: 0; }

/* --- Karten & Kacheln --------------------------------------------------- */

.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.karte-schmal { max-width: 560px; }
.karte.leer { color: var(--text2); text-align: center; padding: 2.5rem; }

.kachel-raster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kachel {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.kachel-wert { font-size: 1.5rem; font-weight: 700; }
.kachel-wert.negativ { color: var(--gefahr); }
.kachel-wert.positiv { color: var(--ok-text); }
.kachel-label { color: var(--text2); font-size: .85rem; margin-top: .15rem; }

/* --- Tabellen ----------------------------------------------------------- */

.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th {
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text2);
  padding: .4rem .6rem;
  border-bottom: 2px solid var(--rand);
}
.tabelle td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}
.tabelle tbody tr:last-child td { border-bottom: none; }
.tabelle tbody tr:hover { background: #f8fafb; }
.tabelle .rechts, th.rechts, td.rechts { text-align: right; }
.tabelle tfoot td { font-weight: 700; border-top: 2px solid var(--rand); border-bottom: none; }

/* --- Formulare ----------------------------------------------------------- */

.formular { display: flex; flex-direction: column; gap: .9rem; }
.feld { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.feld label { font-size: .85rem; font-weight: 600; color: var(--text2); }
.feld-zeile { display: flex; gap: .9rem; }
.feld-kurz { max-width: 110px; }

.feld input, .feld select, .feld textarea {
  font: inherit;
  padding: .5rem .65rem;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.feld input:focus, .feld select:focus, .feld textarea:focus {
  outline: 2px solid var(--akzent-hell);
  border-color: var(--akzent);
}
.feld-hinweis { font-size: .8rem; color: var(--text2); }

.formular-aktionen { display: flex; gap: .5rem; margin-top: .5rem; align-items: center; }
.loeschen-zeile { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rand); }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-block;
  background: var(--akzent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .5rem .9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--akzent-dunkel); text-decoration: none; color: #fff; }
.btn-sekundaer { background: #fff; color: var(--text); border: 1px solid var(--rand); }
.btn-sekundaer:hover { background: var(--bg); color: var(--text); }
.btn-gefahr { background: #fff; color: var(--gefahr); border: 1px solid var(--rand); }
.btn-gefahr:hover { background: var(--gefahr-hell); color: var(--gefahr); }
.btn-klein { padding: .25rem .6rem; font-size: .82rem; font-weight: 500; }
.btn-breit { width: 100%; }

/* --- Abzeichen & Flash --------------------------------------------------- */

.abzeichen {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}
.abzeichen-gruen { background: var(--ok-hell); color: var(--ok-text); }
.abzeichen-rot { background: var(--gefahr-hell); color: var(--gefahr); }
.abzeichen-grau { background: #eef1f4; color: var(--text2); }

.flash {
  padding: .65rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.flash-ok { background: var(--ok-hell); color: var(--ok-text); }
.flash-fehler { background: var(--gefahr-hell); color: var(--gefahr); }

/* --- Login --------------------------------------------------------------- */

body.login-seite {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 14px;
  padding: 2.25rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-karte .untertitel { margin-bottom: 1.5rem; }
.login-karte .formular { text-align: left; }

/* --- Balken-Chart (Dashboard) --------------------------------------------- */

.chart-balken {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
  padding-top: .5rem;
}
.chart-balken .balken-gruppe {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  height: 100%;
  justify-content: flex-end;
}
.chart-balken .balken-paar { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart-balken .balken { width: 45%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-balken .balken.einnahme { background: var(--akzent); }
.chart-balken .balken.ausgabe { background: #c9d4dc; }
.chart-balken .balken-label { font-size: .7rem; color: var(--text2); }

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: .75rem 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-fuss { display: none; }
  .inhalt { padding: 1.25rem 1rem 2.5rem; }
  .feld-zeile { flex-direction: column; }
}
