/* Haushaltsbuch. Nach DESIGN.md: neutrales Grau und Weiss, eine Akzentfarbe
   (das Braun der Schulpunkte), Systemschrift, Radius 4 (Knoepfe, Felder) und
   8 (Karten), Schrift 12 bis 36 px, Text nie unter 14 px ausser in der
   Tableiste und an den Achsen des Diagramms (Ausnahmen in DESIGN.md).
   Jede Bedienflaeche 44 px. Kein color-mix(), die App laeuft ab iOS 16. */

:root {
  --grund: #f4f4f5;
  --flaeche: #ffffff;
  --erhoben: #ededee;
  --schrift: #1c1c1e;
  --leise: #5d5d62;
  --linie: #dfdfe2;
  /* Rand von Bedienelementen, 3:1 gegen die Flaeche (WCAG 1.4.11). */
  --steuer: #8a8a90;
  --akzent: #80603e;
  --akzent-hell: #d7cbbe;
  --akzent-grund: #f4f0ec;
  --auf-akzent: #ffffff;
  --gut: #1f7a45;
  --gut-grund: #e9f2ec;
  --schlecht: #b3261e;
  --schlecht-grund: #f7e9e8;
  --warn-grund: #f3eee6;
  --schrift-familie: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
                     Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #121213;
    --flaeche: #1c1c1e;
    --erhoben: #26262a;
    --schrift: #ececee;
    --leise: #a1a1a8;
    --linie: #333338;
    --steuer: #6e6e75;
    --akzent: #c69a69;
    --akzent-hell: #584838;
    --akzent-grund: #2d2926;
    --auf-akzent: #121213;
    --gut: #5cc98a;
    --gut-grund: #222d29;
    --schlecht: #ff8a7f;
    --schlecht-grund: #332728;
    --warn-grund: #302a22;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 5rem; scroll-padding-bottom: 6rem; }
body {
  margin: 0; background: var(--grund); color: var(--schrift);
  font: 16px/1.5 var(--schrift-familie);
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
}
body.mit-tableiste { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
@media (min-width: 768px) { body.mit-tableiste { padding-bottom: 24px; } }

h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--akzent); }
button, input, select { font: inherit; color: inherit; }
.zahl, .betrag, td.betrag { font-variant-numeric: tabular-nums; }
.leise { color: var(--leise); font-size: 14px; }
.gut { color: var(--gut); }
.schlecht { color: var(--schlecht); }
.versteckt { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

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

.kopf {
  position: sticky; top: 0; z-index: 10;
  background: var(--flaeche); border-bottom: 1px solid var(--linie);
  padding-top: env(safe-area-inset-top);
}
.kopf-innen { max-width: 760px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px; }
.marke { font-weight: 700; font-size: 18px; display: inline-flex; align-items: center;
  gap: 8px; color: var(--schrift); text-decoration: none; }
.marke span { color: var(--akzent); }
.marke svg { width: 28px; height: 28px; flex-shrink: 0; }
.marke-gross { font-size: 24px; }
.marke-gross svg { width: 36px; height: 36px; }
.kopf .haushalt { color: var(--leise); font-size: 14px; margin-left: auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.menue { display: none; gap: 16px; }
.menue a { color: var(--leise); text-decoration: none; padding: 8px 0; }
.menue a[aria-current="page"] { color: var(--akzent); font-weight: 650; }
@media (hover: hover) { .menue a:hover { color: var(--akzent); } }
@media (min-width: 768px) {
  .menue { display: flex; }
  .kopf .haushalt { margin-left: 0; }
  .menue { margin-left: auto; }
}

/* --- Tableiste ------------------------------------------------------ */

.tableiste { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--flaeche); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom); }
.tableiste-innen { max-width: 560px; margin: 0 auto; display: flex; }
.tableiste a { flex: 1 1 0; min-width: 0; min-height: 60px; padding: 8px 2px 6px;
  color: var(--leise); text-decoration: none; font-size: 12px; white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tableiste svg, .menue svg { width: 24px; height: 24px; }
.tableiste a[aria-current="page"] { color: var(--akzent); font-weight: 650; }
.tableiste a:focus-visible { outline: 2px solid var(--akzent); outline-offset: -4px; }
@media (min-width: 768px) { .tableiste { display: none; } }

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

.huelle { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px;
  display: grid; gap: 24px; }
.huelle > * { min-width: 0; }
.huelle-breit { max-width: 760px; }
.ohne-kopf { padding-top: calc(24px + env(safe-area-inset-top)); }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 8px;
  padding: 16px; }
.abschnitt { display: grid; gap: 12px; }
.abschnitt > * { min-width: 0; }
.schmal { max-width: 420px; width: 100%; margin: 0 auto; }

.meldung { border-radius: 4px; padding: 12px; font-size: 14px; border: 1px solid var(--linie);
  background: var(--flaeche); }
