:root {
  --bg: #f3f6fb; --card: #fff; --text: #101827; --muted: #6b7f8c; --line: #e6ebf2;
  --accent: #0088ff; --anthracite: #2b414d; --cyan: #08c9de; --violet: #7952e8; --pos: #12a150; --neg: #e5484d; --warn: #d97706; --radius: 18px;
  --shadow: 0 14px 40px rgba(18, 38, 99, .08), 0 2px 6px rgba(18, 38, 99, .04);
  --grad: linear-gradient(135deg, #7952e8 0%, #0088ff 55%, #08c9de 100%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #101827; --card: #172233; --text: #eef3f8; --muted: #8fa3b3; --line: #243246; --accent: #67b7ff; --pos: #4ade80; --neg: #ff7b7f; --warn: #fbbf24;
    --shadow: 0 14px 40px rgba(0, 0, 0, .35); }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; background: radial-gradient(1200px 500px at 85% -10%, rgba(121,82,232,.09), transparent), var(--bg); background-attachment: fixed; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { margin: .2em 0 .6em; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
h3 { margin: 0 0 .8em; font-size: 1.05rem; font-weight: 700; }
code { background: var(--line); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.top { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: color-mix(in srgb, var(--card) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.03em; font-size: 1.1rem; color: var(--text); }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.top nav a.active, .top nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }

.card { background: var(--card); border: 0; border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid2 > div > .card:last-child { margin-bottom: 16px; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 800px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--card); border: 0; box-shadow: var(--shadow); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-direction: column; color: var(--text); }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi strong { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi.warn strong { color: var(--warn); }
.kpi.hero { background: var(--grad); color: #fff; }
.kpi.hero span, .kpi.hero small { color: rgba(255,255,255,.8); }
a.kpi:hover { text-decoration: none; transform: translateY(-1px); }
.chart { position: relative; height: 300px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.muted { color: var(--muted); } .small { font-size: .85em; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.cats tr.top { cursor: pointer; font-weight: 500; }
.cats tr.top:hover { background: var(--bg); }
.cats tr.sub td:first-child { padding-left: 28px; }
.cats .bar { width: 30%; }
.cats .bar span { display: block; height: 8px; border-radius: 4px; min-width: 2px; margin-top: 6px; }
tr.sub .indent { margin-left: 18px; }
input.bold { font-weight: 600; }

.tx td.desc { max-width: 520px; }
.tx .note { border: 0; background: transparent; padding: 2px 0; font-size: .85em; color: var(--muted); width: 100%; }
.tx .note:focus { background: var(--bg); outline: none; }
.tx .cat-select { max-width: 220px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; background: var(--line); color: var(--muted); white-space: nowrap; cursor: help; }
.ico { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 20px;
  background: color-mix(in srgb, var(--c, #94a3b8) 16%, var(--card)); margin-right: 12px; vertical-align: middle; }
.ico.sm { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; margin-right: 10px; }
.pill { display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 8px; font-size: .75rem; font-weight: 600;
  background: color-mix(in srgb, var(--c, #94a3b8) 14%, var(--card)); color: color-mix(in srgb, var(--c, #64748b) 75%, var(--text)); }
.tx td.desc .ico { float: left; }
.desc-body { overflow: hidden; }

.tx-card h2 { margin: 0; font-size: 1.7rem; }
.tx-card .subtitle { color: var(--muted); font-weight: 700; margin-bottom: 16px; }
.balance { background: var(--grad); color: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; flex-direction: column; max-width: 260px;
  box-shadow: 0 10px 24px rgba(0, 136, 255, .3); }
.balance span, .balance small { font-size: .8rem; opacity: .85; }
.balance strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.tx-item { display: flex; align-items: center; padding: 9px 4px; border-radius: 12px; color: var(--text); }
.tx-item:hover { background: var(--bg); text-decoration: none; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-main small { color: var(--muted); }
.tx-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
.tx-amt.pos { color: var(--pos); }
.more { display: block; margin-top: 8px; font-weight: 600; }
.src-ai { background: #ede9fe; color: #6d28d9; } .src-rule { background: #e0f2fe; color: #0369a1; }
.src-manual { background: #dcfce7; color: #15803d; } .src-none { background: #fef3c7; color: #b45309; }
.src-transfer { background: #e2e8f0; color: #475569; }
@media (prefers-color-scheme: dark) { .src-ai, .src-rule, .src-manual, .src-none { background: var(--line); } }

input, select, button, textarea { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=color]), select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
button { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(0, 136, 255, .25); }
button.danger { background: var(--neg); border-color: var(--neg); color: #fff; }
button.link { background: none; border: 0; padding: 4px; color: var(--accent); }
button.link.danger { color: var(--neg); }
button:disabled { opacity: .5; cursor: wait; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type=search] { min-width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { padding: 6px 10px; cursor: pointer; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg label.on { background: var(--accent); color: #fff; font-weight: 600; }
.seg input { display: none; }
.acc-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; padding: 4px 9px; cursor: pointer; }
.chip input { margin: 0 5px 0 0; vertical-align: -1px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; }
.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 8px 4px 0; }
.form { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.form.wide { max-width: none; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.form label.inline { flex-direction: row; font-weight: 400; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 800px) { .cols3 { grid-template-columns: 1fr; } }
.account-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.account-row input[name=name] { min-width: 220px; font-weight: 600; }
.danger-zone { margin: 0 0 16px 4px; color: var(--muted); font-size: .85em; }
.danger-zone form { margin-top: 8px; }
.scroll { overflow-x: auto; }
.challenge { background: var(--bg); padding: 10px 12px; border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.pager { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.pager a.on { background: var(--accent); color: #fff; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; max-width: 420px; }
.toast.err { background: #b91c1c; }

body.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(360px, 92vw); display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; }
.login-card h1 { margin: 0 0 6px; font-size: 1.3rem; }

/* blueFynio-Branding (Logo-Master 760×208 mit transparentem Schutzraum) */
.brand { gap: 0; margin: -6px 0; }
.brand img { height: 46px; width: auto; display: block; }
.login-logo { display: flex; justify-content: center; }
.login-logo img { width: 100%; max-width: 300px; height: auto; display: block; }
.tagline { margin: -10px 0 4px; text-align: center; color: var(--muted); font-weight: 600; }

/* Vertrags- & Abo-Radar */
.radar-card { display: block; color: var(--text); }
.radar-card:hover { text-decoration: none; transform: translateY(-1px); }
.radar-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.radar-nums strong { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; }
.radar-nums small { color: var(--muted); }
.contract-group { overflow: visible; }
.group-head { display: flex; align-items: center; gap: 4px; padding: 16px 18px 6px; }
.group-head h3 { margin: 0; flex: 1; }
.contract-group td { padding: 12px 18px; }
.contract-group .pill { margin-left: 6px; }
tr.inactive { opacity: .55; }
.badge.up { background: #fee2e2; color: #b91c1c; } .badge.down { background: #dcfce7; color: #15803d; }
@media (prefers-color-scheme: dark) { .badge.up, .badge.down { background: var(--line); } }
td.actions { width: 1%; white-space: nowrap; text-align: right; }
td.actions summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; }
.contract-form { display: grid; gap: 8px; margin: 10px 0; text-align: left; min-width: 240px; }
.contract-form label { display: flex; flex-direction: column; font-size: .85em; gap: 2px; }

/* Bankensuche */
.bank-search { position: relative; }
.bank-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin-top: 4px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; padding: 6px; font-weight: 400; }
.bank-results button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; }
.bank-results button:hover { background: var(--bg); }
.bank-results small { color: var(--muted); }

/* Überträge */
.pair { display: inline-block; margin: 4px 0 0 6px; font-size: .78rem; color: var(--muted); font-weight: 600; }
