:root {
  --bg: #f6f7f9;
  --flaeche: #ffffff;
  --rand: #dfe3e8;
  --text: #1c2530;
  --gedaempft: #64748b;
  --akzent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --fehler: #b91c1c;
  --fehler-bg: #fee2e2;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171f;
    --flaeche: #1a212b;
    --rand: #2c3644;
    --text: #e6ebf2;
    --gedaempft: #93a1b5;
    --akzent: #60a5fa;
    --ok: #86efac;
    --ok-bg: #14351f;
    --warn: #fcd34d;
    --warn-bg: #3a2f0b;
    --fehler: #fca5a5;
    --fehler-bg: #3d1618;
  }
}

* { box-sizing: border-box; }

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

/* ---------------------------------------------------------------- Kopfzeile */

.kopf {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 1.5rem;
  /* min-height statt height: bricht die Navigation auf schmalen Bildschirmen
     um, waechst die Leiste mit, statt den Inhalt darunter zu verdecken. */
  min-height: 54px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.marke { text-decoration: none; letter-spacing: -0.01em; display: flex; align-items: center; gap: 0.32rem; }
.marke-zeichen { display: block; flex: 0 0 auto; margin-right: 0.15rem; }
.marke .org {
  font-weight: 750;
  color: var(--akzent);
  letter-spacing: 0.01em;
}
.marke .produkt { font-weight: 550; color: var(--text); }

.kopf nav { display: flex; gap: 1rem; flex: 1; flex-wrap: wrap; }

.kopf nav a {
  color: var(--gedaempft);
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.kopf nav a:hover { color: var(--text); }
.kopf nav a.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); }

/* ------------------------------------------------------------- Kontomenü */

.konto { position: relative; }
.konto details { position: relative; }
.konto summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.3rem;
  border-radius: 6px;
}
.konto summary::-webkit-details-marker { display: none; }
.konto summary:hover { background: color-mix(in srgb, var(--gedaempft) 14%, transparent); }

.kuerzel {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--akzent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 650;
  flex: 0 0 auto;
}
.konto-name { font-size: 0.85rem; color: var(--text); }
@media (max-width: 720px) { .konto-name { display: none; } }

.konto-menue {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
  padding: 0.3rem;
  z-index: 30;
}
.konto-kopf {
  padding: 0.45rem 0.6rem 0.55rem;
  border-bottom: 1px solid var(--rand);
  margin-bottom: 0.3rem;
  display: flex; flex-direction: column; gap: 0.1rem;
}
.konto-menue a {
  display: block;
  padding: 0.42rem 0.6rem;
  border-radius: 5px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.konto-menue a:hover { background: color-mix(in srgb, var(--akzent) 12%, transparent); }
.konto-menue a.abmelden { color: var(--fehler); }

.leseband {
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.82rem;
  padding: 0.4rem 1.5rem;
  border-bottom: 1px solid var(--rand);
}

/* Partner darf durchaus etwas aendern - deshalb sachlich blau statt warnend gelb */
.leseband.partnerband {
  background: color-mix(in srgb, var(--akzent) 12%, transparent);
  color: var(--akzent);
}

/* --------------------------------------------------------- Anmeldeseite */

body.anmelde-seite {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1100px 500px at 50% -10%,
      color-mix(in srgb, var(--akzent) 14%, transparent), transparent),
    var(--bg);
}

.anmelde-rahmen { width: min(400px, calc(100vw - 2.5rem)); padding: 2rem 0; }

.anmelde-karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 14px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.12);
}

.anmelde-zeichen { display: block; margin-bottom: 0.85rem; }

.anmelde-marke {
  display: flex; align-items: baseline; gap: 0.4rem;
  font-size: 1.4rem; letter-spacing: -0.02em;
}
.anmelde-marke .org { font-weight: 750; color: var(--akzent); }
.anmelde-marke .produkt { font-weight: 550; }

.anmelde-zweck {
  color: var(--gedaempft);
  font-size: 0.85rem;
  margin: 0.3rem 0 1.6rem;
}

/* Passwortfeld mit Umschalter zum Einblenden */

.passwortfeld { position: relative; display: flex; align-items: center; }

/* Platz fuer den Schalter, damit lange Passwoerter nicht darunter laufen.
   Die Typ-Selektoren sind noetig, nicht kosmetisch: die allgemeine Regel fuer
   Eingabefelder steht weiter unten in dieser Datei und wuerde bei gleicher
   Spezifitaet gewinnen. Beide Typen, weil der Schalter zwischen 'password'
   und 'text' umschaltet. */
.passwortfeld input[type="password"],
.passwortfeld input[type="text"] { padding-right: 5.2rem; }

