/* Finanzen – ruhiges, klares Fintech-Design. Tokens zuerst, Komponenten danach. */
:root {
  --bg: #F5F6F8; --flaeche: #FFFFFF; --flaeche-2: #F0F2F5; --linie: #E3E6EA;
  --text: #111827; --text-2: #4B5563; --gedaempft: #6B7280;
  --primaer: #0F766E; --primaer-text: #FFFFFF; --primaer-hell: #E6F4F2; --primaer-tief: #0B5E57;
  --plus: #067647; --minus: #111827; --offen: #B45309; --offen-hell: #FEF3E2;
  --fehler: #B42318; --fehler-hell: #FEECEB;
  --c-einnahmen: #0D9488; --c-ausgaben: #E0654A; --c-balken: #0F766E; --raster: #ECEEF1;
  --schatten: 0 1px 2px rgba(17,24,39,.06), 0 4px 16px rgba(17,24,39,.05);
  --radius: 16px; --radius-s: 10px;
  --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --unten: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1113; --flaeche: #171B1F; --flaeche-2: #1F2429; --linie: #2B3137;
    --text: #F3F4F6; --text-2: #C2C8CF; --gedaempft: #9AA3AD;
    --primaer: #2BB3A3; --primaer-text: #06201D; --primaer-hell: #12312D; --primaer-tief: #5CD0C2;
    --plus: #4ADE9B; --minus: #F3F4F6; --offen: #F5B04C; --offen-hell: #33260F;
    --fehler: #F97066; --fehler-hell: #3A1715;
    --c-einnahmen: #0F9A8B; --c-ausgaben: #E06A4C; --c-balken: #2BB3A3; --raster: #252B31;
    --schatten: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--schrift); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
.zahl, .betrag { font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--primaer); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primaer); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
i[data-icon] svg { width: 22px; height: 22px; display: block; }

/* Layout: unten Navigation (Handy), links Seitenleiste (ab 900 px) */
#inhalt { padding: 16px 16px calc(96px + var(--unten)); max-width: 980px; margin: 0 auto; outline: none; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--flaeche) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--linie); padding: 6px 4px calc(6px + var(--unten));
}
.nav-marke { display: none; }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center;
  color: var(--gedaempft); text-decoration: none; font-size: .75rem; font-weight: 500; border-radius: 12px;
  transition: color .15s, background .15s;
}
.nav a[aria-current="page"] { color: var(--primaer); }
.nav a.nav-scan i { background: var(--primaer); color: var(--primaer-text); border-radius: 14px; padding: 7px 14px; }
@media (min-width: 900px) {
  #shell { display: grid; grid-template-columns: 232px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 20px 12px;
    border-top: 0; border-right: 1px solid var(--linie); background: var(--flaeche); backdrop-filter: none;
  }
  .nav-marke { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.125rem; padding: 4px 12px 20px; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: .95rem; padding: 0 12px; min-height: 44px; }
  .nav a[aria-current="page"] { background: var(--primaer-hell); }
  .nav a.nav-scan i { padding: 0; background: none; color: inherit; }
  #inhalt { padding: 28px 32px 48px; }
}
.marke-icon { width: 30px; height: 30px; border-radius: 8px; background: url(/static/icons/logo.svg) center/cover; flex: none; }

/* Kopfzeile je Ansicht */
.kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.kopf .unterzeile { color: var(--gedaempft); font-size: .875rem; }
.monat-wahl { display: inline-flex; align-items: center; gap: 2px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 999px; padding: 2px; }
.monat-wahl span { min-width: 112px; text-align: center; font-weight: 600; font-size: .9rem; }

/* Karten */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 16px; box-shadow: var(--schatten); }
.karte + .karte, .raster + .karte, .karte + .raster { margin-top: 12px; }
.karte-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.karte-kopf .link { font-size: .875rem; font-weight: 600; text-decoration: none; }
.raster { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; align-items: start; }
.raster > .karte { margin-top: 0 !important; }
@media (min-width: 900px) { .raster.drei { grid-template-columns: repeat(3, 1fr); } .raster.zwei-breit { grid-template-columns: 3fr 2fr; } }
@media (max-width: 899px) { .raster.zwei-breit { grid-template-columns: 1fr; } }

