/* Belegwerk — Designsystem "Fintech Back-Office"
   Dunkle Marine-Sidebar, kühle Arbeitsfläche, Soft-Pill-Status, Plex Mono für Zahlen.
   Kein Framework, keine Toolchain — pures CSS. */

:root {
  --nacht: #0f1729;          /* Sidebar */
  --nacht-hell: #1c2740;     /* Sidebar hover/aktiv */
  --nacht-text: #aeb8cc;     /* Sidebar Sekundärtext */
  --bg: #f3f5f8;             /* Arbeitsfläche */
  --surface: #ffffff;
  --ink: #17202b;
  --ink-2: #5a6572;
  --line: #e1e6ec;
  --line-2: #ccd4dd;
  --brand: #1e5edb;
  --brand-tief: #1749ac;
  --brand-flaeche: #eaf1fd;
  --gruen: #157a55;
  --gruen-flaeche: #e3f2eb;
  --amber: #9a6a0a;
  --amber-flaeche: #faf0d8;
  --rot: #c03e2f;
  --rot-flaeche: #fbe9e6;
  --grau: #66707b;
  --grau-flaeche: #eceff2;
  --radius: 8px;
  --radius-s: 6px;
  --schatten: 0 1px 2px rgba(15, 23, 41, 0.05);
  --schatten-hoch: 0 8px 28px rgba(15, 23, 41, 0.14);
  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, "Cascadia Mono", monospace;
  --sidebar-b: 244px;
  --topbar-h: 54px;
}

* { box-sizing: border-box; }
html { font-size: 14.5px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ Grundgerüst ============ */
.rahmen { display: flex; min-height: 100vh; }

main.inhalt {
  flex: 1;
  min-width: 0;                 /* erlaubt Tabellen-Scroll statt Seiten-Overflow */
  padding: 1.8rem 2.2rem 4rem;
  max-width: 1360px;
}

/* ============ Sidebar ============ */
.seitenleiste {
  width: var(--sidebar-b);
  flex-shrink: 0;
  background: var(--nacht);
  color: #fff;
  padding: 1.1rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.wortmarke {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.2rem 0.45rem;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #fff;
}
.logo-mark {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--brand);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
}
.wortmarke small {
  display: block;
  font-weight: 400;
  font-size: 0.66rem;
  color: var(--nacht-text);
  letter-spacing: 0.02em;
}

.kontextwahl {
  display: grid;
  gap: 0.45rem;
  padding: 0.7rem 0.55rem;
  background: var(--nacht-hell);
  border-radius: var(--radius);
}
.kontextwahl label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--nacht-text);
}
.kontextwahl select {
  width: 100%;
  font: inherit;
  font-size: 0.86rem;
  padding: 0.38rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-s);
  background: var(--nacht);
  color: #fff;
}

nav.hauptnav { display: flex; flex-direction: column; gap: 2px; }
nav.hauptnav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-s);
  color: var(--nacht-text);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
nav.hauptnav a svg { flex-shrink: 0; opacity: 0.75; }
nav.hauptnav a:hover { background: var(--nacht-hell); color: #fff; }
nav.hauptnav a.aktiv {
  background: var(--brand);
  color: #fff;
}
nav.hauptnav a.aktiv svg { opacity: 1; }

.seitenfuss {
  margin-top: auto;
  padding: 0.6rem 0.55rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 0.7rem;
  line-height: 1.6;
  color: var(--nacht-text);
}

/* ============ Mobile Topbar + Drawer ============ */
.topbar { display: none; }
#nav-toggle { display: none; }
.drawer-backdrop { display: none; }

@media (max-width: 920px) {
  .rahmen { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    height: var(--topbar-h);
    padding: 0 1rem;
    background: var(--nacht);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .topbar .wortmarke { padding: 0; font-size: 1rem; }
  .hamburger {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    margin-left: -0.5rem;
    border-radius: var(--radius-s);
    cursor: pointer;
    color: #fff;
  }
  .hamburger:hover { background: var(--nacht-hell); }

  .seitenleiste {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--schatten-hoch);
  }
  #nav-toggle:checked ~ .seitenleiste { transform: translateX(0); }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 23, 41, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  #nav-toggle:checked ~ .drawer-backdrop { opacity: 1; pointer-events: auto; }

  main.inhalt { padding: 1.1rem 1rem 3rem; }
}

/* ============ Typografie ============ */
h1 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  margin: 0 0 0.2rem;
}
.untertitel { color: var(--ink-2); margin: 0 0 1.4rem; font-size: 0.94rem; }
h2 {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 2rem 0 0.7rem;
}

