/* ===== Open-WebUI-Dark-Theme (Basis aus webmail/remote übernommen) ===== */
:root {
  --bg: #171717;
  --bg-side: #0d0d0d;
  --bg-elev: #212121;
  --bg-input: #262626;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #ececec;
  --text-2: #b4b4b4;
  --text-3: #8e8e8e;
  --text-4: #676767;
  --accent: #3b82f6;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --pos: #4ade80;
  --neg: #fb923c;
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; -webkit-font-smoothing: antialiased; }
html { font-size: 14.7px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #93c5fd; }
h1, h2, h3 { font-weight: 500; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* ===== Basis-Elemente ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: none; cursor: pointer; border-radius: 9999px;
  padding: .5rem 1rem; font-weight: 500; font-size: .875rem; background: var(--bg-input); color: var(--text); transition: background .15s, opacity .15s;
  white-space: nowrap; flex-shrink: 0; text-decoration: none; }
.btn:hover { background: #303030; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: #fff; color: #000; }
.btn-primary:hover { background: #e5e5e5; }
.btn-accent { background: rgba(74,222,128,.14); color: #86efac; }
.btn-accent:hover { background: rgba(74,222,128,.22); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn svg { width: 1.05rem; height: 1.05rem; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: .6rem; border: none; cursor: pointer;
  background: transparent; color: var(--text-2); transition: background .15s, color .15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn svg, .nav-item svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.icon-btn.sm { width: 1.6rem; height: 1.6rem; }
.icon-btn.sm svg { width: .95rem; height: .95rem; }

.input, .select, .textarea { width: 100%; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius); padding: .55rem .85rem; outline: none; transition: border-color .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--border-strong); }
.input.invalid { border-color: rgba(239,68,68,.6); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
select { color-scheme: dark; }
select option { background-color: var(--bg-elev); color: var(--text); }
.textarea { resize: vertical; min-height: 4rem; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%23999'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem; padding-right: 2.2rem; }
input[type="date"] { color-scheme: dark; }

label.field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--text-3); }
label.field > span { padding-left: .2rem; }
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 7rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: #fff; width: 1rem; height: 1rem; }
.seg { display: inline-flex; background: var(--bg-input); border-radius: 9999px; padding: .15rem; gap: .1rem; flex-wrap: wrap; }
.seg button { border: none; background: transparent; color: var(--text-3); padding: .3rem .8rem; border-radius: 9999px; cursor: pointer; font-size: .8rem; }
.seg button.on { background: #fff; color: #000; }

.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.error-box { background: rgba(239,68,68,.12); color: #fca5a5; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }
.info-box { background: rgba(59,130,246,.12); color: #bfdbfe; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.mixed { color: #fde68a; }

/* ===== App-Logo: weißes Quadrat, schwarzes Symbol ===== */
.logo { display: inline-flex; align-items: center; justify-content: center; background: #fff; color: #000; flex-shrink: 0; }
.logo .logo-icon { width: 70%; height: 70%; }

/* ===== Login ===== */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-logo { display: flex; align-items: center; gap: .6rem; justify-content: center; font-size: 1.6rem; font-weight: 600; margin-bottom: .5rem; }
.auth-logo .logo { width: 44px; height: 44px; border-radius: 14px; }
.auth-card .input { padding: .75rem 1rem; }
.auth-card .btn { padding: .75rem; }
.auth-switch { text-align: center; font-size: .85rem; color: var(--text-3); }
.auth-switch button { background: none; border: none; color: var(--text); cursor: pointer; text-decoration: underline; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { width: 260px; flex-shrink: 0; background: var(--bg-side); display: flex; flex-direction: column; transition: margin-left .2s ease; border-right: 1px solid rgba(255,255,255,0.03); z-index: 40; }
.sidebar.collapsed { margin-left: -260px; }
.sidebar-top { padding: .6rem .6rem .25rem; display: flex; flex-direction: column; gap: .15rem; position: relative; }
.brand { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem .6rem; font-weight: 600; font-size: 1rem; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; }
.sidebar-search { display: flex; align-items: center; gap: .45rem; margin: .2rem 0 .1rem; padding: .3rem .6rem; background: transparent; border-radius: .6rem; }
.sidebar-search:focus-within { background: var(--bg-input); }
.sidebar-search svg { width: .95rem; height: .95rem; color: var(--text-3); flex-shrink: 0; }
.sidebar-search input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; font-size: .85rem; padding: .15rem 0; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: .25rem .6rem 1rem; }
.sidebar-section { margin-top: .9rem; }
.sidebar-label { font-size: .72rem; font-weight: 500; color: var(--text-4); padding: .2rem .55rem .35rem; display: flex; align-items: center; gap: .3rem; }
.sidebar-label .icon-btn { width: 1.4rem; height: 1.4rem; margin-left: auto; }
.sidebar-label .icon-btn svg { width: .9rem; height: .9rem; }
.sidebar-backdrop { display: none; }

.nav-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .55rem; border-radius: .6rem; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; text-align: left; font-size: .875rem; transition: background .12s, color .12s; position: relative; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-amount { font-size: .72rem; white-space: nowrap; }
.nav-item .emoji { width: 1.1rem; text-align: center; font-size: .95rem; flex-shrink: 0; }
.nav-item .avatar { width: 1.35rem; height: 1.35rem; font-size: .6rem; }
.nav-empty { font-size: .78rem; color: var(--text-4); padding: .3rem .55rem; }

.new-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .6rem; border-radius: .6rem; border: none; background: transparent; color: var(--text); cursor: pointer; font-weight: 500; }
.new-btn:hover { background: var(--bg-hover); }
.new-btn .plus { width: 1.6rem; height: 1.6rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; }
.new-btn .plus svg { width: 1rem; height: 1rem; }

.sidebar-bottom { padding: .5rem .6rem .7rem; position: relative; }
.user-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem; border-radius: .7rem; border: none; background: transparent; cursor: pointer; color: var(--text); text-align: left; }
.user-btn:hover { background: var(--bg-hover); }
.avatar { width: 2rem; height: 2rem; border-radius: 9999px; background: linear-gradient(135deg, #6366f1, #ec4899); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .78rem; color: #fff; flex-shrink: 0; text-transform: uppercase; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 3rem; height: 3rem; font-size: 1.05rem; }
.avatar.sm { width: 1.6rem; height: 1.6rem; font-size: .62rem; }

.menu { position: absolute; z-index: 60; min-width: 13rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: .55rem; border: none; background: none; cursor: pointer; text-align: left; color: var(--text); font-size: .85rem; }
.menu button:hover { background: var(--bg-hover); }
.menu button svg { width: 1rem; height: 1rem; color: var(--text-3); }
.menu .danger, .menu .danger svg { color: #fca5a5; }
.menu .menu-sep { height: 1px; background: var(--border); margin: .25rem .3rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); position: relative; }
.topbar { height: 3.25rem; display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; flex-shrink: 0; position: relative; }
.topbar h1 { font-size: 1.05rem; font-weight: 500; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.page { flex: 1; overflow-y: auto; padding: 1rem 1.5rem 6rem; }
.page-inner { max-width: 52rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: var(--text-4); padding: 2.5rem 1rem; text-align: center; }
.empty svg { width: 2.6rem; height: 2.6rem; opacity: .5; }
.section-title { font-size: .8rem; color: var(--text-3); font-weight: 500; margin: 0 0 -.5rem .2rem; display: flex; align-items: center; gap: .5rem; }

/* ===== Startseite (wie OpenWebUI-Begrüßung) ===== */
.hero { display: flex; flex-direction: column; align-items: center; gap: .6rem; padding: 2rem 1rem .5rem; text-align: center; }
.hero .logo { width: 56px; height: 56px; border-radius: 18px; }
.hero h2 { font-size: 1.8rem; margin: 0; font-weight: 500; }
.hero p { margin: 0; color: var(--text-3); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.stat .stat-label { font-size: .75rem; color: var(--text-3); }
.stat .stat-value { font-size: 1.15rem; font-weight: 600; word-break: break-word; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ===== Listen ===== */
.list { display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); min-width: 0; }
.list-row:last-child { border-bottom: none; }
.list-row.click { cursor: pointer; transition: background .12s; }
.list-row.click:hover { background: var(--bg-hover); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: .75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .amount { text-align: right; flex-shrink: 0; }
.list-row .amount .lbl { font-size: .7rem; }
.list-row .amount .val { font-size: .9rem; font-weight: 500; }
.list-empty { padding: .9rem; font-size: .85rem; color: var(--text-4); text-align: center; }

/* Ausgabenliste wie in Splitwise: Datum | Kategorie-Icon | Text | mein Saldo */
.month { font-size: .75rem; color: var(--text-3); font-weight: 500; padding: .65rem .2rem .35rem; text-transform: capitalize; }
.exp-date { width: 2.4rem; text-align: center; flex-shrink: 0; line-height: 1.1; }
.exp-date .m { font-size: .65rem; color: var(--text-4); text-transform: uppercase; }
.exp-date .d { font-size: 1.05rem; color: var(--text-2); }
.cat-icon { width: 2.3rem; height: 2.3rem; border-radius: .7rem; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0; }
.cat-icon.lg { width: 3.2rem; height: 3.2rem; font-size: 1.6rem; border-radius: 1rem; }
.cat-icon.payment { background: rgba(74,222,128,.12); color: var(--pos); }
.cat-icon.payment svg { width: 1.15rem; height: 1.15rem; }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; padding: .05rem .45rem; border-radius: 9999px; background: var(--bg-input); color: var(--text-2); white-space: nowrap; }
.badge svg { width: .75rem; height: .75rem; }

/* ===== Kopf von Gruppe/Freund ===== */
.head-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.head-card .head-icon { width: 3rem; height: 3rem; border-radius: 1rem; background: var(--bg-input); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 1.5rem; }
.head-card h2 { margin: 0; font-size: 1.3rem; }
.head-card .grow { flex: 1; min-width: 0; }
.head-card .meta { font-size: .82rem; margin-top: .2rem; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: none; background: none; color: var(--text-3); padding: .45rem .8rem; cursor: pointer; border-bottom: 2px solid transparent; font-size: .85rem; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: #fff; }

.debt-row .arrow { color: var(--text-4); }
.debt-row .arrow svg { width: .9rem; height: .9rem; }

.bar { height: .5rem; background: var(--bg-input); border-radius: 9999px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 9999px; }

/* ===== FAB (mobil) / Aktionsleiste ===== */
.fab-bar { position: absolute; left: 0; right: 0; bottom: 1.1rem; display: flex; justify-content: center; gap: .5rem; pointer-events: none; z-index: 20; }
.fab-bar .btn { pointer-events: auto; box-shadow: var(--shadow); padding: .65rem 1.2rem; }

/* ===== Detail-Drawer ===== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 70; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(30rem, 100%); background: var(--bg-elev); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 75; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: .3rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; font-size: .95rem; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 1rem; }
.detail-top { display: flex; gap: .9rem; align-items: center; }
.detail-top h2 { margin: 0; font-size: 1.2rem; word-break: break-word; }
.detail-top .big { font-size: 1.5rem; font-weight: 600; margin-top: .1rem; }
.split-lines { display: flex; flex-direction: column; gap: .45rem; }
.split-line { display: flex; align-items: center; gap: .6rem; font-size: .86rem; }
.split-line .grow { flex: 1; min-width: 0; }
.notes { background: var(--bg-input); padding: .6rem .8rem; border-radius: var(--radius); font-size: .85rem; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.comments { display: flex; flex-direction: column; gap: .6rem; }
.comment { display: flex; gap: .55rem; align-items: flex-start; }
.comment .bubble { background: var(--bg-input); border-radius: .9rem; padding: .45rem .75rem; font-size: .85rem; flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.comment .bubble .who { font-size: .72rem; color: var(--text-3); margin-bottom: .1rem; display: flex; gap: .4rem; align-items: center; }
.comment.system { font-size: .78rem; color: var(--text-4); padding-left: .3rem; }
.comment-box { display: flex; gap: .4rem; padding: .7rem .75rem; border-top: 1px solid var(--border); align-items: flex-end; }
.comment-box .textarea { min-height: 2.5rem; max-height: 8rem; resize: none; padding: .5rem .8rem; border-radius: 1.2rem; }

/* ===== Modals ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 32rem; max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 38rem; }
.modal-head { display: flex; align-items: center; padding: 1rem 1.25rem .5rem; }
.modal-head h2 { margin: 0; font-size: 1.1rem; font-weight: 500; flex: 1; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .75rem 1.25rem 1.1rem; align-items: center; }

/* Ausgabe-Editor */
.exp-main { display: flex; gap: .75rem; align-items: center; }
.cat-btn { border: none; cursor: pointer; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.8rem, 1fr)); gap: .35rem; background: var(--bg-input); border-radius: var(--radius); padding: .5rem; max-height: 14rem; overflow-y: auto; }
.cat-grid button { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem .3rem; border: 1px solid transparent; border-radius: .6rem; background: transparent; cursor: pointer; font-size: .7rem; color: var(--text-2); }
.cat-grid button:hover { background: var(--bg-hover); }
.cat-grid button.on { border-color: var(--border-strong); background: var(--bg-active); color: var(--text); }
.cat-grid button .e { font-size: 1.2rem; }
.amount-input { display: flex; gap: .5rem; }
.amount-input .select { flex: 0 0 6.2rem; }
.amount-input .input { font-size: 1.25rem; font-weight: 600; }
.sentence { font-size: .88rem; color: var(--text-2); background: var(--bg-input); border-radius: var(--radius); padding: .6rem .85rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.sentence .pill { background: #fff; color: #000; border-radius: 9999px; padding: .1rem .6rem; font-weight: 500; font-size: .82rem; border: none; cursor: pointer; }
.people { display: flex; flex-direction: column; gap: .15rem; }
.person { display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem; border-radius: .6rem; }
.person:hover { background: var(--bg-hover); }
.person .grow { flex: 1; min-width: 0; font-size: .87rem; }
.person .val-input { width: 7rem; text-align: right; padding: .35rem .6rem; }
.person .owed { width: 6rem; text-align: right; font-size: .8rem; color: var(--text-3); }
.person.off .grow { color: var(--text-4); }
.remaining { font-size: .78rem; text-align: right; color: var(--neg); }
.remaining.ok { color: var(--pos); }
.sub-box { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; display: flex; flex-direction: column; gap: .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--bg-input); border: 1px solid transparent; border-radius: 9999px; padding: .2rem .65rem .2rem .25rem; cursor: pointer; font-size: .82rem; color: var(--text-2); }
.chip.on { border-color: rgba(255,255,255,.5); color: var(--text); background: var(--bg-active); }
.chip .avatar { width: 1.35rem; height: 1.35rem; font-size: .55rem; }
.pay-flow { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: .5rem 0; }
.pay-flow .party { display: flex; flex-direction: column; align-items: center; gap: .4rem; flex: 1; min-width: 0; }
.pay-flow .party .select { text-align: center; }
.pay-flow .arrow-btn svg { width: 1.3rem; height: 1.3rem; }

/* ===== Statistik ===== */
.stats-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.stats-nav { display: flex; align-items: center; gap: .2rem; }
.stats-nav .icon-btn svg { width: 1rem; height: 1rem; }
.stats-title { font-weight: 500; min-width: 8.5rem; text-align: center; }
.chart-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem .9rem .6rem; display: flex; flex-direction: column; gap: .5rem; }
.chart { display: flex; gap: .5rem; height: 13rem; }
.chart-axis { display: flex; flex-direction: column; justify-content: space-between; font-size: .66rem; color: var(--text-4); text-align: right; padding-bottom: 1.3rem; min-width: 3.6rem; }
.chart-bars { flex: 1; display: flex; align-items: stretch; gap: 3px; position: relative; min-width: 0; }
.chart-grid { position: absolute; inset: 0 0 1.3rem 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-grid span { border-top: 1px dashed rgba(255,255,255,.07); }
.chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; border: none; background: transparent; padding: 0; cursor: pointer; position: relative; z-index: 1; color: inherit; }
.chart-col.empty { cursor: default; }
.chart-bar { display: block; background: linear-gradient(180deg, #60a5fa, #3b82f6); border-radius: 4px 4px 1px 1px; margin-bottom: 1.3rem; transition: height .25s ease, filter .15s; min-height: 0; }
.chart-col:not(.empty):hover .chart-bar { filter: brightness(1.25); }
.chart-col.selected .chart-bar { background: linear-gradient(180deg, #fff, #d4d4d4); }
.chart-label { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: .66rem; color: var(--text-3); white-space: nowrap; }
.chart-year .chart-bars, .chart-month .chart-bars { gap: 6px; }
.chart-year .chart-col { max-width: 5rem; }
.duo-bar { height: .3rem; background: var(--bg-input); border-radius: 9999px; overflow: hidden; margin-top: .3rem; }
.duo-bar > div { height: 100%; border-radius: 9999px; }
.duo-bar .paid, .legend .dot.paid { background: #4ade80; }
.duo-bar .share, .legend .dot.share { background: #60a5fa; }
.legend { display: flex; align-items: center; gap: .4rem; justify-content: center; margin-top: -.6rem; }
.legend .dot { width: .55rem; height: .55rem; border-radius: 9999px; display: inline-block; margin-left: .6rem; }
@media (max-width: 799px) {
  .chart { height: 11rem; }
  .chart-axis { min-width: 3rem; }
  .chart-day .chart-bars { gap: 1px; }
}

/* ===== Persönliche Listen (Tabelle) ===== */
.table-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: .85rem; }
.ptable th { text-align: left; color: var(--text-3); font-weight: 500; font-size: .75rem; padding: .6rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ptable td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ptable tbody tr { cursor: pointer; transition: background .12s; }
.ptable tbody tr:hover { background: var(--bg-hover); }
.ptable tbody tr:last-child td { border-bottom: none; }
.ptable .num { text-align: right; white-space: nowrap; }
.ptable .actions-cell { width: 2.2rem; text-align: right; }
.ptable .actions-cell .icon-btn { opacity: 0; }
.ptable tr:hover .actions-cell .icon-btn { opacity: 1; }
.cell-main { display: flex; align-items: center; gap: .6rem; min-width: 0; max-width: 22rem; }
.cat-icon.sm { width: 1.9rem; height: 1.9rem; font-size: .95rem; border-radius: .55rem; }
.stat.on { border-color: rgba(255,255,255,.35); }
.list-row.dim { opacity: .45; }
.ptable tbody tr.readonly { cursor: default; }
.avatar-stack { display: flex; margin-top: .45rem; }
.avatar-stack > span { margin-left: -.35rem; display: inline-flex; }
.avatar-stack > span:first-child { margin-left: 0; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--bg-elev); }
.avatar.xs { width: 1.15rem; height: 1.15rem; font-size: .5rem; }
.badge.blue { background: rgba(59,130,246,.15); color: #93c5fd; }

/* Schalter (wie remote/webmail) */
.switch { position: relative; width: 2.3rem; height: 1.3rem; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--bg-input); border-radius: 9999px; cursor: pointer; transition: background .15s; border: 1px solid var(--border-strong); }
.switch span::before { content: ""; position: absolute; width: .95rem; height: .95rem; left: .15rem; top: .12rem; background: var(--text-3); border-radius: 9999px; transition: transform .15s, background .15s; }
.switch input:checked + span { background: #fff; }
.switch input:checked + span::before { transform: translateX(.95rem); background: #000; }
.show-mobile { display: none; }
@media (hover: none) { .ptable .actions-cell .icon-btn { opacity: 1; } }
@media (max-width: 799px) {
  .show-mobile { display: block; }
  .cell-main { max-width: 11rem; }
  .ptable td, .ptable th { padding: .5rem .55rem; }
}

/* ===== KI-Assistent (rechte Seitenleiste, aus webmail übernommen) ===== */
.ai-btn { width: 2.1rem; height: 2.1rem; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; }
.ai-btn:hover { background: var(--bg-hover); color: var(--text); }
.ai-btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.ai-btn svg { width: 1.05rem; height: 1.05rem; }
.ai-panel { width: 400px; flex-shrink: 0; background: var(--bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; position: relative; z-index: 30; }
.ai-panel.wide { width: min(640px, 45vw); }
.ai-head { height: 3.25rem; display: flex; align-items: center; gap: .25rem; padding: 0 .5rem 0 .9rem; flex-shrink: 0; }
.ai-head .title { flex: 1; min-width: 0; font-weight: 500; font-size: .95rem; display: flex; align-items: center; gap: .45rem; }
.ai-head .title .model { font-size: .72rem; color: var(--text-3); font-weight: 400; }
.ai-history { position: absolute; top: 3.25rem; left: .5rem; right: .5rem; z-index: 20; max-height: 60%; overflow-y: auto; }
.ai-history .item { display: flex; align-items: center; gap: .3rem; }
.ai-history .item button.open { flex: 1; min-width: 0; }
.ai-scroll { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; display: flex; flex-direction: column; gap: 1.1rem; }
.ai-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; text-align: center; color: var(--text-3); padding: 1rem; }
.ai-empty .hello { font-size: 1.35rem; color: var(--text); font-weight: 500; }
.ai-suggest { display: flex; flex-direction: column; gap: .45rem; width: 100%; max-width: 22rem; }
.ai-suggest button { text-align: left; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius); padding: .6rem .8rem; cursor: pointer; color: var(--text-2); font-size: .85rem; }
.ai-suggest button:hover { border-color: var(--border-strong); color: var(--text); }
.ai-msg.user { align-self: flex-end; max-width: 85%; background: var(--bg-input); border-radius: 1.25rem; padding: .55rem .95rem; white-space: pre-wrap; word-break: break-word; }
.ai-msg.assistant { display: flex; gap: .65rem; align-items: flex-start; }
.ai-msg.assistant .ai-avatar { width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: .05rem; }
.ai-msg.assistant .ai-avatar svg { width: 1rem; height: 1rem; }
.ai-msg .ai-body { flex: 1; min-width: 0; line-height: 1.6; word-break: break-word; }
.ai-tool { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--text-3); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9999px; padding: .15rem .65rem .15rem .45rem; margin: 0 .3rem .35rem 0; }
.ai-tool svg { width: .85rem; height: .85rem; }
.ai-tool.error { color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.ai-tool .spinner { width: .75rem; height: .75rem; border-width: 1.5px; }
.ai-tool.done svg { color: #86efac; }
.ai-typing { display: inline-flex; gap: .25rem; padding: .3rem 0; }
.ai-typing span { width: .4rem; height: .4rem; border-radius: 9999px; background: var(--text-3); animation: aiblink 1.2s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiblink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-error { background: rgba(239, 68, 68, .12); color: #fca5a5; border-radius: var(--radius); padding: .55rem .8rem; font-size: .85rem; }
.ai-input-wrap { padding: .4rem .75rem .9rem; flex-shrink: 0; }
.ai-input { background: var(--bg-input); border: 1px solid var(--border); border-radius: 1.5rem; padding: .55rem .55rem .55rem 1rem; display: flex; align-items: flex-end; gap: .4rem; }
.ai-input:focus-within { border-color: var(--border-strong); }
.ai-input textarea { flex: 1; background: transparent; border: none; outline: none; resize: none; max-height: 12rem; min-height: 1.5rem; line-height: 1.5; padding: .2rem 0; }
.ai-input textarea::placeholder { color: var(--text-4); }
.ai-send { width: 2rem; height: 2rem; border-radius: 9999px; border: none; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.ai-send:disabled { opacity: .3; cursor: default; }
.ai-send svg { width: 1rem; height: 1rem; }
.ai-hint { font-size: .68rem; color: var(--text-4); text-align: center; margin-top: .4rem; }
.md p { margin: 0 0 .6rem; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2rem 0 .6rem; padding-left: 1.3rem; } .md li { margin: .15rem 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1rem; font-weight: 600; margin: .8rem 0 .4rem; }
.md code { font-family: var(--mono); font-size: .82em; background: rgba(255,255,255,.08); padding: .1rem .35rem; border-radius: .35rem; }
.md pre { background: #0d0d0d; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; overflow-x: auto; margin: .4rem 0 .7rem; }
.md pre code { background: none; padding: 0; font-size: .8rem; }
.md blockquote { border-left: 2px solid var(--border-strong); margin: .4rem 0; padding-left: .8rem; color: var(--text-2); }
.md a { color: #93c5fd; }
.md table { border-collapse: collapse; margin: .4rem 0 .7rem; font-size: .82rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-strong); padding: .3rem .55rem; text-align: left; }
.md th { background: rgba(255,255,255,.04); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: .8rem 0; }
.md li.task { list-style: none; margin-left: -1.2rem; }
.md li.task input { accent-color: #fff; margin: 0 .35rem 0 0; vertical-align: -1px; }
.md del { opacity: .7; }
@media (max-width: 1000px) {
  .ai-panel, .ai-panel.wide { position: fixed; right: 0; top: 0; bottom: 0; z-index: 65; width: min(420px, 100vw); box-shadow: var(--shadow); }
}
@media (max-width: 599px) {
  .ai-panel, .ai-panel.wide { width: 100vw; border-left: none; }
  .ai-input-wrap { padding-bottom: max(.9rem, env(safe-area-inset-bottom)); }
  .ai-head { padding-top: env(safe-area-inset-top); height: calc(3.25rem + env(safe-area-inset-top)); }
}

/* ===== Push-Geräte ===== */
.status-dot { width: .5rem; height: .5rem; border-radius: 9999px; background: var(--text-4); flex-shrink: 0; }
.status-dot.ok { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .12); }
.status-dot.bad { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .14); }

/* ===== Installierte App: Statusleiste/Notch (viewport-fit=cover) ===== */
@media (display-mode: standalone) {
  .sidebar-top { padding-top: max(.6rem, env(safe-area-inset-top)); }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(3.25rem + env(safe-area-inset-top)); }
  .sidebar-bottom { padding-bottom: max(.7rem, env(safe-area-inset-bottom)); }
  .fab-bar { bottom: max(1.1rem, calc(env(safe-area-inset-bottom) + .4rem)); }
}

/* ===== Toasts ===== */
.toasts { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; pointer-events: none; max-width: min(28rem, calc(100vw - 2rem)); }
.toast { background: var(--bg-elev); border: 1px solid var(--border-strong); padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .85rem; pointer-events: auto; display: flex; gap: .6rem; align-items: center; }
.toast.error { border-color: rgba(239,68,68,.5); color: #fca5a5; }
.toast.success { border-color: rgba(34,197,94,.4); }
.toast button { background: none; border: none; color: var(--text); text-decoration: underline; cursor: pointer; font-size: .82rem; padding: 0; }

.spinner { width: 1.2rem; height: 1.2rem; border: 2px solid rgba(255,255,255,.15); border-top-color: #fff; border-radius: 9999px; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Mobil ===== */
@media (max-width: 799px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .page { padding: .75rem .9rem 6rem; }
  .stats { grid-template-columns: 1fr; }
  .columns { grid-template-columns: 1fr; }
  .toasts { right: 1rem; left: 1rem; bottom: 1rem; align-items: stretch; max-width: none; }
  .hide-mobile { display: none !important; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 96vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .person .val-input { width: 5.5rem; }
  .person .owed { width: 4.8rem; }
}
