:root {
  --grund: #16202b;
  --grund-hell: #26333f;
  --flaeche: #ffffff;
  --papier: #e9ecef;
  --linie: #cdd4da;
  --linie-zart: #e3e7ea;
  --text: #1e252c;
  --gedimmt: #616c77;
  --marke: #2c5fa8;
  --gut: #0f6b4f;
  --warn: #a66a00;
  --kritisch: #a32020;
  --zahl: "SF Mono", "DejaVu Sans Mono", Consolas, "Liberation Mono", monospace;
  --schrift: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--schrift);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--papier);
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--grund);
  background: var(--grund);
  color: #fff;
  padding: 7px 13px;
  border-radius: 3px;
}
button:hover { background: var(--grund-hell); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--marke);
  outline-offset: 1px;
}
button.leise {
  background: transparent;
  border-color: var(--linie);
  color: var(--text);
}
button.leise:hover { background: #f2f4f6; }
button:disabled { opacity: .45; cursor: not-allowed; }

input, select {
  border: 1px solid var(--linie);
  border-radius: 3px;
  padding: 6px 8px;
  background: #fff;
}

/* ---------- Anmeldung ---------- */
.anmelde-schirm {
  min-height: 100%;
  display: grid;
  place-items: center;
  background: var(--grund);
  padding: 24px;
}
.anmelde-karte {
  width: 100%;
  max-width: 340px;
  background: #fff;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.anmelde-marke {
  margin: 0;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--gedimmt);
  font-size: 12px;
}
.anmelde-karte h1 { margin: 0 0 18px; font-size: 22px; font-weight: 650; }
.anmelde-karte label { font-size: 13px; color: var(--gedimmt); margin-top: 8px; }
.anmelde-karte button { margin-top: 20px; padding: 10px; }
.anmelde-fehler { color: var(--kritisch); min-height: 20px; margin: 10px 0 0; font-size: 13px; }

/* ---------- Grundgerüst ---------- */
.huelle {
  display: grid;
  grid-template-columns: 208px 1fr;
  min-height: 100vh;
}

