/*
 * ESV-Tool – Gestaltung im Stil der Immoverwaltung (Anthrazit, Creme, Gold).
 *
 * Farben stehen NUR in den beiden Variablenblöcken (:root = dunkel, Standard;
 * [data-thema="hell"]). Alle Regeln darunter verwenden ausschließlich Variablen.
 * Der Server setzt data-thema aus dem Cookie esv_thema (frontend/thema.js).
 * Kontraste prüft tests/test_oberflaeche.py nach WCAG 2.x.
 * Die Grundbausteine sind in frontend/BAUSTEINE.md beschrieben.
 */

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

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/schriften/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/schriften/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/schriften/playfair-display-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/schriften/playfair-display-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------ Variablen */

/* Dunkler Modus (Standard) und Grundfarben der Immoverwaltung */
:root {
  color-scheme: dark;

  /* Grundfarben (wörtlich aus der Immoverwaltung) */
  --anthrazit: #1a1a1f;
  --anthrazit-mittel: #222228;
  --anthrazit-hell: #2a2a32;
  --creme: #f5f0e8;
  --creme-karte: #fbf8f3;
  --gold: #c9a84c;
  --gold-hell: #e0c56e;
  --gold-dunkel: #a88a35;
  --gold-text-hell: #7a6324;
  --gedaempft-dunkel: #b5b5be;
  --gedaempft-hell: #5e5e68;
  --ok-dunkel: #8fc9a1;
  --ok-hell: #2f6b45;
  --warnung-dunkel: #e8897f;
  --warnung-hell: #a3362c;

  /* Schriften */
  --schrift-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --schrift-titel: "Playfair Display", Georgia, "Times New Roman", serif;
  --schrift-mono: ui-monospace, "SF Mono", Menlo, monospace;

  /* Flächen */
  --flaeche: var(--anthrazit);
  --flaeche-tief: var(--anthrazit-hell);
  --karte: var(--anthrazit-mittel);
  --karte-erhoben: var(--anthrazit-hell);

  /* Text */
  --text: var(--creme);
  --text-gedaempft: var(--gedaempft-dunkel);
  --gold-text: var(--gold);

  /* Akzent (Gold als Fläche und Linie) */
  --akzent: var(--gold);
  --akzent-hell: var(--gold-hell);
  --akzent-dunkel: var(--gold-dunkel);
  --auf-akzent: var(--anthrazit);
  --akzent-hauch: rgb(201 168 76 / 0.08);

  /* Ränder und Fokus */
  --rand: rgb(201 168 76 / 0.18);
  --rand-feld: rgb(245 240 232 / 0.4);
  --fokus: var(--gold);

  /* Status */
  --ok: var(--ok-dunkel);
  --offen: var(--gold-hell);
  --warnung: var(--warnung-dunkel);
  --auf-warnung: var(--anthrazit);

  /* Schatten und Abdeckung hinter Dialogen */
  --schatten: rgb(0 0 0 / 0.35);
  --abdeckung: rgb(0 0 0 / 0.6);

  /* Diagramme (gelesen über ESV.farbe) */
  --diagramm-1: var(--gold);
  --diagramm-2: var(--gedaempft-dunkel);
  --diagramm-text: var(--gedaempft-dunkel);
  --diagramm-raster: rgb(201 168 76 / 0.18);
}

/* Heller Modus: Creme */
[data-thema="hell"] {
  color-scheme: light;

  --flaeche: var(--creme);
  --flaeche-tief: var(--creme);
  --karte: var(--creme-karte);
  --karte-erhoben: var(--creme-karte);

  --text: var(--anthrazit);
  --text-gedaempft: var(--gedaempft-hell);
  --gold-text: var(--gold-text-hell);

  --akzent: var(--gold);
  --akzent-hell: var(--gold-hell);
  --akzent-dunkel: var(--gold-dunkel);
  --auf-akzent: var(--anthrazit);
  --akzent-hauch: rgb(168 138 53 / 0.1);

  --rand: rgb(168 138 53 / 0.28);
  --rand-feld: rgb(26 26 31 / 0.5);
  --fokus: var(--gold-text-hell);

  --ok: var(--ok-hell);
  --offen: var(--gold-text-hell);
  --warnung: var(--warnung-hell);
  --auf-warnung: var(--creme);

  --schatten: rgb(26 26 31 / 0.1);
  --abdeckung: rgb(26 26 31 / 0.45);

  --diagramm-1: var(--gold-text-hell);
  --diagramm-2: var(--gedaempft-hell);
  --diagramm-text: var(--gedaempft-hell);
  --diagramm-raster: rgb(168 138 53 / 0.28);
}

/* ---------------------------------------------------------------- Basis */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--flaeche);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--schrift-text);
  font-size: 0.875rem;
  line-height: 1.5;
  background: var(--flaeche);
  color: var(--text);
  accent-color: var(--akzent);
  /* Lange Wörter (Namen, E-Mail-Adressen, Dateinamen) brechen um, statt die Seite zu verbreitern */
  overflow-wrap: break-word;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  font-family: var(--schrift-titel);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text);
}

a {
  color: var(--gold-text);
}

td,
.zahl {
  font-variant-numeric: tabular-nums;
}

/* Beträge brechen nie um */
.zahl {
  white-space: nowrap;
}

code {
  font-family: var(--schrift-mono);
}

img {
  max-width: 100%;
}

/* Eingabefelder überall im Farbmodus */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--karte);
  border: 1px solid var(--rand-feld);
  border-radius: 6px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-gedaempft);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
  background: var(--flaeche-tief);
  color: var(--text-gedaempft);
}

/* Sichtbarer Fokus in Gold auf allen Bedienelementen */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.upload-bereich:focus-visible {
  outline: 2px solid var(--fokus);
  outline-offset: 2px;
}

/* Zum Inhalt springen: erster Tabulator-Halt, nur bei Fokus sichtbar */
.sprunglink {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  background: var(--akzent);
  color: var(--auf-akzent);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}

.sprunglink:focus {
  top: 0.75rem;
}

/* Nur je Bildschirmbreite sichtbar (schmal = unter 760 px) */
@media (min-width: 760px) {
  .nur-schmal {
    display: none !important;
  }
}

/* Teile der Kopfzeile: Menüknopf und aufgeklappte Einstellungen erst unter 900 px */
@media (min-width: 900px) {
  .nur-kopf-schmal {
    display: none !important;
  }
}

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

.kopfzeile {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--flaeche);
}

