/* Faktura – Gestaltung im Stil von iOS/macOS, mobil zuerst, ohne Build-Schritt.
   Regel: Antippbar ist, was Akzentfarbe hat, ein gefüllter Knopf ist oder einen Pfeil › trägt. */
:root {
  color-scheme: light dark;
  --bg: #f2f2f7;            /* systemGroupedBackground */
  --flaeche: #ffffff;       /* secondarySystemGroupedBackground */
  --flaeche-2: #f2f2f7;
  --text: #000000;
  --gedaempft: #6c6c70;     /* secondaryLabel, kontraststark */
  --leise: #aeaeb2;
  --linie: #d1d1d6;
  --trenner: rgba(60, 60, 67, .18);
  --fuellung: rgba(118, 118, 128, .12);
  --fuellung-hover: rgba(118, 118, 128, .2);
  --akzent: #5856d6;        /* systemIndigo */
  --akzent-hover: #4b49c4;
  --akzent-hell: rgba(88, 86, 214, .12);
  --auf-akzent: #ffffff;
  --gruen: #248a3d; --gruen-voll: #34c759; --gruen-hell: rgba(52, 199, 89, .14);
  --gelb: #c93400;  --gelb-voll: #ff9500;  --gelb-hell: rgba(255, 149, 0, .14);
  --rot: #d70015;   --rot-voll: #ff3b30;   --rot-hell: rgba(255, 59, 48, .12);
  --radius: 12px;
  --radius-klein: 10px;
  --schatten: none;
  --leiste: rgba(249, 249, 249, .86);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --flaeche: #1c1c1e;
    --flaeche-2: #2c2c2e;
    --text: #ffffff;
    --gedaempft: #98989f;
    --leise: #636366;
    --linie: #38383a;
    --trenner: rgba(84, 84, 88, .65);
    --fuellung: rgba(118, 118, 128, .24);
    --fuellung-hover: rgba(118, 118, 128, .34);
    --akzent: #7d7aff;       /* systemIndigo (dunkel), heller für Lesbarkeit */
    --akzent-hover: #908dff;
    --akzent-hell: rgba(94, 92, 230, .24);
    --auf-akzent: #ffffff;
    --gruen: #30d158; --gruen-voll: #30d158; --gruen-hell: rgba(48, 209, 88, .18);
    --gelb: #ffb340;  --gelb-voll: #ff9f0a;  --gelb-hell: rgba(255, 159, 10, .18);
    --rot: #ff6961;   --rot-voll: #ff453a;   --rot-hell: rgba(255, 69, 58, .18);
    --leiste: rgba(22, 22, 24, .86);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  letter-spacing: -.01em; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); /* Platz für die Tab-Leiste */
}
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: none; opacity: .8; }
h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.025em; margin: 0; line-height: 1.15; }
h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -.015em; margin: 0 0 .75rem; }
.gedaempft { color: var(--gedaempft); }
.klein { font-size: .85rem; }
.rechts { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* Kopfleiste: durchscheinend wie die iOS-Navigationsleiste */
.kopf {
  position: sticky; top: 0; z-index: 10; background: var(--leiste);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--trenner);
  display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
}
.marke { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; color: var(--text); letter-spacing: -.02em; }
.marke::before { content: ""; width: 26px; height: 26px; border-radius: 7px; background: var(--akzent);
  -webkit-mask: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.marke span { display: none; }
.marke:hover { opacity: 1; }
.navi-oben { display: none; gap: .15rem; flex: 1; }
.navi-oben a { color: var(--text); padding: .4rem .75rem; border-radius: 8px; font-size: .95rem; }
.navi-oben a:hover { background: var(--fuellung); opacity: 1; }
.navi-oben a.aktiv { color: var(--akzent); background: var(--akzent-hell); font-weight: 600; }
.kopf .benutzer { margin-left: auto; display: flex; gap: .5rem; align-items: center; }

/* Tab-Leiste unten (mobil) */
.navi-unten {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--leiste);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--trenner); display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.navi-unten a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 6px;
  color: var(--leise); font-size: .68rem; font-weight: 500; letter-spacing: 0; }