.meldung-success { background: var(--gut-grund); border-color: var(--gut); }
.meldung-danger { background: var(--schlecht-grund); border-color: var(--schlecht); }
.meldung-warning { background: var(--warn-grund); border-color: var(--steuer); }
.meldung-info { background: var(--erhoben); }

/* Duenner Balken, eckig, 4 px (DESIGN.md 0a.17). */
.balken { height: 4px; background: var(--erhoben); overflow: hidden; }
.balken > div { height: 100%; background: var(--akzent); }
.balken.drueber > div { background: var(--schlecht); }

/* --- Formulare ------------------------------------------------------ */

.feldname { font-size: 14px; color: var(--leise); margin-bottom: 4px; display: block; }
.feld { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--steuer);
  border-radius: 4px; background: var(--flaeche); font-size: 16px; }
.feld:focus { outline: 2px solid var(--akzent); outline-offset: 1px; border-color: var(--akzent); }
.feld:disabled { background: var(--erhoben); color: var(--leise); }
.reihe { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.reihe > * { min-width: 0; }
.formular { display: grid; gap: 16px; }
.haken { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.haken input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--akzent); }

.betragfeld { display: flex; align-items: baseline; gap: 8px;
  border-bottom: 2px solid var(--steuer); padding-bottom: 4px; }
.betragfeld:focus-within { border-color: var(--akzent); }
.betragfeld input { border: 0; background: transparent; outline: 0; width: 100%;
  font-size: 36px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 0; min-width: 0; }
.betragfeld span { font-size: 24px; color: var(--leise); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--steuer); border-radius: 4px; background: var(--flaeche);
  font-size: 14px; cursor: pointer; user-select: none; -webkit-user-select: none; }
.chips input:checked + span { border-color: var(--akzent); background: var(--akzent-grund);
  font-weight: 650; box-shadow: inset 0 0 0 1px var(--akzent); }
.chips input:focus-visible + span { outline: 2px solid var(--akzent); outline-offset: 2px; }
.chips input:disabled + span { opacity: .6; cursor: default; }

.knopf { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: 4px; border: 1px solid var(--steuer);
  background: transparent; cursor: pointer; font-weight: 600; font-size: 16px;
  color: var(--schrift); text-decoration: none; text-align: center; }
.knopf-voll { background: var(--akzent); border-color: var(--akzent); color: var(--auf-akzent); }
.knopf-breit { width: 100%; }
.knopf-klein { min-height: 44px; padding: 8px 12px; font-size: 14px; }
.knopf-gefahr { color: var(--schlecht); border-color: var(--schlecht); }
.knopf:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.knopf:disabled { opacity: .55; cursor: default; }
@media (hover: hover) {
  .knopf:not(:disabled):hover { background: var(--erhoben); }
  .knopf-voll:not(:disabled):hover { background: var(--akzent); filter: brightness(.94); }
}
.knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }
.knoepfe > .knopf, .knoepfe > form { flex: 1 1 140px; }
.knoepfe > form .knopf { width: 100%; }

/* --- Listen --------------------------------------------------------- */

.liste { display: grid; }
.posten { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px;
  padding: 12px 0; border-top: 1px solid var(--linie); color: inherit; text-decoration: none;
  min-height: 44px; }
.posten:first-child, .tagkopf + .posten { border-top: 0; }
.posten .was { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.posten .betrag { font-weight: 650; text-align: right; }
.posten .info { grid-column: 1 / -1; color: var(--leise); font-size: 14px; }
.posten:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.tagkopf { font-size: 14px; font-weight: 650; color: var(--leise); padding-top: 16px;
  border-top: 1px solid var(--linie); }
.tagkopf:first-child { padding-top: 0; border-top: 0; }

.zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px;
  align-items: center; padding: 12px 0; border-top: 1px solid var(--linie); }
.zeile:first-child { border-top: 0; }
.zeile .info { grid-column: 1 / -1; font-size: 14px; color: var(--leise); }

/* --- Monat ---------------------------------------------------------- */

.monatswahl { display: flex; align-items: center; gap: 8px; }
.monatswahl h1 { flex: 1; text-align: center; }
.pfeil { width: 44px; height: 44px; border-radius: 4px; border: 1px solid var(--steuer);
  background: var(--flaeche); color: var(--schrift); display: inline-flex;
  align-items: center; justify-content: center; flex-shrink: 0; }
.pfeil svg { width: 20px; height: 20px; }
.pfeil.aus { opacity: .35; pointer-events: none; }

.tabelle-huelle { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--leise); padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--linie); white-space: nowrap; }
td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--linie); vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
td.betrag, th.betrag { text-align: right; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 650; border-top: 1px solid var(--steuer); border-bottom: 0; }

.satz { font-size: 18px; font-weight: 650; }
.status { font-size: 14px; display: inline-block; padding: 4px 8px; border-radius: 4px;
  background: var(--erhoben); }