.kopfzeile-innen {
  max-width: 1400px;
  margin: 0 auto;
  height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kopfzeile-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.kopfzeile-logo img {
  display: block;
  height: 34px;
  width: auto;
}

.hauptmenue-liste {
  list-style: none;
  display: flex;
  gap: 2px;
}

.hauptmenue a,
.einstellungen-liste a {
  display: block;
  color: var(--text-gedaempft);
  text-decoration: none;
  font-size: 0.84375rem;
  padding: 8px 9px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.hauptmenue a:hover,
.einstellungen-liste a:hover {
  color: var(--text);
}

.hauptmenue a.aktiv,
.einstellungen-liste a.aktiv {
  color: var(--gold-text);
}

/* Aktive Seite: feine Gold-Linie unter dem Menüpunkt */
.hauptmenue-liste a.aktiv::after {
  content: "";
  display: block;
  height: 1px;
  background: var(--akzent);
  margin-top: 4px;
}

.hauptmenue-titel {
  font-size: 0.75rem;
  color: var(--text-gedaempft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 9px 4px;
  border-top: 1px solid var(--rand);
  margin-top: 8px;
}

.hauptmenue-einstellungen {
  list-style: none;
}

/* Zähler am Menüpunkt „Zahlungen“ (Plakette) */
.nav-zaehler {
  display: inline-block;
  min-width: 1.15rem;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--akzent);
  color: var(--auf-akzent);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.15rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.nav-zaehler[hidden] {
  display: none;
}

.kopfzeile-rechts {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.symbolknopf {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-gedaempft);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.symbolknopf:hover,
.symbolknopf.aktiv,
.symbolknopf[aria-expanded="true"] {
  color: var(--gold-text);
}

.symbolknopf:hover {
  background: var(--akzent-hauch);
}

.symbol {
  display: block;
}

/* Umschalter: im dunklen Modus die Sonne, im hellen den Mond zeigen */
.symbol-mond,
[data-thema="hell"] .symbol-sonne {
  display: none;
}

[data-thema="hell"] .symbol-mond {
  display: block;
}

.symbol-schliessen,
.menueknopf[aria-expanded="true"] .symbol-menue {
  display: none;
}

.menueknopf[aria-expanded="true"] .symbol-schliessen {
  display: block;
}

/* Zahnrad-Menü */
.einstellungen {
  position: relative;
}

.einstellungen-liste {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 13rem;
  list-style: none;
  padding: 6px;
  background: var(--karte-erhoben);
  border: 1px solid var(--rand);
  border-radius: 8px;
  box-shadow: 0 10px 30px var(--schatten);
  z-index: 50;
}

.einstellungen-liste[hidden] {
  display: none;
}

/* Feine Gold-Linie unter der Kopfzeile */
.goldlinie {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--akzent), transparent);
  opacity: 0.6;
}

/* ------------------------------------------------------- Seitenrahmen */

main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 24px 30px;
  flex: 1;
}

.fusszeile {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-gedaempft);
  font-size: 0.8rem;
}

/* ============================================================ Bausteine */

/* Seitenkopf: Titel in Playfair, Untertitel, Hauptaktion rechts */
.seitenkopf {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.seitenkopf h1 {
  font-size: 1.625rem;
  line-height: 1.2;
}

.seitenkopf-unter {
  color: var(--text-gedaempft);
  font-size: 0.8125rem;
  margin-top: 4px;
}

.seitenkopf-aktionen {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Kachelreihe */
.kacheln,
.kennzahlen {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kachel,
.kennzahl {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 14px 16px;
}

.kachel-titel,
.kennzahl .label {
  font-size: 0.75rem;
  color: var(--text-gedaempft);
}

.kachel-wert,
.kennzahl .wert {
  font-size: 1.3125rem;
  white-space: nowrap;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.kachel-wert.warnung {
  color: var(--warnung);
}

.kachel-meta,
.kennzahl-meta {
  font-size: 0.75rem;
  color: var(--text-gedaempft);
  margin-top: 4px;
}

.kennzahlen.kennzahlen-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* Kachel als Link zur gefilterten Liste; .kacheln-5 für eine fünfte Kachel */
a.kachel {
  display: block;
  color: var(--text);
  text-decoration: none;
}

a.kachel:hover {
  border-color: var(--akzent);
}

.kachel[hidden] {
  display: none;
}

.kacheln.kacheln-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* Abschnitt einer Seite: Titel in Playfair, Teile mit kleinem Titel, Weiter-Link */
.abschnitt {
  margin-bottom: 24px;
}

.abschnitt > h2 {
  font-size: 1.125rem;
  margin-bottom: 10px;
}

.abschnitt-teil + .abschnitt-teil {
  margin-top: 16px;
}

.abschnitt-teil h3 {
  font-family: var(--schrift-text);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-gedaempft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

.abschnitt-karte {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 14px 16px;
}

/* Abschnittskopf mit Titel links und einer Aktion rechts (z. B. „Auf Standard zurücksetzen“) */
.abschnitt-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.abschnitt-kopf h2 {
  font-size: 1.125rem;
}

/* Aktionen am Ende eines Seitenformulars (z. B. „Stammdaten speichern“) */
.formular-aktionen {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

/* E-Mail-Vorlagen: Vorschau mit Beispielwerten (reiner Text) */
.mail-vorschau {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--flaeche-tief);
  border: 1px solid var(--rand);
  border-radius: 6px;
}

.mail-vorschau h3 {
  font-family: var(--schrift-text);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-gedaempft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

.mail-vorschau-betreff {
  font-weight: 600;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.mail-vorschau-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.875rem;
}

.abschnitt-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--gold-text);
  text-decoration: none;
}

a.abschnitt-link:hover {
  text-decoration: underline;
}

/* Diagramm mit aufklappbarer Texttabelle der Werte */
.diagramm-flaeche {
  position: relative;
  height: 180px;
  margin-top: 8px;
}

/* Sichtbare Beschriftung vor einer Auswahl in der Filterzeile */
.auswahl-beschriftung {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-gedaempft);
  font-size: 0.8125rem;
}

/* Gesamtsumme unter einem Abschnitt */
.zu-erstatten-summe {
  margin-top: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.diagramm-flaeche.diagramm-hoch {
  height: 280px;
}

.diagramm-tabelle {
  margin-top: 10px;
}

.diagramm-tabelle summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--gold-text);
}

.diagramm-tabelle .tabelle-wrapper {
  margin-top: 8px;
}

/* Filterzeile: Suchfeld, Status-Chips, Auswahl */
.filter-leiste {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-leiste input[type="search"],
.filter-leiste input[type="date"],
.filter-leiste select,
.suchfeld,
.auswahl {
  padding: 8px 11px;
  font-size: 0.8125rem;
}

.filter-leiste input[type="search"],
.suchfeld {
  flex: 1;
  min-width: 160px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font: inherit;
  font-size: 0.78125rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--rand);
  background: transparent;
  color: var(--text-gedaempft);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

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

.chip[aria-pressed="true"],
.chip.an {
  border-color: var(--akzent);
  color: var(--gold-text);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
}

/* Tabelle */
.tabelle-wrapper {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  overflow-x: auto;
}

.datentabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84375rem;
}

.datentabelle th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--text-gedaempft);
  border-bottom: 1px solid var(--rand);
}