.navi-unten a:hover { opacity: 1; }
.navi-unten svg { width: 25px; height: 25px; }
.navi-unten a.aktiv { color: var(--akzent); }
@media (min-width: 900px) {
  .navi-oben { display: flex; }
  .navi-unten { display: none; }
  body { padding-bottom: 0; }
}

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
@media (min-width: 900px) { main { padding: 1.5rem 1.5rem 2rem; } }
.titelzeile { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: .35rem 0 1.1rem; }
.titelzeile .aktionen { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

/* Karten = gruppierte Listen-Abschnitte */
.karte { background: var(--flaeche); border: 0; border-radius: var(--radius); box-shadow: var(--schatten);
  padding: 1rem; margin-bottom: 1rem; }
.raster { display: grid; gap: 1rem; }
.raster > .karte { margin-bottom: 0; }
.raster { margin-bottom: 1rem; }
@media (min-width: 700px) { .raster-2 { grid-template-columns: 1fr 1fr; } .raster-3 { grid-template-columns: repeat(3, 1fr); } }
.kennzahl { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Knöpfe: gefüllt = Hauptaktion, grau getönt = Nebenaktion */
.knopf, button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
  padding: .5rem 1rem; border-radius: var(--radius); border: 0; background: var(--fuellung);
  color: var(--akzent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, transform .1s, opacity .15s; touch-action: manipulation;
}
.knopf:hover, button:hover { background: var(--fuellung-hover); opacity: 1; }
.knopf:active, button:active { transform: scale(.97); }
.knopf:focus-visible, button:focus-visible { outline: 3px solid var(--akzent-hell); outline-offset: 2px; }
.knopf.primaer, button.primaer { background: var(--akzent); color: var(--auf-akzent); }
.knopf.primaer:hover, button.primaer:hover { background: var(--akzent-hover); }
.knopf.gefahr, button.gefahr { color: var(--rot); }
.knopf.klein, button.klein { min-height: 34px; padding: .25rem .75rem; font-size: .88rem; border-radius: 9px; }
button:disabled { opacity: .45; cursor: default; transform: none; }
form.inline { display: inline; }

/* Formulare */
label { display: block; font-size: .82rem; font-weight: 500; color: var(--gedaempft); margin-bottom: .3rem; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16 px: kein automatisches Zoomen auf dem iPhone */
  color: var(--text); background: var(--flaeche); border: 1px solid var(--linie);
  border-radius: var(--radius-klein); padding: .55rem .75rem; min-height: 44px;
}
.karte input, .karte select, .karte textarea, .position input, .position select { background: var(--flaeche-2); border-color: transparent; }
select { -webkit-appearance: none; appearance: none; padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; }
textarea { min-height: 0; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--akzent); box-shadow: 0 0 0 3px var(--akzent-hell); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; vertical-align: -4px; accent-color: var(--akzent); margin: 0 .35rem 0 0; }
input[type=file] { padding: .45rem; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; color: var(--akzent); background: var(--fuellung);
  border: 0; border-radius: 8px; padding: .35rem .8rem; margin-right: .75rem; cursor: pointer; }
.feld { margin-bottom: .9rem; }
.feld .fehler, .fehlerliste, .fehler { color: var(--rot); font-size: .85rem; margin-top: .25rem; }
.feld .hilfe { color: var(--gedaempft); font-size: .8rem; margin-top: .25rem; }
.felder { display: grid; gap: 0 1rem; }
@media (min-width: 700px) { .felder { grid-template-columns: repeat(2, 1fr); } .felder .breit { grid-column: 1 / -1; } }

/* Tabellen / Listen: Zeilen mit Pfeil sind antippbar */
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th { text-align: left; font-size: .75rem; color: var(--gedaempft); font-weight: 500; text-transform: uppercase;
  letter-spacing: .03em; padding: .4rem .5rem .5rem; border-bottom: .5px solid var(--trenner); }
.tabelle td { padding: .7rem .5rem; border-bottom: .5px solid var(--trenner); vertical-align: top; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle tr.klickbar { cursor: pointer; }
.tabelle tr.klickbar td:last-child { position: relative; padding-right: 1.7rem; }
.tabelle tr.klickbar td:last-child::after { content: ""; position: absolute; right: .45rem; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--leise); border-top: 2px solid var(--leise); transform: translateY(-50%) rotate(45deg); border-radius: 1px; }
.tabelle tr.klickbar:hover td { background: var(--fuellung); }
.tabelle tr.klickbar:active td { background: var(--fuellung-hover); }
.tabelle td a { font-weight: 600; color: var(--text); }
@media (max-width: 699px) {
  .tabelle.stapel thead { display: none; }
  .tabelle.stapel tr { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: .65rem 0; border-bottom: .5px solid var(--trenner); }
  .tabelle.stapel tr:last-child { border-bottom: 0; }
  .tabelle.stapel td { border: 0; padding: .1rem .25rem; }
  .tabelle.stapel td.mobil-aus { display: none; }
  .tabelle.stapel td.mobil-voll { grid-column: 1; }
}
.karte > .tabelle:first-child, .karte > table { margin: -.35rem 0; }

.suche { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.suche input { flex: 1 1 200px; border-color: transparent; background: var(--fuellung); }
.suche select { flex: 0 1 180px; }
/* Reiter als Segment-Steuerung */
.reiter { display: flex; gap: 2px; overflow-x: auto; margin-bottom: 1rem; padding: 2px; background: var(--fuellung);
  border-radius: 10px; width: fit-content; max-width: 100%; scrollbar-width: none; }
.reiter::-webkit-scrollbar { display: none; }
.reiter a { padding: .38rem .85rem; border-radius: 8px; color: var(--text); white-space: nowrap; font-size: .88rem; font-weight: 500; }
.reiter a:hover { opacity: 1; background: var(--fuellung); }
.reiter a.aktiv { background: var(--flaeche); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.04); }
@media (prefers-color-scheme: dark) { .reiter a.aktiv { background: #636366; } }

/* Status-Marken */
.marke-status { display: inline-block; font-size: .75rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; white-space: nowrap; }
.s-entwurf { background: var(--gelb-hell); color: var(--gelb); }
.s-fest, .s-offen { background: var(--akzent-hell); color: var(--akzent); }
.s-bezahlt { background: var(--gruen-hell); color: var(--gruen); }
.s-ueberfaellig, .s-storniert { background: var(--rot-hell); color: var(--rot); }

/* Meldungen */
.meldung { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .9rem; border: 0; font-size: .95rem; }
.meldung.success { background: var(--gruen-hell); color: var(--gruen); }
.meldung.error { background: var(--rot-hell); color: var(--rot); }
.meldung.warning { background: var(--gelb-hell); color: var(--gelb); }
.meldung.info { background: var(--akzent-hell); color: var(--akzent); }
.meldung ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.meldung a { font-weight: 600; text-decoration: underline; }

/* Positionen im Bearbeitungsformular */
.position { border: 0; border-radius: var(--radius); padding: .85rem; margin-bottom: .75rem; background: var(--flaeche); }
.karte .position { background: var(--bg); }
.karte .position input, .karte .position select { background: var(--flaeche); }
.position-kopf { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; font-weight: 600; }
.position-kopf .rechts { margin-left: auto; }
.position .zeile { display: grid; gap: 0 .6rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) {
  .position .zeile.oben { grid-template-columns: 1.2fr 2fr 1fr; }
  .position .zeile.unten { grid-template-columns: repeat(6, 1fr); }
}
.position.geloescht { opacity: .45; }
.summenbox { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1.5rem; max-width: 380px; margin-left: auto; font-variant-numeric: tabular-nums; }
.summenbox .gesamt { font-weight: 700; border-top: .5px solid var(--trenner); padding-top: .35rem; }
.aktionsleiste { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--leiste);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  padding: .7rem 0; display: flex; gap: .5rem; justify-content: flex-end; z-index: 5; }
.aktionsleiste button { flex: 1 1 auto; }
@media (min-width: 900px) { .aktionsleiste { bottom: 0; } .aktionsleiste button { flex: 0 0 auto; } }

.anmeldung { max-width: 380px; margin: 10vh auto; }
.anmeldung button { width: 100%; }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
.codes { font-family: ui-monospace, "SF Mono", Menlo, monospace; columns: 2; font-size: 1.05rem; }
details summary { cursor: pointer; color: var(--akzent); font-weight: 500; }
.protokoll td { font-size: .85rem; }

.testbanner { background: var(--gelb-hell); color: var(--gelb); text-align: center; font-weight: 600;
  font-size: .78rem; padding: .35rem 1rem; }

/* Lade-Anzeige beim Hochladen/Erkennen */
.lade { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.lade[hidden] { display: none; }
.lade-box { background: var(--flaeche); border-radius: 22px; padding: 1.75rem 1.5rem; width: min(320px, 86vw);
  text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.kreisel { width: 54px; height: 54px; margin: 0 auto 1rem; border-radius: 50%;
  border: 4px solid var(--akzent-hell); border-top-color: var(--akzent); animation: drehen .9s linear infinite; }
.lade-titel { font-weight: 600; font-size: 1.1rem; margin: 0 0 .35rem; }
.lade-unter { color: var(--gedaempft); font-size: .9rem; margin: 0; min-height: 1.3em; }
@keyframes drehen { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .kreisel { animation-duration: 2.5s; } }

/* „Erledigt“-Karte nach dem Erfassen */
.erledigt { background: var(--flaeche); color: var(--text); border-radius: var(--radius);
  padding: 1.5rem 1rem 1rem; margin-bottom: 1rem; text-align: center; }
.erledigt .haken { width: 60px; height: 60px; margin: 0 auto .6rem; border-radius: 50%; background: var(--gruen-voll);
  color: #fff; font-size: 2rem; line-height: 60px; font-weight: 700; }
.erledigt h1 { font-size: 1.4rem; margin: 0 0 .3rem; }
.erledigt p { margin: .2rem 0; }
.erledigt .aktionen { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.1rem; }
@media (min-width: 700px) { .erledigt .aktionen { flex-direction: row; justify-content: center; } }
.erledigt .knopf { min-height: 50px; font-size: 1.05rem; }
details.spaeter > summary { cursor: pointer; font-weight: 600; color: var(--akzent); padding: .85rem 1rem; list-style: none;
  border-radius: var(--radius); background: var(--flaeche); margin-bottom: .9rem; position: relative; }
details.spaeter > summary::-webkit-details-marker { display: none; }
details.spaeter > summary::after { content: ""; position: absolute; right: 1.1rem; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--leise); border-bottom: 2px solid var(--leise); transform: translateY(-70%) rotate(45deg); transition: transform .2s; }
details.spaeter[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }

/* Navigationslisten wie in den iOS-Einstellungen: jede Zeile antippbar, mit Pfeil */
.abschnitt { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--gedaempft); margin: 1.2rem 1rem .4rem; }
.liste { background: var(--flaeche); border-radius: var(--radius); overflow: hidden; margin-bottom: 1rem; }
.liste > a, .liste .zeilenknopf { display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: .7rem 2.4rem .7rem 1rem;
  color: var(--text); position: relative; font-weight: 400; width: 100%; background: none; border-radius: 0; justify-content: flex-start; }
.liste > * { position: relative; }
.liste > * + *::before { content: ""; position: absolute; left: 1rem; right: 0; top: 0; height: .5px; background: var(--trenner); }
.liste > a::after { content: ""; position: absolute; right: 1.1rem; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--leise); border-top: 2px solid var(--leise); transform: translateY(-50%) rotate(45deg); }
.liste > a span { margin-left: auto; font-size: .9rem; }
.liste > a:hover, .liste .zeilenknopf:hover { background: var(--fuellung); opacity: 1; }
.liste .zeilenknopf.gefahr { color: var(--rot); font-weight: 400; }
.liste form { margin: 0; }
.app-symbol { width: 64px; height: 64px; border-radius: 15px; background: var(--akzent); margin: .25rem auto .9rem;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
/* App-Symbol: weißer Beleg auf Indigo */
.app-symbol, .marke::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-3-2-3 2-3-2-3 2z'/%3E%3Cpath d='M9 8h6M9 12h6M9 16h3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 62%;
}
.knopf.gross { min-height: 52px; font-size: 1.05rem; width: 100%; border-radius: 14px; }
.erfassen { display: grid; gap: .6rem; margin-bottom: 1.2rem; }
@media (min-width: 700px) { .erfassen { grid-template-columns: 1fr 1fr; align-items: start; } .erfassen .hinweis { grid-column: 1 / -1; } }
.erfassen form { margin: 0; }
.erfassen .hinweis { margin: 0 .25rem; }
details.hochladen > summary { list-style: none; }
details.hochladen > summary::-webkit-details-marker { display: none; }
details.hochladen[open] > summary { margin-bottom: .6rem; }
details.hochladen .karte { margin: 0; }
@media (max-width: 899px) { .kopf .benutzer { display: none; } }  /* mobil: Abmelden unter „Mehr“ */

/* Finanzen */
.monatswahl { align-items: center; }
.monatswahl .monat { font-weight: 600; min-width: 9rem; text-align: center; }
.knopf.aus { opacity: .35; pointer-events: none; }
.finanz .summenbox { max-width: none; margin: 0; }
.finanz h2 .klein { font-weight: 400; }
.summenbox .einzug { padding-left: .9rem; }
.summenbox .zwischensumme { font-weight: 600; border-top: .5px solid var(--trenner); padding-top: .3rem; }
.karte.massgeblich { box-shadow: 0 0 0 2px var(--akzent); }
.warnung-text { color: var(--gelb); margin-bottom: 0; }
.warnung-text a { color: inherit; text-decoration: underline; }
tr.gewaehlt td { background: var(--fuellung); }
@media (max-width: 699px) {
  .jahrestabelle .mobil-aus { display: none; }
  .jahrestabelle { font-size: .8rem; }
  .jahrestabelle th, .jahrestabelle td { padding-left: .3rem; padding-right: .3rem; }
  .jahrestabelle tr.klickbar td:last-child::after { display: none; }
}

/* B2B / Studio */
.etikett-studio { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px;
  background: var(--akzent-hell); color: var(--akzent); }
form.anzahlung { display: inline-flex; align-items: center; gap: .35rem; }
form.anzahlung label { margin: 0; }
form.anzahlung input { width: 5.5rem; }