.kachel .titel { color: var(--text-2); font-size: .8125rem; font-weight: 500; }
.kachel .wert { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kachel .hinweis { color: var(--gedaempft); font-size: .8125rem; }
.kachel.held { grid-column: 1 / -1; }
.kachel.held .wert { font-size: 2.25rem; }
.kachel.offen { background: var(--offen-hell); border-color: transparent; cursor: pointer; text-align: left; width: 100%; }
.kachel.offen .wert { color: var(--offen); }

/* Knöpfe */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--linie); background: var(--flaeche); font-weight: 600; cursor: pointer;
  transition: background .15s, transform .1s; text-decoration: none; color: var(--text);
}
.knopf:active { transform: scale(.98); }
.knopf.primaer { background: var(--primaer); border-color: var(--primaer); color: var(--primaer-text); }
.knopf.primaer:hover { background: var(--primaer-tief); }
.knopf.leise { background: transparent; border-color: transparent; color: var(--primaer); }
.knopf.gefahr { color: var(--fehler); }
.knopf.breit { width: 100%; }
.knopf[disabled] { opacity: .55; cursor: default; }
.knopf i svg { width: 20px; height: 20px; }
.icon-knopf { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 12px; cursor: pointer; color: var(--text-2); }
.icon-knopf:hover { background: var(--flaeche-2); }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 8px; }
.gross-knopf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 120px; font-size: 1rem; }
.gross-knopf i svg { width: 30px; height: 30px; }

