/* public/shared/styles.css */

/* === Fonts (self-hosted, aus dem Original-Tutorial übernommen) === */

@font-face {
  font-family: "Amatic SC";
  font-style: normal;
  font-weight: 400;
  src: url("./fonts/amatic-sc/amatic-sc-v13-latin-regular.woff2") format("woff2"),
       url("./fonts/amatic-sc/amatic-sc-v13-latin-regular.woff") format("woff");
}

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 300;
  src: url("./fonts/oswald/oswald-v31-latin-300.woff2") format("woff2"),
       url("./fonts/oswald/oswald-v31-latin-300.woff") format("woff");
}

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400;
  src: url("./fonts/oswald/oswald-v31-latin-regular.woff2") format("woff2"),
       url("./fonts/oswald/oswald-v31-latin-regular.woff") format("woff");
}

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 700;
  src: url("./fonts/oswald/oswald-v31-latin-700.woff2") format("woff2"),
       url("./fonts/oswald/oswald-v31-latin-700.woff") format("woff");
}

/* === Design-Tokens === */

:root {
  --color-einnahme: #28a745;
  --color-einnahme-tint: #d4edda;
  --color-einnahme-border: #c3e6cb;
  --color-ausgabe: #dc3545;
  --color-ausgabe-tint: #f8d7da;
  --color-ausgabe-border: #f5c6cb;
  --color-kredit: #ffc107;
  --color-kredit-text: #856404;
  --color-kredit-tint: #fff3cd;
  --color-kredit-border: #ffeeba;
  --color-primary: #007bff;
  --color-topbar: #343a40;
  --color-bg: #ffffff;
  --color-box-bg: #e9ecef;
  --color-input-bg: #ffffff;
  --color-text: #212529;
  --color-text-muted: #495057;
  --color-border: #ced4da;
}

/* === Allgemeines === */

html {
  font-size: 62.5%;
  box-sizing: border-box;
}

*, *::before, *::after { box-sizing: inherit; }

body, input, textarea, button, select, option {
  font-family: "Oswald", Helvetica, sans-serif;
  font-weight: 300;
  font-size: 1.5rem;
  line-height: 1.5rem;
  letter-spacing: .05rem;
}

body {
  margin: 0;
  padding: 0 0 4rem;
  background: var(--color-bg);
  color: var(--color-text);
}

h1, h2, h3, h4, h5, h6 { font-weight: 400; margin: 0; }

::placeholder { color: #6c757d; }

.page {
  max-width: 100rem;
  margin: 0 auto;
  padding: 0 2rem;
}

/* === Kopfzeile === */

header.topbar {
  background: var(--color-topbar);
  line-height: 8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 2rem;
}

header.topbar h1 {
  font-size: 5rem;
  text-transform: uppercase;
  color: #fff;
  font-family: "Amatic SC", cursive;
  line-height: inherit;
}

header.topbar #logout-btn {
  position: absolute;
  right: 2rem;
  max-width: none;
  margin: 0;
  line-height: 2.5rem;
  font-size: 1.3rem;
  padding: .5rem 1.5rem;
  background: transparent;
  border: .1rem solid rgba(255, 255, 255, .5);
  border-radius: 1.5rem;
  color: #fff;
}

header.topbar #logout-btn:hover { background: rgba(255, 255, 255, .12); }

header.topbar .book-switcher {
  position: absolute;
  left: 2rem;
  display: flex;
  align-items: center;
  gap: .8rem;
}

header.topbar .book-switcher select,
header.topbar .book-switcher button {
  max-width: none;
  margin: 0;
  line-height: 2.5rem;
  font-size: 1.3rem;
  padding: .5rem 1.2rem;
  border-radius: 1.5rem;
  border: .1rem solid rgba(255, 255, 255, .5);
  background: transparent;
  color: #fff;
}

header.topbar .book-switcher select option { color: var(--color-text); }
header.topbar .book-switcher button:hover { background: rgba(255, 255, 255, .12); }

/* === Login === */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--color-box-bg);
  border-radius: 1.5rem;
  padding: 3rem;
  width: 34rem;
}