.datentabelle td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}

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

.datentabelle tbody tr:hover {
  background: var(--akzent-hauch);
}

.datentabelle td.zahl,
.datentabelle th.zahl,
.datentabelle td.rechts,
.datentabelle th.rechts {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.datentabelle code {
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
}

.datentabelle .leer {
  text-align: center;
  color: var(--text-gedaempft);
  padding: 2rem;
  font-style: italic;
}

.datentabelle .aktion-spalte {
  white-space: nowrap;
  width: 1%;
}

.datentabelle td.aktionen .btn-mini {
  margin: 0 0.25rem 0.25rem 0;
}

.datentabelle tfoot td,
.datentabelle tfoot th {
  background: var(--flaeche-tief);
  border-bottom: none;
  border-top: 1px solid var(--rand);
}

/* Zeilenköpfe (erste Zelle einer Werte-Tabelle) sehen aus wie Zellen */
.datentabelle th[scope="row"] {
  padding: 11px 14px;
  font-size: inherit;
  color: var(--text);
}

.klein {
  color: var(--text-gedaempft);
  font-size: 0.75rem;
}

/* Kartenliste (schmale Ansicht) */
.karten-liste {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.karte-zeile {
  display: block;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  text-decoration: none;
}

a.karte-zeile:hover {
  border-color: var(--akzent);
}

.karte-zeile-oben,
.karte-zeile-unten {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.karte-zeile-oben {
  font-size: 0.875rem;
}

.karte-zeile-oben .zahl {
  white-space: nowrap;
}

/* Lange Namen brechen um, statt die Karte zu verbreitern */
.karte-zeile-oben > :first-child,
.karte-zeile-unten > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.karte-zeile-unten {
  margin-top: 6px;
}

/* Knöpfe einer Karte (nicht anklickbare Karte li.karte-zeile) */
.karte-zeile-aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.karte-zeile-aktionen .btn-mini {
  margin-right: 0;
}

/* „Löschen“ abgesetzt vom Bezahlt-Schalter: in der Karte am rechten Rand, in der Tabelle mit Abstand */
.karte-zeile-aktionen .aktion-loeschen {
  margin-left: auto;
}

.datentabelle .aktion-loeschen {
  margin-left: 1rem;
}

/* Formularraster (einspaltig unter 760 px) */
.formular-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.formular-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
  font-weight: 500;
}

/* Ausgeblendete Felder (z. B. Rhythmus-Felder einer nicht wiederkehrenden Vorlage) */
.formular-grid label[hidden] {
  display: none;
}

.formular-grid label.span-2 {
  grid-column: span 2;
}

.formular-grid input,
.formular-grid select,
.formular-grid textarea {
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}

.formular-grid input[type="checkbox"],
.formular-grid input[type="radio"] {
  margin-top: 0;
}

/* Knöpfe: primär Gold, sekundär (.btn), Gefahr */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 0.84375rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid var(--rand);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: var(--akzent);
  background: var(--akzent-hauch);
}

.btn-primary {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--auf-akzent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--akzent-hell);
  border-color: var(--akzent-hell);
}

.btn-gefahr {
  background: var(--warnung);
  border-color: var(--warnung);
  color: var(--auf-warnung);
  font-weight: 600;
}

.btn-gefahr:hover {
  background: var(--warnung);
  border-color: var(--text);
}

