/* ───────────────────────────────────────────────────────────────────────────
   Vier Themes: auto (folgt dem System), hell, dunkel, amoled (echtes Schwarz).
   Gesteuert ueber data-theme am <html>-Element.

   Grosse Tippflaechen (min. 48px), hoher Kontrast, wenig Zierrat.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e4e3df;
  --text: #101013;
  --muted: #6c6c76;
  --accent: #0a6cff;
  --accent-soft: rgba(10, 108, 255, .1);
  /* Schriftfarbe auf der Akzentflaeche. Waehlt der Admin eine helle Farbe,
     setzt das Skript hier Schwarz - sonst waere die Beschriftung unsichtbar. */
  --on-accent: #ffffff;
  --spend: #101013;
  --income: #0b7a4b;
  --danger: #c0392b;
  --warn: #b26a00;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 10px 30px rgba(0, 0, 0, .06);
  --brand-filter: none;         /* Wortmarke: dunkle Variante */
  --ease: cubic-bezier(.22, .9, .28, 1);
  color-scheme: light;
}

/* System folgt -> dunkel */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="amoled"]) {
    --bg: #0d0d10;
    --surface: #17171c;
    --surface-2: #1d1d23;
    --border: #292930;
    --text: #f3f3f5;
    --muted: #9c9ca8;
    --accent: #4f9bff;
    --accent-soft: rgba(79, 155, 255, .16);
    --on-accent: #ffffff;
    --spend: #f3f3f5;
    --income: #45d68a;
    --danger: #ff6f61;
    --warn: #ffb04d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* Ausdrueckliche Wahl: dunkel */
:root[data-theme="dark"] {
  --bg: #0d0d10;
  --surface: #17171c;
  --surface-2: #1d1d23;
  --border: #292930;
  --text: #f3f3f5;
  --muted: #9c9ca8;
  --accent: #4f9bff;
  --accent-soft: rgba(79, 155, 255, .16);
  --on-accent: #ffffff;
  --spend: #f3f3f5;
  --income: #45d68a;
  --danger: #ff6f61;
  --warn: #ffb04d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* AMOLED: echtes Schwarz, damit OLED-Pixel wirklich ausgehen */
:root[data-theme="amoled"] {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #0a0a0a;
  --border: #232326;
  --text: #ffffff;
  --muted: #8e8e98;
  --accent: #4f9bff;
  --accent-soft: rgba(79, 155, 255, .18);
  --on-accent: #ffffff;
  --spend: #ffffff;
  --income: #3ee07f;
  --danger: #ff6f61;
  --warn: #ffb04d;
  --shadow: none;
  color-scheme: dark;
}

/* Weisse Wortmarke in allen dunklen Varianten */
:root[data-theme="dark"],
:root[data-theme="amoled"] { --brand-filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]):not([data-theme="amoled"]) {
    --brand-filter: invert(1);
  }
}

* { box-sizing: border-box; }

/* Verstecken muss verstecken.
   Ohne diese Regel gewinnt jede Klasse mit eigenem "display" gegen das
   hidden-Attribut des Browsers - und dann steht ein Element auf der Seite,
   das der Code laengst ausgeblendet hat. Genau so war der Plus-Knopf
   (.fab { display: grid }) fuer Mama und Baba sichtbar, obwohl app.js ihn
   ausblendet. Dasselbe galt fuer die Topf-Auswahl, die Profil-Reiter und
   die Akzentfarbe. */
[hidden] { display: none !important; }

/* Wortmarke in zwei Fassungen.
   Frueher wurde die dunkle Datei per filter:invert(1) umgedreht. Das geht nur
   bei einem einfarbig schwarzen Logo gut - ein farbiges kaeme falsch heraus.
   Deshalb liegen beide Fassungen als Datei vor und werden hier getauscht.
   scripts/icons.sh baut die helle notfalls aus der dunklen. */
img.wm-light { display: none; }
img.wm-dark  { display: block; }
:root[data-theme="dark"]   img.wm-dark,
:root[data-theme="amoled"] img.wm-dark  { display: none; }
:root[data-theme="dark"]   img.wm-light,
:root[data-theme="amoled"] img.wm-light { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]):not([data-theme="amoled"]) img.wm-dark  { display: none; }
  :root:not([data-theme="light"]):not([data-theme="dark"]):not([data-theme="amoled"]) img.wm-light { display: block; }
}
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap { max-width: 34rem; margin: 0 auto; padding: 1.1rem 1.1rem 3rem; }

