:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2129;
  --line: #2a323c;
  --text: #e8ecf1;
  --muted: #98a3b1;
  --gold: #d4af37;
  --gold-soft: #f0d982;
  --ok: #3fb96b;
  --warn: #e0a423;
  --err: #e2544b;
  --radius: 10px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --fs-1: 12px; --fs-2: 14px; --fs-3: 16px; --fs-4: 20px;
  --fs-5: 24px; --fs-6: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-3);
  line-height: 1.5;
}

a { color: var(--gold-soft); }

.wrap { max-width: 1180px; margin: 0 auto; padding: var(--sp-4); }

header.top {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .wrap {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--sp-3); padding-top: var(--sp-3); padding-bottom: var(--sp-3);
}
.brand { font-weight: 700; letter-spacing: .04em; color: var(--gold); margin-right: auto; }
.brand span { color: var(--muted); font-weight: 400; font-size: var(--fs-2); display: block; }

nav.main { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
nav.main a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 0 var(--sp-4); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
  background: var(--panel-2); font-size: var(--fs-2);
}
nav.main a[aria-current="page"] { border-color: var(--gold); color: var(--gold-soft); }

h1 { font-size: var(--fs-5); margin: 0 0 var(--sp-4); }
h2 { font-size: var(--fs-4); margin: var(--sp-5) 0 var(--sp-3); }
p.lead { color: var(--muted); max-width: 70ch; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--sp-4); margin-bottom: var(--sp-4);
}
.tiles { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.tile {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--sp-4); flex: 1 1 180px;
}
.tile .k { color: var(--muted); font-size: var(--fs-2); }
.tile .v { font-size: var(--fs-5); font-variant-numeric: tabular-nums; margin-top: var(--sp-1); }
.tile .v.pos { color: var(--ok); }
.tile .v.neg { color: var(--err); }

form .form-field { margin-bottom: var(--sp-4); }
label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-2); color: var(--muted); }
label .req { color: var(--gold); }

input[type="text"], input[type="password"], input[type="search"],
input[type="file"], input[type="number"], select {
  width: 100%; min-height: 44px; padding: 0 var(--sp-3);
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: var(--fs-3); font-family: inherit;
}
input[type="file"] { padding: var(--sp-2) var(--sp-3); }
select { appearance: none; background-image: none; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 var(--sp-4);
  border-radius: var(--radius); font-size: var(--fs-3); font-family: inherit;
  cursor: pointer; text-decoration: none; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); margin-right: var(--sp-2);
}
button.primary, .btn.primary {
  background: var(--gold); color: #141005; border-color: var(--gold); font-weight: 600;
}
button.danger, .btn.danger { color: var(--err); border-color: var(--err); background: transparent; }
button:disabled { opacity: .55; cursor: progress; }
:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 2px; }

.inline-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; }
.inline-row .form-field { margin-bottom: 0; }
.inline-row button { margin-right: 0; }

.notice {
  border-radius: var(--radius); padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4); border: 1px solid var(--line); background: var(--panel-2);
}
.notice.success { border-color: var(--ok); }
.notice.error { border-color: var(--err); }
.notice.warn { border-color: var(--warn); }
.notice strong { display: block; margin-bottom: var(--sp-1); }

.err-inline { color: var(--err); font-size: var(--fs-2); margin-top: var(--sp-1); }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { text-align: left; padding: var(--sp-3); border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: var(--fs-2); white-space: nowrap; }
th a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--gold-soft); text-decoration: none;
}
th a:hover { text-decoration: underline; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num.neg { color: var(--err); }
td.num.pos { color: var(--ok); }
tr:last-child td { border-bottom: none; }

.empty { color: var(--muted); padding: var(--sp-5); text-align: center; }

.pager { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-3); }
.pager .info { color: var(--muted); font-size: var(--fs-2); }

.badge {
  display: inline-block; padding: 2px var(--sp-2); border-radius: 999px;
  font-size: var(--fs-1); border: 1px solid var(--line); color: var(--muted);
}
.muted { color: var(--muted); font-size: var(--fs-2); }
.right { text-align: right; }
.stack-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

dialog.confirm {
  border: 1px solid var(--gold); border-radius: var(--radius);
  background: var(--panel); color: var(--text); max-width: 520px; width: calc(100% - 32px);
  padding: var(--sp-5);
}
dialog.confirm::backdrop { background: rgba(0, 0, 0, .65); }
dialog.confirm h2 { margin-top: 0; }
dialog.confirm .actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; }

.preview-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .preview-grid { grid-template-columns: 320px 1fr; } }

