:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1f2328;
  --muted: #667085;
  --border: #e3e0d9;
  --accent: #2f6f5e;
  --accent-soft: #e3efe9;
  --pos: #1a7f37;
  --neg: #b42318;
  --warn-bg: #fff4e5;
  --warn: #9a5b00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #262a2f;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --border: #2f343a;
    --accent: #6cc3a5;
    --accent-soft: #1f3a32;
    --pos: #4cc27a;
    --neg: #ff7a6e;
    --warn-bg: #3a2a12;
    --warn: #f3b54a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Navigation */
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .6rem 16px; display: flex; gap: 1rem;
  align-items: center; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a, .nav summary {
  padding: .35rem .65rem; border-radius: 6px; color: var(--text); cursor: pointer; list-style: none;
}
.nav a:hover, .nav summary:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav details { position: relative; }
.nav details[open] .menu { display: block; }
.menu {
  display: none; position: absolute; top: 2.2rem; left: 0; background: var(--surface); min-width: 220px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: .35rem; box-shadow: var(--shadow);
}
.menu a { display: block; }
.badge {
  display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; font-size: .75rem;
  background: var(--neg); color: #fff; text-align: center; margin-left: .2rem;
}
.badge.neutral { background: var(--muted); }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 16px 4rem; }

/* Bausteine */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 1rem; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface-2); border-radius: 8px; padding: .6rem .75rem; }
.kpi .label { font-size: .78rem; color: var(--muted); }
.kpi .value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; margin: 0; }
.facts div { background: var(--surface-2); border-radius: 8px; padding: .5rem .75rem; }
.facts dt { font-size: .75rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; list-style: none; }
.chips li { background: var(--surface-2); border-radius: 999px; padding: .15rem .6rem; font-size: .85rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: .3rem .7rem; color: var(--text); }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }

.chart { width: 100%; height: 320px; }
.chart.small { height: 240px; }
.chart.sankey { height: 460px; }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .4rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; white-space: nowrap; }
tr.group td { background: var(--surface-2); font-weight: 600; }
tr.total td { font-weight: 700; border-top: 2px solid var(--text); }
td.sticky, th.sticky { position: sticky; left: 0; background: var(--surface); }
tr.group td.sticky { background: var(--surface-2); }

/* Formulare */
form.stack { display: grid; gap: .8rem; max-width: 520px; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
input[type=checkbox] { width: auto; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.helptext, .help { font-size: .8rem; color: var(--muted); }
.errorlist { color: var(--neg); margin: .2rem 0; padding-left: 1rem; font-size: .85rem; }
button, .btn {
  font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer; display: inline-block;
}
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button.ghost { background: transparent; border-color: var(--border); color: var(--text); }
button.small, .btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:hover { text-decoration: none; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.messages li { padding: .6rem .8rem; border-radius: 8px; background: var(--accent-soft); }
.messages li.warning, .messages li.error { background: var(--warn-bg); color: var(--warn); }
.notice { background: var(--warn-bg); color: var(--warn); padding: .6rem .8rem; border-radius: 8px; }

/* Prüfliste */
.tx { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; }
.tx-form { display: grid; grid-template-columns: 1.2fr 1.6fr 70px auto; gap: .5rem; align-items: end; }
.tx-form .actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.tx-amount { font-size: 1.1rem; font-weight: 700; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  .tx-form { grid-template-columns: 1fr; }
  .chart { height: 260px; }
  .nav { order: 3; width: 100%; }
}