/* ── Kopfzeile mit Wortmarke ─────────────────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem 0 1.4rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
}
.brand img {
  height: 21px;
  width: auto;
  /* display setzen die Regeln fuer wm-dark / wm-light weiter oben. Stuende
     hier ein eigenes display:block, gewaenne es den Gleichstand - und beide
     Fassungen der Wortmarke stuenden nebeneinander. */
}
.brand .sep {
  width: 1px;
  height: 17px;
  background: var(--border);
  flex: none;
}
.brand .who {
  color: var(--muted);
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 21px; height: 21px; }

/* ── Profil-Umschalter ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: .45rem; margin-bottom: 1.1rem; }
.tabs button {
  flex: 1;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease),
              border-color .2s var(--ease), transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tabs button:active { transform: scale(.97); }
.tabs button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ── Die grosse Zahl ─────────────────────────────────────────────────────── */
.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.9rem 1.4rem 1.7rem;
  text-align: center;
  margin-bottom: 1rem;
}
.balance-label { color: var(--muted); font-size: .95rem; margin: 0 0 .5rem; }
.balance {
  font-size: clamp(2.8rem, 14vw, 4rem);
  font-weight: 650;
  letter-spacing: -.035em;
  line-height: 1.05;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.balance.is-loading { color: var(--muted); opacity: .35; }
.balance-meta { color: var(--muted); font-size: .87rem; margin: .75rem 0 0; }

/* ── Budget-Karte ────────────────────────────────────────────────────────── */
.budget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.3rem 1.3rem;
  margin-bottom: 1.4rem;
  transition: opacity .28s var(--ease), filter .28s var(--ease);
}
/* Der Toggle-Zustand: aus = sichtbar ausgegraut und nicht bedienbar */
.budget-card.is-off {
  opacity: .45;
  filter: grayscale(1);
  pointer-events: none;
  user-select: none;
}
.budget-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
}
.budget-head .label { color: var(--muted); font-size: .9rem; }
.budget-remaining {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.budget-remaining.is-over { color: var(--danger); }

.bar {
  height: 9px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  transition: width .65s var(--ease), background-color .3s var(--ease);
}
.bar > span.warn { background: var(--warn); }
.bar > span.over { background: var(--danger); }
.budget-foot {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .84rem;
  margin-top: .55rem;
  font-variant-numeric: tabular-nums;
}

/* ── Ansicht-Umschalter (Shops / Einzeln) ────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 .2rem .65rem;
}
h2 {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0;
}
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .8rem;
  font-weight: 500;
  padding: .3rem .65rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); }

/* ── Listen ──────────────────────────────────────────────────────────────── */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  min-height: 58px;
  border-top: 1px solid var(--border);
  animation: row-in .34s var(--ease) both;
}
.list li:first-child { border-top: none; }