.btn:disabled,
.btn-mini:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-mini {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  margin-right: 0.25rem;
  border-radius: 5px;
  border: 1px solid var(--rand);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-mini:hover {
  border-color: var(--akzent);
  background: var(--akzent-hauch);
}

/* Als Link: gleiche Fläche wie der Knopf (schmal mindestens 44 × 44 px) */
a.btn-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* Status-Plakette (umrandet in Statusfarbe) */
.plakette,
.badge {
  display: inline-block;
  font-size: 0.71875rem;
  line-height: 1.5;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  white-space: nowrap;
  color: var(--text-gedaempft);
}

.plakette-ok,
.badge-bezahlt,
.badge-sicher,
.badge.kat-1-30 {
  color: var(--ok);
}

.plakette-offen,
.badge-offen,
.badge-wahrscheinlich,
.badge-organschaft,
.badge.kat-31-60 {
  color: var(--offen);
}

.plakette-warnung,
.badge-mahnung,
.badge.kat-61-90,
.badge.kat-91 {
  color: var(--warnung);
}

.plakette-grau,
.badge-storno,
.badge-entwurf,
.badge-archiviert,
.badge-altbestand,
.badge.kat-nicht-faellig {
  color: var(--text-gedaempft);
}

.badge-storno {
  text-decoration: line-through;
}

.badge-entwurf,
.badge-archiviert,
.badge-altbestand {
  border-style: dashed;
}

/* Hinweis- und Fehlerkasten */
.hinweis-kasten,
.festgeschrieben-hinweis,
.verknuepfung-hinweis {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-left: 4px solid var(--akzent);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0 1rem;
  color: var(--text);
  line-height: 1.45;
}

.hinweis-kasten p + p {
  margin-top: 0.4rem;
}

.hinweis-kasten-fehler,
.verknuepfung-hinweis.original {
  border-left-color: var(--warnung);
}

.hinweis-kasten-ok,
.verknuepfung-hinweis.korrektur {
  border-left-color: var(--ok);
}

.verknuepfung-hinweis a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.verknuepfung-hinweis a:hover {
  text-decoration: none;
}

.hinweis-text {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
  font-style: italic;
}

.hinweis-text code {
  background: var(--flaeche-tief);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.8125rem;
  font-style: normal;
}

/* Anmeldeseite: eigene schlichte Seite ohne Kopfzeile, Karte mittig */
.anmelde-flaeche {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px 24px;
}

.anmelde-karte {
  width: 100%;
  max-width: 380px;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 1.75rem 1.5rem 1.5rem;
}

.anmelde-logo {
  display: block;
  margin: 0 auto 0.75rem;
}

.anmelde-karte h1 {
  font-size: 1.5rem;
  margin: 1rem 0 0.75rem;
  text-align: center;
}

.anmelde-formular {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.anmelde-formular[hidden],
.anmelde-formular label[hidden] {
  display: none;
}

.anmelde-formular label {
  display: flex;
  flex-direction: column;
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
  font-weight: 500;
}

.anmelde-formular input {
  margin-top: 0.3rem;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
}

.anmelde-formular .hinweis-text {
  margin-top: 0;
}

/* Knopf, der wie ein Link aussieht (z. B. „Wiederherstellungscode verwenden“) */
.textknopf {
  background: none;
  border: none;
  padding: 0.4rem 0;
  color: var(--gold-text);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  align-self: center;
}

.textknopf:hover {
  text-decoration: none;
}

/* Dialog */
dialog {
  /* Die globale Regel margin: 0 würde die Mittelung modaler Dialoge aufheben. */
  margin: auto;
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 0;
  max-width: 800px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--karte-erhoben);
  color: var(--text);
  box-shadow: 0 10px 40px var(--schatten);
}

dialog::backdrop {
  background: var(--abdeckung);
}

/* Neue Wiederherstellungscodes (Konto): zwei Spalten, gleich breite Zeichen, schmal einspaltig */
.codes-liste {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 2rem;
  margin: 1rem 0 1.5rem;
  padding-left: 1.75rem;
  font-family: var(--schrift-mono);
  font-size: 1.0625rem;
  letter-spacing: 0.04em;
}

dialog form,
dialog > div {
  padding: 2rem;
}

dialog h2 {
  margin-bottom: 1.5rem;
  font-size: 1.375rem;
  border-bottom: 1px solid var(--akzent);
  padding-bottom: 0.5rem;
}

dialog h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

dialog.bestaetigung {
  max-width: 420px;
}

dialog.dialog-breit {
  width: 95vw;
  max-width: 56rem;
}

.bestaetigung-text {
  white-space: pre-line;
}

.dialog-aktionen {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  border-top: 1px solid var(--rand);
  padding-top: 1rem;
  position: sticky;
  bottom: 0;
  background: var(--karte-erhoben);
  padding-bottom: 1rem;
  margin-bottom: -2rem;
  z-index: 2;
}

/* Meldung (Toast) am Seitenrand oder oben im offenen Dialog (kern.js) */
.meldungen {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.meldungen-rand {
  position: fixed;
  top: 72px;
  right: 1rem;
  max-width: 420px;
  /* Viele Meldungen: der Stapel scrollt in sich, statt aus dem Bild zu wachsen */
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  z-index: 9999;
}

.meldungen-dialog {
  position: sticky;
  top: 0;
  max-height: 40vh;
  overflow-y: auto;
  z-index: 3;
  padding: 0.75rem 2rem 0;
  background: var(--karte-erhoben);
}

.meldung {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--rand);
  border-left: 4px solid var(--akzent);
  background: var(--karte-erhoben);
  color: var(--text);
  font-size: 0.875rem;
  box-shadow: 0 4px 16px var(--schatten);
  animation: meldung-ein 0.15s ease-out;
}

@keyframes meldung-ein {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.meldung-text {
  flex: 1;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.meldung-erfolg {
  border-left-color: var(--ok);
}

.meldung-fehler {
  border-left-color: var(--warnung);
}

.meldung-hinweis {
  border-left-color: var(--akzent);
}

.meldung-schliessen {
  border: none;
  background: none;
  color: var(--text-gedaempft);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* Link in einer Meldung (z. B. „Anmeldung öffnen“ bei beendeter Sitzung) */
.meldung-link {
  align-self: center;
  color: var(--akzent);
  font-weight: 600;
  white-space: nowrap;
}

/* ===================================== Bestehende Seiten (Umbau Tasks 5–9) */

/* Übersicht */
.willkommen,
.stammdaten,
.fortschritt,
.bericht,
.letzte-rechnungen,
.mini-chart-karte,
.chart-karte,
.forderungen-block {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.willkommen h1 {
  font-size: 1.625rem;
  margin-bottom: 0.5rem;
}

.willkommen p {
  color: var(--text-gedaempft);
}

.stammdaten h2,
.forderungen-block h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.stammdaten h2 {
  border-bottom: 1px solid var(--rand);
  padding-bottom: 0.5rem;
}

.stammdaten dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5rem 1.5rem;
}

.stammdaten dt {
  color: var(--text-gedaempft);
}

.stammdaten dd {
  font-family: var(--schrift-mono);
}

/* Kleine Abschnittstitel als Beschriftung (Inter statt Playfair) */
.chart-karte h2,
.chart-karte h3,
.mini-chart-karte h2,
.letzte-rechnungen h2,
.bezahl-block h3,
.mahnungen-leiste h3,
.dokumente-gruppe h4 {
  font-family: var(--schrift-text);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-gedaempft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.75rem;
  border: none;
}

.letzte-rechnungen-liste {
  list-style: none;
}

.letzte-rechnungen-liste li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rand);
  display: grid;
  grid-template-columns: 80px 90px 1fr 100px 80px;
  gap: 1rem;
  align-items: center;
}

.letzte-rechnungen-liste li:last-child {
  border-bottom: none;
}

.letzte-rechnungen-liste a {
  color: var(--text);
  text-decoration: none;
}

.letzte-rechnungen-liste a:hover {
  color: var(--gold-text);
}

.letzte-rechnungen-liste .lr-nr {
  font-family: var(--schrift-mono);
  color: var(--text-gedaempft);
  font-size: 0.8125rem;
}

.letzte-rechnungen-liste .lr-brutto {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.mahnvorschlag-liste li {
  grid-template-columns: 80px 1fr 130px 190px 80px;
}

.mahnvorschlag-liste a.btn-mini {
  display: inline-block;
  text-decoration: none;
}

.mini-chart-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--gold-text);
  text-decoration: none;
}

.mini-chart-link:hover {
  text-decoration: underline;
}

.mini-chart-karte .chart-canvas-wrapper {
  height: 160px;
}

.ueberfaellig {
  color: var(--warnung);
  font-size: 0.8125rem;
}

/* Liste der Etappen (nicht mehr eingebunden) */
.fortschritt ol {
  list-style: none;
}

.fortschritt li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rand);
}

