/* ===========================================================================
   elemente.css — der UI-Baukasten
   ---------------------------------------------------------------------------
   Vier Gruppen, in dieser Reihenfolge:

     A  Eingabe-Elemente        (Aktionen)
     B  Anzeige-Elemente        (Information)
     C  Rückmeldungen & Helfer  (Zustand)
     D  Hilfsklassen

   Navigation und Menüs liegen getrennt in menues.css.
   Was wann sinnvoll ist: references/elemente.md.
   Fertiges HTML zu jedem Element: katalog.html.

   Nach basis.css einbinden. Alles variablengesteuert, keine Inline-Handler.
   ========================================================================= */

/* ###########################################################################
   A  EINGABE-ELEMENTE (Aktionen)
   ######################################################################### */

/* --- Knopfgrössen ------------------------------------------------------- */
.knopf--klein {
  min-height: 36px; padding: 7px 12px; font-size: .85rem;
}
.knopf--gross {
  min-height: 52px; padding: 14px 24px; font-size: 1.05rem;
}
.knopf svg { width: 18px; height: 18px; flex: none; }

/* --- Knopfgruppe (eine Auswahl aus wenigen, immer sichtbaren Möglichkeiten)
   Für 2–4 Möglichkeiten besser als eine Auswahlliste: man sieht alles auf
   einen Blick und braucht nur einen Tipp statt zwei. ---------------------- */
.knopfgruppe { display: inline-flex; border: 1px solid var(--rand); border-radius: var(--radius); overflow: hidden; }
.knopfgruppe button {
  font: inherit; font-size: .88rem; cursor: pointer;
  padding: 9px 15px; min-height: 44px;
  background: var(--flaeche); color: var(--text); border: 0;
  border-right: 1px solid var(--rand);
}
.knopfgruppe button:last-child { border-right: 0; }
.knopfgruppe button[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); font-weight: 600; }

/* --- Kontrollkästchen und Optionsfelder -----------------------------------
   Die ganze Zeile ist anklickbar, nicht nur das kleine Kästchen. Das ist der
   häufigste Grund, warum Formulare auf dem Telefon nerven. ---------------- */
.kontrolle {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 9px 0; min-height: 44px; cursor: pointer;
}
.kontrolle input[type="checkbox"], .kontrolle input[type="radio"] {
  width: 20px; height: 20px; min-height: 0; margin: 2px 0 0; flex: none;
  accent-color: var(--akzent); padding: 0;
}
.kontrolle span { font-size: .95rem; }
.kontrolle small { display: block; color: var(--schwach); font-size: .84rem; }
.kontrolle--rahmen {
  border: 1px solid var(--rand); border-radius: var(--radius);
  padding: 11px 13px; margin-bottom: 8px;
}
.kontrolle--rahmen:has(input:checked) { border-color: var(--akzent); background: var(--flaeche2); }

/* --- Schalter (an/aus, wirkt sofort) --------------------------------------
   Nur nehmen, wenn die Änderung SOFORT gilt. Muss erst gespeichert werden,
   gehört ein Kontrollkästchen hin — sonst glaubt der Nutzer, es sei schon
   erledigt. ------------------------------------------------------------- */
.schalter { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.schalter input { position: absolute; opacity: 0; width: 0; height: 0; }
.schalter .bahn {
  width: 46px; height: 26px; border-radius: 999px; flex: none; position: relative;
  background: var(--rand); transition: background .15s ease;
}
.schalter .bahn::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--flaeche);
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s ease;
}
.schalter input:checked + .bahn { background: var(--akzent); }
.schalter input:checked + .bahn::after { transform: translateX(20px); }
.schalter input:focus-visible + .bahn { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* --- Schieberegler ------------------------------------------------------ */
.regler { width: 100%; accent-color: var(--akzent); min-height: 44px; }
.regler-zeile { display: flex; align-items: center; gap: 14px; }
.regler-zeile output {
  min-width: 76px; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 650; font-size: 1.05rem;
}

/* --- Feld mit Einheit (m², µm, CHF, %) ----------------------------------- */
.feld-einheit { display: flex; align-items: stretch; }
.feld-einheit input {
  border-top-right-radius: 0; border-bottom-right-radius: 0; border-right: 0;
  text-align: right;
}
.feld-einheit .einheit {
  display: grid; place-items: center; padding: 0 13px;
  background: var(--flaeche2); color: var(--schwach); font-size: .9rem;
  border: 1px solid var(--rand);
  border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius);
}

