/*
 * Adminaufgaben-Inventar — handgeschriebenes CSS, kein Build-Step.
 *
 * Visuelle Identität nach ai-at.eu. Die beiden Marken-Token stammen direkt aus
 * den CSS-Variablen der Website (--lg-primary / --lg-secondary):
 *
 *   Blau   #005AF0   Leitfarbe: Links, Knöpfe, Balken, aktive Zustände
 *   Grün   #C6F2B8   Sekundärfarbe, ausschließlich als weiche Fläche
 *
 * Schrift: GEIST und Geist Mono, dieselben Familien wie ai-at.eu, selbst
 * gehostet unter public/fonts/ (SIL Open Font License). Bewusst NICHT von
 * ai-at.eu oder Google verlinkt: Die Anwendung läuft in einem Cluster und darf
 * für ihre Darstellung nicht von fremden Hosts abhängen.
 *
 * Kontrastwerte (WCAG 2.2 AA: 4.5:1 Text, 3:1 UI-Elemente):
 *   hell:   #000000 auf #ffffff  = 21.0:1   Fließtext
 *           #616161 auf #ffffff  =  6.2:1   Sekundärtext
 *           #757575 auf #ffffff  =  4.6:1   Tertiärtext
 *           #005af0 auf #ffffff  =  5.7:1   Links, Balken
 *           #ffffff auf #005af0  =  5.7:1   Knopfbeschriftung
 *           #000000 auf #c6f2b8  = 16.8:1   Text im grünen Panel
 *   dunkel: #ededed auf #151515  = 15.6:1
 *           #a1a1a1 auf #151515  =  7.9:1
 *           #4d8dff auf #151515  =  5.7:1
 */

/* --- Schriften ----------------------------------------------------------- */

@font-face {
  font-family: "Geist";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/public/fonts/Geist-Regular.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("/public/fonts/Geist-500.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/public/fonts/Geist-600.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/public/fonts/GeistMono-Regular.woff2") format("woff2");
}

/* --- Token --------------------------------------------------------------- */

:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --fg: #000000;
  --muted: #616161;
  --muted-2: #757575;
  --border: #e0e0e0;
  --border-strong: #c9c9c9;

  --accent: #005af0;
  --accent-tief: #0043b8;
  --accent-weich: #dde8fc;
  --accent-fg: #ffffff;

  /* Sekundärfarbe der Marke — nur als Fläche, nie als Text. */
  --marke-gruen: #c6f2b8;
  --marke-gruen-linie: #a8e096;

  --fehler: #b3261e;

  /* Ampel. Bewusst getrennt von den Markenfarben: Statusfarben, die mit dem
     Markenblau konkurrieren, verlieren ihre Signalwirkung. */
  --ampel-rot: #b3261e;
  --ampel-gelb: #a5720b;
  --ampel-gruen: #2c6b34;

  --radius: 8px;
  --radius-s: 6px;
  --abstand: 1rem;
  --ziel-min: 44px;

  --schrift: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --schrift-zahl: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  font-size: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #151515;
    --surface-2: #1f1f1f;
    --fg: #ededed;
    --muted: #a1a1a1;
    --muted-2: #8f8f8f;
    --border: #2a2a2a;
    --border-strong: #3d3d3d;
    --accent: #4d8dff;
    --accent-tief: #7aa9ff;
    --accent-weich: #10243f;
    --accent-fg: #0a0a0a;
    --marke-gruen: #1a3320;
    --marke-gruen-linie: #2c5435;
    --fehler: #f2857c;
    --ampel-rot: #f2857c;
    --ampel-gelb: #dfa63f;
    --ampel-gruen: #7cc98a;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #151515;
  --surface-2: #1f1f1f;
  --fg: #ededed;
  --muted: #a1a1a1;
  --muted-2: #8f8f8f;
  --border: #2a2a2a;
  --border-strong: #3d3d3d;
  --accent: #4d8dff;
  --accent-tief: #7aa9ff;
  --accent-weich: #10243f;
  --accent-fg: #0a0a0a;
  --marke-gruen: #1a3320;
  --marke-gruen-linie: #2c5435;
  --fehler: #f2857c;
  --ampel-rot: #f2857c;
  --ampel-gelb: #dfa63f;
  --ampel-gruen: #7cc98a;
}