/* Seitenkopf: Varianten der bestehenden Seiten */
.seitenkopf--abstand {
  margin-top: 2rem;
}

.filter-leiste--kopf {
  margin: 0;
}

/* Sortierbare Spalten */
.datentabelle th.sortierbar {
  cursor: default;
  user-select: none;
}

.datentabelle th.sortierbar::after {
  content: " ⇅";
  opacity: 0.4;
  font-size: 0.85em;
}

.datentabelle th.sortierbar.sort-auf::after {
  content: " ↑";
  opacity: 1;
  color: var(--gold-text);
}

.datentabelle th.sortierbar.sort-ab::after {
  content: " ↓";
  opacity: 1;
  color: var(--gold-text);
}

.sortierknopf {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: inherit;
}

.sortierknopf:hover {
  color: var(--gold-text);
}

/* Positionen-Tabelle im Dialog */
.positionen-tabelle {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.positionen-tabelle th,
.positionen-tabelle td {
  padding: 0.4rem;
  border-bottom: 1px solid var(--rand);
}

.positionen-tabelle th {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-gedaempft);
  text-align: left;
}

.positionen-tabelle th.zahl,
.positionen-tabelle td.zahl {
  text-align: right;
}

.positionen-tabelle input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.positionen-tabelle .summenfeld {
  font-variant-numeric: tabular-nums;
  color: var(--text-gedaempft);
}

/* Summenblock */
.summen-block {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--flaeche-tief);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}

.summen-block > div {
  display: flex;
  gap: 1rem;
}

.summen-block > div.brutto {
  font-size: 1.1rem;
  border-top: 1px solid var(--akzent);
  padding-top: 0.4rem;
  margin-top: 0.2rem;
}

/* Import-Bericht (Seite stillgelegt) */
.bericht-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.bericht ul {
  list-style: none;
  margin-bottom: 1.5rem;
}

.bericht li {
  padding: 0.4rem 0.8rem;
  border-left: 3px solid var(--akzent);
  background: var(--flaeche-tief);
  margin-bottom: 0.3rem;
}

.bericht li.leer {
  border-left-color: var(--rand);
  color: var(--text-gedaempft);
  font-style: italic;
}

.bericht li.fehler {
  border-left-color: var(--warnung);
}

/* Dokumente, Status und Mahnungen im Detail-Dialog */
.dokumente-leiste,
.status-leiste,
.mahnungen-leiste {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--flaeche-tief);
  border-radius: 6px;
}

.dokumente-leiste {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dokumente-gruppe {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dokumente-gruppe h4 {
  margin: 0;
}

.dokumente-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.dokumente-buttons .btn-mini,
.dokumente-buttons a.btn-mini {
  text-decoration: none;
  font-weight: 500;
}

.dokumente-buttons .btn-mini:hover,
.dokumente-buttons a.btn-mini:hover,
.status-buttons .btn-mini.aktiv,
.status-leiste .btn-mini.aktiv {
  background: var(--akzent);
  border-color: var(--akzent);
  color: var(--auf-akzent);
}

.status-leiste {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-buttons {
  display: flex;
  gap: 0.5rem;
}

.mahnungen-leiste {
  border-left: 4px solid var(--warnung);
}

.mahnungen-leiste h3 {
  margin-top: 0;
}

.mahnung-eintrag {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rand);
  gap: 1rem;
  flex-wrap: wrap;
}

.mahnung-eintrag:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
}

.mahnung-eintrag a.btn-mini {
  text-decoration: none;
}

/* Bezahl-Blöcke (Eingangsbuch, Stammdaten) */
.bezahl-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.bezahl-block {
  background: var(--karte);
  border: 1px solid var(--rand);
  border-left: 3px solid var(--akzent);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

.bezahl-block dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.3rem;
  margin: 0;
}

.bezahl-block dt {
  color: var(--text-gedaempft);
}

.bezahl-block dd {
  overflow-wrap: anywhere;
}

.bezahl-block dd.mono {
  font-family: var(--schrift-mono);
  font-size: 0.8125rem;
}

.bezahl-block .hinweis {
  margin-top: 0.6rem;
  font-size: 0.8125rem;
  color: var(--warnung);
}

/* QR-Code: bleibt auf heller Fläche, damit er sich in beiden Modi scannen lässt */
.qr-block {
  margin-top: 1rem;
  text-align: center;
  background: var(--creme-karte);
  color: var(--anthrazit);
  padding: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--rand);
}

.qr-block img {
  display: block;
  margin: 0 auto;
}

.qr-block .qr-hinweis {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--gedaempft-hell);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.platzhalter-liste {
  list-style: none;
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.4rem 1rem;
  font-size: 0.875rem;
}

.platzhalter-liste li {
  padding: 0.3rem 0;
}

.platzhalter-liste code {
  background: var(--flaeche-tief);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--gold-text);
  margin-right: 0.4rem;
}

.platzhalter-liste em {
  color: var(--text-gedaempft);
  font-style: normal;
}

/* Auswertungen */
.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.charts-grid .chart-karte {
  margin-bottom: 0;
}

.chart-karte--breit {
  grid-column: 1 / -1;
}

.chart-canvas-wrapper {
  position: relative;
  height: 280px;
}

.chart-karte--breit .chart-canvas-wrapper {
  height: 300px;
}

.leer-hinweis {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--text-gedaempft);
  font-style: italic;
  text-align: center;
}

.diagramm-leer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--karte);
  color: var(--text-gedaempft);
}

.aging-zusammenfassung {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.aging-kachel {
  background: var(--flaeche-tief);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--akzent);
}

.aging-kachel.aging-summe {
  border-left-color: var(--text);
}

.aging-kachel.kat-nicht-faellig { border-left-color: var(--text-gedaempft); }
.aging-kachel.kat-1-30 { border-left-color: var(--ok); }
.aging-kachel.kat-31-60 { border-left-color: var(--offen); }
.aging-kachel.kat-61-90 { border-left-color: var(--warnung); }
.aging-kachel.kat-91 { border-left-color: var(--warnung); }

.aging-label {
  font-size: 0.75rem;
  color: var(--text-gedaempft);
}

.aging-wert {
  font-size: 1.2rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 0.2rem;
}

.aging-meta {
  font-size: 0.75rem;
  color: var(--text-gedaempft);
  margin-top: 0.2rem;
}

.trend-hoch {
  color: var(--ok);
}

.trend-runter {
  color: var(--warnung);
}