/* --- Passwortfeld mit Anzeigen-Knopf --------------------------------------
   Tippfehler beim Passwort sind auf dem Telefon die Regel, nicht die
   Ausnahme. Ohne Anzeigen-Knopf rät der Nutzer. ------------------------- */
.passwortfeld { position: relative; }
.passwortfeld input { padding-right: 92px; }
.passwortfeld button {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  min-height: 36px; padding: 6px 11px; font: inherit; font-size: .82rem;
  background: var(--flaeche2); color: var(--text);
  border: 1px solid var(--rand); border-radius: var(--radius); cursor: pointer;
}

/* --- Suchfeld mit Löschknopf -------------------------------------------- */
.suchfeld { position: relative; }
.suchfeld input { padding-left: 38px; }
.suchfeld svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--schwach); pointer-events: none;
}
.suchfeld .leeren {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--flaeche2); color: var(--schwach); font: inherit; line-height: 1;
}

/* --- Dateiablage --------------------------------------------------------- */
.ablage {
  display: block; text-align: center; cursor: pointer;
  padding: calc(var(--luft) * 1.6) var(--luft);
  border: 2px dashed var(--rand); border-radius: var(--radius);
  background: var(--flaeche2); color: var(--schwach);
}
.ablage:hover, .ablage[data-drueber="1"] { border-color: var(--akzent); color: var(--text); }
.ablage b { display: block; color: var(--text); margin-bottom: 3px; }
.ablage input[type="file"] { display: none; }
.ablage__liste { list-style: none; margin: 9px 0 0; padding: 0; text-align: left; }
.ablage__liste li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 9px; background: var(--flaeche); border: 1px solid var(--rand-fein);
  border-radius: var(--radius); margin-bottom: 5px; font-size: .87rem; color: var(--text);
}

/* --- Chips (Mehrfachauswahl, Filter) ------------------------------------ */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; min-height: 38px; cursor: pointer;
  font: inherit; font-size: .87rem;
  background: var(--flaeche2); color: var(--text);
  border: 1px solid var(--rand); border-radius: 999px;
}
.chip[aria-pressed="true"] { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.chip .weg { font-size: 1.1rem; line-height: 1; opacity: .75; }

/* --- Feldgruppe --------------------------------------------------------- */
.feldgruppe {
  border: 1px solid var(--rand); border-radius: var(--radius);
  padding: var(--luft); margin: 0 0 var(--luft);
}
.feldgruppe > legend {
  padding: 0 8px; font-size: .82rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--schwach);
}

/* --- Pflichtfeld und Zeichenzähler -------------------------------------- */
.pflicht { color: var(--fehler); margin-left: 3px; }
.zaehler { display: block; text-align: right; font-size: .78rem; color: var(--schwach); margin-top: 4px; }
.zaehler[data-voll="1"] { color: var(--fehler); font-weight: 600; }

/* ###########################################################################
   B  ANZEIGE-ELEMENTE (Information)
   ######################################################################### */

/* --- Schlüssel-Wert-Liste (Stammdaten, Details) -------------------------- */
.schluesselwerte { margin: 0; }
.schluesselwerte > div {
  display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--rand-fein);
}
.schluesselwerte > div:last-child { border-bottom: 0; }
.schluesselwerte dt { color: var(--schwach); font-size: .87rem; }
.schluesselwerte dd { margin: 0; }
@media (max-width: 480px) { .schluesselwerte > div { grid-template-columns: 1fr; gap: 2px; } }