.tx-main { min-width: 0; display: flex; align-items: center; gap: .8rem; }
.dot {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.tx-merchant { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-when { color: var(--muted); font-size: .84rem; margin-top: .05rem; }
.tx-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  color: var(--spend);
}
.tx-amount.is-income { color: var(--income); }

/* ── Zustaende ───────────────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; line-height: 1.6; }
.banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: 12px;
  padding: .8rem 1rem;
  margin-bottom: 1rem;
  font-size: .92rem;
  animation: row-in .3s var(--ease) both;
}

/* ── Knoepfe ─────────────────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  min-height: 54px;
  padding: .95rem 1.3rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .12s var(--ease), opacity .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: .95rem;
  min-height: 48px;
  border: 1px solid var(--border);
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.sm { min-height: 44px; font-size: .93rem; }

.foot { text-align: center; margin-top: 1.5rem; }

/* ── Anmelde- und Einrichtungsseite ──────────────────────────────────────── */
.center {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 1.4rem;
}
.center .mark {
  width: 82px;
  height: 82px;
  margin-bottom: 1.5rem;
  filter: var(--brand-filter);
  animation: pop-in .5s var(--ease) both;
}
.center h1 { font-size: 1.55rem; font-weight: 650; margin: 0 0 .5rem; letter-spacing: -.02em; }
/* Die Anmeldeseite zeigt nur noch die Wortmarke - kein zweites Logo darueber. */
.center .brandmark { margin: 0 0 1.3rem; line-height: 0; }
.center .brandmark img {
  height: 40px;
  width: auto;
  max-width: min(78vw, 320px);
  object-fit: contain;
  animation: pop-in .5s var(--ease) both;
}
.center p { color: var(--muted); margin: 0 0 1.9rem; max-width: 22rem; line-height: 1.55; }
.center .actions { width: 100%; max-width: 20rem; }

/* ── Einstellungen (Modal) ───────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(3px);
  z-index: 40;
  animation: fade-in .22s var(--ease) both;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  max-height: 88svh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  padding: .6rem 1.1rem calc(1.6rem + env(safe-area-inset-bottom));
  animation: sheet-up .32s var(--ease) both;
}
@media (min-width: 34rem) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30rem;
    border-radius: 22px;
    border: 1px solid var(--border);
    animation: pop-in .28s var(--ease) both;
  }
}
.grabber {
  width: 40px; height: 4px;
  border-radius: 99px;
  background: var(--border);
  margin: .4rem auto 1rem;
}
.sheet h2 { margin: 1.5rem 0 .6rem .15rem; }
.sheet h2:first-of-type { margin-top: .4rem; }

.group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  min-height: 56px;
  border-top: 1px solid var(--border);
}
.row:first-child { border-top: none; }
.row .label { font-size: .97rem; }
.row .hint { color: var(--muted); font-size: .82rem; margin-top: .1rem; }

.choice { display: flex; gap: 4px; padding: 3px; background: var(--surface-2);
          border: 1px solid var(--border); border-radius: 11px; flex-wrap: wrap; }
.choice button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .87rem;
  font-weight: 500;
  padding: .42rem .7rem;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.choice button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Schalter */
.switch {
  flex: none;
  position: relative;
  width: 52px; height: 31px;
  border-radius: 99px;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: background .25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .25s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(21px); }

input[type="number"], input[type="text"] {
  width: 8.5rem;
  min-height: 44px;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.archive-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  min-height: 52px;
  border-top: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.archive-link:first-child { border-top: none; }
.archive-link .when { font-weight: 500; }
.archive-link .sum { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .92rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.4rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--text);
  color: var(--bg);
  padding: .7rem 1.2rem;
  border-radius: 99px;
  font-size: .93rem;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
  animation: toast-in .3s var(--ease) both;
}

/* ── Bewegung ────────────────────────────────────────────────────────────── */
@keyframes row-in {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: none; }
}
@media (min-width: 34rem) {
  @keyframes pop-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
    to   { opacity: 1; transform: translate(-50%, -50%); }
  }
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translateX(-50%); }
}
.fade-swap { animation: row-in .3s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ═══ Erweiterungen: Toepfe, Zahltag, Logos, Eintragen ══════════════════════ */

/* Akzentfarbe kann der Admin setzen; --accent-user kommt dann per JS dazu. */
:root { --accent-user: none; }

/* ── Nur-Ansehen-Hinweis ─────────────────────────────────────────────────── */
.readonly-tag {
  margin: .8rem 0 0;
  font-size: .78rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Toepfe innerhalb der Budget-Karte ───────────────────────────────────── */
.pots {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.pot-row { display: flex; flex-direction: column; gap: .35rem; }
.pot-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-size: .89rem;
}
.pot-line .name { color: var(--muted); }
.pot-line .left { font-variant-numeric: tabular-nums; font-weight: 600; }
.pot-line .left.is-over { color: var(--danger); }
.pot-row .bar { height: 5px; }

/* ── Zahltag ─────────────────────────────────────────────────────────────── */
.payday {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--border);
  font-size: .87rem;
  color: var(--muted);
}
.payday strong { color: var(--text); font-weight: 600; }
.payday .est { font-size: .78rem; opacity: .7; }

/* ── Logos in der Liste ──────────────────────────────────────────────────── */
/* Das Logo fuellt die Flaeche randlos aus - kein weisser Kasten dahinter.
   Die Rundung kommt vom Container, das Bild wird passend beschnitten. */
.dot.has-icon {
  background: transparent;
  border: none;
  padding: 0;
  overflow: hidden;
}
.dot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.tag {
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 .3rem;
  margin-left: .4rem;
  white-space: nowrap;
}

.list li.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.list li.tappable:active { background: var(--surface-2); }

/* ── Schwebender Eintragen-Knopf ─────────────────────────────────────────── */
.fab {
  position: fixed;
  right: 1.1rem;
  bottom: calc(1.3rem + env(safe-area-inset-bottom));
  z-index: 30;
  width: 58px; height: 58px;
  border: none;
  border-radius: 19px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  transition: transform .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 25px; height: 25px; }

/* ── Buchungs-Vorschau im Aktionsblatt ───────────────────────────────────── */
.tx-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .95rem 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.tx-preview .who { font-weight: 500; }
.tx-preview .when { color: var(--muted); font-size: .84rem; margin-top: .1rem; }
.tx-preview .amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.tx-preview .amount.is-income { color: var(--income); }

/* ── Farbwahl ────────────────────────────────────────────────────────────── */
.color-pick { display: flex; align-items: center; gap: .5rem; }
input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
}
.btn.sm { min-height: 40px; font-size: .88rem; padding: .5rem .9rem; width: auto; }