/* Verlauf eines Belegs (Änderungsprotokoll) */
.verlauf {
  list-style: none;
  padding: 0;
}

.verlauf li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--rand);
}

.verlauf li:last-child {
  border-bottom: none;
}

.verlauf-zeit {
  color: var(--text-gedaempft);
  margin-right: 0.5rem;
  white-space: nowrap;
}

/* Storno in der Liste: Original durchgestrichen, Stornobeleg mit Verweis */
.zeile-storniert td:not(.aktion-spalte) code,
.zeile-storniert td.zahl {
  text-decoration: line-through;
  color: var(--text-gedaempft);
}

.storno-verweis {
  font-size: 0.78rem;
  color: var(--warnung);
}

.storno-verweis a {
  color: inherit;
  text-decoration: underline;
}

.zeile-stornobeleg td.zahl,
.zu-erstatten {
  color: var(--warnung);
}

.zu-erstatten {
  margin: 0.5rem 0;
  font-weight: 600;
}

.korrektur-indikator {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.8125rem;
  cursor: help;
}

.korrektur-indikator.original {
  color: var(--warnung);
}

.korrektur-indikator.korrektur {
  color: var(--ok);
}

/* Upload-Bereich Eingangsbuch */
.upload-bereich {
  background: var(--karte);
  border: 2px dashed var(--rand);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: border-color 0.15s, background 0.15s;
}

.upload-bereich:hover,
.upload-bereich.aktiv {
  border-color: var(--akzent);
  background: var(--akzent-hauch);
}

.upload-bereich.lade {
  opacity: 0.6;
  cursor: wait;
}

.upload-bereich strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.upload-bereich .hilfe {
  display: block;
  color: var(--text-gedaempft);
}

button.upload-bereich {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
}

/* Schalter mit Text (z. B. Eingangsbuch „bezahlt“/„offen“); Zustand über aria-pressed */
.schalter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  background: transparent;
  border: 1px solid var(--rand);
  border-radius: 999px;
  color: var(--text-gedaempft);
  font: inherit;
  font-size: 0.8125rem;
  white-space: nowrap;
  cursor: pointer;
}

.schalter:hover {
  border-color: var(--akzent);
}

.schalter:disabled {
  opacity: 0.6;
  cursor: wait;
}

.schalter-bahn {
  position: relative;
  flex: none;
  width: 30px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--text-gedaempft);
  background: var(--flaeche-tief);
}

.schalter-bahn::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-gedaempft);
  transition: transform 0.15s;
}

.schalter[aria-pressed="true"] {
  color: var(--ok);
  border-color: currentColor;
}

.schalter[aria-pressed="true"] .schalter-bahn {
  background: var(--ok);
  border-color: var(--ok);
}

.schalter[aria-pressed="true"] .schalter-bahn::after {
  transform: translateX(14px);
  background: var(--karte);
}

/* Nur für Bildschirmleser (sichtbar ausgeblendet) */
.nur-vorlesen {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Lange Namen (z. B. Lieferanten) brechen in der Tabelle um, statt die Spalte zu sprengen */
.datentabelle td.umbruch {
  overflow-wrap: anywhere;
  min-width: 10rem;
}

/* Stammdaten: Logo-Vorschau (helle Fläche in beiden Modi, da das Logo für Briefpapier gedacht ist) */
.logo-vorschau {
  margin-bottom: 0.75rem;
}

.logo-vorschau-bild {
  max-width: 200px;
  max-height: 80px;
  border: 1px solid var(--rand);
  border-radius: 4px;
  padding: 0.5rem;
  background: var(--creme-karte);
}

.logo-fehlt {
  color: var(--text-gedaempft);
  font-style: italic;
}

.stammdaten-text {
  font-size: 0.875rem;
  color: var(--text-gedaempft);
  margin-bottom: 0.75rem;
}

/* Zahlungen: Kontoabgleich */
.abgleich-buchung strong {
  display: block;
}

.abgleich-text {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-gedaempft);
  max-width: 34rem;
  overflow-wrap: anywhere;
}

.abgleich-teile {
  margin: 0.25rem 0;
  padding-left: 1.1rem;
}

.abgleich-vorschlag .hinweis-text,
.abgleich-gebucht .hinweis-text {
  display: block;
  font-size: 0.78rem;
}

.abgleich-ergebnis {
  margin: 0.75rem 0 1rem;
  font-weight: 600;
}

.abgleich-auswahl {
  max-height: 16rem;
  overflow-y: auto;
}

.abgleich-summe {
  margin-top: 0.75rem;
  font-weight: 600;
}

.abgleich-summe.zu-hoch {
  color: var(--warnung);
}

/* Auftraggeber und Verwendungszweck brechen um, statt die Seite zu verbreitern */
.abgleich-buchung {
  overflow-wrap: anywhere;
}

td.abgleich-buchung {
  min-width: 12rem;
}

/* Sammelaktionen: bleiben beim Scrollen unter der Kopfzeile (60 px + Goldlinie) sichtbar */
.sammel-leiste {
  position: sticky;
  top: 61px;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  /* Hintergrund über den Seitenrand von main hinaus: beim Scrollen scheint seitlich nichts durch */
  margin: 0 -24px 12px;
  padding: 8px 24px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}

.sammel-leiste[hidden] {
  display: none;
}

/* Buchung als Karte: Auswahl mit Buchungstag, Text, Zuordnung */
.buchung-auswahl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.karte-zeile .abgleich-buchung,
.karte-zeile .abgleich-zuordnung {
  margin-top: 8px;
  font-size: 0.875rem;
}

.karte-zeile .abgleich-text {
  max-width: none;
}

/* ------------------------------------------------------- Zustände */

[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
}

[aria-busy="true"]::after {
  content: " …";
}

.versteckt {
  display: none !important;
}

/* Rechnungsliste: ganze Zeile öffnet das Detail, lange Kundennamen gekürzt (voller Name als title) */
.datentabelle tr.klickbar {
  cursor: pointer;
}