/* --- Kennzahl mit Trend -------------------------------------------------- */
.kennzahl__wert {
  font-family: var(--schrift-titel); font-size: 1.9rem; font-weight: 700;
  line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.kennzahl__trend { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; font-weight: 600; }
.kennzahl__trend--hoch  { color: var(--erfolg); }
.kennzahl__trend--runter{ color: var(--fehler); }
.kennzahl__trend--gleich{ color: var(--schwach); }
.kennzahl__bezug { font-size: .8rem; color: var(--schwach); }

/* --- Fortschrittsbalken -------------------------------------------------- */
.balken { height: 8px; background: var(--rand-fein); border-radius: 999px; overflow: hidden; }
.balken > i { display: block; height: 100%; background: var(--akzent); border-radius: 999px; }
.balken--gross { height: 14px; }
.balken__text { display: flex; justify-content: space-between; font-size: .82rem; color: var(--schwach); margin-bottom: 5px; }

/* --- Abzeichen (Anzahl) und Etikett (Kategorie) -------------------------- */
.abzeichen {
  display: inline-grid; place-items: center; min-width: 21px; height: 21px;
  padding: 0 6px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--akzent); color: var(--akzent-text); font-variant-numeric: tabular-nums;
}
.abzeichen--still { background: var(--flaeche2); color: var(--schwach); border: 1px solid var(--rand); }
.etikett {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius);
  font-size: .78rem; background: var(--flaeche2); color: var(--schwach);
  border: 1px solid var(--rand);
}

/* --- Avatar -------------------------------------------------------------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; object-fit: cover;
  background: var(--akzent); color: var(--akzent-text);
  font-size: .8rem; font-weight: 700;
}
.avatar--klein { width: 26px; height: 26px; font-size: .68rem; }
.avatar--gross { width: 52px; height: 52px; font-size: 1.05rem; }

/* --- Medienzeile (Bild/Avatar + Text + Aktion) --------------------------- */
.medienzeile {
  display: flex; align-items: center; gap: 13px;
  padding: 11px 0; border-bottom: 1px solid var(--rand-fein);
}
.medienzeile__text { flex: 1; min-width: 0; }
.medienzeile__text b { display: block; font-size: .95rem; }
.medienzeile__text span { display: block; color: var(--schwach); font-size: .85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Trennlinie mit Titel ------------------------------------------------ */
.trenner {
  display: flex; align-items: center; gap: 13px;
  margin: calc(var(--luft) * 1.3) 0; color: var(--schwach);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
}
.trenner::before, .trenner::after { content: ""; flex: 1; height: 1px; background: var(--rand); }

/* --- Zeitachse (Verlauf, Journal, Protokoll) ------------------------------
   Genau das Richtige für Guthaben-Buchungen, Auftragsverlauf und
   Mail-Versandlog: man sieht, WANN was passiert ist, nicht nur den Endstand. */
.zeitachse { list-style: none; margin: 0; padding: 0; }
.zeitachse li { position: relative; padding: 0 0 var(--luft) 26px; }
.zeitachse li::before {
  content: ""; position: absolute; left: 3px; top: 5px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--flaeche); border: 2px solid var(--akzent);
}
.zeitachse li:not(:last-child)::after {
  content: ""; position: absolute; left: 8px; top: 18px; bottom: 0;
  width: 2px; background: var(--rand);
}
.zeitachse li.still::before { border-color: var(--rand); }
.zeitachse time { display: block; font-size: .78rem; color: var(--schwach); }
.zeitachse b { font-size: .95rem; }
.zeitachse p { margin: 3px 0 0; font-size: .89rem; color: var(--schwach); }

/* --- Ausklapper (FAQ, Details, "mehr anzeigen") --------------------------
   Auf <details> gebaut: braucht kein JavaScript und funktioniert auch dann,
   wenn ein Skript nicht lädt. -------------------------------------------- */
.ausklapper {
  border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--flaeche); margin-bottom: 8px;
}
.ausklapper > summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 13px 15px; min-height: 48px; font-weight: 600; list-style: none;
}
.ausklapper > summary::-webkit-details-marker { display: none; }
.ausklapper > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--schwach); border-bottom: 2px solid var(--schwach);
  transform: rotate(45deg);
}
.ausklapper[open] > summary::after { transform: rotate(-135deg); }
.ausklapper[open] > summary { border-bottom: 1px solid var(--rand-fein); }
.ausklapper__inhalt { padding: 13px 15px; }