.seitenkopf {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ============ Meldungen ============ */
.meldung {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-s);
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
  border: 1px solid;
}
.meldung.ok { background: var(--gruen-flaeche); border-color: #bfe0d1; color: var(--gruen); }
.meldung.fehler { background: var(--rot-flaeche); border-color: #efc4bd; color: var(--rot); }

/* ============ Status-Pills ============ */
.stempel {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.74rem;
  font-weight: 550;
  padding: 0.16rem 0.6rem;
  border-radius: 99px;
  white-space: nowrap;
}
.stempel::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 99px;
  background: currentColor;
}
.stempel.rot { color: var(--rot); background: var(--rot-flaeche); }
.stempel.bernstein { color: var(--amber); background: var(--amber-flaeche); }
.stempel.gruen { color: var(--gruen); background: var(--gruen-flaeche); }
.stempel.grau { color: var(--grau); background: var(--grau-flaeche); }

/* ============ Hero: Belegstand + Journalleiste ============ */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 1.1rem 1.3rem 1rem;
  margin-bottom: 1.2rem;
}
.hero-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}
.hero-kopf h2 { margin: 0; font-size: 0.86rem; color: var(--ink-2); font-weight: 550; text-transform: uppercase; letter-spacing: 0.08em; }
.hero-wert {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hero-wert small { font-size: 0.85rem; color: var(--ink-2); font-family: var(--font-ui); font-weight: 400; }

.journalleiste {
  display: flex;
  gap: 1px;
  height: 36px;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--bg);
}
.journalleiste a {
  flex: 1;
  min-width: 2px;
  transition: opacity 0.1s;
}
.journalleiste a:hover { opacity: 0.72; }
.journalleiste a.s-offen { background: var(--rot); }
.journalleiste a.s-vorschlag { background: var(--amber); }
.journalleiste a.s-gematcht, .journalleiste a.s-dummy { background: var(--gruen); }
.journalleiste a.s-ignoriert { background: var(--line-2); }
.journal-legende {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  font-size: 0.76rem;
  color: var(--ink-2);
}
.journal-legende i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 0.32rem;
}
@media (max-width: 920px) {
  .journalleiste { gap: 0; }
  .journalleiste a { min-width: 1px; }
}

/* ============ KPI-Kacheln ============ */
.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}
.kennzahl {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 0.75rem 0.95rem;
  border-top: 3px solid var(--line-2);
}
.kennzahl.k-rot { border-top-color: var(--rot); }
.kennzahl.k-bernstein { border-top-color: var(--amber); }
.kennzahl.k-gruen { border-top-color: var(--gruen); }
.kennzahl.k-grau { border-top-color: var(--grau); }
.kennzahl.k-brand { border-top-color: var(--brand); }
.kennzahl b {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.kennzahl span {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--ink-2);
}
a.kennzahl { text-decoration: none; color: inherit; }
a.kennzahl:hover { border-color: var(--line-2); box-shadow: var(--schatten-hoch); }

/* ============ Karten & Buttons ============ */
.karte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 1.1rem 1.3rem;
}
.aktionszeile { display: flex; gap: 0.55rem; flex-wrap: wrap; align-items: center; }

