/* Gestaltung des Haushaltsbuchs.
 *
 * Gedacht fuers iPhone: grosse Tippflaechen, Platz fuer die Home-Leiste
 * unten, keine Schriftgroesse unter 16 Pixel (darunter zoomt Safari beim
 * Antippen von Eingabefeldern von selbst hinein).
 *
 * Die Farben nehmen das Symbol auf: dunkles Gruen, dazu Gruen fuer
 * Einnahmen und Rot fuer Ausgaben — die einzige Farbunterscheidung, die im
 * Haushaltsbuch wirklich zaehlt.
 */

:root {
  --gruen: #0b5c3f;
  --gruen-hell: #12805a;
  --gruen-blass: #e7f5ef;

  --einnahme: #15803d;
  --ausgabe: #dc2626;
  --warnung: #d97706;

  --grund: #f3f5f4;
  --karte: #ffffff;
  --rand: #e2e8e5;
  --schrift: #14201b;
  --schrift-leise: #64748b;

  --rundung: 16px;
  --schatten: 0 1px 3px rgba(15, 40, 30, 0.08), 0 6px 16px rgba(15, 40, 30, 0.05);

  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
  --leiste-hoehe: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gruen: #0f6b4a;
    --gruen-hell: #2dd4a7;
    --gruen-blass: #17302a;

    --einnahme: #4ade80;
    --ausgabe: #f87171;
    --warnung: #fbbf24;

    --grund: #0c1411;
    --karte: #16211d;
    --rand: #26332e;
    --schrift: #e8f0ec;
    --schrift-leise: #94a8a0;

    --schatten: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

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

/* Muss ganz oben stehen und muss !important sein: Klassen wie .anmeldung
 * setzen selbst ein display, und das schlaegt sonst das eingebaute
 * display:none des hidden-Merkmals. Ohne diese Zeile bliebe die
 * Anmeldemaske ueber der App liegen. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--grund);
  color: var(--schrift);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Verhindert, dass die ganze Seite beim Wischen mitfedert. */
  overscroll-behavior-y: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* --------------------------------------------------------------- Anmeldung */

.anmeldung {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--gruen) 0%, #063528 100%);
}

.anmelde-karte {
  width: min(380px, 100%);
  background: var(--karte);
  border-radius: 24px;
  padding: 32px 24px 28px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.anmelde-symbol {
  border-radius: 18px;
  margin-bottom: 12px;
}

.anmelde-hinweis {
  color: var(--schrift-leise);
  margin: 6px 0 22px;
}

/* ------------------------------------------------------------------ Felder */

.feld {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.feld > span {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--schrift-leise);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  color: var(--schrift);
  background: var(--grund);
  border: 1px solid var(--rand);
  border-radius: 12px;
  appearance: none;
}

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

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

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

.schalter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--rand);
}

.schalter span {
  font-size: 15px;
}

.schalter small {
  display: block;
  color: var(--schrift-leise);
  font-size: 13px;
  line-height: 1.3;
}

.schalter input[type='checkbox'] {
  width: 52px;
  height: 31px;
  flex: 0 0 52px;
  border-radius: 999px;
  background: var(--rand);
  border: none;
  position: relative;
  transition: background 0.15s;
}

.schalter input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.schalter input[type='checkbox']:checked {
  background: var(--gruen-hell);
}

.schalter input[type='checkbox']:checked::after {
  transform: translateX(21px);
}

/* ------------------------------------------------------------------ Knoepfe */

.knopf {
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-weight: 600;
  background: var(--gruen);
  color: #fff;
}

.knopf:active {
  opacity: 0.75;
}

.knopf-voll {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.knopf-leise {
  background: var(--grund);
  color: var(--schrift);
  border: 1px solid var(--rand);
}

.knopf-rot {
  background: transparent;
  color: var(--ausgabe);
  border: 1px solid var(--rand);
}

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

.knopf-reihe .knopf {
  flex: 1;
}

/* Der Name im Sperrbildschirm — da steht schon fest, wer angemeldet ist. */
.gesperrt-name {
  font-size: 19px;
  font-weight: 650;
  text-align: center;
  padding: 6px 0 16px;
}

.knopf-schlicht {
  display: block;
  width: 100%;
  border: none;
  background: none;
  color: var(--schrift-leise);
  font-size: 14px;
  font-weight: 600;
  padding: 16px 8px 4px;
}

/* Trennlinie mit Wort in der Mitte, auf dem Anmeldebildschirm. */
.trennlinie {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--schrift-leise);
  font-size: 13px;
}

.trennlinie::before,
.trennlinie::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rand);
}

.fehlermeldung {
  color: var(--ausgabe);
  font-size: 14px;
  margin: 0 0 12px;
  text-align: left;
}

/* -------------------------------------------------------------------- Kopf */

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--oben);
  background: color-mix(in srgb, var(--grund) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rand);
}