/* --- Sortierbare Tabellenköpfe ------------------------------------------- */
table.liste th a {
  display: inline-flex; align-items: center; gap: 5px;
  color: inherit; text-decoration: none;
}
table.liste th a::after { content: "⇅"; opacity: .4; font-size: .9em; }
table.liste th[aria-sort="ascending"]  a::after { content: "↑"; opacity: 1; color: var(--akzent); }
table.liste th[aria-sort="descending"] a::after { content: "↓"; opacity: 1; color: var(--akzent); }

/* --- Summenzeile --------------------------------------------------------- */
table.liste tfoot td {
  font-weight: 700; background: var(--flaeche2);
  border-top: 2px solid var(--rand); border-bottom: 0;
}

/* --- Codeblock und Zitat ------------------------------------------------- */
.codeblock {
  font-family: var(--mono); font-size: .85rem; line-height: 1.6;
  background: var(--flaeche2); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 13px 15px; overflow-x: auto;
}
.zitat {
  margin: var(--luft) 0; padding-left: 18px;
  border-left: 3px solid var(--akzent); color: var(--text); font-size: 1.05rem;
}

/* --- Bildhalter ---------------------------------------------------------- */
.bildhalter {
  display: grid; place-items: center; aspect-ratio: 4 / 3;
  background: var(--flaeche2); border: 1px solid var(--rand-fein);
  border-radius: var(--radius); color: var(--schwach); font-size: .82rem; overflow: hidden;
}
.bildhalter img { width: 100%; height: 100%; object-fit: cover; }

/* ###########################################################################
   C  RÜCKMELDUNGEN & HELFER (Zustand)
   ######################################################################### */

/* --- Schnappmeldung (kurze Bestätigung, verschwindet von selbst) ----------
   Nur für Nebensächliches ("Kopiert", "Sortierung gespeichert"). Alles, was
   der Nutzer wissen MUSS, gehört als .hinweis auf die Seite — eine Meldung,
   die von selbst verschwindet, hat er vielleicht nie gesehen. ------------ */
