/* Farben und Masse an einer Stelle. Helle Werte auf :root, dunkle sowohl per
   Systemeinstellung als auch per Umschalter — damit der Umschalter in beide
   Richtungen gewinnt. */
:root {
  color-scheme: light;
  --flaeche:        #fcfcfb;
  --ebene:          #f9f9f7;
  --rand:           #e1e0d9;
  --ink:            #0b0b0b;
  --ink-zweit:      #52514e;
  --ink-leise:      #898781;
  --serie:          #2a78d6;
  --serie-flaeche:  rgba(42, 120, 214, 0.12);
  --gut:            #0ca30c;
  --warnung:        #fab219;
  --kritisch:       #d03b3b;
  --radius:         12px;
  --luecke:         16px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --flaeche:       #1a1a19;
    --ebene:         #0d0d0d;
    --rand:          #2c2c2a;
    --ink:           #ffffff;
    --ink-zweit:     #c3c2b7;
    --ink-leise:     #898781;
    --serie:         #3987e5;
    --serie-flaeche: rgba(57, 135, 229, 0.16);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --flaeche:       #1a1a19;
  --ebene:         #0d0d0d;
  --rand:          #2c2c2a;
  --ink:           #ffffff;
  --ink-zweit:     #c3c2b7;
  --ink-leise:     #898781;
  --serie:         #3987e5;
  --serie-flaeche: rgba(57, 135, 229, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ebene);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--serie); }

/* ─── Kopf ─────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  padding: 12px var(--luecke) 0;
  padding-top: calc(12px + env(safe-area-inset-top));
}

.kopfzeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.marke { display: flex; align-items: center; gap: 10px; }

.plakette {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--rand);
  color: var(--ink-zweit);
  white-space: nowrap;
}
.plakette.papier { color: var(--serie); border-color: var(--serie); }
.plakette.echt   { color: var(--kritisch); border-color: var(--kritisch); }

header { padding-bottom: 12px; }

/* Der Kontostand ist die eine Zahl, wegen der man die App oeffnet. */
.stand { padding: 8px 0 20px; text-align: center; }

.stand__wert {
  font-size: clamp(38px, 11vw, 52px);
  font-weight: 660;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stand__zusatz {
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-leise);
}
.stand__zusatz .positiv,
.stand__zusatz .negativ { font-weight: 600; }

/* ─── Grundraster ──────────────────────────────────────────────────────── */

main { padding: var(--luecke); max-width: 1100px; margin: 0 auto; }

section[hidden] { display: none; }

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: var(--luecke);
  margin-bottom: var(--luecke);
}

.karte h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-leise);
  margin: 0 0 12px;
  font-weight: 600;
}

/* ─── Kennzahlen ───────────────────────────────────────────────────────── */

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: var(--luecke);
}

.kachel {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.kachel .titel {
  font-size: 12px;
  color: var(--ink-leise);
  margin-bottom: 6px;
}

.kachel .wert {
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kachel .zusatz { font-size: 12px; color: var(--ink-zweit); margin-top: 4px; }

.positiv { color: var(--gut); }
.negativ { color: var(--kritisch); }

/* ─── Diagramm ─────────────────────────────────────────────────────────── */

.diagramm-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.bereichswahl { display: flex; gap: 4px; }

.bereichswahl button {
  appearance: none;
  background: none;
  border: 1px solid var(--rand);
  border-radius: 8px;
  color: var(--ink-zweit);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.bereichswahl button[aria-pressed="true"] {
  color: var(--flaeche);
  background: var(--ink);
  border-color: var(--ink);
}

.diagramm { position: relative; width: 100%; }
.diagramm svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagramm { min-height: 240px; }

.gitter { stroke: var(--rand); stroke-width: 1; }
.achsentext { fill: var(--ink-leise); font-size: 11px; font-variant-numeric: tabular-nums; }
.linie { fill: none; stroke: var(--serie); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.flaeche { fill: var(--serie-flaeche); }
.grundlinie { stroke: var(--ink-leise); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.7; }
.fadenkreuz { stroke: var(--ink-leise); stroke-width: 1; }
.punkt { fill: var(--serie); stroke: var(--flaeche); stroke-width: 2; }

.hinweisfeld {
  position: absolute;
  pointer-events: none;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: opacity 0.1s;
}
.hinweisfeld.sichtbar { opacity: 1; }

/* ─── Listen ───────────────────────────────────────────────────────────── */

.zeile {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rand);
}
.zeile:last-child { border-bottom: none; }

.zeile .haupt { flex: 1; min-width: 0; }
.zeile .rechts { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.zeile .titel { font-weight: 600; font-size: 15px; }
.zeile .betrag {
  font-size: 17px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}
.zeile .grund {
  color: var(--ink-leise);
  font-style: italic;
}
.zeile .neben { font-size: 13px; color: var(--ink-zweit); margin-top: 2px; }
.zeile .zeit { font-size: 12px; color: var(--ink-leise); margin-top: 3px; }

.etikett {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--rand);
  color: var(--ink-zweit);
  margin-right: 6px;
}
.etikett.eroeffnen  { color: var(--serie);    border-color: var(--serie); }
.etikett.schliessen { color: var(--ink-zweit); }
.etikett.abschluss  { color: var(--gut);      border-color: var(--gut); }
.etikett.strategie  { color: var(--warnung);  border-color: var(--warnung); }
.etikett.fehler     { color: var(--kritisch); border-color: var(--kritisch); }

.leer { color: var(--ink-leise); font-size: 14px; padding: 8px 0; }

.fliesstext p {
  margin: 0 0 12px;
  color: var(--ink-zweit);
  font-size: 14px;
  line-height: 1.65;
}
.fliesstext p:last-child { margin-bottom: 0; }

button.mehr {
  appearance: none;
  background: none;
  border: 1px solid var(--rand);
  border-radius: 8px;
  color: var(--ink-zweit);
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  margin-top: 10px;
  cursor: pointer;
}

.warnleiste {
  background: color-mix(in srgb, var(--warnung) 14%, var(--flaeche));
  border: 1px solid var(--warnung);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: var(--luecke);
  font-size: 14px;
}

pre.text {
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-zweit);
  margin: 0;
}


/* ─── Anmeldung ────────────────────────────────────────────────────────── */

.anmeldung {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.anmeldung form {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 28px;
  width: min(340px, 100%);
  text-align: center;
}

.anmeldung input {
  width: 100%;
  font: inherit;
  font-size: 22px;
  text-align: center;
  letter-spacing: 0.3em;
  padding: 12px;
  margin: 18px 0 12px;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--ebene);
  color: var(--ink);
}

.anmeldung button {
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--serie);
  color: #fff;
  cursor: pointer;
}

.fehlertext { color: var(--kritisch); font-size: 13px; min-height: 18px; margin-top: 10px; }

footer {
  text-align: center;
  font-size: 12px;
  padding: 8px 16px 28px;
}
footer a { color: var(--ink-leise); text-decoration: none; }