:root[data-theme="light"] {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --fg: #000000;
  --muted: #616161;
  --muted-2: #757575;
  --border: #e0e0e0;
  --border-strong: #c9c9c9;
  --accent: #005af0;
  --accent-tief: #0043b8;
  --accent-weich: #dde8fc;
  --accent-fg: #ffffff;
  --marke-gruen: #c6f2b8;
  --marke-gruen-linie: #a8e096;
  --fehler: #b3261e;
  --ampel-rot: #b3261e;
  --ampel-gelb: #a5720b;
  --ampel-gruen: #2c6b34;
}

* {
  box-sizing: border-box;
}

html {
  /* 2.4.11 Focus Not Obscured: fokussierte Inhalte nicht unter den
     Sticky-Header schieben. */
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--schrift);
  font-size: 0.975rem;
  line-height: 1.6;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

/* --- Skip-Link ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--radius-s);
  text-decoration: none;
  transition: top 150ms ease;
}
.skip-link:focus {
  top: 0.5rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* --- Kopfbereich --------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--abstand);
  padding: 0.85rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 0.75rem;
  border-radius: var(--radius-s);
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-list a:hover {
  background: var(--surface-2);
  color: var(--fg);
}

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

.logout-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}

main {
  max-width: 70rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}
main:focus {
  outline: none;
}

.schmal {
  max-width: 40rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  color: var(--muted-2);
  font-size: 0.8rem;
}
.site-footer p {
  max-width: 67rem;
  margin: 0 auto;
}

/* --- Typografie ---------------------------------------------------------- */

h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.15rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.035em;
  text-wrap: balance;
  margin: 0 0 0.6rem;
}

h2,
.abschnitt-titel {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 2.5rem 0 0.5rem;
}

.lede {
  color: var(--muted);
  max-width: 44rem;
  margin: 0 0 1.5rem;
}

.hinweis {
  color: var(--muted-2);
  font-size: 0.85rem;
  margin-top: 1.75rem;
}

.brotkrume {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
}

.kopfzeile {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--abstand);
}

/* --- Knöpfe -------------------------------------------------------------- */

.knopf,
.knopf-still {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--ziel-min);
  padding: 0 1.2rem;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

.knopf {
  background: var(--accent);
  color: var(--accent-fg);
}
.knopf:hover {
  background: var(--accent-tief);
}

.knopf-still {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
}
.knopf-still:hover {
  border-color: var(--muted-2);
}
.knopf-still.gefahr:hover {
  color: var(--fehler);
  border-color: var(--fehler);
}

.aktionen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.75rem;
}
.aktionen form {
  margin: 0;
}

/* --- Formular ------------------------------------------------------------ */

.feld {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

label,
legend {
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

input[type="text"],
input[type="password"],
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.7rem;
  min-height: var(--ziel-min);
  width: 100%;
  max-width: 34rem;
}
textarea {
  min-height: 5rem;
  line-height: 1.5;
  resize: vertical;
}
select {
  cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

[aria-invalid="true"] {
  border-color: var(--fehler);
}

.feld-hinweis {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted-2);
}

.feld-fehler {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--fehler);
}

.meldung {
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-s);
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.meldung.fehler {
  color: var(--fehler);
  border: 1px solid var(--fehler);
  font-weight: 500;
}

/* --- Radio-Gruppe (Ampel im Formular) ------------------------------------ */

fieldset.feld-gruppe {
  border: none;
  margin: 0 0 1.25rem;
  padding: 0;
  min-width: 0;
}

fieldset.feld-gruppe legend {
  padding: 0;
}

.radio-reihe {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.45rem;
  max-width: 34rem;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  cursor: pointer;
  font-weight: 400;
  /* 2.5.8: die gesamte Fläche ist das Ziel, nicht nur der kleine Kreis. */
  min-height: var(--ziel-min);
}

.radio-option:hover {
  border-color: var(--muted-2);
}

.radio-option input[type="radio"] {
  margin: 0;
  flex: none;
  width: auto;
  min-height: 0;
  accent-color: var(--accent);
}

.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-weich);
}

.radio-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.radio-punkt {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--muted-2);
}

.radio-option.ampel-rot .radio-punkt {
  background: var(--ampel-rot);
}
.radio-option.ampel-gelb .radio-punkt {
  background: var(--ampel-gelb);
}
.radio-option.ampel-gruen .radio-punkt {
  background: var(--ampel-gruen);
}

.radio-label {
  font-weight: 500;
}

/* --- Referenzbeispiel am Formular ---------------------------------------- */
/* Die einzige Stelle mit der Sekundärfarbe der Marke — Fläche, kein Text. */