/* Diagramme: Balken und Kreis (TCK-2026-0924) */
.bars {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  height: 220px; padding: var(--sp-3) var(--sp-2) 0; overflow-x: auto;
}
.bar-col { flex: 1 1 40px; min-width: 32px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; gap: 2px; height: calc(100% - 24px); width: 100%; justify-content: center; }
.bar { width: 12px; min-height: 2px; border-radius: 3px 3px 0 0; }
.bar.in { background: var(--ok); }
.bar.out { background: var(--err); }
.bar-label { color: var(--muted); font-size: var(--fs-1); margin-top: var(--sp-1); white-space: nowrap; }
.legend { color: var(--muted); font-size: var(--fs-2); display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: var(--sp-1); vertical-align: middle; border: 1px solid var(--line); }
.legend .swatch.in { background: var(--ok); }
.legend .swatch.out { background: var(--err); }

.pie-wrap { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: center; }
.pie { width: 180px; height: 180px; flex: 0 0 auto; }
.cat-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 320px; }
.cat-legend li { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.cat-legend li:last-child { border-bottom: none; }
.cat-legend .amount { margin-left: auto; font-variant-numeric: tabular-nums; }
.cat-legend .sum { border-top: 1px solid var(--gold); }

details.cat-edit { margin-bottom: var(--sp-2); }
details.cat-edit > summary { list-style: none; cursor: pointer; }
details.cat-edit > summary::-webkit-details-marker { display: none; }
details.cat-edit[open] { text-align: left; }
details.cat-edit[open] .form-field { margin-bottom: var(--sp-2); }
.badge.warn { color: var(--warn); border-color: var(--warn); }

/* Zähl-Verweise und Farbeingabe brauchen ebenfalls 44 px Tap-Ziel (ui-standards) */
a.count-link, td.num a.count-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 var(--sp-2);
  color: var(--gold-soft);
}
input[type="color"] { min-height: 44px; min-width: 44px; padding: var(--sp-1); }
summary.btn { display: inline-flex; }

/* Vermögen, Budget, Sparziele (TCK-2026-0925) */
.line-chart-wrap { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: center; }
.line-chart {
  width: 100%; max-width: 640px; height: 200px; flex: 1 1 320px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.line-chart .axis { stroke: var(--line); stroke-width: .3; }
.line-chart .line { fill: none; stroke: var(--gold); stroke-width: 1; }
.line-chart .point { fill: var(--gold-soft); }
.line-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 260px; min-width: 200px; }
.line-legend li {
  display: flex; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-1) 0; border-bottom: 1px solid var(--line);
}
.line-legend li:last-child { border-bottom: none; }
.line-legend .amount { margin-left: auto; font-variant-numeric: tabular-nums; }

.budget-list, .goal-list { list-style: none; margin: 0; padding: 0; }
.budget-row, .goal-row {
  border-bottom: 1px solid var(--line); padding: var(--sp-3) 0;
}
.budget-row:last-child, .goal-row:last-child { border-bottom: none; }
.budget-head, .goal-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.budget-head .name, .goal-head .name { font-weight: 600; }
.budget-head .amount, .goal-head .amount {
  margin-left: auto; font-variant-numeric: tabular-nums;
}
.budget-track {
  height: 14px; border-radius: 7px; background: var(--panel-2);
  border: 1px solid var(--line); overflow: hidden;
}
.budget-fill { height: 100%; border-radius: 7px; min-width: 2px; }
.budget-fill.ampel-gruen, .badge.ampel-gruen { background: var(--ok); border-color: var(--ok); }
.budget-fill.ampel-gelb, .badge.ampel-gelb { background: var(--warn); border-color: var(--warn); }
.budget-fill.ampel-rot, .badge.ampel-rot { background: var(--err); border-color: var(--err); }
.budget-fill.sparziel { background: var(--gold); }
.badge.ampel-gruen, .badge.ampel-gelb, .badge.ampel-rot { color: #141005; }
.plain-list { margin: 0; padding-left: var(--sp-5); color: var(--text); }

@media (max-width: 640px) {
  .wrap { padding: var(--sp-3); }
  nav.main { width: 100%; }
  nav.main a { flex: 1 1 auto; justify-content: center; }
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr {
    display: block; border-bottom: 1px solid var(--line); padding: var(--sp-3);
  }
  table.stack-mobile td {
    display: flex; justify-content: space-between; gap: var(--sp-3);
    border: none; padding: var(--sp-1) 0;
  }
  table.stack-mobile td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-2); }
  table.stack-mobile td.num { text-align: right; }
}