/* ── Archiv-Zeile mit Loeschknopf ────────────────────────────────────────── */
.archive-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .8rem;
  border-top: 1px solid var(--border);
}
.archive-row:first-child { border-top: none; }
.archive-row a {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  color: inherit;
  text-decoration: none;
}
.archive-row .when { font-weight: 500; }
.archive-row .sum { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .92rem; }
.archive-row .del {
  flex: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--danger);
  border-radius: 8px;
  font: 500 .8rem/1 var(--font-body, inherit);
  padding: .45rem .6rem;
  cursor: pointer;
  min-height: 36px;
}

/* Topf-Limits im Einstellungsblatt */
.pot-limit-row { display: flex; align-items: center; justify-content: space-between;
                 gap: 1rem; padding: .8rem 1rem; min-height: 56px; border-top: 1px solid var(--border); }
.pot-limit-row .label { font-size: .97rem; }

.sheet-hint {
  margin: -.2rem .15rem .6rem;
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ═══ Bedienung wie eine App, nicht wie eine Webseite ═══════════════════════ */

/* Kein versehentliches Markieren beim Tippen und Wischen. Eingabefelder und
   die Diagnose-Texte bleiben ausgenommen - dort will man kopieren koennen. */
html, body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  /* Kein Doppeltipp-Zoom und keine 300ms-Verzoegerung beim Antippen */
  touch-action: manipulation;
}
/* Bilder nicht ziehbar - sonst haengt beim Wischen ein Logo am Finger.
   Klickbar bleiben sie, damit ein Logo in einer antippbaren Zeile nicht stoert. */