.login-box h1 {
  font-family: "Amatic SC", cursive;
  text-transform: uppercase;
  font-size: 4rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-box label {
  display: block;
  margin-bottom: 1.5rem;
  color: var(--color-text-muted);
  font-size: 1.3rem;
}

.login-box input {
  display: block;
  width: 100%;
  margin-top: .5rem;
  padding: .6rem 1.5rem;
  border: .1rem solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-input-bg);
  color: var(--color-text-muted);
  font-size: 1.5rem;
}

.login-box input:focus, .entry-form-box input:focus, .summary-box select:focus {
  outline: 0;
  border-color: #80bdff;
  box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25);
}

.login-box .form-actions { justify-content: center; }

.login-box .login-links {
  display: flex;
  justify-content: space-between;
  margin: 0;
}

.login-box .login-links button {
  max-width: none;
  margin: 0;
}

/* === Buttons === */

button {
  cursor: pointer;
  max-width: 24rem;
  line-height: 2.5rem;
  font-size: 1.4rem;
  background: var(--color-primary);
  border: .1rem solid var(--color-primary);
  padding: .5rem 2rem;
  color: #fff;
  border-radius: 1.5rem;
  margin: 1rem 0;
  transition: filter .15s ease-in-out;
}

button:hover { filter: brightness(1.08); }

button#resend-btn, button#back-btn {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
  padding: .5rem .5rem;
}

button.delete-btn, button.entfernen-button, button.bearbeiten-button {
  max-width: none;
  margin: 0;
}

button#cancel-edit-btn {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.error {
  color: var(--color-ausgabe);
  min-height: 1.2em;
  font-size: 1.3rem;
}

/* === Eingabeformular === */

.entry-form-box {
  background: var(--color-box-bg);
  border-radius: 1.5rem;
  padding: 3rem;
  margin-bottom: 2rem;
}

.entry-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.entry-form-box h2 { font-size: 2.2rem; }
.entry-form-header h2 { margin: 0; white-space: nowrap; }

