/* Schlicht und ohne Bibliothek. Zwei Leute, ein Werkzeug — es muss lesbar
   sein, nicht beeindruckend. */

:root {
  --grund: #fbfaf8;
  --flaeche: #ffffff;
  --linie: #ddd8d0;
  --text: #1c1a17;
  --leise: #6b655c;
  --betont: #2f5d50;
  --fehler: #a3341f;
  --rundung: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #171614;
    --flaeche: #201e1b;
    --linie: #3a3630;
    --text: #ece8e1;
    --leise: #9b948a;
    --betont: #7fbfa9;
    --fehler: #e0836c;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* --- Anmeldung ---------------------------------------------------------- */

.mitte {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.karte {
  width: 100%;
  max-width: 340px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  padding: 28px;
  display: grid;
  gap: 6px;
}

.karte h1 {
  margin: 0 0 14px;
  font-size: 19px;
}

label {
  font-size: 13px;
  color: var(--leise);
  margin-top: 8px;
}

input {
  font: inherit;
  color: inherit;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  padding: 9px 10px;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--betont);
  outline-offset: 1px;
}

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--rundung);
  padding: 9px 14px;
  background: var(--betont);
  color: var(--grund);
  margin-top: 18px;
}

/* Ausgegraut heisst wirklich grau, nicht nur blass. Ein abgeschwaechtes Gruen
   sieht auf einem hellen Hintergrund noch nach "anklickbar" aus. */
button:disabled {
  background: var(--linie);
  color: var(--leise);
  cursor: default;
  opacity: 0.7;
}

button.schlicht:disabled {
  background: transparent;
  opacity: 0.45;
}

button.schlicht {
  margin: 0;
  background: transparent;
  color: var(--leise);
  border-color: var(--linie);
  padding: 5px 11px;
  font-size: 13px;
}

button.schlicht:hover {
  color: var(--text);
}

/* --- Oberflaeche -------------------------------------------------------- */

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}

.inhalt {
  padding: 20px;
}

.kopflabel {
  margin: 0 0 0 14px;
  font-size: 13px;
}

.fueller {
  flex: 1;
}

.kopf select {
  font: inherit;
  color: inherit;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  padding: 5px 8px;
}

/* --- Reiter ------------------------------------------------------------- */

.reiter {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}

.reiter-knopf {
  margin: 0;
  background: transparent;
  color: var(--leise);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
}

.reiter-knopf[aria-current='true'] {
  color: var(--text);
  border-bottom-color: var(--betont);
}

.reiter-knopf .zahl {
  color: var(--leise);
  font-size: 12px;
  margin-left: 5px;
}

/* --- Filter ------------------------------------------------------------- */

.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 14px 0;
}

.filterfeld {
  display: grid;
  gap: 3px;
}

.filterfeld label {
  margin: 0;
  font-size: 12px;
}

.filterfeld input,
.filterfeld select {
  padding: 6px 8px;
  font-size: 14px;
  min-width: 150px;
}

.filterfeld .schmalfeld {
  min-width: 80px;
  width: 80px;
}

.filter button {
  margin: 0;
}

/* --- Tabelle ------------------------------------------------------------ */

.tabelle-rahmen {
  overflow-x: auto;
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  background: var(--flaeche);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

caption {
  padding: 16px;
  text-align: left;
}

th,
td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--linie);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--flaeche);
  font-size: 12px;
  font-weight: 600;
  color: var(--leise);
  cursor: pointer;
  user-select: none;
}

th:first-child,
td:first-child {
  cursor: default;
  width: 1%;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--betont) 8%, transparent);
}

tr.gewaehlt {
  background: color-mix(in srgb, var(--betont) 16%, transparent);
}

.rechts {
  text-align: right;
}

.fussleiste {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
  margin: 10px 2px;
}

/* --- Branchen ----------------------------------------------------------- */

h2 {
  font-size: 17px;
  margin: 0 0 6px;
}

.schmal {
  max-width: 62ch;
}

.liste {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.karte.breit {
  max-width: 62ch;
  padding: 0;
}

details.karte > summary {
  cursor: pointer;
  padding: 13px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

details.karte[open] > summary {
  border-bottom: 1px solid var(--linie);
  margin-bottom: 14px;
}

details.karte > :not(summary) {
  margin-left: 16px;
  margin-right: 16px;
}

details.karte[open] > :last-child {
  margin-bottom: 16px;
}

textarea {
  font: inherit;
  color: inherit;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  padding: 9px 10px;
  resize: vertical;
  width: auto;
}

/* Nur die Anzeige. Gespeichert bleibt der Name klein — er ist Fremdschluessel
   und steht in Befehlszeilen. "kfz-betriebe" wird dabei zu "Kfz-Betriebe". */
.branchenname {
  text-transform: capitalize;
}

.meldung {
  border-top: 1px solid var(--linie);
  padding-top: 12px;
  margin-top: 16px;
}

.knoepfe {
  display: flex;
  gap: 10px;
  align-items: center;
}

.knoepfe button {
  margin-top: 0;
}

.meldung p {
  margin: 0 0 8px;
}

.warnung {
  color: var(--fehler);
  font-weight: 600;
}

.hinweis {
  font-size: 12px;
  color: var(--leise);
  margin: 4px 0 0;
}

/* --- Kleinteile --------------------------------------------------------- */

.klein {
  font-size: 12px;
}

.leise {
  color: var(--leise);
}

.fehler {
  color: var(--fehler);
  font-size: 13px;
  margin: 12px 0 0;
}

[hidden] {
  display: none !important;
}

/* --- Fenster ------------------------------------------------------------ */

dialog {
  border: 1px solid var(--linie);
  border-radius: var(--rundung);
  background: var(--flaeche);
  color: var(--text);
  padding: 0;
  width: min(52ch, calc(100vw - 32px));
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.3);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--linie);
}

