/* Einnahmen SaaS – Stylesheet (Light/Dark, responsive, ohne externe Abhängigkeiten) */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #0f1419;
  --text-2: #3f4753;
  --muted: #69717d;
  --primary: #2a6fd0;
  --primary-hover: #1f5db3;
  --primary-soft: #e6effb;
  --on-primary: #ffffff;
  --success: #12784a;
  --success-soft: #e3f4ea;
  --warning: #9a5b00;
  --warning-soft: #fdf1dc;
  --danger: #c22f2f;
  --danger-soft: #fbe7e7;
  --info: #2a6fd0;
  --info-soft: #e6effb;
  --wa: #128c4b;
  --wa-hover: #0e7440;
  --series-income: #2a78d6;
  --series-expense: #eb6834;
  --chart-grid: #e6e8ec;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 0.06);
  --shadow: 0 1px 3px rgb(16 24 40 / 0.08), 0 8px 24px rgb(16 24 40 / 0.06);
  --shadow-lg: 0 24px 64px rgb(16 24 40 / 0.22);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 252px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1012;
    --surface: #18191b;
    --surface-2: #202124;
    --surface-3: #2a2b2f;
    --border: #2b2d31;
    --border-strong: #3a3c42;
    --text: #f0efec;
    --text-2: #c9c8c0;
    --muted: #9b9a92;
    --primary: #3f8be6;
    --primary-hover: #5a9dee;
    --primary-soft: #1b2a3f;
    --on-primary: #ffffff;
    --success: #4cc488;
    --success-soft: #15291f;
    --warning: #e6ab45;
    --warning-soft: #2f2414;
    --danger: #f07a7a;
    --danger-soft: #341a1a;
    --info: #6aa6f0;
    --info-soft: #1b2a3f;
    --wa: #1f9d58;
    --wa-hover: #26b566;
    --series-income: #3987e5;
    --series-expense: #d95926;
    --chart-grid: #2c2e33;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 24px 64px rgb(0 0 0 / 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1012;
  --surface: #18191b;
  --surface-2: #202124;
  --surface-3: #2a2b2f;
  --border: #2b2d31;
  --border-strong: #3a3c42;
  --text: #f0efec;
  --text-2: #c9c8c0;
  --muted: #9b9a92;
  --primary: #3f8be6;
  --primary-hover: #5a9dee;
  --primary-soft: #1b2a3f;
  --on-primary: #ffffff;
  --success: #4cc488;
  --success-soft: #15291f;
  --warning: #e6ab45;
  --warning-soft: #2f2414;
  --danger: #f07a7a;
  --danger-soft: #341a1a;
  --info: #6aa6f0;
  --info-soft: #1b2a3f;
  --wa: #1f9d58;
  --wa-hover: #26b566;
  --series-income: #3987e5;
  --series-expense: #d95926;
  --chart-grid: #2c2e33;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 24px 64px rgb(0 0 0 / 0.6);
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.d-block { display: block; }
.small { font-size: 0.8rem; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success); }
.pre-line { white-space: pre-line; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.icon-xs { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
}
.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
.backdrop { position: fixed; inset: 0; z-index: 35; background: rgb(0 0 0 / 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.nav-open .backdrop { opacity: 1; pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: var(--on-primary); }
.brand-mark .icon { width: 20px; height: 20px; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; flex: 1; }
.sidebar-close { margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav form { margin: 0; }
.nav-section { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 16px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: var(--radius-sm); border: 0; background: none;
  color: var(--text-2); font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid var(--border); margin-top: 12px; }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text small { color: var(--muted); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); color: var(--text); font-weight: 650; flex: none; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.3rem; background: var(--primary-soft); color: var(--primary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.15rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 16px; display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 1400px; margin: 0 auto; }

.viewing-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.viewing-banner form { margin: 0; }

@media (min-width: 1024px) {
  .sidebar { transform: none; position: sticky; top: 0; height: 100vh; height: 100dvh; }
  .backdrop, .menu-btn, .sidebar-close { display: none !important; }
  .content { padding: 24px 28px; gap: 20px; }
  .topbar { padding: 14px 28px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; line-height: 1.2; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger-text { color: var(--danger); }
.btn-wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-hover); border-color: var(--wa-hover); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 0.875rem; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn-wa { color: var(--wa); }
.icon-btn-wa:hover { background: var(--success-soft); color: var(--wa); }
.inline-form { display: inline; margin: 0; }

.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-icon-dark { display: inline; }
}

/* ---------- Karten & KPIs ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--muted); }
.link { display: inline-flex; align-items: center; gap: 4px; font-weight: 550; font-size: 0.9rem; }
.subhead { font-size: 0.85rem; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm); min-width: 0;
}
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; font-weight: 550; }
.kpi-value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.is-negative { color: var(--danger); }
.kpi-sub { color: var(--muted); font-size: 0.82rem; }

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-main { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-main { grid-template-columns: minmax(0, 1fr) 320px; }
}

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 14px; }
.stat-row dt { color: var(--muted); font-size: 0.8rem; }
.stat-row dd { margin: 2px 0 0; font-weight: 650; font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (max-width: 480px) { .stat-row { grid-template-columns: 1fr 1fr; } }

.progress-wrap { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--muted); }
progress { flex: 1; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--surface-3); appearance: none; -webkit-appearance: none; }
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--success); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--success); border-radius: 99px; }

.def-list { display: grid; gap: 10px; margin: 0 0 16px; }
.def-list div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--border); padding-bottom: 8px; }
.def-list dt { color: var(--muted); }
.def-list dd { margin: 0; font-weight: 550; text-align: right; overflow-wrap: anywhere; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap; line-height: 1.4;
  background: var(--surface-3); color: var(--text-2);
}
.badge .icon { width: 13px; height: 13px; }
.badge-lg { font-size: 0.85rem; padding: 5px 12px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.lang-tag { font-size: 0.7rem; font-weight: 700; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 4px; margin-left: 4px; }

/* ---------- Toolbar & Filter ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar-text { margin: 0; flex: 1 1 320px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; align-items: center; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }

/* ---------- Formulare ---------- */
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* verhindert Zoom auf iOS */
}
@media (min-width: 768px) { input, select, textarea { font-size: 0.95rem; } }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
.filters select, .filters input[type="month"] { width: auto; flex: 0 1 auto; }
::placeholder { color: var(--muted); opacity: 0.8; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 0.85rem; font-weight: 550; color: var(--text-2); }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.field-group { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 12px; margin: 0; min-width: 0; }
.field-group legend { padding: 0 6px; font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field-group .form-grid { margin-bottom: 8px; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 550; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 44px; height: 26px; flex: none; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 0; padding: 0; margin: 0; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 550; color: var(--text-2); }
.segmented input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.code-input { font-family: var(--mono); font-size: 1.3rem !important; letter-spacing: 0.3em; text-align: center; }
.inline-row { display: flex; gap: 8px; margin-bottom: 10px; }
.inline-row input { max-width: 200px; }
.secret { display: block; margin: 8px 0 4px; padding: 10px 12px; font-size: 1rem; letter-spacing: 0.06em; word-break: break-all; cursor: copy; }
.secret.small { font-size: 0.75rem; letter-spacing: 0; }
.secret.is-copied { outline: 2px solid var(--success); }
.steps { padding-left: 1.2rem; margin: 0 0 12px; display: grid; gap: 10px; }

/* ---------- Tabellen ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface-2); }
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child { border-top-right-radius: var(--radius-sm); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tfoot td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.actions-col { width: 1%; }
.actions { white-space: nowrap; text-align: right; }
.actions > * { vertical-align: middle; }
.strong-link { font-weight: 650; color: var(--text); }

/* Auf schmalen Displays werden Tabellenzeilen zu Karten */
@media (max-width: 760px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tfoot, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 4px; margin-bottom: 10px; background: var(--surface); }
  .table-cards tbody tr:hover { background: var(--surface); }
  .table-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: 7px 10px; text-align: right; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: 0.8rem; font-weight: 550; text-align: left; flex: none; }
  .table-cards td.num { text-align: right; }
  .table-cards td.actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
  .table-cards td.actions::before { content: none; }
  .table-cards td:empty { display: none; }
  .table-cards td > small.d-block { display: inline; margin-left: 6px; }
}

.empty { color: var(--muted); text-align: center; padding: 28px 12px; margin: 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; font-size: 0.9rem; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.list-main:hover { text-decoration: none; }
.list-main:hover strong { color: var(--primary); }
.list-main strong, .list-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-main small { color: var(--muted); }
.amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-list { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--text-2); display: grid; gap: 4px; }

/* ---------- Detailseite ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 550; width: fit-content; }
.detail-head { display: flex; flex-direction: column; gap: 16px; }
.detail-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-title > div { flex: 1; min-width: 200px; }
.detail-title h2 { font-size: 1.35rem; }
.detail-title p { margin: 4px 0 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 560px) { .detail-actions .btn { flex: 1 1 calc(50% - 8px); } }

/* ---------- Diagramm ---------- */
.legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: 0.85rem; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.swatch-income { background: var(--series-income); }
.swatch-expense { background: var(--series-expense); }
.chart { margin: 0; }
.chart svg { display: block; width: 100%; height: auto; max-height: 300px; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis { fill: var(--muted); font: 11px var(--font); }
.chart-hit { fill: transparent; }
.bar-income { fill: var(--series-income); }
.bar-expense { fill: var(--series-expense); }
.chart-group { outline: none; }
.chart-group:hover .chart-hit, .chart-group:focus-visible .chart-hit { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; padding: 6px 0; }

/* ---------- Modals ---------- */
dialog.modal {
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: var(--text);
  overflow: visible;
}
dialog.modal-sm { width: min(480px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgb(10 12 16 / 0.55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modal-in 0.18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-card {
  display: flex; flex-direction: column; max-height: calc(100dvh - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  margin: 0;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
@media (max-width: 560px) {
  dialog.modal, dialog.modal-sm { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh; }
  .modal-card { max-height: 92dvh; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-foot { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
}

/* ---------- Toasts & Alerts ---------- */
.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 460px; width: 100%;
  padding: 10px 8px 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  box-shadow: var(--shadow); pointer-events: auto; animation: modal-in 0.2s ease-out; transition: opacity 0.3s, transform 0.3s;
}
.toast span { flex: 1; }
.toast-success { border-left-color: var(--success); }
.toast-success > .icon { color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error > .icon { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning > .icon { color: var(--warning); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--info-soft); color: var(--info); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

/* ---------- Login ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent), var(--bg); }
.auth-wrap { width: min(420px, 100%); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-size: 1.1rem; font-weight: 700; }
.auth-card { display: flex; flex-direction: column; gap: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.4rem; }
.auth-card p { margin: 0; }
.auth-theme { position: fixed; top: 12px; right: 12px; }
.error-card { text-align: center; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); letter-spacing: -0.04em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .sidebar, .topbar, .toolbar, .actions, .detail-actions, .toasts, .backdrop { display: none !important; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}
