/* myBudgetBook – Stylesheet */
:root {
  --bg: #f4f5fa;
  --bg-elev: #ffffff;
  --bg-soft: #eef0f7;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: #eef2ff;
  --on-primary: #ffffff;
  --income: #16a34a;
  --income-soft: #dcfce7;
  --expense: #dc2626;
  --expense-soft: #fee2e2;
  --transfer: #0284c7;
  --transfer-soft: #e0f2fe;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 8px 24px -12px rgba(17, 24, 39, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1117;
  --bg-elev: #181b25;
  --bg-soft: #20242f;
  --text: #f3f4f6;
  --text-2: #d1d5db;
  --muted: #9ca3af;
  --border: #2a2f3d;
  --primary: #818cf8;
  --primary-2: #6366f1;
  --primary-soft: #262a48;
  --on-primary: #0f1117;
  --income: #4ade80;
  --income-soft: #14532d;
  --expense: #f87171;
  --expense-soft: #5c1a1a;
  --transfer: #38bdf8;
  --transfer-soft: #0c3550;
  --warn: #fbbf24;
  --warn-soft: #4a3410;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --bg-elev: #181b25;
    --bg-soft: #20242f;
    --text: #f3f4f6;
    --text-2: #d1d5db;
    --muted: #9ca3af;
    --border: #2a2f3d;
    --primary: #818cf8;
    --primary-2: #6366f1;
    --primary-soft: #262a48;
    --on-primary: #0f1117;
    --income: #4ade80;
    --income-soft: #14532d;
    --expense: #f87171;
    --expense-soft: #5c1a1a;
    --transfer: #38bdf8;
    --transfer-soft: #0c3550;
    --warn: #fbbf24;
    --warn-soft: #4a3410;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.noscript { padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.trf { color: var(--transfer); }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Splash ---------- */
.splash { position: fixed; inset: 0; padding-top: env(safe-area-inset-top, 0px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bg); z-index: 200; }
.splash-logo { font-size: 48px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px)); background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-logo { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.auth h1 { font-size: 24px; margin-bottom: 4px; }
.auth .lead { color: var(--muted); margin: 0 0 22px; }
.code-input { font-family: var(--mono); font-size: 32px; letter-spacing: .5em; text-align: center; padding: 14px 8px 14px 20px !important; }
.remember {
  display: flex; align-items: center; gap: 14px; margin: 18px 0 8px; padding: 14px 16px;
  border: 2px solid var(--primary); border-radius: 14px; background: var(--primary-soft); cursor: pointer; user-select: none;
}
.remember strong { display: block; font-size: 15px; }
.remember .small { display: block; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #9ca3af; border-radius: 30px; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(22px); }
.e2e-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--income-soft); color: var(--income); font-size: 12px; font-weight: 700; letter-spacing: .01em; margin-bottom: 14px; cursor: pointer; border: 1px solid transparent; transition: border-color .15s, transform .05s; white-space: nowrap; max-width: 100%; overflow: hidden; }
.e2e-badge:hover { border-color: var(--income); }
.e2e-badge::after { content: "i"; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; font: 700 12px/1 var(--font); margin-left: 2px; flex: none; }
.sidebar-footer .e2e-badge { margin: 0 0 4px; align-self: flex-start; font-size: 11px; padding: 4px 9px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 14px; }
.auth-links button { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 4px 0; }
.auth-links button:disabled { color: var(--muted); cursor: default; }
.auth .hint-box { margin-top: 18px; padding: 12px 14px; background: var(--bg-soft); border-radius: 12px; font-size: 13px; color: var(--text-2); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--bg-elev); border-right: 1px solid var(--border); padding: calc(20px + env(safe-area-inset-top, 0px)) 14px calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-icon { font-size: 24px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .bottomnav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--bg-soft); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-ico { width: 22px; text-align: center; font-size: 17px; opacity: .9; }
.sidebar-footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 14px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.user-chip .name { font-weight: 600; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; padding: calc(14px + env(safe-area-inset-top, 0px)) 28px 14px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.page-title { font-size: 22px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.view { padding: 8px 28px 100px; max-width: 1240px; width: 100%; }
.bottomnav { display: none; }

/* Monatswähler */
.monthpicker { display: inline-flex; align-items: center; gap: 2px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 2px; }
.monthpicker button { background: none; border: 0; padding: 6px 10px; border-radius: 9px; cursor: pointer; color: var(--text); }
.monthpicker button:hover { background: var(--bg-soft); }
.monthpicker .label { font-weight: 600; min-width: 130px; text-align: center; }
.monthpicker input[type="month"] { position: absolute; opacity: 0; width: 0; height: 0; }
.monthpicker.period { position: relative; }
.monthpicker button:disabled { opacity: .35; cursor: default; }
.period-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; width: 300px; max-width: calc(100vw - 24px); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); text-align: left; animation: pop .15s ease; }
.period-pop .seg button { padding: 7px 8px; }
.period-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.period-months .chip { justify-content: center; padding: 8px 4px; font-weight: 600; }
.period-months .chip.muted { opacity: .5; }
.period-year { font-size: 16px; }
.monthpicker.period .label { white-space: nowrap; }
@media (max-width: 860px) {
  .period-pop { position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top, 0px)); width: auto; max-width: none; }
  .period-months { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- Karten & Grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-23 { grid-template-columns: 2fr 1fr; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title h3 { font-size: 15px; font-weight: 700; }
.card-title .link { font-size: 13px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12px; color: var(--muted); }
.stat.income .value { color: var(--income); }
.platforms { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.platform { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); cursor: help; }
.platform.active { border-color: var(--income); color: var(--text); }
.platform-ico { font-size: 15px; }
.stat-info { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid currentColor; font: 700 10px/1 var(--font); opacity: .7; vertical-align: middle; margin-left: 2px; }
.stat[data-explain]:hover { border-color: var(--primary); }
.stat.expense .value { color: var(--expense); }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-item.clickable { cursor: pointer; border-radius: 10px; margin: 0 -4px; padding: 10px 8px; }
.row-item.clickable:hover { background: var(--bg-soft); }
.cat-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; background: var(--bg-soft); }
.cat-ico.sm { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
.row-item .title { font-weight: 600; }
.row-item .sub { font-size: 12px; color: var(--muted); }
.row-item .amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-group { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 18px 4px 6px; display: flex; justify-content: space-between; }
.date-group:first-child { padding-top: 4px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty .big { font-size: 36px; margin-bottom: 8px; }

/* Fortschrittsbalken */
.bar { height: 8px; background: var(--bg-soft); border-radius: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: var(--primary); transition: width .4s ease; }
.bar.warn > i { background: var(--warn); }
.bar.over > i { background: var(--expense); }
.budget-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.budget-row:last-child { border: 0; }
.budget-row .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
tbody tr:hover td { background: var(--bg-soft); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- Buttons & Forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid transparent; background: var(--primary); color: var(--on-primary); font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-lg { padding: 14px 20px; font-size: 16px; width: 100%; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-soft); filter: none; }
.btn-danger { background: var(--expense); color: #fff; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.icon-btn { background: transparent; border: 0; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="month"], input[type="search"], input[type="file"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[type="color"] { width: 48px; height: 42px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elev); cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.check input { width: 18px !important; height: 18px !important; min-height: 0 !important; min-width: 0 !important; padding: 0 !important; flex: none !important; accent-color: var(--primary); }
.amount-input { font-size: 26px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; padding: 12px 14px !important; }
.seg { display: inline-flex; background: var(--bg-soft); border-radius: 12px; padding: 3px; gap: 2px; width: 100%; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button.active[data-v="income"] { color: var(--income); }
.seg button.active[data-v="expense"] { color: var(--expense); }
.seg button.active[data-v="transfer"] { color: var(--transfer); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 10px; border-radius: 20px; background: var(--bg-soft); border: 1px solid transparent; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-soft); color: var(--text-2); }
.badge.income { background: var(--income-soft); color: var(--income); }
.badge.expense { background: var(--expense-soft); color: var(--expense); }
.badge.transfer { background: var(--transfer-soft); color: var(--transfer); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filterbar select, .filterbar input:not([type=checkbox]) { width: auto; min-width: 140px; min-height: 38px; padding: 6px 10px; }
.filterbar input[type="search"] { flex: 1; min-width: 160px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 14px 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; max-height: 160px; overflow: auto; padding: 4px; background: var(--bg-soft); border-radius: 10px; }
.emoji-grid button { border: 0; background: transparent; font-size: 20px; padding: 4px; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover, .emoji-grid button.active { background: var(--bg-elev); }
.color-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.color-grid button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-grid button.active { border-color: var(--text); }
.suggest { position: relative; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 180px; overflow: auto; }
.suggest-list div { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.suggest-list div:hover, .suggest-list div.active { background: var(--bg-soft); }

/* ---------- FAB ---------- */
.fab { position: fixed; right: 28px; bottom: 28px; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); font-size: 30px; line-height: 1; box-shadow: 0 8px 24px -6px rgba(79, 70, 229, .6); cursor: pointer; z-index: 45; display: flex; align-items: center; justify-content: center; }
.fab:hover { filter: brightness(1.08); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 23, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; animation: fade .15s ease; }
.modal { width: 100%; max-width: 520px; padding-bottom: env(safe-area-inset-bottom, 0px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; background: var(--bg-elev); border-radius: 20px; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 8px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 22px 18px; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 22px 20px; flex-wrap: wrap; }
.modal-foot .spacer { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 150; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 12px; background: #111827; color: #fff; font-size: 14px; box-shadow: var(--shadow); animation: fade .2s ease; max-width: 90vw; }
.toast.err { background: var(--expense); }
.toast.ok { background: var(--income); }

/* Chart-Container */
.chart-box { position: relative; height: 240px; }
/* Karten in der 2:1-Reihe: Diagramm füllt die Kartenhöhe, statt Leerraum zu lassen */
.grid-23 > .card { display: flex; flex-direction: column; }
.grid-23 > .card > .chart-box { flex: 1 1 auto; min-height: 240px; height: auto; }
.chart-box.tall { height: 300px; }
.chart-box.sm { height: 200px; }
.donut-wrap { display: flex; flex-direction: column; gap: 12px; }
.donut-wrap .chart-box { height: 190px; }
.donut-wrap > * { min-width: 0; }
.cat-list .row-item { padding: 8px 4px; gap: 10px; color: var(--text); }
.cat-list .row-item .title { font-size: 14px; font-weight: 600; }
.cat-list .row-item .amount { font-size: 14px; }

/* Konto-Karten */
.acct-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--bg-soft); }
.acct-card .ico { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; flex: none; }
.acct-card .bal { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.acct-card.archived { opacity: .55; }

/* Setting groups */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border: 0; }
.setting-row .desc { font-size: 13px; color: var(--muted); }
.setting-row select, .setting-row input { width: auto; min-width: 160px; }
.danger-zone { border-color: var(--expense); }
.more-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.more-grid a { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; color: var(--text); font-weight: 600; }
.more-grid .nav-ico { font-size: 22px; }
.import-preview td { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-soft); }
.dragging { opacity: .4; }
.handle { cursor: grab; color: var(--muted); padding: 0 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-23 { grid-template-columns: 1fr; }
  .grid-23 > .card > .chart-box { height: 240px; flex: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .sidebar-backdrop.open { display: block; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .page-title { font-size: 19px; }
  .view { padding: 4px 14px 120px; }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--bg-elev); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottomnav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; color: var(--muted); min-width: 56px; }
  .bottomnav a.active { color: var(--primary); }
  .bottomnav .nav-ico { font-size: 20px; width: auto; }
  .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 54px; height: 54px; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.keep { grid-template-columns: 1fr 1fr; }
  .card { padding: 14px 16px; }
  .stat .value { font-size: 20px; }
  .monthpicker .label { min-width: 96px; font-size: 14px; padding: 6px 4px; }
  .monthpicker button { padding: 6px 8px; }
}
@media (max-width: 480px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4.stats { grid-template-columns: 1fr 1fr; }
  .more-grid { grid-template-columns: 1fr 1fr; }
  .filterbar select, .filterbar input:not([type=checkbox]) { min-width: 0; flex: 1 1 45%; }
}
@media print {
  .sidebar, .bottomnav, .fab, .topbar-actions, .menu-btn { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Als installierte App: zusätzlicher Puffer für Statusleiste / Kamera-Aussparung */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(14px + max(env(safe-area-inset-top, 0px), 14px)); }
  .auth { padding-top: calc(24px + max(env(safe-area-inset-top, 0px), 24px)); }
  .sidebar { padding-top: calc(20px + max(env(safe-area-inset-top, 0px), 14px)); }
  .toasts { bottom: calc(24px + max(env(safe-area-inset-bottom, 0px), 8px)); }
}
@media (display-mode: standalone) and (max-width: 860px) {
  .topbar { padding-top: calc(10px + max(env(safe-area-inset-top, 0px), 18px)); }
  .bottomnav { padding-bottom: calc(6px + max(env(safe-area-inset-bottom, 0px), 10px)); }
  .fab { bottom: calc(76px + max(env(safe-area-inset-bottom, 0px), 10px)); }
}