.beispiel {
  background: var(--marke-gruen);
  border: 1px solid var(--marke-gruen-linie);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 0 0 2rem;
  font-size: 0.88rem;
  max-width: 34rem;
}
.beispiel p {
  margin: 0 0 0.5rem;
}
.beispiel p:last-child {
  margin-bottom: 0;
}
.beispiel-titel {
  font-family: var(--schrift-zahl);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

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

.tabelle-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.25rem;
}

.daten-tabelle {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

.daten-tabelle caption {
  text-align: left;
  padding: 1rem 1.1rem 0.6rem;
  color: var(--muted-2);
  font-size: 0.8rem;
}

.daten-tabelle th,
.daten-tabelle td {
  text-align: left;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.daten-tabelle thead th {
  font-family: var(--schrift-zahl);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 400;
  white-space: nowrap;
}

.daten-tabelle tbody tr:last-child th,
.daten-tabelle tbody tr:last-child td {
  border-bottom: none;
}

.daten-tabelle tbody th {
  font-weight: 500;
}

.daten-tabelle .zahl {
  text-align: right;
  font-family: var(--schrift-zahl);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rhythmus {
  color: var(--muted);
  font-size: 0.85rem;
}

.marke {
  display: inline-block;
  font-family: var(--schrift-zahl);
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

/* --- Ampel --------------------------------------------------------------- */
/*
 * Die Farbe trägt die Bedeutung NIE allein — neben dem Punkt steht immer das
 * Wort (hoch / mittel / niedrig). Deshalb muss der Punkt nur die 3:1-Schwelle
 * für grafische Objekte erfüllen: Er ist eine zweite Kodierung, keine
 * Informationsquelle.
 */

.ampel {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  font-size: 0.88rem;
}

.ampel-punkt {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--muted-2);
}

.ampel-rot .ampel-punkt {
  background: var(--ampel-rot);
}
.ampel-gelb .ampel-punkt {
  background: var(--ampel-gelb);
}
.ampel-gruen .ampel-punkt {
  background: var(--ampel-gruen);
}

/* --- Merkmalsliste (Detailansicht) --------------------------------------- */

.merkmale {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem;
  margin: 1.75rem 0 0;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.merkmale > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.merkmale dt {
  font-family: var(--schrift-zahl);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.merkmale dd {
  margin: 0;
}
.zahl-gross {
  font-family: var(--schrift-zahl);
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

/* --- Kennzahlen ---------------------------------------------------------- */

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.kennzahl {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
}
.kennzahl p {
  margin: 0;
}

.kennzahl-bezeichnung {
  font-family: var(--schrift-zahl);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.kennzahl-wert {
  font-family: var(--schrift-zahl);
  font-variant-numeric: tabular-nums;
  font-size: 1.9rem;
  letter-spacing: -0.04em;
  line-height: 1.2;
  margin-top: 0.15rem;
}

.kennzahl-balken {
  display: block;
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0.5rem 0 0.4rem;
}
.kennzahl-balken > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
/* Ziel noch nicht erreicht. Der Zahlenwert daneben bleibt die eigentliche
   Information — Farbe allein trägt hier nichts. */
.kennzahl-balken.offen > span {
  background: var(--ampel-gelb);
}

.kennzahl-zusatz {
  font-size: 0.78rem;
  color: var(--muted-2);
}

/* --- Balkenliste --------------------------------------------------------- */

.balken-liste {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.balken-zeile {
  display: grid;
  grid-template-columns: minmax(10rem, 22rem) minmax(0, 1fr) 5.5rem;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-s);
}
.balken-zeile:hover {
  background: var(--surface-2);
}

.balken-label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  line-height: 1.35;
}

.balken-zusatz {
  font-size: 0.76rem;
  color: var(--muted-2);
}

.balken-spur {
  display: block;
  height: 14px;
}

.balken-fuellung {
  display: block;
  height: 100%;
  background: var(--accent);
  /* Abgerundetes Datenende, am Nullpunkt verankert. */
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}

.balken-wert {
  text-align: right;
  font-family: var(--schrift-zahl);
  font-variant-numeric: tabular-nums;
  font-size: 0.86rem;
}

@media (max-width: 640px) {
  .balken-zeile {
    grid-template-columns: minmax(0, 1fr) 5rem;
  }
  .balken-spur {
    grid-column: 1 / -1;
    order: 3;
  }
}

/* --- Leerzustand --------------------------------------------------------- */

.leerzustand {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3.5rem 1.5rem;
  text-align: center;
  margin-top: 1.25rem;
}
.leerzustand h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}
.leerzustand p {
  max-width: 30rem;
  margin: 0 auto 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}
