@font-face {
  font-family: 'Syne';
  src: url('fonts/syne-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Syne';
  src: url('fonts/syne-latin-800-normal.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Outfit';
  src: url('fonts/outfit-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Outfit';
  src: url('fonts/outfit-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Outfit';
  src: url('fonts/outfit-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #14161a;
  --surface: #1b1e24;
  --surface-raised: #21242b;
  --line: #2a2e36;
  --text: #f2f1ee;
  --text-muted: #9297a1;
  --text-faint: #5a5f68;

  /* MasterAds Markenfarben */
  --orange: #ee7500;
  --orange-ink: #201200;
  --blue: #35adda;
  --red: #d1594a;
  --green: #3ecf8e;

  --font-headline: 'Syne', var(--font-ui-fallback);
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  /* Kategorie-Farben: feste Zuordnung statt generischer Grautoene, damit
     Kategorien auf einen Blick unterscheidbar sind (analog TaktKraft-Pattern) */
  --cat-wohnen: #35adda;
  --cat-auto: #ee7500;
  --cat-essen: #3ecf8e;
  --cat-freizeit: #c792ea;
  --cat-business: #e0a94c;
  --cat-abos: #d1594a;
  --cat-sonstiges: #9297a1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: 3rem;
}

button { font-family: inherit; }

/* ---------- Ledger head / balance ---------- */

.ledger-head {
  padding: calc(env(safe-area-inset-top, 0px) + 1.25rem) 1.25rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}

.ledger-head__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.brand-mark {
  font-family: var(--font-headline);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--orange);
  margin-bottom: 0.5rem;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.eyebrow--due {
  color: var(--orange);
}

.bell {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  display: flex;
}

.bell:hover { color: var(--orange); }
.bell.is-active { color: var(--blue); }

.balance {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.balance__label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.balance__amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.balance__amount.is-negative {
  color: var(--red);
}

.balance-sub {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.balance-sub[hidden] { display: none; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.85rem 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--orange);
}

main {
  max-width: 640px;
  margin: 0 auto;
}

.panel-block {
  padding: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.panel-block h2 {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
}

.panel-block h2 .sum {
  font-family: var(--font-mono);
  color: var(--red);
  text-transform: none;
  letter-spacing: 0;
}

/* ---------- Notify banner ---------- */

.notify-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(238,117,0,0.14), rgba(53,173,218,0.10));
  border: 1px solid rgba(238,117,0,0.35);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.notify-banner strong { font-size: 0.92rem; }
.notify-banner p { margin: 0.2rem 0 0; font-size: 0.8rem; color: var(--text-muted); }

.notify-banner button {
  background: var(--orange);
  color: var(--orange-ink);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Lists ---------- */

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

.list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

.list li:last-child { border-bottom: none; }

.check {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  border: 1.5px solid var(--text-faint);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  position: relative;
}

.check.is-done {
  background: var(--blue);
  border-color: var(--blue);
}

.check.is-done::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.item-main { flex: 1; min-width: 0; }
.item-text { font-size: 0.95rem; color: var(--text); }
.item-text.is-done { color: var(--text-faint); text-decoration: line-through; }

.item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  font-family: var(--font-mono);
}

.item-meta.is-overdue { color: var(--red); }

.item-delete {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.item-delete:hover { color: var(--red); }

.list--tx .item-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  white-space: nowrap;
}

.list--tx .item-amount.is-positive { color: var(--blue); }
.list--tx .item-amount.is-negative { color: var(--red); }

.book-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}

.book-btn:hover { color: var(--orange); border-color: var(--orange); }

.empty {
  color: var(--text-faint);
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

/* ---------- Forms ---------- */

.quick-add {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.quick-add input[type="text"] { flex: 1; }
.quick-add input[type="date"] { width: 130px; }

.inline-form { display: flex; gap: 0.5rem; }

.tx-form { display: flex; flex-direction: column; gap: 0.6rem; }
.tx-form__row { display: flex; gap: 0.6rem; }
.tx-form__row input[type="number"] { flex: 1; }

.quick-add-v2 {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.quick-add-v2__submit {
  align-self: flex-start;
  background: var(--orange);
  color: var(--orange-ink);
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font-size: 0.92rem;
  font-family: inherit;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
}

button[type="submit"] {
  background: var(--orange);
  color: var(--orange-ink);
  border: none;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

button[type="submit"]:hover { filter: brightness(1.08); }
.quick-add button[type="submit"] { padding: 0 1rem; }

/* ---------- Toast ---------- */

/* .toast Basis-Styles siehe unten (konsolidierte, aktuelle Fassung) */

@media (max-width: 420px) {
  .balance__amount { font-size: 1.9rem; }
}

/* ---------- Segmented controls & date chips (v2 UX) ---------- */

.segmented {
  display: flex;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.segmented__btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}

.segmented__btn.is-active {
  background: var(--orange);
  color: var(--orange-ink);
}

.segmented--secondary .segmented__btn.is-active {
  background: var(--blue);
  color: #0c2530;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.chip {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.chip.is-active {
  background: rgba(238,117,0,0.16);
  border-color: var(--orange);
  color: var(--orange);
}

.chip-date-input {
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

.link-icon {
  text-decoration: none;
  font-size: 0.8rem;
  opacity: 0.75;
}
.link-icon:hover { opacity: 1; }

/* ---------- v3: Sparkline, Monatsstats, Konten, Verwaltung ---------- */

.sparkline {
  width: 100%;
  height: 32px;
  margin-top: 0.6rem;
  display: block;
}

.month-stats {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.month-stats__in { color: var(--blue); }
.month-stats__out { color: var(--red); }
.month-stats__label { color: var(--text-faint); font-family: var(--font-ui); }

#account-chips:not(:empty) { margin-bottom: 0.8rem; }

.hint {
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.filter-row input[type="text"] { flex: 1; }

.export-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.export-btn {
  display: inline-block;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.export-btn:hover { border-color: var(--orange); color: var(--orange); }

.token-value-box {
  background: var(--surface-raised);
  border: 1px solid var(--orange);
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.token-value-box code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--orange);
  word-break: break-all;
  margin: 0.4rem 0;
  user-select: all;
}

.item-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  padding: 0.3rem 0;
}

.item-edit-form input, .item-edit-form select {
  width: 100%;
}

.item-edit-actions {
  display: flex;
  gap: 0.5rem;
}

.item-edit-actions button {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text-muted);
}

.item-edit-actions button.save {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--orange-ink);
}

.item-text-clickable { cursor: pointer; }
.item-text-clickable:hover { text-decoration: underline dotted; }

.item-category {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--text-faint);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* Feste Kategorie-Farben statt generischem Grau - auf einen Blick unterscheidbar */
.item-category[data-cat="wohnen"] { color: var(--cat-wohnen); border-color: var(--cat-wohnen); }
.item-category[data-cat="auto"] { color: var(--cat-auto); border-color: var(--cat-auto); }
.item-category[data-cat="essen"] { color: var(--cat-essen); border-color: var(--cat-essen); }
.item-category[data-cat="freizeit"] { color: var(--cat-freizeit); border-color: var(--cat-freizeit); }
.item-category[data-cat="business"] { color: var(--cat-business); border-color: var(--cat-business); }
.item-category[data-cat="abos"] { color: var(--cat-abos); border-color: var(--cat-abos); }
.item-category[data-cat="sonstiges"] { color: var(--cat-sonstiges); border-color: var(--cat-sonstiges); }

.recur-badge {
  display: inline-block;
  font-size: 0.68rem;
  color: var(--blue);
  margin-left: 0.4rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.25rem);
  transform: translateX(-50%);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 90vw;
}

.toast.is-error { border-color: var(--red); color: var(--red); }
.toast[hidden] { display: none; }

#toast-undo {
  background: none;
  border: none;
  color: var(--orange);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  white-space: nowrap;
}

/* ---------- Auth-Screen (Supabase Login/MFA) ---------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-screen[hidden] { display: none; }

.auth-box {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.auth-box .brand-mark {
  font-size: 1.1rem;
  margin-bottom: 0;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.auth-form[hidden] { display: none; }

.auth-form input {
  width: 100%;
  text-align: center;
  font-size: 1rem;
  padding: 0.7rem;
}

.auth-form button[type="submit"] {
  padding: 0.7rem;
  font-size: 0.95rem;
}

.auth-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.auth-error {
  color: var(--red);
  font-size: 0.82rem;
  text-align: center;
  margin: 0;
}

.auth-secondary-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
}

.auth-secondary-btn:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- Sicherheit (Verwaltung) ---------- */

.mfa-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.mfa-qr-box img {
  background: #fff;
  padding: 8px;
  border-radius: 6px;
  width: 180px;
  height: 180px;
}
