:root {
  --bg: #f4f6f8;
  --karte: #ffffff;
  --rand: #e2e6ea;
  --text: #1f2933;
  --grau: #6b7683;
  --akzent: #2563eb;
  --gruen: #157347;
  --rot: #b02a37;
  --gelb: #b7791f;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
header {
  background: var(--karte);
  border-bottom: 1px solid var(--rand);
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header .titel { font-weight: 600; }
header .titel a { color: var(--text); }
header nav a { margin-left: 1.2rem; font-size: 0.95rem; }
main { max-width: 900px; margin: 1.5rem auto; padding: 0 1.5rem; }
main.schmal { max-width: 620px; margin: 3rem auto; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.6rem; color: var(--grau); }
.karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1rem;
}
.karte.breit { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--rand); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--grau); }
tr:last-child td { border-bottom: none; }
.badge {
  display: inline-block; font-size: 0.78rem; font-weight: 600;
  padding: 0.15rem 0.55rem; border-radius: 999px;
}
.badge.ok { background: #e6f4ea; color: var(--gruen); }
.badge.neutral { background: #eef1f4; color: var(--grau); }
.badge.warn { background: #fdf3e0; color: var(--gelb); }
input, button, select, textarea {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--rand);
  border-radius: 7px;
  background: #fff;
}
textarea { resize: vertical; }
button, .btn {
  background: var(--akzent); color: #fff; border: none; cursor: pointer;
  font-weight: 500; padding: 0.5rem 1rem; border-radius: 7px;
  display: inline-block;
}
.btn:hover { text-decoration: none; }
button.sekundaer { background: #eef1f4; color: var(--text); }
button.klein { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
button:hover { opacity: 0.92; }
button:disabled { opacity: 0.35; cursor: default; }
.zeile { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.zeile + .zeile { margin-top: 0.6rem; }
.feld { margin-bottom: 0.9rem; display: flex; flex-direction: column; gap: 0.3rem; }
.feld > label { font-size: 0.85rem; color: var(--grau); }
.feld.fehlerhaft input, .feld.fehlerhaft select, .feld.fehlerhaft textarea {
  border-color: var(--rot);
}
.checkbox-zeile {
  display: flex; align-items: center; gap: 0.45rem; font-size: 0.95rem;
  white-space: nowrap;
}
.checkbox-zeile input { width: auto; padding: 0; }
.hinweis { color: var(--grau); font-size: 0.85rem; }
.fehler { color: var(--rot); font-size: 0.85rem; }
.fehler-box {
  background: #fdecea; color: var(--rot); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}
.grau { color: var(--grau); font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.leer { color: var(--grau); font-style: italic; padding: 0.5rem 0; }
.beschreibung { white-space: pre-wrap; color: var(--grau); }
.zentriert { max-width: 380px; margin: 4rem auto; }
.feldtitel { font-size: 0.85rem; color: var(--grau); }
.optionen-liste { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.1rem 0; }
.bereich-zeile { display: flex; align-items: center; gap: 0.6rem; }
.bereich-zeile input[type=range] { flex: 1; padding: 0; border: none; background: none; }
.bereich-zeile output {
  min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600;
}
input[type=color] { padding: 0.2rem; height: 2.4rem; width: 4rem; }

/* Bestellungen */
.artikel-zeile { display: flex; align-items: center; gap: 0.8rem; }
.artikel-zeile label { font-size: 0.95rem; color: var(--text); }
.artikel-zeile input.menge { width: 5rem; text-align: right; }
.summe-zeile {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1px solid var(--rand); margin-top: 0.9rem; padding-top: 0.7rem;
  font-weight: 600; font-size: 1.1rem;
}
.summe-zeile output { font-variant-numeric: tabular-nums; }
td.rechts, th.rechts { text-align: right; }
table.bestellung { margin: 1rem 0; }
tr.summe td { font-weight: 600; border-top: 2px solid var(--rand); }
form.inline { display: inline; }
form.inline select { padding: 0.25rem 0.4rem; font-size: 0.85rem; }
header nav .grau { margin-left: 1.2rem; }

/* Feldliste im Editor */
table.felder td { vertical-align: top; }
table.felder td.nr { color: var(--grau); width: 2rem; }
table.felder td.aktionen { text-align: right; white-space: nowrap; width: 1%; }
.feld-neu {
  margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--rand);
}
.entfernte { margin-top: 0.8rem; }
.entfernte summary { cursor: pointer; color: var(--grau); font-size: 0.85rem; }

/* Öffentliche Seite */
body.oeffentlich { background: #eceff2; }
.vorschau-hinweis {
  background: #fdf3e0; color: var(--gelb); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}

/* --- Bestandssystem ---------------------------------------------------- */
main { max-width: 1100px; }
h1 .badge { vertical-align: middle; margin-left: 0.5rem; }
.rechts { text-align: right; }
.rot { color: var(--rot); font-weight: 600; }
.gruen { color: var(--gruen); }
tr.inaktiv td { opacity: 0.55; }
tr.summe td { font-weight: 600; border-top: 2px solid var(--rand); }

.kacheln { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kachel {
  flex: 1 1 10rem; display: flex; flex-direction: column; gap: 0.2rem;
  margin-bottom: 0; text-decoration: none; color: var(--text);
}
.kachel:hover { text-decoration: none; border-color: var(--akzent); }
.kachel .zahl { font-size: 1.6rem; font-weight: 600; }
.kachel.warnung { border-color: var(--gelb); background: #fffdf7; }

.blaettern { justify-content: center; margin-bottom: 1.5rem; }
.btn.aktiv { background: var(--akzent); color: #fff; }
.trefferzeile { padding: 0.35rem 0; border-bottom: 1px solid var(--rand); }
.trefferzeile:last-child { border-bottom: none; }

/* Beleg-Druckansicht */
body.druck { background: #eceff2; }
.druckleiste {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  max-width: 800px; margin: 1rem auto; padding: 0 1rem;
}
.beleg {
  background: #fff; max-width: 800px; margin: 0 auto 3rem; padding: 2.5rem;
  border: 1px solid var(--rand); border-radius: 4px;
}
.beleg-kopf { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 2.5rem; }
.beleg-kopf h1 { font-size: 1.6rem; margin-bottom: 0.8rem; }
.kopfdaten td { border: none; padding: 0.15rem 0 0.15rem 1rem; }
.beleg-positionen { margin-bottom: 1.5rem; }
.beleg-positionen th { border-bottom: 2px solid var(--text); }

@media print {
  .druckleiste, header { display: none; }
  body.druck { background: #fff; }
  .beleg { border: none; margin: 0; padding: 0; max-width: none; }
}

.ok-box {
  background: #e6f4ea; color: var(--gruen); border-radius: 7px;
  padding: 0.6rem 0.8rem; font-size: 0.9rem;
}
.beleg-absender {
  font-size: 0.85rem; padding-bottom: 1.2rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--rand);
}
.beleg-fuss {
  font-size: 0.78rem; margin-top: 2.5rem; padding-top: 0.8rem;
  border-top: 1px solid var(--rand);
}

.badge.offen { background: #fdecea; color: var(--rot); }

tr.zeile-fehler td { background: #fdf6f5; }
tr.zeile-warnung td { background: #fffdf7; }
.kachel.fehlerhaft-kachel { border-color: var(--rot); }
pre.detail {
  white-space: pre-wrap; font-size: 0.78rem; color: var(--grau);
  background: #f7f8fa; padding: 0.6rem; border-radius: 6px; margin: 0.4rem 0 0;
  max-height: 16rem; overflow: auto;
}
details summary { cursor: pointer; font-size: 0.8rem; }

/* Kleiner Dreher für "wird gerade erledigt" */
.dreher {
  display: inline-block; width: 0.7em; height: 0.7em; margin-right: 0.3em;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: drehen 0.8s linear infinite;
  vertical-align: -0.1em;
}
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dreher { animation: none; } }

.btn.klein { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* Balken für Monatsverläufe — ohne Diagramm-Bibliothek */
.balken {
  height: 0.9rem; min-width: 2px; border-radius: 3px;
  background: var(--akzent); opacity: 0.75;
}
h2 .btn.klein { vertical-align: middle; margin-left: 0.6rem; font-weight: 400; }

.tabellenfuss {
  margin: 0.5rem 0 0; padding-top: 0.5rem; border-top: 1px solid var(--rand);
  font-size: 0.88rem; color: var(--grau);
}
.tabellenfuss strong { color: var(--text); }
