/* ============================================================================
   Nalubalance – Verwaltungsoberfläche
   Alle Farben als CSS-Variablen an dieser einen Stelle (siehe Vorgabe).
   Mobil zuerst: Basis-Regeln gelten fürs Handy, @media (min-width) erweitert
   für größere Bildschirme.
   ============================================================================ */

:root {
  --sand: #DEC49B;         /* Markenfarbe, Akzente */
  --sand-hell: #F7F1E6;    /* Karten, Zeilen */
  --sand-dunkel: #B8965F;  /* Knöpfe, aktive Elemente */
  --ink: #2A2620;          /* Text */
  --ink-leicht: #7A7266;   /* Nebentext */
  --linie: #E5DCC9;        /* Trennlinien */
  --bg: #FDFBF7;           /* Seitenhintergrund */

  --gefahr: #A13D3D;       /* nur für die Anonymisieren-Gefahrenzone */
  --gefahr-hell: #F6E9E9;
  --erfolg: #4F7A5A;       /* dezente Erfolgsmeldungen */

  --radius: 10px;
  --abstand: 16px;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut ist nicht immer stärker als eine Klassenregel mit
   gleicher Spezifität (z. B. .feld { display:flex }, .feld-reihe {
   display:grid }) – je nach Deklarationsreihenfolge gewinnt sonst die
   Klasse und ein per JS/HTML als hidden markiertes Element bleibt trotzdem
   sichtbar (Ursache für: Eventpreis (€) sichtbar, obwohl Serie gewählt ist).
   Diese Regel stellt sicher, dass hidden immer gewinnt, unabhängig davon,
   welche anderen Klassen ein Element sonst noch trägt. */
[hidden] { display: none !important; }

/* Gemeinsamer, seitenübergreifender Fehlerbereich (siehe auth.js): wird dort
   per JS erzeugt und an den Anfang von <body> gestellt, damit jeder
   unbehandelte Fehler (window.onerror, unhandledrejection, oder ein
   Absturz in init()) sichtbar gemeldet wird, statt eine Seite still und
   scheinbar funktionsfähig zurückzulassen (siehe z. B. der ART_LABEL-Bug in
   kurs-detail.js/teilnehmer-detail.js). Bewusst nicht Teil der einzelnen
   HTML-Dateien, damit jede Seite ihn automatisch bekommt, ohne dass Sarah
   oder wir daran denken müssen, ihn beim Anlegen einer neuen Seite
   mitzukopieren. */
.globaler-fehler-leiste {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--gefahr);
  color: #fff;
  padding: 12px var(--abstand);
  font-size: 0.92rem;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.globaler-fehler-leiste strong { font-weight: 700; }
.globaler-fehler-leiste .globaler-fehler-details {
  display: block;
  margin-top: 4px;
  opacity: 0.85;
  font-size: 0.85rem;
  word-break: break-word;
}
.globaler-fehler-leiste button {
  flex: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}
.globaler-fehler-leiste button:hover { background: rgba(255,255,255,0.25); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--sand-dunkel); }

h1, h2, h3 {
  margin: 0 0 8px 0;
  font-weight: 600;
  color: var(--ink);
}
h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }

.muted { color: var(--ink-leicht); font-size: 0.9rem; }

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

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--abstand);
  padding: 12px var(--abstand);
  background: var(--sand-hell);
  border-bottom: 1px solid var(--linie);
  position: sticky;
  top: 0;
  z-index: 10;
}

header.app-header .logo-zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--sand-dunkel);
  text-decoration: none;
  font-size: 1.05rem;
}

header.app-header .logo-symbol {
  height: 40px;
  width: auto;
  display: block;
}

header.app-header nav {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

header.app-header nav a {
  text-decoration: none;
  color: var(--ink);
  font-size: 0.95rem;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}
header.app-header nav a.aktiv {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--sand-dunkel);
}

/* v21: wer ist angemeldet (siehe auth.js) */
header.app-header nav a.nav-nutzer {
  color: var(--ink-leicht);
  font-size: 0.85rem;
  padding: 2px 8px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: #fff;
}
header.app-header nav a.nav-nutzer:hover { color: var(--ink); }