button, .knopf {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.46rem 0.95rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
button:hover, .knopf:hover { border-color: var(--ink-2); background: #fafbfc; }
button.primaer, .knopf.primaer {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
button.primaer:hover, .knopf.primaer:hover { background: var(--brand-tief); border-color: var(--brand-tief); }
button.klein, .knopf.klein { font-size: 0.79rem; padding: 0.28rem 0.65rem; }
button.gruenknopf { border-color: #bfe0d1; color: var(--gruen); background: var(--gruen-flaeche); }
button.gruenknopf:hover { background: var(--gruen); border-color: var(--gruen); color: #fff; }
button.rotknopf { border-color: #efc4bd; color: var(--rot); background: var(--rot-flaeche); }
button.rotknopf:hover { background: var(--rot); border-color: var(--rot); color: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .hamburger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* Arbeitsschritte als Prozesskette */
.prozess {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.55rem;
}
.prozess form { display: contents; }
.prozess button {
  width: 100%;
  justify-content: flex-start;
  padding: 0.55rem 0.8rem;
}
.prozess .schritt-nr {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  width: 20px; height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.prozess button:hover .schritt-nr { border-color: var(--line-2); }

/* ============ Tabellen ============ */
.tabellen-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  background: var(--surface);
}
table.journal {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.88rem;
}
table.journal th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-2);
  font-weight: 600;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line-2);
  background: #f8fafc;
  position: sticky;
  top: 0;
}
table.journal td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.journal tbody tr:last-child td { border-bottom: none; }
table.journal tbody tr:hover { background: #f6f8fb; }
table.journal tr.klickbar { cursor: pointer; }

.zahl {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.zahl.negativ { color: var(--rot); }
.mono { font-family: var(--font-mono); font-size: 0.8rem; }
.gedimmt { color: var(--ink-2); }
.klein { font-size: 0.8rem; }

/* Spalten mit niedriger Priorität auf schmalen Screens ausblenden */
@media (max-width: 700px) {
  .sp-schmal { display: none; }
  table.journal { min-width: 480px; }
}

/* ============ Detailzeile ============ */
tr.detailzeile > td {
  background: #f6f8fb;
  border-bottom: 2px solid var(--line-2);
  padding: 1rem 1.2rem 1.3rem;
}
.detail-raster {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 1fr);
  gap: 1.4rem;
}
@media (max-width: 1100px) { .detail-raster { grid-template-columns: 1fr; } }
.detail-block h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.belegrahmen {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  background: #fff;
  width: 100%;
  height: 420px;
}
.kandidat {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
  box-shadow: var(--schatten);
}
.kandidat.aktiv-match { border-left: 3px solid var(--gruen); }
.kandidat .scorezeile {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--ink-2);
  font-family: var(--font-mono);
  margin: 0.3rem 0 0.5rem;
}
.score-punkt {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--brand);
  margin-right: 0.3rem;
}

/* ============ Formulare & Filter ============ */
input[type="text"], input[type="search"], input[type="date"], input[type="file"], input[type="password"], select, textarea {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
}
textarea.yaml {
  width: 100%;
  min-height: 380px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  tab-size: 2;
}
.formzeile { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }

.filterzeile {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.filterzeile a {
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
}
.filterzeile a:hover { border-color: var(--ink-2); }
.filterzeile a.aktiv { background: var(--nacht); color: #fff; border-color: var(--nacht); }
.filter-suche { margin-left: auto; }
@media (max-width: 700px) {
  .filter-suche { margin-left: 0; width: 100%; }
  .filter-suche input[type="search"] { flex: 1; }
}

.leer {
  text-align: center;
  color: var(--ink-2);
  padding: 3rem 1rem;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
}

.todoliste { list-style: none; padding: 0; margin: 0; }
.todoliste li {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}
.todoliste li:last-child { border-bottom: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ============ Benutzerverwaltung ============ */
.karten-titel {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.9rem;
  letter-spacing: -0.01em;
}

.benutzer-karte { margin-bottom: 1rem; }

/* Rechte-Raster: feste Spaltenbreite statt gleichmäßiger Verteilung — sonst
   springen die Checkboxen je nach Beschriftungslänge in andere Spalten. */
.rechte-raster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.15rem 0.7rem;
  padding: 0.75rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}

.recht {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.35rem;
  border-radius: var(--radius-s);
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
}
.recht:hover { background: var(--surface); }
.recht input { accent-color: var(--brand); width: 15px; height: 15px; cursor: pointer; }
.recht input:checked + span { font-weight: 550; color: var(--ink); }
.recht span { color: var(--ink-2); }

.benutzer-fuss {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.benutzer-fuss .formzeile { margin: 0; flex: 1 1 280px; }
.benutzer-fuss .formzeile input { flex: 1 1 200px; }

/* Anlegen-Formular: beide Felder gleich breit, Passwort-Platzhalter passt sonst
   nicht ins Feld. */
.neuer-benutzer { margin-bottom: 0.9rem; }
.neuer-benutzer input { flex: 1 1 220px; min-width: 200px; }

button.gefahr {
  color: var(--rot);
  border-color: #efc4bd;
  background: var(--rot-flaeche);
}
button.gefahr:hover { background: #f8ddd8; }