.kopf-inhalt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  min-height: 52px;
}

#kopf-titel {
  font-size: 22px;
}

.kopf-rechts {
  display: flex;
  align-items: center;
  gap: 2px;
}

.kopf-knopf {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  padding: 4px 10px;
  color: var(--gruen-hell);
}

.kopf-monat {
  border: none;
  background: var(--karte);
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ Inhalt */

#inhalt {
  padding: 14px 16px calc(var(--leiste-hoehe) + var(--unten) + 90px);
  max-width: 780px;
  margin: 0 auto;
}

.karte {
  background: var(--karte);
  border-radius: var(--rundung);
  box-shadow: var(--schatten);
  padding: 16px;
  margin-bottom: 14px;
}

.karte-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.karte-kopf h2 {
  font-size: 17px;
}

.karte-kopf button {
  border: none;
  background: none;
  color: var(--gruen-hell);
  font-size: 14px;
  font-weight: 600;
  padding: 4px;
}

.leer {
  text-align: center;
  color: var(--schrift-leise);
  padding: 28px 16px;
  font-size: 15px;
}

.leer-gross {
  font-size: 40px;
  display: block;
  margin-bottom: 10px;
}

/* --------------------------------------------------------------- Kennzahlen */

.summe-gross {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.summe-klein {
  font-size: 13px;
  color: var(--schrift-leise);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.zwei-spalten {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kennzahl {
  background: var(--karte);
  border-radius: var(--rundung);
  box-shadow: var(--schatten);
  padding: 14px;
}

.kennzahl .wert {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.ein {
  color: var(--einnahme);
}

.aus {
  color: var(--ausgabe);
}

/* ------------------------------------------------------------------ Konten */

.konto-band {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 16px 8px;
  margin: 0 -16px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.konto-band::-webkit-scrollbar {
  display: none;
}

.konto-kachel {
  flex: 0 0 auto;
  min-width: 150px;
  background: var(--karte);
  border-radius: var(--rundung);
  box-shadow: var(--schatten);
  padding: 14px;
  scroll-snap-align: start;
  border-left: 4px solid var(--gruen);
  text-align: left;
  border-top: none;
  border-right: none;
  border-bottom: none;
}

.konto-kachel .name {
  font-size: 13px;
  color: var(--schrift-leise);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.konto-kachel .saldo {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.merkmal {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--gruen-blass);
  color: var(--gruen-hell);
  vertical-align: middle;
}

/* ---------------------------------------------------------------- Buchungen */

.tag-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 4px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--schrift-leise);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.liste {
  background: var(--karte);
  border-radius: var(--rundung);
  box-shadow: var(--schatten);
  overflow: hidden;
}

.zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rand);
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
}

.zeile:last-child {
  border-bottom: none;
}

.zeile:active {
  background: var(--grund);
}

.zeile-symbol {
  flex: 0 0 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--gruen-blass);
}

.zeile-mitte {
  flex: 1;
  min-width: 0;
}

.zeile-titel {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zeile-unter {
  font-size: 13px;
  color: var(--schrift-leise);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.zeile-betrag {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.punkt {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ Balken */

.balken-hintergrund {
  height: 8px;
  border-radius: 999px;
  background: var(--rand);
  overflow: hidden;
  margin-top: 6px;
}

.balken-fuellung {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s;
}

.budget-zeile {
  padding: 10px 0;
  border-bottom: 1px solid var(--rand);
}

.budget-zeile:last-child {
  border-bottom: none;
}

.budget-kopf {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  gap: 8px;
}

/* --------------------------------------------------------------- Diagramme */

.diagramm {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 14px;
}

.legende-punkt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ Belege */

.beleg-gitter {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.beleg-kachel {
  background: var(--karte);
  border-radius: var(--rundung);
  box-shadow: var(--schatten);
  overflow: hidden;
  border: none;
  padding: 0;
  text-align: left;
}

.beleg-bild {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--gruen-blass);
}

.beleg-ersatz {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: var(--gruen-blass);
}

.beleg-text {
  padding: 10px 12px 12px;
}

.beleg-text .titel {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.beleg-text .unter {
  font-size: 12px;
  color: var(--schrift-leise);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.beleg-gross {
  width: 100%;
  border-radius: 12px;
  display: block;
  max-height: 46vh;
  object-fit: contain;
  background: var(--grund);
}

/* ------------------------------------------------------------------ Suchen */

.suchleiste {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.suchleiste input {
  flex: 1;
}

.reiter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin: 0 -16px 4px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}

.reiter::-webkit-scrollbar {
  display: none;
}

.reiter button {
  flex: 0 0 auto;
  border: 1px solid var(--rand);
  background: var(--karte);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.reiter button[aria-pressed='true'] {
  background: var(--gruen);
  color: #fff;
  border-color: var(--gruen);
}

/* ---------------------------------------------------------- Neu-Knopf, Leiste */

.knopf-neu {
  position: fixed;
  right: 18px;
  bottom: calc(var(--leiste-hoehe) + var(--unten) + 16px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--gruen);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  font-weight: 300;
  box-shadow: 0 6px 20px rgba(11, 92, 63, 0.4);
  z-index: 30;
}

.knopf-neu:active {
  transform: scale(0.94);
}

.leiste {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  padding-bottom: var(--unten);
  background: color-mix(in srgb, var(--karte) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--rand);
  z-index: 25;
}

.leiste-knopf {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 2px 6px;
  height: var(--leiste-hoehe);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--schrift-leise);
}

.leiste-knopf[aria-current='page'] {
  color: var(--gruen-hell);
}

.leiste-symbol {
  font-size: 21px;
  line-height: 1;
}

.leiste-text {
  font-size: 10.5px;
  font-weight: 600;
}

/* ------------------------------------------------------------------ Dialoge */

.blatt-huelle {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.blatt-schatten {
  position: absolute;
  inset: 0;
  background: rgba(6, 20, 15, 0.45);
  animation: einblenden 0.2s;
}

.blatt {
  position: relative;
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--karte);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(24px + var(--unten));
  animation: hochschieben 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  -webkit-overflow-scrolling: touch;
}

@keyframes hochschieben {
  from {
    transform: translateY(100%);
  }
}

@keyframes einblenden {
  from {
    opacity: 0;
  }
}

.blatt-griff {
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: var(--rand);
  margin: 6px auto 8px;
}

/* Bleibt beim Blättern oben stehen: Sonst wäre bei einer langen Liste kein
 * Weg mehr heraus, ohne ganz nach oben zu scrollen. */
.blatt-leiste {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 -18px 6px;
  padding: 2px 12px 8px;
  background: var(--karte);
}

.blatt-knopf {
  border: none;
  background: none;
  color: var(--gruen-hell);
  font-size: 16px;
  font-weight: 600;
  padding: 8px 10px;
  min-height: 40px;
}

.blatt-zu {
  font-size: 19px;
  color: var(--schrift-leise);
  min-width: 44px;
}

.blatt h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.blatt-unter {
  color: var(--schrift-leise);
  font-size: 14px;
  margin: 0 0 16px;
}

/* Auswahl zwischen Einnahme und Ausgabe. */
.wahl {
  display: flex;
  background: var(--grund);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 16px;
}

.wahl button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--schrift-leise);
}

.wahl button[aria-pressed='true'] {
  background: var(--karte);
  color: var(--schrift);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* Betragsfeld: gross und mittig, weil es das Wichtigste ist. */
.betrag-feld {
  text-align: center;
  font-size: 40px !important;
  font-weight: 700;
  padding: 10px !important;
  border: none !important;
  background: none !important;
  font-variant-numeric: tabular-nums;
}

.betrag-feld:focus {
  outline: none !important;
}

.rubrik-gitter {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.rubrik-knopf {
  border: 1px solid var(--rand);
  background: var(--karte);
  border-radius: 12px;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.rubrik-knopf span:first-child {
  font-size: 19px;
}

.rubrik-knopf[aria-pressed='true'] {
  border-color: var(--gruen-hell);
  background: var(--gruen-blass);
  border-width: 2px;
}

/* Auswahlliste im Dialog (Aktionen). */
.aktion {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: none;
  background: none;
  padding: 15px 6px;
  border-bottom: 1px solid var(--rand);
  text-align: left;
  font-size: 16px;
}

.aktion:last-of-type {
  border-bottom: none;
}

.aktion-symbol {
  flex: 0 0 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gruen-blass);
  display: grid;
  place-items: center;
  font-size: 21px;
}

.aktion small {
  display: block;
  color: var(--schrift-leise);
  font-size: 13px;
}

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

.meldung {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--leiste-hoehe) + var(--unten) + 86px);
  background: #14201b;
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  max-width: 88vw;
  text-align: center;
}

.meldung.schlecht {
  background: var(--ausgabe);
}

/* --------------------------------------------------------------- Kleinkram */

.lade {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: drehen 0.7s linear infinite;
  vertical-align: -3px;
}

@keyframes drehen {
  to {
    transform: rotate(360deg);
  }
}

.hinweis {
  background: var(--gruen-blass);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 14px;
}

.hinweis-warnung {
  background: color-mix(in srgb, var(--warnung) 16%, transparent);
}

.klein {
  font-size: 13px;
  color: var(--schrift-leise);
}

.rechts {
  text-align: right;
}

.tabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tabelle th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--schrift-leise);
  padding: 6px 4px;
  border-bottom: 1px solid var(--rand);
}

.tabelle td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--rand);
  vertical-align: top;
}

.tabelle tr:last-child td {
  border-bottom: none;
}