.schiene {
  background: var(--grund);
  color: #cfd8e0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.schiene-kopf { padding: 20px 18px 22px; display: flex; flex-direction: column; }
.schiene-marke { font-weight: 700; letter-spacing: .14em; font-size: 12px; color: #7d8b99; }
.schiene-titel { color: #fff; font-size: 16px; font-weight: 600; margin-top: 2px; }
.schiene-liste { list-style: none; margin: 0; padding: 0; flex: 1; }
.schiene-liste button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  color: #b6c2ce;
  padding: 9px 18px;
  border-radius: 0;
}
.schiene-liste button:hover { background: #1e2a36; color: #fff; }
.schiene-liste button.aktiv { background: #1e2a36; color: #fff; border-left-color: var(--marke); }
.schiene-fuss {
  padding: 16px 18px;
  border-top: 1px solid #2a3743;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}
.schiene-fuss .rolle { color: #7d8b99; font-size: 12px; }
.schiene-fuss button { margin-top: 10px; border-color: #3a4854; color: #cfd8e0; }
.schiene-fuss button:hover { background: #26333f; }

.buehne { display: flex; flex-direction: column; min-width: 0; }

.kopfleiste {
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
  padding: 12px 20px;
  display: flex;
  gap: 18px;
  align-items: flex-end;
}
.filter { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--gedimmt); }
.filter.wachsen { flex: 1; max-width: 420px; }
.filter input, .filter select { min-width: 150px; }
.stand { margin-left: auto; font-size: 12px; color: var(--gedimmt); font-variant-numeric: tabular-nums; }

.ansicht { padding: 20px; min-width: 0; }

h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.hinweis { color: var(--gedimmt); margin: 0 0 18px; max-width: 66ch; }

/* ---------- Kennzahlenstreifen ---------- */
.streifen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  background: var(--flaeche);
  border: 1px solid var(--linie);
  margin-bottom: 22px;
}
.kachel {
  border: 0;
  border-right: 1px solid var(--linie-zart);
  border-top: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--text);
  text-align: left;
  padding: 14px 16px 13px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.kachel:last-child { border-right: 0; }
.kachel:hover { background: #f4f6f8; }
.kachel .wert {
  font-family: var(--zahl);
  font-variant-numeric: tabular-nums;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: -.02em;
}
.kachel .wert span { font-size: 15px; color: var(--gedimmt); margin-left: 2px; }
.kachel .name { font-size: 12px; color: var(--gedimmt); }
.kachel.warnt { border-top-color: var(--warn); }
.kachel.warnt .wert { color: var(--warn); }
.kachel.kritisch { border-top-color: var(--kritisch); }
.kachel.kritisch .wert { color: var(--kritisch); }
.kachel.erreicht .wert { color: var(--gut); }

/* ---------- Tabellen ---------- */
.tafel { background: var(--flaeche); border: 1px solid var(--linie); }
.tafel-kopf {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--linie);
}
.tafel-kopf .anzahl { font-family: var(--zahl); color: var(--gedimmt); font-size: 12px; }
.tafel-kopf .rechts { margin-left: auto; display: flex; gap: 8px; }
.rollen { overflow-x: auto; max-height: calc(100vh - 300px); }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--linie-zart);
  white-space: nowrap;
}
thead th {
  position: sticky;
  top: 0;
  background: #f6f8f9;
  border-bottom: 1px solid var(--linie);
  font-size: 12px;
  font-weight: 600;
  color: var(--gedimmt);
  z-index: 1;
}
tbody tr:hover { background: #f4f6f8; }
tbody tr.gewaehlt { background: #eaf0f8; }
td.zahl, th.zahl { font-family: var(--zahl); font-variant-numeric: tabular-nums; text-align: right; }
td.wahl { width: 30px; padding-left: 12px; }
.frist-mark { border-left: 3px solid transparent; }
.frist-mark.kritisch { border-left-color: var(--kritisch); }
.frist-mark.warnt { border-left-color: var(--warn); }
.frist-mark.ruhig { border-left-color: var(--linie); }

.status { font-size: 12px; }
.status::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--gedimmt);
  vertical-align: baseline;
}
.status.offen::before { background: #9aa5af; }
.status.geplant::before, .status.avisiert::before { background: var(--marke); }
.status.in_arbeit::before { background: #6b3fa0; }
.status.erledigt::before { background: var(--warn); }
.status.freigegeben::before, .status.uebermittelt::before, .status.abgerechnet::before { background: var(--gut); }
.status.nicht_angetroffen::before, .status.nicht_ausfuehrbar::before, .status.nacharbeit::before { background: var(--kritisch); }

.leer { padding: 40px 16px; color: var(--gedimmt); text-align: center; }
.leer strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Auswahlleiste ---------- */
.auswahlleiste {
  position: fixed;
  bottom: 0;
  left: 208px;
  right: 0;
  background: var(--grund);
  color: #fff;
  padding: 11px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5;
}
.auswahlleiste span { font-variant-numeric: tabular-nums; margin-right: 8px; }
.auswahlleiste button { border-color: #3a4854; }
.auswahlleiste button:not(.leise) { background: var(--marke); border-color: var(--marke); }
.auswahlleiste button.leise { color: #cfd8e0; }
.auswahlleiste input, .auswahlleiste select { background: #fff; color: var(--text); }

/* ---------- Import ---------- */
.schritte { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.schritt { background: var(--flaeche); border: 1px solid var(--linie); padding: 16px; }
.schritt[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.schritt-kopf { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.schritt-nr {
  font-family: var(--zahl);
  color: var(--gedimmt);
  border: 1px solid var(--linie);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 12px;
}
.zuordnung { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 0; }
.zuordnung label { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.zuordnung .pflicht::after { content: " · Pflicht"; color: var(--kritisch); font-size: 11px; }
.zeile-knopf { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

.bericht { display: flex; gap: 20px; flex-wrap: wrap; margin: 12px 0; }
.bericht div { font-size: 13px; }
.bericht .wert { font-family: var(--zahl); font-size: 20px; display: block; }
.bericht .schlecht .wert { color: var(--kritisch); }

.balken { display: flex; align-items: center; gap: 8px; }
.balken-spur { width: 90px; height: 8px; background: var(--linie-zart); position: relative; }
.balken-fuell { position: absolute; inset: 0 auto 0 0; background: var(--marke); }
.balken-fuell.voll { background: var(--warn); }
.balken-fuell.ueber { background: var(--kritisch); }

.meldung {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--grund);
  color: #fff;
  padding: 11px 15px;
  border-radius: 3px;
  max-width: 380px;
  z-index: 20;
}
.meldung.fehler { background: var(--kritisch); }

.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) {
  .huelle { grid-template-columns: 1fr; }
  .schiene { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .schiene-liste { display: flex; flex: 1 0 100%; overflow-x: auto; }
  .schiene-kopf { padding: 12px 16px; }
  .schiene-fuss { border: 0; flex-direction: row; align-items: center; gap: 10px; }
  .auswahlleiste { left: 0; flex-wrap: wrap; }
  .zwei-spalten, .zuordnung { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Formulare ---------- */
.formular { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; padding: 16px; }
.formular label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--gedimmt); }
.formular label.pflicht::after { content: " · Pflicht"; color: var(--kritisch); font-size: 11px; }
.formular .breit { grid-column: 1 / -1; }

/* ---------- Tour ---------- */
.tour-kennzahl { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--linie); background: var(--flaeche); margin-bottom: 16px; }
.tour-kennzahl div { flex: 1 1 120px; padding: 12px 16px; border-right: 1px solid var(--linie-zart); }
.tour-kennzahl div:last-child { border-right: 0; }
.tour-kennzahl .wert { font-family: var(--zahl); font-variant-numeric: tabular-nums; font-size: 22px; display: block; line-height: 1.2; }
.tour-kennzahl .name { font-size: 12px; color: var(--gedimmt); }
.tour-kennzahl div.warnt .wert { color: var(--warn); }
.tour-kennzahl div.kritisch .wert { color: var(--kritisch); }

.warnbox { border-left: 3px solid var(--warn); background: #fdf6e8; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.warnbox p { margin: 0 0 4px; }
.warnbox p:last-child { margin-bottom: 0; }

.tour-halt td.folge { font-family: var(--zahl); color: var(--gedimmt); width: 36px; }
tr.teilweise { background: #fdf6e8; }