.passwort-schalter {
  position: absolute;
  right: 4px;
  background: transparent;
  color: var(--gedaempft);
  border: 0;
  border-radius: 5px;
  padding: 0.3rem 0.5rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  width: auto;
}
.passwort-schalter:hover { color: var(--akzent); background: color-mix(in srgb, var(--akzent) 12%, transparent); }
.passwort-schalter:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }

.anmelde-fuss {
  color: var(--gedaempft);
  font-size: 0.78rem;
  text-align: center;
  margin: 1.1rem auto 0;
  max-width: 34ch;
  line-height: 1.5;
}

/* ------------------------------------------------------ Zugänge-Verwaltung */

details.bearbeiten, .bearbeiten { margin-top: 0.6rem; }
summary.mini-link {
  cursor: pointer;
  color: var(--akzent);
  font-size: 0.82rem;
  list-style: none;
}
summary.mini-link::-webkit-details-marker { display: none; }
summary.mini-link:hover { text-decoration: underline; }
td details[open] summary.mini-link { margin-bottom: 0.5rem; }
td details { min-width: 260px; }

main { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.4rem; margin: 0 0 1.25rem; font-weight: 620; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 0.75rem; font-weight: 600; }
h3 { font-size: 0.92rem; margin: 1.1rem 0 0.5rem; font-weight: 600; color: var(--gedaempft); }

/* ------------------------------------------------------------------ Bausteine */