.datentabelle td.kuerzen {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.beleg-link {
  color: var(--text);
  text-decoration: none;
}

.beleg-link:hover,
.beleg-link:hover code {
  color: var(--gold-text);
  text-decoration: underline;
}

/* Summenzeile unter der Kartenliste (schmal) */
.karten-summe {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 8px;
  padding: 11px 13px;
  background: var(--flaeche-tief);
  border: 1px solid var(--rand);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.karten-summe strong {
  white-space: nowrap;
}

.karten-liste .leer-karte {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-gedaempft);
  font-style: italic;
}

/* Dialog-Kopf (Titel und Schließen) und Dialog-Fuß (Summen und Knöpfe) bleiben beim Scrollen sichtbar */
.dialog-kopf {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: -2rem -2rem 1rem;
  padding: 1rem 2rem 0.75rem;
  background: var(--karte-erhoben);
  border-bottom: 1px solid var(--akzent);
}

.dialog-kopf h2 {
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
  overflow-wrap: anywhere;
}

.dialog-kopf h2 .plakette {
  vertical-align: middle;
}

.dialog-kopf .symbolknopf {
  flex-shrink: 0;
  font-size: 1.375rem;
}

.dialog-fuss {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 1rem -2rem -2rem;
  padding: 0 2rem;
  background: var(--karte-erhoben);
  border-top: 1px solid var(--rand);
}

.dialog-fuss .summen-block {
  margin-top: 0.75rem;
}

.dialog-fuss .dialog-aktionen {
  position: static;
  margin: 0;
  border-top: none;
  padding: 0.75rem 0 1rem;
}

/* Detailansicht: Aktionsleiste unter dem Kopf, Abschnitte als Karten */
.detail-aktionen {
  margin-bottom: 1rem;
}

.detail-aktionen .hinweis-text {
  margin: 0 0 0.5rem;
}

dialog .abschnitt-karte p {
  margin: 0.25rem 0;
}

dialog .abschnitt-karte .tabelle-wrapper {
  margin-top: 0.25rem;
}

/* ------------------------------------------------------- Breiten */

@media (max-width: 1100px) {
  .kennzahlen.kennzahlen-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Kopfzeile verdichtet (900–1180 px): sieben Menüpunkte passen ohne Überlauf in eine Zeile */
@media (min-width: 900px) and (max-width: 1180px) {
  .kopfzeile-innen {
    gap: 10px;
    padding: 0 16px;
  }

  .kopfzeile-logo img {
    height: 30px;
  }

  .hauptmenue-liste {
    gap: 0;
  }

  .hauptmenue a {
    font-size: 0.8125rem;
    padding: 8px 5px;
  }
}

/*
 * Kopfzeile schmal: unter 900 px. Logo, Farbmodus und Menüknopf; das Menü klappt
 * als Liste auf (enthält dann auch die Einstellungen). Die übrigen Regeln für
 * schmale Bildschirme (Karten, Formulare, 44-px-Flächen) gelten erst unter 760 px.
 */
@media (max-width: 899.98px) {
  .nur-kopf-breit {
    display: none !important;
  }

  .hauptmenue {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding: 8px 14px 14px;
    background: var(--flaeche);
    border-bottom: 1px solid var(--rand);
    box-shadow: 0 10px 30px var(--schatten);
  }

  .hauptmenue.offen {
    display: block;
  }

  .hauptmenue-liste {
    flex-direction: column;
  }

  .hauptmenue a {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.9375rem;
    padding: 10px 9px;
  }

  .hauptmenue-liste a.aktiv::after {
    display: none;
  }

  .hauptmenue a.aktiv {
    background: var(--akzent-hauch);
  }
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .aging-zusammenfassung {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Rechnungsliste 760–1099,98 px (z. B. iPad hochkant und quer): ohne Spalte „Versand“, engere Zellen, kürzere
   Kundenspalte, Plakette darf umbrechen; Nr. bis Status samt Knopf passen ohne Scrollen in den Rahmen */
@media (min-width: 760px) and (max-width: 1099.98px) {
  .rechnungen-tabelle .spalte-versand {
    display: none;
  }

  .rechnungen-tabelle th,
  .rechnungen-tabelle td {
    padding-left: 8px;
    padding-right: 8px;
  }

  .rechnungen-tabelle td.kuerzen {
    max-width: 8rem;
  }

  .rechnungen-tabelle .plakette {
    white-space: normal;
  }
}

/* Schmal: unter 760 px. Logo, Farbmodus und Menüknopf; Menü klappt als Liste auf. */
@media (max-width: 759.98px) {
  .codes-liste {
    grid-template-columns: minmax(0, 1fr);
  }

  .anmelde-formular input,
  .anmelde-formular .btn,
  .textknopf {
    min-height: 44px;
  }

  .nur-breit {
    display: none !important;
  }

  .kopfzeile-innen {
    height: 54px;
    padding: 0 14px;
  }

  .kopfzeile-logo img {
    height: 28px;
  }

  .symbolknopf,
  .btn,
  .btn-mini,
  .chip,
  .schalter,
  .meldung-schliessen {
    min-width: 44px;
    min-height: 44px;
  }

  .abschnitt-link,
  .meldung-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Sortierknöpfe im Tabellenkopf und Belegnummern als Link: Fläche 44 × 44 px */
  .sortierknopf,
  .beleg-link {
    display: inline-flex;
    align-items: center;
    min-width: 44px;
    min-height: 44px;
  }

  /* Kästchen mit Beschriftung: Zeile 44 px hoch, Kästchen selbst 22 px */
  .checkbox,
  .buchung-auswahl {
    min-height: 44px;
  }

  input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }

  .diagramm-tabelle summary {
    padding: 13px 0;
  }

  .filter-leiste input,
  .filter-leiste select,
  .formular-grid input,
  .formular-grid select {
    min-height: 44px;
  }

  main {
    padding: 18px 14px 22px;
  }

  .seitenkopf h1 {
    font-size: 1.375rem;
  }

  .seitenkopf-aktionen {
    width: 100%;
  }

  .seitenkopf-aktionen .btn {
    flex: 1;
    padding: 11px;
  }

  .kacheln,
  .kacheln.kacheln-5,
  .kennzahlen,
  .kennzahlen.kennzahlen-5 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .kachel,
  .kennzahl {
    padding: 10px 12px;
  }

  .kachel-wert,
  .kennzahl .wert {
    font-size: 1.0625rem;
  }

  .formular-grid,
  .bezahl-grid,
  .platzhalter-liste,
  .bericht-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .formular-grid label.span-2 {
    grid-column: auto;
  }

  .letzte-rechnungen-liste li,
  .mahnvorschlag-liste li {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.25rem 1rem;
  }

  dialog {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  dialog form,
  dialog > div {
    padding: 1.25rem 1rem;
  }

  /* Editor und Detail füllen den Bildschirm; der Dialog scrollt in sich */
  dialog.dialog-vollbild {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
  }

  .dialog-kopf {
    margin: -1.25rem -1rem 1rem;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
  }

  .dialog-kopf h2 {
    font-size: 1.125rem;
  }

  .dialog-fuss {
    margin: 1rem -1rem -1.25rem;
    padding: 0 1rem;
  }

  .dialog-fuss .summen-block {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem 1rem;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
  }

  .dialog-fuss .summen-block > div.brutto {
    font-size: 1rem;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
  }

  .dialog-fuss .dialog-aktionen {
    padding: 0.5rem 0 0.75rem;
  }

  .dialog-fuss .dialog-aktionen .btn {
    flex: 1;
  }

  /* Positionen gestapelt: Beschreibung, darunter Menge, Einheit, Preis, Summe */
  .positionen-stapelbar,
  .positionen-stapelbar tbody {
    display: block;
  }

  .positionen-stapelbar thead {
    display: none;
  }

  .positionen-stapelbar tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--rand);
  }

  .positionen-stapelbar td {
    display: block;
    padding: 0;
    border: none;
  }

  .positionen-stapelbar td.zahl {
    text-align: left;
  }

  .positionen-stapelbar td[data-beschriftung]::before {
    content: attr(data-beschriftung);
    display: block;
    margin-bottom: 2px;
    font-size: 0.75rem;
    color: var(--text-gedaempft);
  }

  .positionen-stapelbar .pos-beschreibung,
  .positionen-stapelbar .pos-entfernen {
    grid-column: 1 / -1;
  }

  .positionen-stapelbar .pos-entfernen {
    justify-self: end;
  }

  .positionen-stapelbar .summenfeld {
    padding-top: 0.6rem;
  }

  /* 16 px: iOS vergrößert die Seite sonst beim Fokus */
  .positionen-stapelbar input {
    min-height: 44px;
    font-size: 1rem;
  }

  /* Tabellen im Dialog gestapelt: je Zeile ein Block, Zellen mit Beschriftung (data-beschriftung) */
  .tabelle-stapelbar,
  .tabelle-stapelbar tbody {
    display: block;
  }

  .tabelle-stapelbar thead {
    display: none;
  }

  .tabelle-stapelbar tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.5rem 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--rand);
  }

  .tabelle-stapelbar tbody tr:last-child {
    border-bottom: none;
  }

  .tabelle-stapelbar td {
    display: block;
    min-width: 0;
    padding: 0;
    border: none;
    overflow-wrap: anywhere;
  }

  .tabelle-stapelbar td.zahl,
  .tabelle-stapelbar td.rechts {
    text-align: left;
  }

  .tabelle-stapelbar td[data-beschriftung]::before {
    content: attr(data-beschriftung);
    display: block;
    margin-bottom: 2px;
    font-size: 0.75rem;
    color: var(--text-gedaempft);
  }

  .tabelle-stapelbar td.leer,
  .tabelle-stapelbar td.stapel-ende {
    grid-column: 1 / -1;
  }

  .tabelle-stapelbar td.stapel-ende {
    justify-self: end;
  }

  .tabelle-stapelbar input,
  .tabelle-stapelbar select {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }

  .abgleich-auswahl {
    max-height: 45vh;
  }

  /* Schmal nicht fixiert: drei umbrechende Knopfzeilen kosten sonst rund 170 px der Höhe */
  .sammel-leiste {
    position: static;
    margin: 0 0 12px;
    padding: 8px 0;
  }

  .sammel-leiste .btn {
    flex: 1 1 auto;
    white-space: normal;
  }

  .dialog-aktionen {
    margin-bottom: -1.25rem;
  }

  .meldungen-dialog {
    padding: 0.75rem 1rem 0;
  }

  .meldungen-rand {
    top: 62px;
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
    max-height: calc(100vh - 74px);
  }
}

