/* Tradebook — Gestaltung nach dem Design-CI (MeinManager/doku/Tradebook Design-CI.pdf).
   Heller Grund fuer draussen, dunkle Fassung fuer abends. Farbe bedeutet die Richtung des Geldes:
   Gruen = Geld rein, Lehm = Geld raus, Bernstein = wartet noch auf Uebertragung. */

@font-face { font-family: "Jakarta"; font-weight: 400; font-display: swap; src: url("fonts/PlusJakartaSans-400.woff2") format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 600; font-display: swap; src: url("fonts/PlusJakartaSans-600.woff2") format("woff2"); }
@font-face { font-family: "Jakarta"; font-weight: 700; font-display: swap; src: url("fonts/PlusJakartaSans-700.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("fonts/IBMPlexMono-400.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("fonts/IBMPlexMono-600.woff2") format("woff2"); }

:root {
  --paper: #F2F4F0;
  --surface: #FFFFFF;
  --surface-2: #F8FAF7;
  --ink: #18201C;
  --ink-2: #47534C;
  --muted: #79847D;
  --line: #DCE2D9;
  --line-soft: #E9EDE6;
  --green: #2F7D4F;
  --green-soft: #E4F0E8;
  --clay: #A8452F;
  --clay-soft: #F6E6E1;
  --amber: #9A6B14;
  --amber-soft: #F7EDD8;
  --r-knopf: 8px;
  --r-karte: 12px;
  --sans: "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Plex", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141815;
    --surface: #1C221E;
    --surface-2: #232A25;
    --ink: #E8EDE9;
    --ink-2: #B3BDB7;
    --muted: #8A958E;
    --line: #333C36;
    --line-soft: #2A322C;
    --green: #5FB277;
    --green-soft: #1E3326;
    --clay: #E08E76;
    --clay-soft: #3A251F;
    --amber: #D9AE5E;
    --amber-soft: #352B16;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Muss vor allem anderen stehen: sonst gewinnt ein spaeteres display:flex gegen das
   hidden-Attribut, und verborgene Teile wie das Menue stehen dauerhaft offen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ---------------------------------------------------------------- Anmeldung */
.tor { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.tor-karte {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-karte);
  padding: 26px 22px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}
.tor-karte h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.tor-text { margin: 0; color: var(--ink-2); font-size: 15px; }
.tor-klein { margin: 0; color: var(--muted); font-size: 12px; }
.tor-fehler { margin: 0; color: var(--clay); font-size: 14px; font-weight: 600; }

/* ---------------------------------------------------------------- Rahmen */
.app { max-width: 560px; margin: 0 auto; padding: 0 16px; }

.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 0 12px;
  position: sticky; top: 0; background: var(--paper); z-index: 20;
}
.kopf-titel { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kopf-titel h1 {
  margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.015em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kopf-unter { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.rund {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-knopf);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  display: grid; place-items: center; font-size: 17px;
}
.zurueck-knopf {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-knopf);
  display: grid; place-items: center; font-size: 22px; color: var(--ink-2); margin-left: -8px;
}

.inhalt { display: flex; flex-direction: column; gap: 14px; padding-bottom: 28px; }
.lade { color: var(--muted); padding: 30px 0; text-align: center; font-size: 15px; }

/* ---------------------------------------------------------------- Kassenstand */
.stand {
  background: var(--green-soft); border-radius: var(--r-karte); padding: 16px 17px;
  display: flex; flex-direction: column; gap: 2px;
}
.stand .etikett {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--green); font-weight: 600;
}
.stand .zahl {
  font-family: var(--mono); font-size: 30px; font-weight: 600; letter-spacing: -.025em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stand .zahl.neg { color: var(--clay); }
.stand .eur { font-family: var(--mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stand .warte {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(47,125,79,.22);
  font-size: 12.5px; color: var(--amber); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.punkt { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: none; }
.punkt.gruen { background: var(--green); }

/* ---------------------------------------------------------------- Kennzahlen */
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.kennzahl {
  border: 1px solid var(--line-soft); border-radius: var(--r-knopf); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 1px; background: var(--surface);
}
.kennzahl .k-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.kennzahl .k-wert { font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.k-wert.out { color: var(--clay); }
.k-wert.in { color: var(--green); }

/* ---------------------------------------------------------------- Listen */
.listenkopf {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-top: 2px;
}
.liste { display: flex; flex-direction: column; }
.zeile {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 11px; align-items: center;
  padding: 11px 0; border-bottom: 1px solid var(--line-soft); text-align: left; width: 100%;
}
.zeile:last-child { border-bottom: none; }
.marke {
  width: 30px; height: 30px; border-radius: var(--r-knopf); display: grid; place-items: center;
  font-size: 14px; font-weight: 700; flex: none;
}
.marke.out { background: var(--clay-soft); color: var(--clay); }
.marke.in { background: var(--green-soft); color: var(--green); }
.zeile .was { display: flex; flex-direction: column; min-width: 0; }
.zeile .was .t {
  font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zeile .was .m {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.zeile .was .m .warte { color: var(--amber); font-weight: 600; }
.betrag {
  font-family: var(--mono); font-size: 14.5px; font-weight: 600;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.betrag.out { color: var(--clay); }
.betrag.in { color: var(--green); }

/* ---------------------------------------------------------------- Knöpfe */
.knopf {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; border-radius: var(--r-knopf); padding: 12px 16px;
  font-size: 16px; font-weight: 700; width: 100%;
  background: var(--green); color: #fff;
}
.knopf.rand { background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: 15px; }
.knopf.gefahr { background: var(--clay); color: #fff; }
.knopf.leise { background: none; color: var(--clay); border: 1px solid var(--line); font-weight: 600; font-size: 15px; }
.knopf:disabled { opacity: .45; }
.knopf:active { filter: brightness(.94); }

/* ---------------------------------------------------------------- Richtung */
.richtung { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.richtung button {
  border-radius: var(--r-knopf); padding: 15px 8px; min-height: 60px;
  font-size: 15px; font-weight: 700;
  border: 2px solid var(--line); background: var(--surface); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.richtung button .pfeil { font-size: 17px; line-height: 1; }
.richtung button[aria-pressed="true"].out { border-color: var(--clay); background: var(--clay-soft); color: var(--clay); }
.richtung button[aria-pressed="true"].in { border-color: var(--green); background: var(--green-soft); color: var(--green); }

/* ---------------------------------------------------------------- Felder */
.feld { display: flex; flex-direction: column; gap: 6px; }
.feld-label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.eingabe-feld {
  border: 1px solid var(--line); border-radius: var(--r-knopf); background: var(--surface-2);
  padding: 12px 13px; width: 100%; min-height: 44px; color: var(--ink);
}
.eingabe-feld:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.eingabe-feld.betrag-feld {
  font-family: var(--mono); font-size: 24px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.hinweis { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.hinweis.warn { color: var(--clay); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); border-radius: var(--r-knopf); padding: 9px 13px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--surface); min-height: 40px;
}
/* Die gewaehlte Marke wird dunkel gefuellt, nicht gruen: Gruen bleibt dem Geld vorbehalten. */
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.foto-knopf {
  border: 2px dashed var(--line); border-radius: var(--r-knopf); padding: 15px;
  display: flex; align-items: center; gap: 12px; background: var(--surface-2); width: 100%; text-align: left;
}
.foto-knopf .sym {
  width: 38px; height: 38px; border-radius: var(--r-knopf); background: var(--surface);
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; flex: none;
}
.foto-knopf .txt { display: flex; flex-direction: column; min-width: 0; }
.foto-knopf .txt b { font-size: 15px; font-weight: 700; }
.foto-knopf .txt span { font-size: 12.5px; color: var(--muted); }
.foto-knopf.hat { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.foto-vorschau { width: 100%; border-radius: var(--r-knopf); border: 1px solid var(--line); display: block; }

/* ---------------------------------------------------------------- Abschluss */
.rechnung { display: flex; flex-direction: column; }
.r-zeile {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px;
}
.r-zeile span { color: var(--ink-2); }
.r-zeile b { font-family: var(--mono); font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.r-zeile.summe { border-top: 1px solid var(--line); border-bottom: 2px solid var(--line); margin-top: 3px; }
.r-zeile.summe span { color: var(--ink); font-weight: 700; }
.r-zeile.summe b { font-size: 17px; }
.plus { color: var(--green); }
.minus { color: var(--clay); }

.anteil { background: var(--green-soft); border-radius: var(--r-karte); padding: 15px 16px; display: flex; flex-direction: column; gap: 2px; }
.anteil .a-label {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--green); font-weight: 600;
}
.anteil .a-zahl { font-family: var(--mono); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.anteil .a-eur { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.anteil .a-zweit {
  margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(47,125,79,.22);
  display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2);
}
.anteil .a-zweit b { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Runden-Verlauf */
.runde-zeile {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: baseline;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft); width: 100%; text-align: left;
}
.runde-zeile:last-child { border-bottom: none; }
.runde-zeile .rt { font-size: 15.5px; font-weight: 700; }
.runde-zeile .rd { font-family: var(--mono); font-size: 11px; color: var(--muted); grid-column: 1; }
.runde-zeile .rr { font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; grid-row: 1; grid-column: 2; }
.runde-zeile .rs { font-family: var(--mono); font-size: 11px; color: var(--muted); grid-row: 2; grid-column: 2; text-align: right; font-variant-numeric: tabular-nums; }
.laeuft {
  display: inline-block; font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em;
  text-transform: uppercase; font-weight: 600; background: var(--amber-soft); color: var(--amber);
  border-radius: 4px; padding: 2px 6px; vertical-align: middle; margin-left: 7px;
}

/* ---------------------------------------------------------------- Leer, Hilfe */
.leer {
  border: 1px solid var(--line); border-radius: var(--r-karte); background: var(--surface);
  padding: 22px 18px; text-align: center; display: flex; flex-direction: column; gap: 7px;
}
.leer b { font-size: 16px; }
.leer span { color: var(--muted); font-size: 14px; }

.hilfe-block { display: flex; flex-direction: column; gap: 16px; }
.hilfe-block h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.hilfe-block p { margin: 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; }

/* ---------------------------------------------------------------- Menü, Meldung, Dialog */
.menue {
  position: fixed; top: calc(60px + env(safe-area-inset-top)); right: 16px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-karte);
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.3); overflow: hidden; min-width: 180px;
  display: flex; flex-direction: column;
}
.menue-punkt {
  padding: 13px 16px; text-align: left; font-size: 15px; font-weight: 600;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-soft);
}
.menue-punkt:last-child { border-bottom: none; color: var(--clay); }

.meldung {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 11px 18px;
  border-radius: var(--r-knopf); font-size: 14.5px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center;
}
.meldung.fehler { background: var(--clay); color: #fff; }

.abdeckung {
  position: fixed; inset: 0; background: rgba(24,32,28,.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.dialog {
  background: var(--surface); border-radius: var(--r-karte) var(--r-karte) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 11px;
}
.dialog .schritt {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--clay); font-weight: 600;
}
.dialog h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.dialog p { margin: 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.dialog p b { color: var(--ink); font-weight: 600; font-family: var(--mono); }
.dialog .knoepfe { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

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