/* --- Auswertung ----------------------------------------------------- */

.filter { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.filter .feld { width: auto; flex: 1 1 160px; }
.umschalter { display: inline-flex; border: 1px solid var(--steuer); border-radius: 4px;
  overflow: hidden; }
.umschalter a { min-height: 44px; padding: 10px 16px; background: var(--flaeche);
  color: var(--schrift); text-decoration: none; font-size: 14px; }
.umschalter a + a { border-left: 1px solid var(--steuer); }
.umschalter a[aria-current="true"] { background: var(--akzent); color: var(--auf-akzent);
  font-weight: 650; }

.kennzahlen { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.kennzahlen div { padding: 12px 12px 12px 0; border-top: 1px solid var(--linie); min-width: 0; }
.kennzahlen div:nth-child(-n+2) { border-top: 0; }
.kennzahlen dt { font-size: 14px; color: var(--leise); }
.kennzahlen dd { margin: 0; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kennzahlen dd small { display: block; font-size: 14px; font-weight: 400; color: var(--leise); }
@media (max-width: 359px) {
  .kennzahlen { grid-template-columns: 1fr; }
  .kennzahlen div:nth-child(2) { border-top: 1px solid var(--linie); }
}

.diagramm svg { width: 100%; height: auto; display: block; }
/* Achsen 11 px: Monatskuerzel unter zwoelf Saeulen auf 320 px (DESIGN.md). */
.diagramm .achse { fill: var(--leise); font-size: 11px; font-family: var(--schrift-familie); }
.diagramm .gitter { stroke: var(--linie); stroke-width: 1; }
.diagramm .saeule { fill: var(--akzent-hell); }
.diagramm .saeule.jetzt { fill: var(--akzent); }
.diagramm .saeule.drueber { fill: var(--schlecht); fill-opacity: .55; }
.diagramm .ziel { stroke: var(--schrift); stroke-width: 1.5; stroke-dasharray: 4 4; }
.diagramm .zielschrift { fill: var(--schrift); font-size: 11px; font-weight: 600;
  font-family: var(--schrift-familie); }
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--leise); }
.legende i { display: inline-block; width: 12px; height: 12px; border-radius: 2px;
  margin-right: 6px; vertical-align: -1px; background: var(--akzent-hell); }
.legende i.jetzt { background: var(--akzent); }
.legende i.drueber { background: var(--schlecht); opacity: .55; }

.kat { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px;
  padding: 12px 0; border-top: 1px solid var(--linie); }
.kat:first-child { border-top: 0; }
.kat .name { font-weight: 600; min-width: 0; }
.kat .betrag { font-weight: 650; text-align: right; }
.kat .balken, .kat .vergleich { grid-column: 1 / -1; }
.kat .vergleich { font-size: 14px; color: var(--leise); }

/* --- Mehr ----------------------------------------------------------- */

.einstellung { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
  align-items: center; padding: 8px 0; border-top: 1px solid var(--linie); }
.einstellung:first-child { border-top: 0; }
.einstellung .feld { width: 120px; text-align: right; }
.einstellung .feld.breit { width: 100%; text-align: left; }
.person { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 8px 12px;
  padding: 12px 0; border-top: 1px solid var(--linie); align-items: end; }
.person:first-child { border-top: 0; }
.person .info { grid-column: 1 / -1; font-size: 14px; color: var(--leise); }
.punkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 6px; vertical-align: 0; }
details.aufklapp summary { cursor: pointer; min-height: 44px; display: flex;
  align-items: center; color: var(--akzent); font-weight: 600; }
details.aufklapp[open] summary { margin-bottom: 8px; }

/* --- Plus ----------------------------------------------------------- */

.angebote { display: grid; gap: 8px; }
.angebot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px;
  text-align: left; padding: 12px 16px; border: 1px solid var(--steuer); border-radius: 4px;
  background: var(--flaeche); cursor: pointer; min-height: 56px; width: 100%; }
.angebot .name { font-weight: 650; }
.angebot .preis { font-weight: 650; font-variant-numeric: tabular-nums; }
.angebot .zusatz { grid-column: 1 / -1; font-size: 14px; color: var(--leise); }
.angebot:disabled { opacity: .6; cursor: default; }
.angebot:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* --- Anmeldung, Fuss ------------------------------------------------ */

.turnstile-platz { min-height: 65px; }
.fuss { max-width: 560px; margin: 0 auto; padding: 16px 16px 24px; display: flex;
  gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--linie); }
.fuss a { color: var(--leise); font-size: 14px; text-decoration: none; padding: 8px 0; }

.text { display: grid; gap: 12px; }
.text h2 { margin-top: 16px; }
.text p, .text li { max-width: 70ch; }
.text ul { margin: 0; padding-left: 20px; }

@media (prefers-reduced-motion: no-preference) {
  .balken > div { transition: width .2s ease-out; }
}