/* Bewegung abschaltbar */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Druckansicht der Seiten (nicht der Rechnungs-PDF): helle Farben unabhängig vom Modus, ohne Kopfzeile,
   Menü, Knöpfe, Filter und Meldungen; Tabellen statt Karten. Links ohne angehängte Adressen. */
@media print {
  :root,
  :root[data-thema] {
    color-scheme: light;

    --flaeche: var(--creme);
    --flaeche-tief: var(--creme);
    --karte: var(--creme-karte);
    --karte-erhoben: var(--creme-karte);
    --text: var(--anthrazit);
    --text-gedaempft: var(--gedaempft-hell);
    --gold-text: var(--gold-text-hell);
    --akzent-hauch: transparent;
    --rand: var(--gedaempft-hell);
    --rand-feld: var(--gedaempft-hell);
    --fokus: var(--gold-text-hell);
    --ok: var(--ok-hell);
    --offen: var(--gold-text-hell);
    --warnung: var(--warnung-hell);
    --auf-warnung: var(--creme);
    --schatten: transparent;
    --abdeckung: transparent;
  }

  html,
  body {
    background: var(--karte);
  }

  body {
    display: block;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .sprunglink,
  .kopfzeile,
  .fusszeile,
  .meldungen,
  .filter-leiste,
  .sammel-leiste,
  .seitenkopf-aktionen,
  .upload-bereich,
  .formular-aktionen,
  .dialog-aktionen,
  .detail-aktionen,
  .karte-zeile-aktionen,
  .aktion-spalte,
  button:not(.sortierknopf):not(.schalter),
  .btn,
  .btn-mini,
  .nur-schmal {
    display: none !important;
  }

  /* Tabellen statt Karten, auch wenn die Druckbreite unter 760 px liegt (verborgene bleiben verborgen) */
  .tabelle-wrapper.nur-breit:not([hidden]) {
    display: block !important;
  }

  .tabelle-wrapper {
    overflow: visible;
    border: none;
  }

  .datentabelle td.kuerzen {
    max-width: none;
    white-space: normal;
    overflow: visible;
  }

  .datentabelle tr,
  .kachel,
  .abschnitt-karte {
    break-inside: avoid;
  }

  a {
    color: var(--text);
    text-decoration: none;
  }

  /* Neue Wiederherstellungscodes (Konto): der Ausdruck zeigt nur die Überschrift und die Codes */
  body.druck-codes main > :not(#codes-dialog),
  body.druck-codes #codes-dialog .hinweis-text {
    display: none !important;
  }

  body.druck-codes #codes-dialog {
    position: static;
    display: block;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    border: none;
    box-shadow: none;
    background: var(--karte);
  }

  body.druck-codes #codes-dialog::backdrop {
    background: transparent;
  }

  /* Was per hidden ausgeblendet ist, kommt nie in den Ausdruck */
  [hidden] {
    display: none !important;
  }
}
