/* ---------- Schrift (lokal, keine Verbindung zu Google) ---------- */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* ---------- Farben ---------- */
:root {
    --accent: #7B6CFF;
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar-w: 256px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #14141B;
    --panel: #18181F;
    --card: #1D1D26;
    --card-2: #23232E;
    --hover: rgba(255, 255, 255, .045);
    --border: rgba(255, 255, 255, .075);
    --border-strong: rgba(255, 255, 255, .13);
    --text: #EDEDF2;
    --text-2: #B9B9C6;
    --muted: #868699;
    --grid: rgba(255, 255, 255, .06);
    --pos: #4ADE80;
    --pos-bg: rgba(74, 222, 128, .12);
    --neg: #F87171;
    --neg-bg: rgba(248, 113, 113, .12);
    --warn: #FBBF24;
    --warn-bg: rgba(251, 191, 36, .1);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --compare: rgba(237, 237, 242, .45);
    --accent-text: #fff;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #F4F5F8;
    --panel: #FFFFFF;
    --card: #FFFFFF;
    --card-2: #F6F7FA;
    --hover: rgba(17, 20, 35, .04);
    --border: #E7E8EE;
    --border-strong: #D7D9E1;
    --text: #12131A;
    --text-2: #3E4150;
    --muted: #6E7183;
    --grid: rgba(17, 20, 35, .07);
    --pos: #16A34A;
    --pos-bg: rgba(22, 163, 74, .1);
    --neg: #DC2626;
    --neg-bg: rgba(220, 38, 38, .08);
    --warn: #B45309;
    --warn-bg: rgba(245, 158, 11, .12);
    --shadow: 0 1px 2px rgba(17, 20, 35, .04), 0 4px 14px rgba(17, 20, 35, .04);
    --shadow-lg: 0 24px 64px rgba(17, 20, 35, .18);
    --compare: rgba(18, 19, 26, .35);
}

:root {
    --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
    --accent-line: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- Grundlagen ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; }