#fenster-zu {
  margin: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 1;
  font-size: 20px;
  background: transparent;
  color: var(--leise);
  border-radius: var(--rundung);
}

#fenster-zu:hover {
  background: var(--grund);
  color: var(--text);
}

#fenster-inhalt {
  padding: 16px 18px 18px;
}

#fenster-inhalt p {
  margin: 0 0 10px;
}

#fenster-inhalt p:last-of-type {
  margin-bottom: 0;
}

#fenster-inhalt button {
  margin-top: 14px;
}

.probe {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--leise);
}

.fussleiste .knoepfe button,
.filter .knoepfe button {
  margin-top: 0;
}

/* --- Laufstand ---------------------------------------------------------- */

.lauf {
  padding: 12px 20px;
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche);
  display: grid;
  gap: 8px;
}

.lauf-kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

/* Ein laufender Lauf bekommt eine Kante in der Betonfarbe, ein verwaister in
   der Fehlerfarbe. Fertig und abgebrochen bleiben ruhig — sie verlangen
   nichts. */
.lauf-laeuft {
  border-left: 3px solid var(--betont);
}

.lauf-warnung {
  border-left: 3px solid var(--fehler);
}

.lauf p {
  margin: 0;
}

.kennzahlen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
}

.kennzahlen > span {
  display: grid;
  gap: 1px;
}

.balken {
  height: 5px;
  border-radius: 3px;
  background: var(--linie);
  overflow: hidden;
  max-width: 420px;
}

.balken > div {
  height: 100%;
  background: var(--betont);
  transition: width 0.4s ease;
}

/* Wegklick-Kreuz am beendeten Laufhinweis. Ganz rechts, damit es nicht
   zwischen den Zahlen steht. */
.lauf-kopf .wegklicken {
  margin: 0 0 0 auto;
  padding: 0;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 18px;
  background: transparent;
  color: var(--leise);
  border-radius: var(--rundung);
}

.lauf-kopf .wegklicken:hover {
  background: var(--grund);
  color: var(--text);
}

/* --- Marken an den Laeufen ---------------------------------------------- */

.marke {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--linie);
  color: var(--leise);
}

.marke-laeuft {
  border-color: var(--betont);
  color: var(--betont);
}

.marke-fehler {
  border-color: var(--fehler);
  color: var(--fehler);
}

details.karte > .kennzahlen {
  margin-bottom: 12px;
}

details.karte .probe {
  margin-bottom: 12px;
}

/* --- Detailansicht, schiebt sich von rechts ein ------------------------- */

#tafel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--flaeche);
  border-left: 1px solid var(--linie);
  box-shadow: -8px 0 28px rgb(0 0 0 / 0.18);
  display: flex;
  flex-direction: column;
  z-index: 20;
  animation: einschieben 0.18s ease-out;
}

@keyframes einschieben {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* Wer die Bewegung nicht will, bekommt sie nicht. */
@media (prefers-reduced-motion: reduce) {
  #tafel { animation: none; }
}

#tafel header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 14px 18px;
  border-bottom: 1px solid var(--linie);
}

#tafel-zu {
  margin: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  flex: none;
  line-height: 1;
  font-size: 20px;
  background: transparent;
  color: var(--leise);
  border-radius: var(--rundung);
}

#tafel-zu:hover {
  background: var(--grund);
  color: var(--text);
}

#tafel-inhalt {
  overflow-y: auto;
  padding: 16px 18px 28px;
}

/* Der Inhalt schiebt sich nicht unter die Tafel, sondern macht Platz. */
body.tafel-offen .inhalt {
  padding-right: calc(20px + min(440px, 100vw));
}

.wege {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

a.knopf {
  display: inline-block;
  font: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--rundung);
  padding: 8px 13px;
  background: var(--betont);
  color: var(--grund);
}

a.knopf.schlicht {
  background: transparent;
  color: var(--leise);
  border-color: var(--linie);
  padding: 5px 11px;
  font-size: 13px;
}

a.knopf.schlicht:hover {
  color: var(--text);
}

.block {
  margin-bottom: 16px;
}

.block p {
  margin: 2px 0 0;
  white-space: pre-line;
}

.block .probe {
  margin-top: 6px;
}

/* Der Firmenname als Knopf — sieht aus wie Text, verhaelt sich wie ein Link. */
.namensknopf {
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  border: 0;
  font: inherit;
  text-align: left;
  border-bottom: 1px solid transparent;
}

.namensknopf:hover {
  border-bottom-color: var(--betont);
  color: var(--betont);
}