/* Nachtrag: Zähler "Neue Anmeldungen" im Menü (siehe auth.js) */
.nav-zaehler {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--sand-dunkel);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

/* ---------- Layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--abstand);
}

.karte {
  background: #fff;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: var(--abstand);
  margin-bottom: var(--abstand);
}

/* ---------- Formulare ---------- */

.feld {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feld-reihe {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

label {
  font-size: 0.85rem;
  color: var(--ink-leicht);
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--sand-dunkel);
  outline-offset: 1px;
}

textarea { min-height: 72px; resize: vertical; }

/* Umschalter (z. B. Privatperson/Firma, Archiviert) */
.umschalter {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Buttons ---------- */

button, .knopf {
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.knopf-primaer, button.primaer {
  background: var(--sand-dunkel);
  color: #fff;
}
.knopf-primaer:hover, button.primaer:hover { background: #a3824f; }

.knopf-sekundaer, button.sekundaer {
  background: #fff;
  border-color: var(--linie);
  color: var(--ink);
}
.knopf-sekundaer:hover, button.sekundaer:hover { background: var(--sand-hell); }

.knopf-gefahr, button.gefahr {
  background: #fff;
  border-color: var(--gefahr);
  color: var(--gefahr);
}
.knopf-gefahr:hover, button.gefahr:hover { background: var(--gefahr-hell); }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.knopf-reihe {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ---------- Meldungen ---------- */

.meldung {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.meldung-fehler   { background: var(--gefahr-hell); color: var(--gefahr); }
.meldung-warnung  { background: var(--sand-hell); color: #7a5a20; border: 1px solid var(--sand); }
.meldung-erfolg   { background: #eaf2ec; color: var(--erfolg); }

/* ---------- Teilnehmerliste ---------- */

.liste-werkzeuge {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--abstand);
}

.teilnehmer-eintrag {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--linie);
  text-decoration: none;
  color: var(--ink);
}
.teilnehmer-eintrag:hover { background: var(--sand-hell); }

.teilnehmer-eintrag .name { font-weight: 600; }
.teilnehmer-eintrag .details { color: var(--ink-leicht); font-size: 0.85rem; margin-top: 2px; }

/* Nachtrag: Eingang "Neue Anmeldungen" (anmeldung-detail.html) */
.anmeldung-felder {
  margin: 0;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
}
.anmeldung-felder dt { color: var(--ink-leicht); font-size: 0.85rem; }
.anmeldung-felder dd { margin: 0; }
@media (max-width: 480px) {
  .anmeldung-felder { grid-template-columns: 1fr; gap: 2px; }
  .anmeldung-felder dt { margin-top: 8px; }
}

.vorschlag-eintrag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--linie);
  flex-wrap: wrap;
}
.vorschlag-eintrag .name { font-weight: 600; }
.vorschlag-eintrag .details { color: var(--ink-leicht); font-size: 0.85rem; margin-top: 2px; }

.abzeichen {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.abzeichen-archiviert { background: var(--linie); color: var(--ink-leicht); }
.abzeichen-anonymisiert { background: var(--gefahr-hell); color: var(--gefahr); }
.abzeichen-erfolg { background: #eaf2ec; color: var(--erfolg); }
.abzeichen-warnung { background: var(--sand-hell); color: #7a5a20; border: 1px solid var(--sand); }

/* ---------- Gefahrenzone (Anonymisieren) ---------- */

.gefahrenzone {
  border: 1px solid var(--gefahr);
  background: var(--gefahr-hell);
  border-radius: var(--radius);
  padding: var(--abstand);
  margin-top: 24px;
}
.gefahrenzone h3 { color: var(--gefahr); }

.gefahrenzone-trenner {
  border: none;
  border-top: 1px solid var(--gefahr);
  opacity: 0.3;
  margin: 20px 0;
}

/* ---------- Inline-Warnhinweise an Formularfeldern (z. B. Steuernummer) ---------- */

.feld-warnung {
  margin: 0;
  font-size: 0.82rem;
  color: #7a5a20;
}

/* ---------- Login ---------- */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--abstand);
}
.login-karte {
  width: 100%;
  max-width: 360px;
}

.login-logo {
  display: block;
  width: 220px;
  max-width: 80%;
  height: auto;
  margin: 0 auto 20px auto;
}

/* ---------- Größere Bildschirme ---------- */

@media (min-width: 640px) {
  .feld-reihe-2 { grid-template-columns: 1fr 1fr; }
  .feld-reihe-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Nachtrag: Liste der verfügbaren Platzhalter unter Textfeldern (Einstellungen) */
.platzhalter-liste { margin: 0; font-size: 0.82rem; }

/* ---------- Seite "Rechnungen" (Abtippansicht für Fattura Smart, v19) ----------
   Mobil zuerst: Bezeichnung über dem Wert, "Kopieren" rechts daneben, große
   Knöpfe. Ab 640px Bezeichnung links in einer eigenen Spalte. */
.rf-stand { margin: 0 0 10px; font-weight: 600; color: var(--ink-leicht); }
.rf-karte { padding: 14px var(--abstand); }
.rf-kopf {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 10px;
}
.rf-kopf .abzeichen { margin-left: 0; }
.rf-ref { font-weight: 700; text-decoration: none; }
.rf-warnung { margin-bottom: 10px; }
.rf-felder { border-top: 1px solid var(--linie); }
.rf-zeile {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label label" "wert knopf";
  align-items: center;
  gap: 2px 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--linie);
}
.rf-label { grid-area: label; font-size: 0.8rem; font-weight: 600; color: var(--ink-leicht); }
.rf-wert {
  grid-area: wert;
  font-size: 1.12rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  min-width: 0;
}
.rf-zeile > button, .rf-zeile > span:last-child { grid-area: knopf; }
.rf-kopieren { min-width: 108px; min-height: 44px; padding: 8px 12px; }
.rf-zeile.kopiert .rf-label::after { content: " ✓ kopiert"; color: var(--erfolg); font-weight: 600; }
.rf-zeile.kopiert .rf-kopieren { border-color: var(--erfolg); }
.rf-fehlt { color: var(--gefahr); font-size: 0.95rem; }
.rf-rabatt { display: block; margin-top: 2px; font-size: 0.85rem; font-weight: 400; color: #7a5a20; }
.rf-zeile-text { align-items: start; }
.rf-zeile-text .rf-kopieren { align-self: start; }
.rf-text { font-size: 1rem; font-weight: 400; min-height: 64px; }
.rf-text[readonly] { background: var(--sand-hell); }
.rf-abschluss { margin-top: 14px; }
.rf-abschluss .feld { margin-bottom: 8px; }
.rf-erfassen { width: 100%; min-height: 48px; }
.rf-abschluss-erfasst .rf-rechnung-zeile { margin: 0 0 10px; }
/* v20: Rechnungsnummer unter "erfasst" nachtragen */
.rf-nr-nachtragen {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  margin-bottom: 10px;
}
.rf-nr-nachtragen .feld { flex: 1 1 180px; margin-bottom: 0; }
.rf-nr-nachtragen button { min-height: 44px; }
.rf-karte-erledigt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  background: #f3f8f4;
  border-color: #cfe2d4;
}
.rf-erledigt-text { margin: 0; }
.rf-haken { color: var(--erfolg); font-weight: 700; margin-right: 4px; }
@media (min-width: 640px) {
  .rf-zeile {
    grid-template-columns: 150px 1fr auto;
    grid-template-areas: "label wert knopf";
    gap: 10px 14px;
  }
  .rf-label { font-size: 0.85rem; }
  .rf-erfassen { width: auto; }
}

/* ---------- v21: Verlauf im Buchungsdetail ---------- */
.verlauf-liste { list-style: none; margin: 0; padding: 0; }
.verlauf-liste li { padding: 8px 0; border-bottom: 1px solid var(--linie); }
.verlauf-liste li:last-child { border-bottom: none; }
.verlauf-was { font-weight: 600; }
.verlauf-zeit { font-size: 0.85rem; }

/* v21: Sprungziele (z. B. #mein-konto) nicht unter der festen Leiste verstecken */
.karte { scroll-margin-top: 96px; }