.num, .kpi-value, .goal-value, td.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh;
    background: linear-gradient(90deg, var(--panel) var(--sidebar-w), transparent 0); }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand--center { justify-content: center; padding-bottom: 28px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
    color: #fff;
    box-shadow: 0 6px 18px var(--accent-soft);
}
.brand-mark svg { width: 19px; height: 19px; stroke-width: 2.2; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; font-weight: 650; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 16px 10px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: 9px;
    color: var(--text-2); text-decoration: none; font-weight: 500;
    border: 1px solid transparent; background: none; cursor: pointer; text-align: left; width: 100%;
    transition: background .15s, color .15s;
}
.nav-item svg { color: var(--muted); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.is-active {
    background: var(--card-2); color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow);
}
.nav-item.is-active svg { color: var(--accent); }
.nav-badge { margin-left: auto; font-size: 11.5px; color: var(--muted); background: var(--hover); border: 1px solid var(--border); padding: 1px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
    background: var(--accent-soft); color: var(--accent);
    border: 1px solid var(--accent-line);
}
.user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-text strong { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-text small { color: var(--muted); font-size: 12px; }
.user .icon-btn { margin-left: auto; }

.main { padding: 26px 32px 48px; min-width: 0; max-width: 1480px; width: 100%; }

.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar-title h1 { font-size: 24px; font-weight: 650; }
.topbar-title p { margin-top: 2px; font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.icon-btn.menu-btn { display: none; }
.scrim { position: fixed; inset: 0; display: none; }

/* ---------- Bausteine ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 16px; }
.card-head p { font-size: 12.5px; margin-top: 3px; }
.card-head--pad { padding: 20px 20px 0; }
.card-head--wrap { flex-wrap: wrap; }

.grid { display: grid; gap: 16px; margin-top: 16px; }
.grid--main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 15px; border-radius: 10px;
    font-weight: 600; font-size: 13.5px; white-space: nowrap;
    border: 1px solid var(--border-strong); background: var(--card);
    color: var(--text); cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke-width: 2.1; }
.btn--primary {
    background: var(--accent); border-color: transparent; color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px var(--accent-soft);
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--hover); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.btn--block { width: 100%; height: 44px; }
.btn--danger { background: var(--neg); border-color: transparent; color: #fff; }
.btn--danger:hover { filter: brightness(1.08); }
.btn--danger-ghost { background: transparent; color: var(--neg); border-color: transparent; }
.btn--danger-ghost:hover { background: var(--neg-bg); }
.btn[disabled] { opacity: .55; cursor: default; }

.icon-btn {
    width: 36px; height: 36px; display: inline-grid; place-items: center;
    border-radius: 10px; border: 1px solid transparent; background: transparent;
    color: var(--muted); cursor: pointer; text-decoration: none;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn--bordered { border-color: var(--border-strong); background: var(--card); height: 38px; width: 38px; }
.icon-btn--sm { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn[disabled] { opacity: .3; pointer-events: none; }
.icon-btn--sm svg { width: 16px; height: 16px; }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--card); border: 1px solid var(--border-strong);
    border-radius: 11px;
}
.segmented button {
    border: 0; background: transparent; color: var(--muted);
    padding: 6px 12px; border-radius: 8px; font-weight: 500; font-size: 13px; cursor: pointer;
    transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--card-2); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong), 0 1px 3px rgba(0, 0, 0, .12); }
[data-theme="light"] .segmented button.is-active { background: var(--accent); color: #fff; box-shadow: none; }
.segmented--full { display: flex; }
.segmented--full button { flex: 1; height: 32px; }

.chip {
    display: inline-flex; align-items: center; gap: 4px;
    height: 22px; padding: 0 7px; border-radius: 6px;
    font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
    background: var(--hover); color: var(--text-2); border: 1px solid var(--border);
}
.chip svg { width: 13px; height: 13px; stroke-width: 2.3; }
.chip--pos { color: var(--pos); background: var(--pos-bg); border-color: transparent; }
.chip--neg { color: var(--neg); background: var(--neg-bg); border-color: transparent; }
.chip--accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
[data-theme="dark"] .chip--accent { color: color-mix(in srgb, var(--accent) 55%, #fff); }

.alert { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; }
.alert--warn { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.alert--warn a { font-weight: 600; }
.alert--error { background: var(--neg-bg); color: var(--neg); margin: 0 0 16px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 18px 18px 16px; }
.kpi-head { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .kpi-icon { color: color-mix(in srgb, var(--accent) 60%, #fff); }
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-head .spark { margin-left: auto; }
.kpi-body { margin-top: 12px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.kpi-foot { display: flex; align-items: center; gap: 7px; margin-top: 8px; font-size: 12px; white-space: nowrap; }
.kpi-foot .muted { overflow: hidden; text-overflow: ellipsis; }
.spark { width: 92px !important; height: 34px !important; flex: none; }

/* ---------- Diagramme ---------- */
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot--accent { background: var(--accent); }
.dot--dashed { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--compare); }

.chart-wrap { position: relative; width: 100%; }
.chart-wrap--lg { height: 320px; }
.card--chart { display: flex; flex-direction: column; }
.card--chart .chart-wrap--lg { flex: 1; min-height: 300px; height: auto; }
.chart-wrap--sm { height: 170px; }

.donut-wrap { position: relative; width: 210px; height: 210px; margin: 4px auto 18px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center small { color: var(--muted); font-size: 12px; }
.donut-center strong { font-size: 19px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.source-list li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); font-size: 13px; }
.source-list li:first-child { border-top: 0; }
.source-list .sw { width: 10px; height: 10px; border-radius: 3px; }
.source-list .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-list .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.source-list .pct { color: var(--muted); font-size: 12px; width: 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Monatsziel ---------- */
.goal-value { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal-value strong { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.progress { height: 10px; background: var(--hover); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: 14px 0 16px; }
.progress span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, transparent), var(--accent)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.goal-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.goal-meta div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.goal-meta small { font-size: 11.5px; }
.goal-meta strong { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 20px; background: var(--card-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr { transition: background .12s; cursor: pointer; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table td.num { font-weight: 600; }
.table td.note { color: var(--text-2); max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
.table td.act { width: 1%; padding-right: 12px; text-align: right; }
.table .date-sub { color: var(--muted); font-size: 12px; margin-left: 6px; }
.table .empty td { text-align: center; color: var(--muted); padding: 40px 20px; cursor: default; }
.table .empty:hover { background: none; }
.tag { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--hover); border: 1px solid var(--border); }
.tag i { width: 8px; height: 8px; border-radius: 50%; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--card); color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; width: 190px; }
.search svg { width: 16px; height: 16px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 6px; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field--full { grid-column: 1 / -1; }
.input, .select {
    height: 40px; width: 100%; padding: 0 12px;
    background: var(--card-2); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: 10px;
    font: inherit; outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.select { width: auto; height: 36px; padding-right: 30px; appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23868699' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; background-size: 16px;
}
.form .select, .form--grid .select { width: 100%; height: 40px; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }
input[type="date"].input::-webkit-calendar-picker-indicator { opacity: .6; cursor: pointer; }
[data-theme="dark"] input[type="date"].input::-webkit-calendar-picker-indicator { filter: invert(1); }
.input-affix { position: relative; display: block; }
.input-affix .input { padding-right: 34px; }
.input-affix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-weight: 500; }
.input-affix--lg .input { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; justify-content: flex-end; }
.form-error { color: var(--neg); font-size: 13px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
    display: inline-flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 13px 0 11px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: var(--card-2);
    color: var(--text-2); font-weight: 500; font-size: 13px; cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.pill i { width: 9px; height: 9px; border-radius: 50%; }
.pill:hover { color: var(--text); }
.pill.is-active { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--text); }

.color-pick {
    position: relative; width: 34px; height: 34px; border-radius: 9px; flex: none;
    border: 1px solid var(--border-strong); overflow: hidden; cursor: pointer;
    display: inline-block;
}
.color-pick input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); border: 0; padding: 0; cursor: pointer; background: none; }
.color-pick--lg { width: 32px; height: 32px; border-radius: 50%;
    background: conic-gradient(#f87171, #fbbf24, #4ade80, #22d3ee, #818cf8, #e879f9, #f87171); }
.color-pick--lg input { opacity: 0; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer; position: relative; box-shadow: 0 0 0 1px var(--border-strong) inset; }
.swatch.is-active::after, .color-pick--lg.is-active::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--text); pointer-events: none; }
.color-pick--lg { overflow: visible; }

/* ---------- Einstellungen ---------- */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.src-edit { list-style: none; margin: 0 0 14px; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.src-edit li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--card); }
.src-edit li:first-child { border-top: 0; }
.src-edit .input { height: 36px; flex: 1; min-width: 0; }
.src-edit .count { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 82px; text-align: right; font-variant-numeric: tabular-nums; }
.src-edit .moves { display: flex; }
.src-new { display: flex; gap: 10px; align-items: center; }
.src-new .input { flex: 1; }
.src-new .color-pick { width: 38px; height: 38px; }
.card--danger { border-color: color-mix(in srgb, var(--neg) 25%, var(--border)); }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Dialoge ---------- */
.modal { border: 0; padding: 0; background: transparent; color: var(--text); max-width: calc(100vw - 32px); }
.modal::backdrop { background: rgba(8, 8, 14, .6); backdrop-filter: blur(4px); }
.modal[open] .modal-card { animation: pop .18s cubic-bezier(.2, .8, .2, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-card { width: 520px; max-width: 100%; background: var(--card); border: 1px solid var(--border-strong); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; }
.modal-card--sm { width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }

/* ---------- Hinweise ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .2s ease; }
.toast svg { color: var(--pos); }
.toast--err svg { color: var(--neg); }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(600px 400px at 50% -10%, var(--accent-soft), transparent 70%),
        var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px 28px; box-shadow: var(--shadow-lg); text-align: center; }
.login-card h1 { font-size: 22px; }
.login-card > .muted { margin: 6px 0 24px; }
.login-card .form { text-align: left; }
.login-card .field input { height: 44px; padding: 0 14px; background: var(--card-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 11px; font: inherit; outline: none; }
.login-card .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-foot { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; color: var(--muted); font-size: 12.5px; }
.login-foot svg { width: 14px; height: 14px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1280px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .grid--main, .settings { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.is-open { transform: none; box-shadow: var(--shadow-lg); }
    .scrim { display: block; background: rgba(0, 0, 0, .45); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
    .scrim.is-open { opacity: 1; pointer-events: auto; }
    .icon-btn.menu-btn { display: inline-grid; margin-left: -8px; }
    .main { padding: 16px 16px 40px; }
    .topbar-actions { margin-left: 0; width: 100%; }
    .topbar-actions .segmented { flex: 1; }
    .topbar-actions .segmented button { flex: 1; padding: 6px 4px; }
}
@media (max-width: 600px) {
    .kpis { grid-template-columns: minmax(0, 1fr); }
    .topbar-title h1 { font-size: 20px; }
    .topbar-actions .btn--primary span { display: none; }
    .topbar-actions .btn--primary { width: 38px; padding: 0; }
    .form--grid, .form-row { grid-template-columns: 1fr; }
    .table .hide-sm { display: none; }
    .table th, .table td { padding-left: 14px; padding-right: 10px; }
    .table .date-sub { display: none; }
    .table td.act, .table th:last-child { display: none; }
    .tag { font-size: 12px; padding: 2px 8px 2px 7px; }
    .topbar-actions .segmented button { font-size: 12px; }
    .search input { width: 140px; }
    .chart-wrap--lg { height: 260px; }
    .modal-card { padding: 18px; }
}
.show-sm { display: none; }
@media (max-width: 600px) { .hide-sm { display: none; } .show-sm { display: inline; } }

/* ---------- Feinschliff für alle Breiten ---------- */
.card-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.card-head h2 { white-space: nowrap; }
.card-head--wrap, .card--chart .card-head { flex-wrap: wrap; }
.card--chart .legend { padding-top: 2px; }
.kpi-label { min-width: 0; }

/* Karten passen sich ihrer eigenen Breite an (z. B. schmale rechte Spalte) */
.stack > .card, .kpi { container-type: inline-size; }
@container (max-width: 340px) {
    .goal-meta { grid-template-columns: 1fr 1fr; }
    .goal-meta div:last-child { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
    .goal-value strong { font-size: 23px; }
}
@container (max-width: 250px) {
    .kpi-value { font-size: 22px; }
    .kpi .spark { width: 64px !important; }
}

.topbar.ohne-zeitraum .topbar-actions { width: auto; margin-left: auto; }

@media (max-width: 1100px) {
    .src-new { flex-wrap: wrap; }
}
@media (max-width: 600px) {
    .main { padding-left: 14px; padding-right: 14px; }
    .card { padding: 16px; }
    .card--flush { padding: 0; }
    .card-head--pad { padding: 16px 16px 0; }
    .card-head h2 { white-space: normal; }
    .card--chart .legend { width: 100%; }
    .kpi-value { font-size: 24px; }
    .goal-value strong { font-size: 23px; }
    .table .d-lang { display: none; }
    .table .d-kurz { display: inline; }
    .donut-wrap { width: 190px; height: 190px; }

    /* Einkommensquellen: Name volle Breite, Bedienelemente darunter */
    .src-edit li { display: grid; grid-template-columns: auto 1fr auto auto; grid-template-areas: "farbe name name name" "anz anz moves del"; row-gap: 8px; }
    .src-edit .color-pick { grid-area: farbe; }
    .src-edit .input { grid-area: name; }
    .src-edit .count { grid-area: anz; text-align: left; min-width: 0; }
    .src-edit .moves { grid-area: moves; }
    .src-edit [data-quelle-loeschen] { grid-area: del; }
    .src-new .input { flex: 1 1 calc(100% - 50px); }
    .src-new .btn { width: 100%; }
    .data-actions .btn { width: 100%; }
    .form-actions .btn { width: 100%; }
    .modal-foot { flex-wrap: wrap; }
    .toasts { left: 14px; right: 14px; bottom: 14px; }
}
.d-kurz { display: none; }
@media (max-width: 600px) {
    .filters { width: 100%; }
    .filters .search { flex: 1 1 100%; }
    .filters .search input { width: 100%; }
    .filters .select { flex: 1; min-width: 0; }
}
@media (max-width: 380px) {
    .topbar-actions .segmented button { padding: 6px 2px; }
    .kpi-head { gap: 8px; }
    .filters { width: 100%; }
    .filters .search { flex: 1 1 100%; }
    .filters .search input { width: 100%; }
    .filters .select { flex: 1; min-width: 0; }
}

/* Lange Namen von Einkommensquellen */
.tag { max-width: 210px; }
.tag i { flex: none; }
.tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.source-list .name { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; }
.source-list li { align-items: start; }
.source-list .sw { margin-top: 4px; }
.pill { max-width: 100%; }
.pill > i { flex: none; }
@media (max-width: 1280px) { .tag { max-width: 160px; } }
@media (max-width: 600px) { .tag { max-width: 112px; } }
.pill { height: auto; min-height: 34px; padding-top: 6px; padding-bottom: 6px; text-align: left; line-height: 1.3; }

/* Handy: Tabelle wird zur Liste (Quelle + Betrag oben, Datum + Notiz darunter) */
@media (max-width: 600px) {
    .table thead { display: none; }
    .table, .table tbody { display: block; }
    .table tbody tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "quelle quelle betrag" "datum notiz notiz";
        column-gap: 8px; row-gap: 4px;
        padding: 12px 16px;
        border-bottom: 1px solid var(--border);
    }
    .table tbody tr:last-child { border-bottom: 0; }
    .table tbody td { padding: 0; border: 0; white-space: nowrap; }
    .table tbody td:nth-child(1) { grid-area: datum; color: var(--muted); font-size: 12.5px; }
    .table tbody td:nth-child(2) { grid-area: quelle; min-width: 0; }
    .table tbody td.note { grid-area: notiz; display: block; max-width: none; width: auto; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
    .table tbody td.note::before { content: "· "; }
    .table tbody td.num { grid-area: betrag; align-self: center; font-size: 15px; }
    .table .d-lang { display: inline; }
    .table .d-kurz { display: none; }
    .table .tag { max-width: 100%; }
    .table .empty { display: block; }
    .table .empty td { display: block; padding: 32px 16px; white-space: normal; }
    .table-wrap { border-top: 1px solid var(--border); }
}

/* Einnahme eintragen (in den Einstellungen) */
.settings > .card--wide { grid-column: 1 / -1; }
.schnell-grid { display: grid; grid-template-columns: 180px 220px minmax(0, 1fr); gap: 14px; }
@media (max-width: 900px) {
    .schnell-grid { grid-template-columns: 1fr 1fr; }
    .schnell-grid .schnell-notiz { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .schnell-grid { grid-template-columns: 1fr; }
}
.table .empty a { color: var(--accent); font-weight: 600; }

/* Tabelle passt sich der Kartenbreite an */
.card--flush { container-type: inline-size; }
@container (max-width: 660px) {
    .table .date-sub { display: none; }
    .table th, .table td { padding-left: 16px; padding-right: 10px; }
}
@media (max-width: 900px) { .app { background: none; } }
@media (max-width: 600px) {
    .table tbody tr { grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "quelle quelle betrag act" "datum notiz notiz act"; padding-right: 8px; }
    .table tbody td.act { display: block; grid-area: act; align-self: center; width: auto; padding: 0; }
}