.karten { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.85rem; }

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.karte .wert { font-size: 1.7rem; font-weight: 600; letter-spacing: -0.02em; }
.karte .label { color: var(--gedaempft); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.karte .zusatz { color: var(--gedaempft); font-size: 0.82rem; margin-top: 0.15rem; }

.karte.ok .wert { color: var(--ok); }
.karte.warn .wert { color: var(--warn); }
.karte.fehler .wert { color: var(--fehler); }

.block {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.zeile { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.rechts { margin-left: auto; }
.spalten2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .spalten2 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ Tabellen */

.tabellen-rahmen { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--rand); vertical-align: top; }
th { color: var(--gedaempft); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--akzent) 6%, transparent); }
td a { color: var(--akzent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* -------------------------------------------------------------------- Marken */

.marker {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.marker.ok { background: var(--ok-bg); color: var(--ok); }
.marker.warn { background: var(--warn-bg); color: var(--warn); }
.marker.fehler { background: var(--fehler-bg); color: var(--fehler); }
.marker.neutral { background: color-mix(in srgb, var(--gedaempft) 18%, transparent); color: var(--gedaempft); }

/* ----------------------------------------------------------- Formularelemente */

button, .knopf {
  background: var(--akzent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .knopf:hover { filter: brightness(1.08); }
button.still, .knopf.still { background: transparent; color: var(--akzent); border: 1px solid var(--rand); }

input[type=text], input[type=number], input[type=password], textarea, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 0.42rem 0.6rem;
  font: inherit;
  font-size: 0.88rem;
  width: 100%;
}
textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.82rem; line-height: 1.5; }
label { display: block; font-size: 0.8rem; color: var(--gedaempft); margin-bottom: 0.2rem; }
.feld { margin-bottom: 0.8rem; }

.hinweis {
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 6px;
  padding: 0.55rem 0.8rem;
  font-size: 0.86rem;
  margin-top: 0.75rem;
}
.hinweis.fehler { background: var(--fehler-bg); color: var(--fehler); }

.gedaempft { color: var(--gedaempft); }
.klein { font-size: 0.82rem; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.82rem; }

pre.code {
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 0.75rem;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  max-height: 460px;
}

/* ------------------------------------------------- Gegenüberstellung Original */

.bloecke { display: flex; flex-direction: column; gap: 0.35rem; max-height: 620px; overflow-y: auto; }

.bloeck {
  border-left: 3px solid var(--rand);
  padding: 0.3rem 0.55rem;
  font-size: 0.84rem;
  border-radius: 0 4px 4px 0;
}
.bloeck .nr { color: var(--gedaempft); font-size: 0.72rem; font-family: ui-monospace, Consolas, monospace; }
.bloeck.ueberschrift { font-weight: 620; border-left-color: var(--akzent); }
.bloeck.offen { background: var(--warn-bg); border-left-color: var(--warn); }

.abschnitt { margin-bottom: 0.9rem; }
.abschnitt .titel { font-weight: 600; font-size: 0.82rem; color: var(--gedaempft); text-transform: uppercase; letter-spacing: 0.03em; }
.abschnitt ul { margin: 0.3rem 0 0; padding-left: 1.1rem; }
.abschnitt li { margin-bottom: 0.15rem; font-size: 0.86rem; }
.abschnitt p { margin: 0.25rem 0 0; font-size: 0.86rem; }
.abschnitt.leer .titel { opacity: 0.5; }

.balken { height: 6px; background: var(--rand); border-radius: 99px; overflow: hidden; min-width: 70px; }
.balken > span { display: block; height: 100%; background: var(--ok); }
.balken.warn > span { background: var(--warn); }
.balken.fehler > span { background: var(--fehler); }
.balken.gross-balken { height: 10px; }

/* ================================================================ Datenfluss
   Startseite: drei Stufen nebeneinander, Pfeile dazwischen. Auf schmalen
   Bildschirmen untereinander, Pfeile drehen sich mit.                        */

.unterzeile { color: var(--gedaempft); margin: -0.6rem 0 1.4rem; max-width: 62ch; }

.fluss {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 980px) {
  .fluss { grid-template-columns: 1fr; }
  .fluss .pfeil { transform: rotate(90deg); padding: 0.15rem 0; }
}

.stufe {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
}

.stufe.mitte { border-color: color-mix(in srgb, var(--akzent) 45%, var(--rand)); }

.stufe-kopf { display: flex; gap: 0.7rem; align-items: flex-start; margin-bottom: 0.9rem; }
.stufe-kopf h2 { margin: 0; font-size: 1rem; font-weight: 620; }
.stufe-sub { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--gedaempft); }

.stufe-nr {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--akzent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 0.82rem; font-weight: 700;
}

.pfeil {
  display: grid;
  place-items: center;
  color: var(--gedaempft);
  font-size: 1.5rem;
  padding: 0 0.15rem;
  opacity: 0.65;
}

.quelle-karte {
  background: var(--bg);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  margin-bottom: 0.85rem;
}
.quelle-karte + .quelle-karte { margin-top: -0.2rem; }

.gross { font-size: 2.1rem; font-weight: 640; letter-spacing: -0.03em; line-height: 1.15; margin-top: 0.55rem; }
.gross .von { font-size: 1.1rem; font-weight: 500; color: var(--gedaempft); margin-left: 0.15rem; }
.gross-label { color: var(--gedaempft); font-size: 0.8rem; margin-bottom: 0.7rem; }

dl.werte { display: grid; grid-template-columns: auto 1fr; gap: 0.28rem 0.8rem; margin: 0; font-size: 0.83rem; }
dl.werte dt { color: var(--gedaempft); }
dl.werte dd { margin: 0; text-align: right; }

.mess { margin: 0.35rem 0 0.85rem; }

.erklaerung {
  font-size: 0.83rem;
  color: var(--gedaempft);
  line-height: 1.5;
  margin: 0 0 0.9rem;
  flex: 1;
}

.adresse { margin: 0.2rem 0 0.85rem; }
.kopier { display: flex; gap: 0.4rem; align-items: center; }
.kopier code {
  flex: 1;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.74rem;
  overflow-x: auto;
  white-space: nowrap;
}

button.mini, .mini {
  font-size: 0.74rem;
  padding: 0.3rem 0.5rem;
  background: transparent;
  color: var(--akzent);
  border: 1px solid var(--rand);
}

button.voll, .knopf.voll { width: 100%; text-align: center; margin-top: auto; }

/* --------------------------------------------------------- Auffälligkeiten */

.problem {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1.1rem;
  font-size: 0.87rem;
  border-bottom: 1px solid var(--rand);
}
.problem:last-child { border-bottom: 0; }
.problem .punkt { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.problem.warnung .punkt { background: var(--warn); }
.problem.fehler .punkt { background: var(--fehler); }
.problem a { color: var(--akzent); text-decoration: none; white-space: nowrap; font-size: 0.83rem; }
.problem a:hover { text-decoration: underline; }

/* ------------------------------------------------- Fortschritt bei KI-Läufen */

.fortschritt { margin-top: 0.9rem; }

.schrittliste { list-style: none; margin: 0 0 0.6rem; padding: 0; }
.schrittliste li {
  font-size: 0.85rem;
  padding: 0.2rem 0;
  color: var(--gedaempft);
}
.schrittliste li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.schrittliste li.fehler { color: var(--fehler); }
.schrittliste li.fehler::before { content: "✗ "; color: var(--fehler); }

.schritt-laeuft {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.86rem;
  padding: 0.5rem 0.75rem;
  background: color-mix(in srgb, var(--akzent) 10%, transparent);
  border-radius: 6px;
}

.spinner {
  width: 14px; height: 14px;
  flex: 0 0 auto;
  border: 2px solid color-mix(in srgb, var(--akzent) 30%, transparent);
  border-top-color: var(--akzent);
  border-radius: 50%;
  animation: dreh 0.7s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }

/* Rücksicht auf Nutzer, die Bewegung im Betriebssystem abgeschaltet haben */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.5s; }
}

button:disabled, button[disabled] { opacity: 0.55; cursor: progress; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { display: block; }