/* === Filterleiste (Art-Filter + Suche) === */

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.typ-filter { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.typ-filter-label { color: var(--color-text-muted); margin-right: .2rem; }

.typ-filter-btn {
  margin: 0;
  padding: .6rem 1.6rem;
  border-radius: 1.5rem;
  border: .1rem solid;
  cursor: pointer;
}
.typ-filter-btn.alle { background: var(--color-input-bg); color: var(--color-text-muted); border-color: var(--color-border); }
.typ-filter-btn.alle[aria-pressed="true"] { background: var(--color-topbar); border-color: var(--color-topbar); color: #fff; }
.typ-filter-btn.einnahme { background: var(--color-einnahme-tint); color: var(--color-einnahme); border-color: var(--color-einnahme-border); }
.typ-filter-btn.ausgabe { background: var(--color-ausgabe-tint); color: var(--color-ausgabe); border-color: var(--color-ausgabe-border); }
.typ-filter-btn.kredit { background: var(--color-kredit-tint); color: var(--color-kredit-text); border-color: var(--color-kredit-border); }
.typ-filter-btn.einnahme[aria-pressed="true"] { background: var(--color-einnahme); border-color: var(--color-einnahme); color: #fff; }
.typ-filter-btn.ausgabe[aria-pressed="true"] { background: var(--color-ausgabe); border-color: var(--color-ausgabe); color: #fff; }
.typ-filter-btn.kredit[aria-pressed="true"] { background: var(--color-kredit); border-color: var(--color-kredit); color: #212529; }

#entry-search {
  width: 28rem;
  max-width: 100%;
  padding: .6rem 1.2rem;
  border: .1rem solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-input-bg);
  color: var(--color-text);
}

.filter-result { margin: -.5rem 0 1.5rem; color: var(--color-text-muted); }
.filter-empty { color: var(--color-text-muted); }

@media (max-width: 600px) {
  #entry-search { width: 100%; }
}

.form-row {
  display: flex;
  align-items: flex-start;
}

.form-row > * { flex-grow: 1; }

[class$="-eingabe-gruppe"] {
  display: flex;
  margin: 1rem 0;
  width: 100%;
}

[class$="-eingabe-gruppe"] > label,
[class$="-eingabe-gruppe"] > input {
  line-height: 2.5rem;
  border: .1rem solid var(--color-border);
}

[class$="-eingabe-gruppe"] > label {
  padding: .5rem 1.8rem .5rem 2rem;
  background: var(--color-box-bg);
  color: var(--color-text-muted);
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}

[class$="-eingabe-gruppe"] > input {
  padding: .375rem .75rem;
  flex-grow: 1;
  min-width: 0;
  color: var(--color-text-muted);
  background: var(--color-input-bg);
}

[class$="-eingabe-gruppe"] > :first-child {
  border-right: none;
  border-top-left-radius: 1.5rem;
  border-bottom-left-radius: 1.5rem;
}

[class$="-eingabe-gruppe"] > :last-child {
  border-left: none;
  border-top-right-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
}

/* Titel + Typ (Einnahme / Ausgabe / Kredit) */

.titel-typ-eingabe-gruppe > input[type="text"] {
  border-right: none;
  border-left: none;
}

.titel-typ-eingabe-gruppe label.typ-label {
  width: 11rem;
  border-left: none;
}

/* nur die letzte Typ-Option (Kredit) behält ihren rechten Rand, damit die
   Pille dort sauber abschließt — die mittleren Optionen sind rundum nahtlos */
.titel-typ-eingabe-gruppe label.typ-label:not(:last-child) {
  border-right: none;
}

.titel-typ-eingabe-gruppe label.typ-label[for="einnahme"] {
  background: var(--color-einnahme-tint);
  color: var(--color-einnahme);
  border-color: var(--color-einnahme-border);
}

.titel-typ-eingabe-gruppe label.typ-label[for="ausgabe"] {
  background: var(--color-ausgabe-tint);
  color: var(--color-ausgabe);
  border-color: var(--color-ausgabe-border);
}

.titel-typ-eingabe-gruppe label.typ-label[for="kredit"] {
  background: var(--color-kredit-tint);
  color: var(--color-kredit-text);
  border-color: var(--color-kredit-border);
}

.titel-typ-eingabe-gruppe > input[type="radio"] { display: none; }

.titel-typ-eingabe-gruppe > input[type="radio"]:checked + label {
  color: #fff;
  z-index: 1;
}

.titel-typ-eingabe-gruppe > input[value="einnahme"]:checked + label {
  background: var(--color-einnahme);
  box-shadow: 0 0 0 .2rem rgba(40, 167, 69, .5);
}

.titel-typ-eingabe-gruppe > input[value="ausgabe"]:checked + label {
  background: var(--color-ausgabe);
  box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .5);
}

.titel-typ-eingabe-gruppe > input[value="kredit"]:checked + label {
  background: var(--color-kredit);
  color: var(--color-kredit-text);
  box-shadow: 0 0 0 .2rem rgba(255, 193, 7, .5);
}

/* Betrag + Datum */

.betrag-datum-eingabe-gruppe > input:nth-of-type(1) {
  border-right: none;
  border-left: none;
}

.betrag-datum-eingabe-gruppe > label:nth-of-type(2) {
  border-right: none;
  border-left: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  margin-top: .5rem;
}

/* === Layout / Monatslisten === */

.layout {
  display: grid;
  grid-template-columns: 1fr 30rem;
  gap: 2rem;
  align-items: start;
}

.monatsliste {
  margin: 0 0 2rem;
  border-bottom: .1rem solid var(--color-border);
  padding-bottom: 1rem;
}

.monatsliste > h2 {
  display: flex;
  align-items: center;
  font-size: 2.4rem;
  margin-bottom: 1rem;
}

.monatsliste > h2 > .monat-jahr { flex-grow: 1; }

.monatsliste > h2 > .monatsbilanz {
  flex-grow: 0;
  font-size: 1.8rem;
  padding: .5rem 1rem;
  color: #fff;
  border-radius: 1.2rem;
}

.monatsliste > h2 > .monatsbilanz.positive { background: var(--color-einnahme); }
.monatsliste > h2 > .monatsbilanz.negative { background: var(--color-ausgabe); }

.monatsliste > ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.monatsliste > ul > li {
  display: flex;
  line-height: 2.5rem;
  margin: 1.2rem 0;
}

.monatsliste > ul > li > .datum {
  width: 12rem;
  padding: .5rem 1.8rem .5rem 2rem;
  border: .1rem solid var(--color-border);
  border-right: none;
  border-top-left-radius: 1.5rem;
  border-bottom-left-radius: 1.5rem;
  flex-grow: 0;
  background: var(--color-box-bg);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.monatsliste > ul > li > .titel {
  padding: .5rem 2rem;
  border-top: .1rem solid var(--color-border);
  border-bottom: .1rem solid var(--color-border);
  flex-grow: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monatsliste > ul > li > .betrag {
  padding: .5rem 2rem;
  border-top: .1rem solid var(--color-border);
  border-bottom: .1rem solid var(--color-border);
  flex-grow: 0;
  font-variant-numeric: tabular-nums;
}

.monatsliste > ul > li > .bearbeiten-button {
  color: var(--color-text-muted);
  background: var(--color-box-bg);
  padding: .5rem 1.2rem;
  border-top: .1rem solid var(--color-border);
  border-bottom: .1rem solid var(--color-border);
  flex-grow: 0;
  display: flex;
  align-items: center;
}

.monatsliste > ul > li > .entfernen-button {
  color: var(--color-text-muted);
  background: var(--color-box-bg);
  padding: .5rem 1.5rem;
  border: .1rem solid var(--color-border);
  border-left: none;
  border-top-right-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
  flex-grow: 0;
  display: flex;
  align-items: center;
}

.monatsliste > ul > li > .bearbeiten-button svg,
.monatsliste > ul > li > .entfernen-button svg { width: 1.3rem; height: 1.3rem; pointer-events: none; }

.monatsliste > ul > li > .bearbeiten-button:hover { color: var(--color-primary); }
.monatsliste > ul > li > .entfernen-button:hover { color: var(--color-ausgabe); }

.monatsliste > ul > li.ausgabe > .titel,
.monatsliste > ul > li.ausgabe > .betrag {
  background: var(--color-ausgabe-tint);
  color: var(--color-ausgabe);
  border-color: var(--color-ausgabe-border);
}

.monatsliste > ul > li.einnahme > .titel,
.monatsliste > ul > li.einnahme > .betrag {
  background: var(--color-einnahme-tint);
  color: var(--color-einnahme);
  border-color: var(--color-einnahme-border);
}

.monatsliste > ul > li.kredit > .titel,
.monatsliste > ul > li.kredit > .betrag {
  background: var(--color-kredit-tint);
  color: var(--color-kredit-text);
  border-color: var(--color-kredit-border);
}

/* === Sidebar / Gesamtbilanz / Chart === */

.sidebar { display: flex; flex-direction: column; gap: 2rem; }

.summary-box, .chart-box {
  background: var(--color-box-bg);
  border-radius: 1.5rem;
  padding: 3rem;
}

.summary-box h2 { font-size: 2.2rem; margin-bottom: 1.5rem; }

.summary-box .zeitraum-gruppe { margin-bottom: 1.5rem; }
.summary-box .zeitraum-gruppe label {
  display: block;
  margin-bottom: .5rem;
  color: var(--color-text-muted);
  font-size: 1.3rem;
}

.summary-box select {
  width: 100%;
  padding: .5rem 1rem;
  border: .1rem solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-input-bg);
  color: var(--color-text-muted);
}

.gesamtbilanz-zeile {
  display: flex;
  line-height: 2.5rem;
}

.gesamtbilanz-zeile > span:nth-of-type(1) { flex-grow: 1; color: var(--color-text-muted); }
.gesamtbilanz-zeile > span:nth-of-type(2) { flex-grow: 0; padding: .2rem .75rem; font-variant-numeric: tabular-nums; }

.gesamtbilanz-zeile.kredite > span:nth-of-type(2) { border-bottom: .1rem solid var(--color-border); }

.gesamtbilanz-zeile.bilanz { margin-top: 1rem; }
.gesamtbilanz-zeile.bilanz > span:nth-of-type(1) { font-weight: 400; }
.gesamtbilanz-zeile.bilanz > span:nth-of-type(2) { color: #fff; border-radius: 1.2rem; }
.gesamtbilanz-zeile.bilanz > span:nth-of-type(2).positive { background: var(--color-einnahme); }
.gesamtbilanz-zeile.bilanz > span:nth-of-type(2).negative { background: var(--color-ausgabe); }

.gesamtbilanz-zeile.real { margin-top: .3rem; font-size: 1.3rem; }
.gesamtbilanz-zeile.real > span:nth-of-type(1) { font-style: italic; }
.gesamtbilanz-zeile.real > span:nth-of-type(2) { color: #fff; border-radius: 1.2rem; }
.gesamtbilanz-zeile.real > span:nth-of-type(2).positive { background: var(--color-einnahme); opacity: .75; }
.gesamtbilanz-zeile.real > span:nth-of-type(2).negative { background: var(--color-ausgabe); opacity: .75; }

.summary-box #print-btn { width: 100%; max-width: none; text-align: center; }

.chart-box { text-align: center; }
.chart-box #detail-toggle { width: 100%; max-width: none; }

/* lange Titel (nowrap) dürfen die Grid-Spalte nicht über den Bildschirm hinaus aufblähen */
.layout > * { min-width: 0; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  [class$="-eingabe-gruppe"] { margin: .5rem 0; }
}

/* === Share (Lese-Link) === */

button.secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.share-dialog {
  width: min(52rem, calc(100vw - 3.2rem));
  border: none;
  border-radius: 1.5rem;
  padding: 3rem;
  background: var(--color-box-bg);
  color: var(--color-text);
}

.share-dialog::backdrop { background: rgba(0, 0, 0, .45); }

.share-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.share-dialog h2 { font-size: 2.2rem; overflow-wrap: anywhere; }
.share-dialog h3 { font-size: 1.7rem; margin: 2rem 0 .5rem; }

.share-close {
  margin: 0;
  padding: 0 1rem;
  font-size: 2.4rem;
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
}

.share-intro, .share-note { color: var(--color-text-muted); font-size: 1.3rem; line-height: 2rem; }

.share-dialog label {
  display: block;
  margin: 1.2rem 0 .5rem;
  color: var(--color-text-muted);
  font-size: 1.3rem;
}

.share-dialog select, .share-dialog input[type="text"] {
  width: 100%;
  padding: .5rem 1.2rem;
  border: .1rem solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-input-bg);
  color: var(--color-text-muted);
  line-height: 2.5rem;
}

.share-dialog label.share-checkbox { display: flex; align-items: center; gap: .8rem; cursor: pointer; }

.share-scope-row { display: flex; gap: .8rem; }
.share-scope-row select { flex: 1; min-width: 0; }

.share-copy-row { display: flex; gap: .8rem; align-items: center; }
.share-copy-row input { flex: 1; min-width: 0; }
.share-copy-row button { margin: 0; white-space: nowrap; }

.share-code {
  font-size: 2.6rem;
  line-height: 3.5rem;
  letter-spacing: .4rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.share-list { list-style: none; padding: 0; margin: 0; }
.share-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-top: .1rem solid var(--color-border);
  font-size: 1.3rem;
}
.share-list li button { margin: .6rem 0; font-size: 1.3rem; }
.share-list li.share-list-empty { color: var(--color-text-muted); padding: .8rem 0; }

/* Viewer-Seite */

.share-gate { min-height: calc(100vh - 12rem); }
.share-gate p { text-align: center; line-height: 2.2rem; }

.share-banner {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}
.share-banner h2 { font-size: 2.6rem; overflow-wrap: anywhere; }
.share-hint { color: var(--color-text-muted); font-size: 1.3rem; }
.share-empty { color: var(--color-text-muted); }

/* ohne Bearbeiten/Löschen-Buttons schließt der Betrag die Zeile ab */
.monatsliste > ul > li > .betrag:last-child {
  border-right: .1rem solid var(--color-border);
  border-top-right-radius: 1.5rem;
  border-bottom-right-radius: 1.5rem;
}
.monatsliste > ul > li.ausgabe > .betrag:last-child { border-right-color: var(--color-ausgabe-border); }
.monatsliste > ul > li.einnahme > .betrag:last-child { border-right-color: var(--color-einnahme-border); }
.monatsliste > ul > li.kredit > .betrag:last-child { border-right-color: var(--color-kredit-border); }

/* Kopfzeile auf schmalen Screens: Buttons unter den Titel statt darüber */
@media (max-width: 800px) {
  header.topbar { flex-wrap: wrap; line-height: normal; padding: 1rem 1.6rem 1.6rem; gap: 1rem; }
  header.topbar h1 { width: 100%; text-align: center; line-height: 6rem; }
  header.topbar .book-switcher, header.topbar #logout-btn { position: static; }
  header.topbar .book-switcher { flex-wrap: wrap; justify-content: center; }
}

/* === Belegfoto === */

.receipt-buttons { display: flex; gap: .8rem; flex-wrap: wrap; }
.receipt-buttons button { margin: 0; white-space: nowrap; }

@media (max-width: 600px) {
  .entry-form-header { flex-direction: column; align-items: stretch; }
  .receipt-buttons button { flex: 1; }
}

/* === Handy (schmal) === */

/* ohne Fehlermeldung kein Leerraum unter "Hinzufügen" */
#form-error:empty { display: none; }

@media (max-width: 600px) {
  .page { padding: 0 1.2rem; }
  .entry-form-box, .summary-box, .chart-box { padding: 1.8rem 1.6rem; }
  .entry-form-header h2 { white-space: normal; font-size: 1.9rem; line-height: 2.4rem; }

  /* Eingabegruppen zweizeilig: [Label|Feld] / [Label|Feld] bzw. [Einnahme|Ausgabe|Kredit].
     Die erste Zeile ergibt genau 100 %, dadurch bricht der Rest sicher um. */
  [class$="-eingabe-gruppe"] { flex-wrap: wrap; row-gap: .8rem; }
  [class$="-eingabe-gruppe"] > label { padding: .5rem 1rem; flex: 0 0 10rem; }
  [class$="-eingabe-gruppe"] > input { flex: 1 1 calc(100% - 10rem); }
  .titel-typ-eingabe-gruppe label.typ-label { flex: 1 1 30%; width: auto; padding: .5rem; }

  /* neue Zeilenenden runden */
  .titel-typ-eingabe-gruppe > input[type="text"],
  .betrag-datum-eingabe-gruppe > input:nth-of-type(1) {
    border-right: .1rem solid var(--color-border);
    border-top-right-radius: 1.5rem;
    border-bottom-right-radius: 1.5rem;
  }
  .titel-typ-eingabe-gruppe label.typ-label[for="einnahme"],
  .betrag-datum-eingabe-gruppe > label:nth-of-type(2) {
    border-left: .1rem solid var(--color-border);
    border-top-left-radius: 1.5rem;
    border-bottom-left-radius: 1.5rem;
  }
  .titel-typ-eingabe-gruppe label.typ-label[for="einnahme"] { border-left-color: var(--color-einnahme-border); }

  .typ-filter-btn { padding: .5rem 1.2rem; }

  .monatsliste > h2 { font-size: 2rem; }
  .monatsliste > h2 > .monatsbilanz { font-size: 1.5rem; }
  .monatsliste > ul > li { margin: .8rem 0; }
  .monatsliste > ul > li > .datum { width: auto; padding: .5rem .8rem .5rem 1rem; }
  .monatsliste > ul > li > .titel { padding: .5rem .8rem; }
  .monatsliste > ul > li > .betrag { padding: .5rem .8rem; white-space: nowrap; }
  .monatsliste > ul > li > .bearbeiten-button { padding: .5rem .8rem; }
  .monatsliste > ul > li > .entfernen-button { padding: .5rem 1rem; }
}

.receipt-dialog { max-height: calc(100vh - 3.2rem); overflow-y: auto; }

.receipt-dialog input[type="date"] {
  width: 100%;
  padding: .5rem 1.2rem;
  border: .1rem solid var(--color-border);
  border-radius: 1.5rem;
  background: var(--color-input-bg);
  color: var(--color-text-muted);
  line-height: 2.5rem;
}

.receipt-preview {
  display: block;
  max-width: 100%;
  max-height: 24rem;
  margin: 1rem auto;
  object-fit: contain;
  border-radius: 1rem;
}

.receipt-warnings { list-style: none; padding: 0; margin: 1rem 0 0; }
.receipt-warnings li {
  background: var(--color-kredit-tint);
  color: var(--color-kredit-text);
  border: .1rem solid var(--color-kredit-border);
  border-radius: 1rem;
  padding: .6rem 1.2rem;
  margin-bottom: .6rem;
  line-height: 2rem;
}

.receipt-two-col { display: flex; gap: 1rem; }
.receipt-two-col > div { flex: 1; min-width: 0; }

#receipt-split-btn { margin: 1.2rem 0 0; }

.receipt-split-row { display: flex; gap: .6rem; margin-bottom: .6rem; align-items: center; }
.receipt-split-row .split-titel { flex: 2; min-width: 0; }
.receipt-split-row .split-betrag { flex: 1; min-width: 0; }
.receipt-split-row button { margin: 0; padding: .5rem 1.2rem; }
.receipt-rest { font-weight: 400; margin: .4rem 0 0; }

.receipt-dialog details { margin-top: 1.2rem; color: var(--color-text-muted); }
.receipt-dialog summary { cursor: pointer; }
.receipt-positions { list-style: none; padding: 0; margin: .6rem 0 0; }
.receipt-positions li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; line-height: 2rem; }

.receipt-question { margin: 2rem 0 0; line-height: 2rem; }
.receipt-actions { flex-wrap: wrap; gap: .8rem; }
.receipt-actions button { margin: 0; max-width: none; }

.beleg-link { text-decoration: none; margin-right: .6rem; }

/* === Große Beträge (bis 99.999.999.999,99 € und Summen darüber) === */
.monatsliste > h2 { flex-wrap: wrap; gap: .4rem 1rem; }
.monatsliste > h2 > .monat-jahr { min-width: 0; }
.monatsliste > h2 > .monatsbilanz {
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.monatsliste > ul > li > .betrag {
  flex-shrink: 0; /* der Titel kürzt sich, der Betrag nicht */
  text-align: right;
  white-space: nowrap; /* Einzelbeträge sind auf 99.999.999.999,99 € begrenzt: nie mitten in der Zahl umbrechen */
}

.gesamtbilanz-zeile { flex-wrap: wrap; }
.gesamtbilanz-zeile > span:nth-of-type(1) { min-width: 0; }
.gesamtbilanz-zeile > span:nth-of-type(2) {
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
  text-align: right;
  overflow-wrap: anywhere;
}

.summary-box, .chart-box { min-width: 0; }

/* Eintrag mit unbrauchbarem Altbetrag: sichtbar, damit er korrigiert oder gelöscht werden kann */
.monatsliste > ul > li > .betrag.betrag-defekt { color: var(--color-ausgabe); font-style: italic; }

/* Ladefehler statt leerer Seite */
.load-error {
  margin: 1.5rem auto;
  padding: 1.2rem 1.6rem;
  max-width: 80rem;
  border: .1rem solid var(--color-ausgabe);
  border-radius: 1.5rem;
  color: var(--color-ausgabe);
  background: var(--color-box-bg);
  font-size: 1.5rem;
}
.load-error[hidden] { display: none; }

@media (max-width: 480px) {
  .monatsliste > ul > li > .betrag { white-space: normal; }
}

/* Schmale Screens: Datum oben, darunter Titel und Betrag; der Betrag bleibt unzerteilt
   (große Beträge dürfen nicht mitten in der Zahl umbrechen), der Titel kürzt sich mit "…". */
@media (max-width: 480px) {
  .monatsliste > ul > li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }
  .monatsliste > ul > li > .datum {
    grid-column: 1 / 3;
    grid-row: 1;
    width: auto;
    border-bottom-left-radius: 0;
    border-bottom: none;
    padding-bottom: 0;
    line-height: 2rem;
  }
  .monatsliste > ul > li > .titel { grid-column: 1; grid-row: 2; border-bottom-left-radius: 1.5rem; }
  .monatsliste > ul > li > .betrag {
    grid-column: 2;
    grid-row: 2;
    max-width: none;
    white-space: nowrap;
    overflow-wrap: normal;
  }
  .monatsliste > ul > li > .bearbeiten-button { grid-column: 3; grid-row: 1 / 3; }
  .monatsliste > ul > li > .entfernen-button { grid-column: 4; grid-row: 1 / 3; }
  /* Ansicht ohne Buttons (Freigabelink): Betrag schließt die Zeile rechts ab */
  .monatsliste > ul > li:not(:has(button)) > .datum {
    border-right: .1rem solid var(--color-border);
    border-top-right-radius: 1.5rem;
  }
}

/* display:flex der Klasse darf das hidden-Attribut nicht aushebeln (Share-Seite: Code-Fenster/Meldung) */
.login-page[hidden] { display: none; }
