:root {
  --papier: #fbfaf7;
  --karte: #ffffff;
  --linie: #e3e0d8;
  --text: #23211d;
  --leise: #6d6a63;
  --akzent: #2f5d50;
  --akzent-hell: #e8f0ec;
  --rot: #b23b3b;
  --gelb: #b8860b;
  --gruen: #2f7a4f;
  --grau: #9a968d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--papier);
  color: var(--text);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 3rem;
}

a { color: var(--akzent); }

header.kopf {
  background: var(--akzent);
  color: #fff;
  padding: .7rem 1rem .2rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
header.kopf .zeile { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
header.kopf h1 { font-size: 1.05rem; margin: 0; font-weight: 600; }
header.kopf .stand { font-size: .82rem; opacity: .85; }
header.kopf a.abmelden { color: #fff; opacity: .8; font-size: .8rem; margin-left: auto; }

nav.haupt { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; }
nav.haupt a {
  color: #fff;
  text-decoration: none;
  padding: .4rem .6rem;
  border-radius: 6px 6px 0 0;
  font-size: .88rem;
  opacity: .82;
  white-space: nowrap;
}
nav.haupt a.hier { background: var(--papier); color: var(--akzent); opacity: 1; font-weight: 600; }
nav.haupt a .zahl {
  background: rgba(255,255,255,.25);
  border-radius: 999px;
  padding: 0 .35rem;
  font-size: .78rem;
  margin-left: .2rem;
}
nav.haupt a.hier .zahl { background: var(--akzent-hell); }

main { padding: 1rem; max-width: 62rem; margin: 0 auto; }

h2 { font-size: 1.2rem; margin: 0 0 .3rem; }
p.erklaerung { color: var(--leise); margin: .2rem 0 1rem; font-size: .92rem; }

.hinweis {
  background: var(--akzent-hell);
  border: 1px solid var(--akzent);
  border-radius: 8px;
  padding: .6rem .8rem;
  margin-bottom: 1rem;
  display: flex;
  gap: .8rem;
  align-items: center;
  flex-wrap: wrap;
}
.hinweis form { margin: 0; }

.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: .8rem;
  margin-bottom: .7rem;
}
.karte h3 { margin: 0 0 .2rem; font-size: 1.02rem; }
.karte h3 a { text-decoration: none; }
.meta { color: var(--leise); font-size: .87rem; margin: .1rem 0; }
.begruendung { font-size: .9rem; margin: .4rem 0 .2rem; color: #43403a; }

.score {
  display: inline-block;
  background: var(--akzent);
  color: #fff;
  border-radius: 6px;
  padding: .1rem .45rem;
  font-weight: 600;
  font-size: .9rem;
}
.note { display: inline-block; background: #6b4fa0; color: #fff; border-radius: 6px;
        padding: .1rem .45rem; font-weight: 600; font-size: .9rem; }

.ampel { font-size: .85rem; font-weight: 600; }
.ampel::before { content: "●  "; }
.ampel.rot { color: var(--rot); }
.ampel.gelb { color: var(--gelb); }
.ampel.gruen { color: var(--gruen); }
.ampel.grau { color: var(--grau); font-weight: 400; }

.knoepfe { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.knoepfe form { margin: 0; }

button, .knopf {
  font: inherit;
  font-size: .9rem;
  padding: .45rem .7rem;
  border: 1px solid var(--linie);
  background: #f4f2ec;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  display: inline-block;
  min-height: 2.2rem;
}
button:hover, .knopf:hover { background: #eae7df; }
button.wichtig, a.knopf.wichtig { background: var(--akzent); color: #fff;
                                  border-color: var(--akzent); }
button.gefahr { color: var(--rot); }
button.klein, .knopf.klein { font-size: .82rem; padding: .3rem .5rem; min-height: 0; }

.marke {
  display: inline-block; font-size: .78rem; padding: .1rem .4rem;
  border-radius: 999px; background: #efece4; color: var(--leise);
  border: 1px solid var(--linie);
}
.marke.aktiv { background: var(--akzent-hell); color: var(--akzent); border-color: var(--akzent); }
.marke.offen { background: #fdf3d8; color: #8a6d1f; border-color: #e0c97f; }

input[type=text], input[type=password], input[type=number], input[type=date],
textarea, select {
  font: inherit;
  padding: .45rem .5rem;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: #fff;
  max-width: 100%;
}
textarea { width: 100%; min-height: 4rem; }
input[type=number] { width: 5rem; }
label { font-size: .88rem; color: var(--leise); display: block; margin-bottom: .2rem; }
fieldset { border: 1px solid var(--linie); border-radius: 8px; margin: 0 0 .7rem; }
legend { font-size: .88rem; color: var(--leise); padding: 0 .3rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--linie); vertical-align: top; }
th { color: var(--leise); font-weight: 600; font-size: .85rem; }

pre.brief {
  background: #fff;
  border: 1px solid var(--linie);
  border-radius: 10px;
  padding: 1rem;
  white-space: pre-wrap;
  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto;
}

.zaehlerreihe { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.zaehlerreihe .kachel {
  background: var(--karte); border: 1px solid var(--linie); border-radius: 10px;
  padding: .5rem .8rem; min-width: 6.5rem;
}
.zaehlerreihe .kachel b { display: block; font-size: 1.35rem; }
.zaehlerreihe .kachel span { font-size: .82rem; color: var(--leise); }

.balken { background: #e7e4dc; border-radius: 999px; height: .55rem; overflow: hidden; margin: .4rem 0; }
.balken i { display: block; height: 100%; background: var(--akzent); }

.leer { color: var(--leise); font-style: italic; padding: 1rem 0; }
.leise { color: var(--leise); font-size: .87rem; }
.trenner { border: 0; border-top: 1px solid var(--linie); margin: 1.4rem 0; }
.reihe { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }

table.kurzfassung { margin: .5rem 0 .6rem; }
table.kurzfassung th {
  width: 7.5rem; vertical-align: top; font-weight: 600; color: var(--leise);
  border-bottom: 1px solid var(--linie);
}
table.kurzfassung td { border-bottom: 1px solid var(--linie); }
table.kurzfassung tr:last-child th, table.kurzfassung tr:last-child td { border-bottom: 0; }

.zeile-frist { margin-top: .25rem; }

.filter { margin: 0 0 1rem; }
.filterzeile { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-bottom: .3rem; }
.filterzeile > span { min-width: 5.5rem; font-size: .85rem; }

table.knapp td, table.knapp th { padding: .3rem .4rem; }
table.knapp tr:nth-child(even) { background: #fff; }
table.knapp form { margin: 0; }

.karte.dringend { border-color: var(--rot); border-width: 2px; background: #fffaf8; }
.dringend-band {
  color: #fff; background: var(--rot); border-radius: 6px;
  padding: .25rem .5rem; font-size: .85rem; font-weight: 600;
  margin: -.2rem -.2rem .5rem; display: inline-block;
}

/* Fassungen eines Anschreibens: eine Reihe von Kacheln, die aktive ist gefüllt.
   Kein Zahlensalat mehr, sondern je Fassung Herkunft, Datum und was passiert. */
.fassungsreihe { display: flex; flex-wrap: wrap; gap: .45rem; }
.fassung {
  display: flex; flex-direction: column; gap: .1rem;
  border: 1px solid var(--linie); border-radius: .55rem;
  padding: .45rem .7rem; min-width: 11rem;
  background: var(--karte); color: var(--text);
  text-decoration: none; line-height: 1.25;
}
a.fassung:hover { background: #eae7df; }
.fassung small { font-size: .78rem; color: var(--leise); white-space: nowrap; }
.fassung.aktiv { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.fassung.aktiv small { color: rgba(255,255,255,.85); }

.hinweisbalken {
  background: #fdf3d8; border: 1px solid #e0c97f; color: #6b551a;
  border-radius: .5rem; padding: .5rem .7rem; margin: 0 0 .8rem;
}
.hinweisbalken .knopf, .hinweisbalken code { margin-left: .35rem; }

.briefkopfzeile {
  display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap;
  margin: 0 0 .3rem;
}

/* Einrichtung: Werk – deine Fassung – wirklich benutzt */
.karte.feld textarea { font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.karte.feld .spalten { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-top: .3rem; }
.karte.gefahr { border-color: var(--rot); border-width: 2px; }
.karte.gefahr b { color: var(--rot); }
code {
  background: #f1efe9; border: 1px solid var(--linie); border-radius: 4px;
  padding: 0 .25rem; font-size: .9em;
}

/* Nach einer Aktion bleibt die Seite stehen, wo sie ist (die Knöpfe schicken per
   fetch). Die angefasste Karte wird kurz umrandet – zeitlich begrenzt, nicht über
   :target, das klebte dauerhaft in der Adresse. */
.karte.frisch, table.knapp tr.frisch td { animation: frisch 3s ease-out; }
@keyframes frisch {
  0%   { background: var(--akzent-hell); box-shadow: 0 0 0 2px var(--akzent); }
  70%  { background: var(--akzent-hell); box-shadow: 0 0 0 2px var(--akzent); }
  100% { background: var(--karte);       box-shadow: none; }
}

/* Vorgezogene Karten: bleiben in der Liste, werden aber sichtbar markiert. */
.karte.vorgezogen { border-left: 4px solid var(--akzent); }
.marke.rechner { background: #e7e2f5; color: #46356e; border-color: #b9a9e0; }
.letzte-aktion { margin-top: .3rem; font-size: .85rem; }

/* Bestätigung direkt an der Karte statt als Balken ganz oben. */
.karten-hinweis {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  background: var(--akzent-hell); border: 1px solid var(--akzent);
  border-radius: .5rem; padding: .35rem .6rem; margin: .5rem 0 0;
  font-size: .9rem;
}
.karten-hinweis form { margin: 0; }