/* Chips / Segmente */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 0 12px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--linie);
  background: var(--flaeche); font-size: .875rem; font-weight: 500; cursor: pointer; color: var(--text-2);
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--flaeche-2); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.segment button { min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; color: var(--text-2); }
.segment button[aria-pressed="true"] { background: var(--flaeche); color: var(--text); box-shadow: var(--schatten); }
.wahl { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.wahl button { min-height: 52px; border-radius: 12px; border: 1px solid var(--linie); background: var(--flaeche); cursor: pointer; font-weight: 600; font-size: .875rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.wahl button small { font-weight: 500; color: var(--gedaempft); font-size: .75rem; }
.wahl button[aria-pressed="true"] { border-color: var(--primaer); background: var(--primaer-hell); color: var(--primaer-tief); box-shadow: inset 0 0 0 1px var(--primaer); }

/* Listen */
.liste { list-style: none; margin: 0; padding: 0; }
.tag-kopf { font-size: .8125rem; font-weight: 600; color: var(--gedaempft); padding: 14px 4px 6px; display: flex; justify-content: space-between; }
.zeile {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; margin-bottom: 6px; cursor: pointer;
  width: 100%; text-align: left; transition: background .15s;
}
.zeile:hover { background: var(--flaeche-2); }
.zeile .rund { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--flaeche-2); color: var(--text-2); }
.zeile .rund svg { width: 20px; height: 20px; }
.zeile .haupt { min-width: 0; }
.zeile .titel { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .neben { color: var(--gedaempft); font-size: .8125rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.zeile .rechts { text-align: right; }
.betrag { font-weight: 650; white-space: nowrap; }
.betrag.plus { color: var(--plus); }
.marke { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--flaeche-2); color: var(--text-2); }
.marke.frau { background: #FCE7F3; color: #9D174D; }
.marke.firma { background: #E0F2FE; color: #075985; }
.marke.betrieb { background: #EDE9FE; color: #5B21B6; }
.marke.ok { background: var(--primaer-hell); color: var(--primaer-tief); }
.marke.warn { background: var(--offen-hell); color: var(--offen); }
.marke.fehler { background: var(--fehler-hell); color: var(--fehler); }
@media (prefers-color-scheme: dark) {
  .marke.frau { background: #3B1229; color: #F9A8D4; }
  .marke.firma { background: #0C2A3D; color: #7DD3FC; }
  .marke.betrieb { background: #261A47; color: #C4B5FD; }
}
.marke svg { width: 12px; height: 12px; }
.leer { text-align: center; color: var(--gedaempft); padding: 32px 16px; }
.leer svg { width: 40px; height: 40px; margin: 0 auto 8px; opacity: .6; }

/* Formulare */
.feld { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.feld label { font-size: .875rem; font-weight: 600; color: var(--text-2); }
.feld .hilfe { font-size: .8125rem; color: var(--gedaempft); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--linie);
  background: var(--flaeche); font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaer); outline-offset: 0; border-color: transparent; }
.suche { position: relative; margin-bottom: 12px; }
.suche input { padding-left: 42px; }
.suche i { position: absolute; left: 12px; top: 13px; color: var(--gedaempft); }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primaer); }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fehlertext { color: var(--fehler); font-size: .875rem; margin: 8px 0 0; }

/* Blatt (Bottom-Sheet am Handy, Dialog am Desktop) */
.blatt-hintergrund { position: fixed; inset: 0; background: rgba(15,18,22,.45); z-index: 40; animation: einblenden .2s ease-out; }
.blatt {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--flaeche); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(0,0,0,.18);
  animation: hochschieben .24s cubic-bezier(.2,.8,.2,1);
}
.blatt-griff { width: 40px; height: 4px; background: var(--linie); border-radius: 4px; margin: 8px auto 0; }
.blatt-kopf { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 20px; }
.blatt-inhalt { overflow-y: auto; padding: 8px 20px calc(24px + var(--unten)); }
@media (min-width: 900px) {
  .blatt { left: 50%; top: 50%; bottom: auto; right: auto; transform: translate(-50%, -50%); width: 560px; border-radius: 20px; max-height: 86vh; animation: einblenden .18s ease-out; }
  .blatt-griff { display: none; }
}
@keyframes hochschieben { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes einblenden { from { opacity: 0; } to { opacity: 1; } }

/* Meldung */
.meldung {
  position: fixed; left: 50%; bottom: calc(92px + var(--unten)); transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); animation: einblenden .15s;
}
@media (min-width: 900px) { .meldung { bottom: 24px; } }

/* Diagramme */
.diagramm svg { width: 100%; height: auto; display: block; overflow: visible; }
.diagramm text { fill: var(--text-2); font-size: 12px; font-family: var(--schrift); }
.diagramm .achse { stroke: var(--raster); stroke-width: 1; }
.legende { display: flex; gap: 16px; font-size: .8125rem; color: var(--text-2); margin-bottom: 8px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende b { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.balken-zeile { display: grid; grid-template-columns: minmax(96px, 38%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: .875rem; }
.balken-zeile .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.balken-zeile .spur { display: block; height: 12px; }
.balken-zeile .balken { height: 12px; border-radius: 0 4px 4px 0; background: var(--c-balken); min-width: 2px; }
.balken-zeile .wert { color: var(--text-2); text-align: right; min-width: 72px; }
.tipp { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 8px; font-size: .8125rem; white-space: nowrap; transform: translate(-50%, -110%); z-index: 5; }
.diagramm { position: relative; }

/* Belege */
.beleg-bild { width: 100%; max-height: 52vh; object-fit: contain; background: var(--flaeche-2); border-radius: 12px; }
.beleg-pdf { width: 100%; height: 52vh; border: 0; border-radius: 12px; background: var(--flaeche-2); }
.position { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--linie); cursor: pointer; }
.position input { width: 20px; height: 20px; accent-color: var(--primaer); }
.vorschau { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--flaeche-2); }
.laeuft { animation: puls 1.2s ease-in-out infinite; }
@keyframes puls { 50% { opacity: .45; } }

/* Start (Login/Einrichtung) */
.start { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.start .karte { width: 100%; max-width: 400px; padding: 28px 24px; }
.start .marke-icon { display: block; width: 56px; height: 56px; border-radius: 15px; margin-bottom: 16px; }
.start p { color: var(--text-2); margin: 6px 0 20px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: 220px; margin: 0 auto 12px; }
.qr svg { width: 100%; height: auto; display: block; }
code.geheim { display: block; word-break: break-all; font-size: .8125rem; background: var(--flaeche-2); padding: 8px; border-radius: 8px; text-align: center; }

.trenner { height: 1px; background: var(--linie); margin: 16px 0; }
.klein { font-size: .8125rem; color: var(--gedaempft); }
.text-2 { color: var(--text-2); }
.rechts { text-align: right; }
.mt { margin-top: 16px; }
.summe-gross { font-size: 2.25rem; font-weight: 700; letter-spacing: -.02em; color: var(--offen); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Belohnung im Sparpotenzial */
.gespart { display: flex; gap: 12px; align-items: center; background: var(--primaer-hell); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.gespart > span { width: 36px; height: 36px; border-radius: 50%; background: var(--plus); color: #fff; display: grid; place-items: center; flex: none; }
.gespart > span svg { width: 20px; height: 20px; }
.gespart-wert { font-size: 1.5rem; font-weight: 700; color: var(--plus); }

/* Zeugnis und Wochen-Challenge */
.zeugnis { display: flex; gap: 14px; align-items: center; }
.note { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.75rem; font-weight: 800; flex: none; color: #fff; }
.note-1 { background: #067647; } .note-2 { background: #0D9488; } .note-3 { background: #B7791F; } .note-4 { background: #C2410C; } .note-5 { background: #B42318; }
.balken-spur { height: 12px; background: var(--flaeche-2); border-radius: 999px; margin: 10px 0 6px; overflow: hidden; }
.balken-fuell { height: 100%; background: var(--plus); border-radius: 999px; transition: width .4s ease-out; }
.balken-fuell.drueber { background: var(--fehler); }
.wochen { display: flex; gap: 6px; margin-top: 10px; }
.wochen span { width: 16px; height: 16px; border-radius: 5px; background: var(--flaeche-2); }
.wochen span.ja { background: var(--plus); } .wochen span.nein { background: var(--fehler-hell); border: 1px solid var(--fehler); }

.knopf > svg { width: 18px; height: 18px; }
