/* Layout: Zahlenband und Verlauf oben, dichte Zeilenliste (wie ein Kontobuch), Detailseite mit Reitern, Bearbeiten als Seitenfenster. */
:root {
  --bg: #F2F4F7;
  --surface: #FFFFFF;
  --fg: #16202B;
  --muted: #5A6978;
  --line: #D8DFE6;
  --hover: #F6F8FB;
  --accent: #2A4494;
  --accent-fg: #FFFFFF;
  --accent-soft: #E4E9F7;
  --good: #1B7A45;
  --good-soft: #E1F2E8;
  --warn: #9A5600;
  --warn-soft: #FBEBD2;
  --bad: #B3261E;
  --bad-soft: #FBE3E1;
  --bar-cost: #AAB6C3;
  --scrim: rgba(18, 28, 40, 0.45);
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E151D;
    --surface: #16202B;
    --fg: #E7EDF3;
    --muted: #95A4B3;
    --line: #2A3745;
    --hover: #1B2733;
    --accent: #93A8F2;
    --accent-fg: #0E151D;
    --accent-soft: #232F52;
    --good: #5FCB8B;
    --good-soft: #17352A;
    --warn: #F0B35A;
    --warn-soft: #3D2D12;
    --bad: #FF8A80;
    --bad-soft: #432120;
    --bar-cost: #53626F;
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E151D;
  --surface: #16202B;
  --fg: #E7EDF3;
  --muted: #95A4B3;
  --line: #2A3745;
  --hover: #1B2733;
  --accent: #93A8F2;
  --accent-fg: #0E151D;
  --accent-soft: #232F52;
  --good: #5FCB8B;
  --good-soft: #17352A;
  --warn: #F0B35A;
  --warn-soft: #3D2D12;
  --bad: #FF8A80;
  --bad-soft: #432120;
  --bar-cost: #53626F;
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  padding-block: calc(24px + env(safe-area-inset-top, 0px)) calc(32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app { max-width: 1080px; margin-inline: auto; display: flex; flex-direction: column; gap: 28px; }
#view { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.7rem, 4vw, 2.3rem); line-height: 1.1; margin: 0; text-wrap: balance; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h2.section { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; font-family: var(--font-body); }
.date { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; text-decoration: none; }
.back:hover { text-decoration: underline; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 14px; font-weight: 500; line-height: 1.2; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger.armed { background: var(--bad); color: var(--surface); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.fig { padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fig + .fig { border-left: 1px solid var(--line); }
.fig-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fig-value { font-family: var(--font-mono); font-size: clamp(1.1rem, 2.2vw, 1.45rem); font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fig-sub { font-size: 13px; color: var(--muted); }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.duo { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; margin-bottom: 12px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart { width: 100%; min-height: 220px; }
.chart svg { display: block; }
.chart text { fill: var(--muted); font-family: var(--font-body); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar-u { fill: var(--accent); }
.chart .bar-k { fill: var(--bar-cost); }
.chart-empty { color: var(--muted); font-size: 14px; margin: 0; padding: 40px 0; text-align: center; }

.next { display: flex; flex-direction: column; gap: 4px; }
.nx { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 8px 10px; margin-inline: -10px; border-radius: 6px; text-decoration: none; color: inherit; min-width: 0; }
.nx:hover { background: var(--hover); }
.nx-main { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.nx-main small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.empty-note { color: var(--muted); font-size: 14px; margin: 0; }

.badge { display: inline-block; border-radius: 4px; padding: 2px 7px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.search { flex: 1 1 240px; min-width: 0; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 12px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip .count { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-left: 4px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip[aria-pressed="true"] .count { color: inherit; opacity: 0.85; }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.sort select { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 8px 10px; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.head, .row { display: grid; grid-template-columns: minmax(200px, 2.2fr) 110px 104px 104px 112px minmax(150px, 1.3fr); gap: 12px; padding: 12px 16px; align-items: center; }
.head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--line); padding-block: 10px; }
.row { border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.c { min-width: 0; }
.c-um, .c-ko, .c-er, .h-num { text-align: right; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 14px; }
.name-link { font-weight: 600; font-size: 16px; color: var(--fg); text-decoration: none; overflow-wrap: anywhere; }
.name-link:hover { text-decoration: underline; }
.meta { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.bar { height: 5px; margin-top: 8px; }
.bar-i { display: flex; height: 100%; border-radius: 3px; overflow: hidden; }
.seg-cost { background: var(--bar-cost); }
.seg-profit { background: var(--good); }
.seg-bad { background: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.s-aktiv { color: var(--good); }
.s-aufbau, .s-interessent { color: var(--accent); }
.s-pause, .s-ehemalig { color: var(--muted); }
.fr-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.none { color: var(--muted); }
.state { padding: 36px 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.state h2 { margin: 0; font-family: var(--font-display); font-size: 1.25rem; }
.state p { margin: 0; color: var(--muted); max-width: 46ch; }

/* Detailseite */
.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 20px; }
.info dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.info dd { margin: 0; overflow-wrap: anywhere; }
.info .wide { grid-column: 1 / -1; white-space: pre-wrap; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-bottom: 2px solid transparent; background: none; padding: 10px 14px; margin-bottom: -1px; color: var(--muted); font-weight: 500; }
.tab:hover { color: var(--fg); }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab .count { font-family: var(--font-mono); font-size: 12px; margin-left: 4px; }
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form .field { flex: 1 1 150px; }
.inline-form .field.grow { flex: 2 1 220px; }
.inline-form .field.full { flex: 1 1 100%; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; min-width: 440px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.items { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item-main { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.item-main small { display: block; color: var(--muted); font-size: 13px; }
.item-actions { display: flex; gap: 8px; margin-left: auto; }
.task-check { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.done .item-main { text-decoration: line-through; color: var(--muted); }

.sheet-wrap { position: fixed; inset: 0; display: flex; justify-content: flex-end; z-index: 20; }
.scrim { position: absolute; inset: 0; background: var(--scrim); }
.sheet { position: relative; width: min(500px, 100%); height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); padding-left: 20px; padding-right: max(20px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; }
.sheet h2 { margin: 0; font-family: var(--font-display); font-size: 1.4rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.close { border: 0; background: none; font-size: 26px; line-height: 1; padding: 4px 8px; color: var(--muted); }
form { display: flex; flex-direction: column; gap: 14px; }
.inline-form { flex-direction: row; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 9px 10px; font-size: 16px; }
.field textarea { min-height: 84px; resize: vertical; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.hint { font-size: 13px; color: var(--muted); }
.err { color: var(--bad); font-size: 14px; min-height: 1em; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-top: 4px; }
.actions .spacer { flex: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 6px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
.toast.error { background: var(--bad); color: var(--surface); }

.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.theme-switch button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 13px; color: var(--muted); }
.theme-switch button + button { border-left: 1px solid var(--line); }
.theme-switch button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

@media (max-width: 860px) {
  .duo { grid-template-columns: minmax(0, 1fr); }
  .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fig:nth-child(3) { border-left: 0; }
  .fig:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .head { display: none; }
  .row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
  .c-name { grid-column: 1 / -1; }
  .c-status { grid-column: 1 / 2; }
  .c-fr { grid-column: 2 / -1; }
  .c-um, .c-ko, .c-er { text-align: left; }
  .c-um::before, .c-ko::before, .c-er::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-family: var(--font-body); }
}
@media (max-width: 480px) {
  .figs { grid-template-columns: minmax(0, 1fr); }
  .fig + .fig { border-left: 0; border-top: 1px solid var(--line); }
  .fig:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .two { grid-template-columns: minmax(0, 1fr); }
  .sheet { border-left: 0; }
  .tab { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