img { -webkit-user-drag: none; user-drag: none; }
input, textarea, .selectable, .selectable * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* ── Diagnose: was kam zuletzt an? ───────────────────────────────────────── */
.raw-list { display: flex; flex-direction: column; gap: 1px; }
.raw-item {
  background: var(--surface);
  padding: .7rem .85rem;
  border-top: 1px solid var(--border);
}
.raw-item:first-child { border-top: none; }
.raw-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .35rem;
  font-size: .78rem;
  color: var(--muted);
}
.raw-status {
  font-size: .7rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .1rem .35rem;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.raw-status.ok { color: var(--income); border-color: var(--income); }
.raw-status.skip { color: var(--warn); border-color: var(--warn); }
.raw-text {
  font-family: ui-monospace, Menlo, monospace;
  font-size: .78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 8px;
  padding: .5rem .6rem;
}
.raw-text em { font-style: normal; color: var(--danger); }

/* Fassungs-Kennung ganz unten im Einstellungsblatt - damit auf einen Blick
   klar ist, welche Fassung der Browser gerade wirklich anzeigt. */
.version {
  margin: 1.2rem 0 0;
  text-align: center;
  font-size: .74rem;
  font-family: ui-monospace, Menlo, monospace;
  color: var(--muted);
  opacity: .7;
}

/* ── Suchfeld ueber der Liste ──────────────────────────────────────────────── */
.search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: .7rem;
}
.search svg {
  position: absolute;
  left: .8rem;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: .62rem .8rem .62rem 2.3rem;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search input:focus { border-color: var(--accent); }
/* Das eingebaute Kreuzchen von Chrome und Safari passt nicht zum Rest. */
.search input::-webkit-search-cancel-button { display: none; }
.search button {
  position: absolute;
  right: .35rem;
  width: 30px;
  height: 30px;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.search button:hover { color: var(--text); background: var(--surface-2); }

/* ── Beschreibung an einer Buchung ─────────────────────────────────────────── */
.tx-note {
  margin-top: .18rem;
  font-size: .82rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Aufteilung auf mehrere Toepfe ─────────────────────────────────────────── */
.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.split-head h2 { margin-bottom: 0; }

/* Der Rest ist die wichtigste Zahl dieser Ansicht: Solange er nicht null ist,
   ergibt die Aufteilung nicht die Zahlung, die abgebucht wurde. */
.split-rest {
  margin-top: .6rem;
  padding: .55rem .9rem;
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
  border-radius: 10px;
}
/* Erst eine schlichte Flaeche als Rueckfall, dann die getoente Fassung fuer
   Browser, die color-mix koennen. Ohne den Rueckfall waere der Hintergrund
   in aelteren Fassungen von Samsung Internet schlicht durchsichtig. */
.split-rest.is-ok  { color: var(--income); background: var(--surface-2); }
.split-rest.is-off { color: var(--danger); background: var(--surface-2); }
@supports (background: color-mix(in srgb, red 10%, transparent)) {
  .split-rest.is-ok  { background: color-mix(in srgb, var(--income) 12%, transparent); }
  .split-rest.is-off { background: color-mix(in srgb, var(--danger) 12%, transparent); }
}

#tx-split-rows input,
#tx-edit-area input {
  width: 8.5rem;
  padding: .42rem .55rem;
  font: inherit;
  font-size: .95rem;
  text-align: right;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  outline: none;
}
#tx-edit-area input[type="text"] { width: 11rem; text-align: left; }
#tx-edit-area input[type="datetime-local"] { width: 12.5rem; text-align: left; }
#tx-split-rows input:focus,
#tx-edit-area input:focus { border-color: var(--accent); }

/* ── Positionen eines Einkaufs ─────────────────────────────────────────────── */
/* Eine Position ist eine Zeile des Kassenbons: Name, Betrag, Topf, Pfand.
   Auf dem Handy braucht das zwei Reihen - alles nebeneinander waere zu eng. */
.split-item {
  padding: .7rem .85rem;
  border-top: 1px solid var(--border);
}
.split-item:first-child { border-top: none; }
.split-line {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.split-line + .split-line { margin-top: .5rem; }

.split-item input,
.split-item select {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .42rem .55rem;
  outline: none;
  min-width: 0;
}
.split-item input:focus,
.split-item select:focus { border-color: var(--accent); }

.split-label  { flex: 1 1 auto; }
.split-amount { flex: 0 0 6.2rem; text-align: right; }
.split-pot    { flex: 1 1 auto; -webkit-appearance: none; appearance: none;
                background-image: none; }

.split-drop {
  flex: none;
  width: 32px;
  height: 32px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.split-drop:hover { color: var(--danger); background: var(--surface-2); }

.split-deposit {
  flex: none;
  padding: .42rem .75rem;
  font: inherit;
  font-size: .88rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}
.split-deposit[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

#tx-split-add { margin-top: .6rem; width: 100%; }

/* ── Topf-Filter über der Liste ────────────────────────────────────────────── */
.pot-filter {
  display: flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: .7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow-x: auto;
  scrollbar-width: none;
}
.pot-filter::-webkit-scrollbar { display: none; }
.pot-filter button {
  flex: 1 0 auto;
  padding: .42rem .8rem;
  font: inherit;
  font-size: .88rem;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
}
.pot-filter button[aria-selected="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Bei gefilterter Ansicht: "von 27,00 €" klein unter dem Anteil */
.tx-of {
  display: block;
  margin-top: .1rem;
  font-size: .72rem;
  font-weight: 400;
  color: var(--muted);
}

/* ── Riegel bei einer neuen Fassung ────────────────────────────────────────── */
/* Absichtlich nicht wegtippbar: eine alte Oberfläche mit einer neuen
   Schnittstelle ist genau die Mischung, die vorher weiße Seiten ergab. */
.update-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(4px);
}
.update-box {
  width: 100%;
  max-width: 22rem;
  padding: 1.6rem 1.4rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.update-box h2 { margin: 0 0 .6rem; font-size: 1.15rem; }
.update-box p { margin: 0 0 1.2rem; color: var(--muted); line-height: 1.55; font-size: .94rem; }
.update-box .btn { width: 100%; }
.update-version {
  margin: .9rem 0 0 !important;
  font-size: .74rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  opacity: .7;
}

/* ── Kassenbon: die Positionen eines Einkaufs ──────────────────────────────── */
/* Eine Zeile lesen können ist wichtiger, als sie bearbeiten zu können.
   Deshalb steht hier nur, was drinsteht — angetippt öffnet sich das
   Fenster mit Menge, Preis und Pfand. */
.bon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.bon-empty {
  margin: 0;
  padding: 1.1rem .9rem;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}
.bon-row {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
}
.bon-row:first-child { border-top: none; }
.bon-open {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  min-width: 0;
  padding: .7rem .3rem .7rem .9rem;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
}
.bon-open:hover { background: var(--surface-2); }
.bon-texts { display: block; min-width: 0; }
.bon-left { display: flex; align-items: baseline; gap: .35rem; min-width: 0; }
.bon-qty {
  flex: none;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
}
.bon-name {
  font-size: .97rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bon-meta {
  display: block;
  margin-top: .12rem;
  font-size: .78rem;
  color: var(--muted);
}
.bon-price { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.bon-drop {
  flex: none;
  width: 40px;
  font-size: 1.15rem;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
}
.bon-drop:hover { color: var(--danger); background: var(--surface-2); }

/* ── Produkt-Kacheln ───────────────────────────────────────────────────────── */
/* Drei nebeneinander, vier Reihen hoch, danach wird gescrollt.
   Weniger Reihen? --tiles-rows unten auf 3 stellen. */
.tiles {
  --tiles-rows: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-top: .8rem;
  max-height: calc(var(--tiles-rows) * (5.6rem + .5rem));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  aspect-ratio: 1;
  padding: .45rem;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  cursor: pointer;
  overflow: hidden;
}
.tile:active { transform: scale(.96); }
.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 9px;
}
/* Mit Bild steht kein Text mehr da — das Bild IST der Name. */
.tile-text {
  font-size: .82rem;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.tile-price {
  position: absolute;
  right: .3rem;
  bottom: .25rem;
  padding: .05rem .3rem;
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface);
  border-radius: 6px;
}
#pick-search {
  width: 100%;
  padding: .62rem .8rem;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#pick-search:focus { border-color: var(--accent); }
#pick-search::-webkit-search-cancel-button { display: none; }

/* ── Ein Blatt über dem anderen ────────────────────────────────────────────── */
#sheet-pick, #sheet-item { z-index: 60; }

/* ── Mengen-Schalter ───────────────────────────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: .3rem; }
.stepper button {
  width: 38px;
  height: 38px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.stepper button:active { background: var(--accent-soft); }
.stepper input {
  width: 3.4rem;
  padding: .42rem .3rem;
  font: inherit;
  font-size: .98rem;
  text-align: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

#sheet-item input[type="text"],
#sheet-item input[type="number"],
#sheet-item select {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .42rem .55rem;
  outline: none;
}
#sheet-item input[type="number"] { width: 6.5rem; text-align: right; }
#sheet-item input[type="text"] { width: 11rem; }
#sheet-item select { max-width: 11rem; }
#sheet-item input:focus, #sheet-item select:focus { border-color: var(--accent); }
.stepper input[type="number"] { width: 3.4rem !important; }

.item-total {
  margin-top: .8rem;
  padding: .6rem .9rem;
  font-size: .98rem;
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 10px;
}

/* ═══ Blätter: ein gemeinsames Raster ═══════════════════════════════════════ */
/* Vorher hatte jede Knopfgruppe ihre eigenen Abstände als style="" im HTML —
   1rem hier, 1,4rem dort, 1,6rem woanders. Das sah unruhig aus und war der
   Grund für "achte auf die Abstände zwischen buttons". Jetzt eine Klasse. */
.sheet-actions {
  display: grid;
  gap: .55rem;
  margin-top: 1.4rem;
}
.sheet-actions.is-last { margin-top: 1.7rem; }
.sheet-actions .btn { min-height: 50px; }
/* Löschen steht abgesetzt: Abstand ist hier eine Sicherheitsmaßnahme. */
.sheet-actions .btn.danger { margin-top: .5rem; }

/* Überschriften im Blatt bekommen überall dieselbe Luft */
.sheet h2 {
  margin: 1.7rem 0 .65rem;
  font-size: .78rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.sheet h2:first-of-type { margin-top: .5rem; }
.sheet .sheet-hint { margin: -.2rem 0 .65rem; line-height: 1.5; }

/* Reihen, die nur einen Knopf enthalten */
.row.is-action { padding: .75rem 1rem; }
.row.is-action .btn { width: 100%; }
.row.is-action.two { gap: .55rem; }
.row.is-action.two .btn { flex: 1; }

/* Größere Ziele fürs Antippen */
.sheet .row { min-height: 58px; }
.sheet .switch { flex: none; }

/* ═══ Wer sieht wen ═════════════════════════════════════════════════════════ */
.who-row {
  padding: .8rem 1rem;
  border-top: 1px solid var(--border);
}
.who-row:first-child { border-top: none; }
.who-head { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.who-name { font-size: .97rem; font-weight: 500; }
.who-sub { font-size: .8rem; color: var(--muted); }
.who-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.who-chips button {
  padding: .38rem .75rem;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.who-chips button[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.who-chips button:disabled { opacity: .5; }

/* ═══ Pfand-Zeile unter dem Budget ══════════════════════════════════════════ */
.deposit-line {
  margin-top: .7rem;
  padding-top: .7rem;
  font-size: .84rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ═══ Kassenzettel unter einer Buchung ══════════════════════════════════════ */
.tx-more {
  flex: none;
  width: 30px;
  height: 30px;
  margin-left: .2rem;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .18s var(--ease);
}
.tx-more svg { width: 17px; height: 17px; }
.tx-more[aria-expanded="true"] { transform: rotate(180deg); color: var(--accent); }
.list li.is-open { flex-wrap: wrap; }

.receipt {
  flex: 1 0 100%;
  margin: .7rem 0 0;
  padding: .55rem 0 0;
  list-style: none;
  border-top: 1px dashed var(--border);
}
.receipt li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: .5rem;
  padding: .3rem 0;
  font-size: .85rem;
}
.receipt-left { min-width: 0; }
.receipt-qty { margin-right: .3rem; font-weight: 600; color: var(--accent); }
.receipt-deposit { margin-left: .4rem; font-size: .76rem; color: var(--muted); }
.receipt-pot {
  padding: .1rem .4rem;
  font-size: .7rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 5px;
  white-space: nowrap;
}
.receipt-price { font-variant-numeric: tabular-nums; }

/* ── Knöpfe unter dem Kassenbon ────────────────────────────────────────────── */
.bon-buttons {
  display: flex;
  gap: .5rem;
  margin-top: .6rem;
}
.bon-buttons .btn { flex: 1; }
#tx-split-add { margin-top: 0; width: auto; }

/* Das Vorlagen-Blatt nutzt dieselben Zeilen wie der Kassenbon */
#tpl-list .bon-row:first-child { border-top: none; }
#tpl-list { overflow: hidden; }
#tpl-name { width: 11rem; padding: .42rem .55rem; font: inherit; font-size: .95rem;
            color: var(--text); background: var(--surface-2);
            border: 1px solid var(--border); border-radius: 9px; outline: none; }
#tpl-name:focus { border-color: var(--accent); }