.schnapp-bereich {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 300;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 24px));
}
.schnapp {
  background: var(--dunkel); color: var(--dunkel-text);
  border-radius: var(--radius); padding: 12px 15px; font-size: .92rem;
  box-shadow: 0 6px 22px rgba(0,0,0,.28);
  display: flex; align-items: center; gap: 10px;
  animation: schnapp-auf .18s ease;
}
.schnapp--fehler { background: var(--fehler); color: #fff; } /* feste-farbe-ok: Weiss auf Fehlerrot, in jeder Farbwelt lesbar */
.schnapp button { margin-left: auto; background: none; border: 0; color: inherit;
  font: inherit; cursor: pointer; opacity: .8; min-height: 32px; }
@keyframes schnapp-auf { from { opacity: 0; transform: translateY(10px); } }

/* --- Ladeanzeige --------------------------------------------------------- */
.laden {
  display: inline-block; width: 20px; height: 20px; vertical-align: -4px;
  border: 2px solid var(--rand); border-top-color: var(--akzent);
  border-radius: 50%; animation: dreh .8s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }
.laden-zeile { display: flex; align-items: center; gap: 11px; color: var(--schwach);
  padding: var(--luft); justify-content: center; }

/* --- Skelett (Platzhalter beim Laden) ------------------------------------
   Besser als ein Dreh-Rädchen, weil man schon sieht, wie viel kommt. ---- */
.skelett {
  background: linear-gradient(90deg, var(--flaeche2) 25%, var(--rand-fein) 37%, var(--flaeche2) 63%);
  background-size: 400% 100%; border-radius: var(--radius);
  animation: schimmer 1.4s ease infinite; height: 14px; margin-bottom: 9px;
}
.skelett--titel { height: 22px; width: 45%; }
.skelett--kurz  { width: 65%; }
@keyframes schimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Wer Bewegung im Betriebssystem abgeschaltet hat, bekommt keine. */
@media (prefers-reduced-motion: reduce) {
  .laden, .skelett, .schnapp { animation: none; }
  .schalter .bahn, .schalter .bahn::after { transition: none; }
}

/* --- Dialog (Bestätigung, kleines Formular) ------------------------------
   Baut auf .overlay aus basis.css auf – die Höhe setzt app.js aus
   window.innerHeight, weil vh/dvh in der WebView oft 0 sind. ------------ */
.dialog { justify-content: center; align-items: center; background: rgba(0,0,0,.45); } /* feste-farbe-ok: durchscheinender Schleier */
.dialog__karte {
  background: var(--flaeche); color: var(--text); width: min(460px, calc(100% - 28px));
  max-height: 82%; display: flex; flex-direction: column;
  border-radius: var(--radius-gross); box-shadow: 0 12px 44px rgba(0,0,0,.32);
}
.dialog__kopf { padding: var(--luft); border-bottom: 1px solid var(--rand-fein); }
.dialog__kopf b { font-size: 1.08rem; }
.dialog__inhalt { padding: var(--luft); overflow-y: auto; min-height: 0; }
.dialog__fuss {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: var(--luft); border-top: 1px solid var(--rand-fein);
}
@media (max-width: 640px) {
  /* Am Telefon von unten einfahren – das ist mit dem Daumen erreichbar. */
  .dialog { align-items: flex-end; }
  .dialog__karte {
    width: 100%; max-height: 88%;
    border-radius: var(--radius-gross) var(--radius-gross) 0 0;
  }
  .dialog__fuss { padding-bottom: calc(var(--luft) + env(safe-area-inset-bottom, 0px)); }
  .dialog__fuss .knopf { flex: 1; }
}

/* --- Hilfeblase ---------------------------------------------------------- */
.hilfe {
  position: relative; display: inline-grid; place-items: center;
  width: 19px; height: 19px; border-radius: 50%; cursor: help;
  background: var(--flaeche2); border: 1px solid var(--rand);
  color: var(--schwach); font-size: .7rem; font-weight: 700;
}
.hilfe::after {
  content: attr(data-hilfe); position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: 240px; z-index: 80;
  background: var(--dunkel); color: var(--dunkel-text);
  padding: 8px 11px; border-radius: var(--radius);
  font-size: .8rem; font-weight: 400; line-height: 1.45; text-align: left;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.hilfe:hover::after, .hilfe:focus-visible::after { opacity: 1; }

/* --- Fehlerübersicht am Formularanfang -----------------------------------
   Bei einem langen Formular sieht man den Fehler weiter unten nicht. Diese
   Liste steht oben und verlinkt zu den Feldern. -------------------------- */
.fehleruebersicht {
  border: 1px solid var(--fehler); border-left-width: 4px;
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: var(--luft);
  background: var(--flaeche);
}
.fehleruebersicht b { display: block; color: var(--fehler); margin-bottom: 6px; }
.fehleruebersicht ul { margin: 0; padding-left: 20px; }
.fehleruebersicht a { color: var(--fehler); }

/* --- Offline-Band (PWA) ---------------------------------------------------
   Wird von app.js ein- und ausgeblendet. Ohne diese Rückmeldung tippt der
   Nutzer weiter und wundert sich, warum nichts ankommt. ------------------ */
.offline-band {
  position: fixed; left: 0; right: 0; top: 0; z-index: 320; display: none;
  background: var(--warn); color: #1a1a1a; text-align: center; /* feste-farbe-ok: dunkler Text auf Warnfarbe */
  padding: 7px 12px; font-size: .87rem; font-weight: 600;
}
.offline-band[data-an="1"] { display: block; }

/* --- Speicherstand -------------------------------------------------------- */
.speicherstand { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--schwach); }
.speicherstand::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--erfolg); }
.speicherstand[data-offen="1"]::before { background: var(--warn); }

/* ###########################################################################
   D  HILFSKLASSEN
   ######################################################################### */
.reihe   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reihe--ende { justify-content: flex-end; }
.schub   { flex: 1; }
.stapel > * + * { margin-top: var(--luft); }
.mitte   { text-align: center; }
.rechts  { text-align: right; }
.gedraengt { --luft: 9px; }
