/* Connectra, Buchhaltung. Helle Oberflaeche der Phase P11 (kb/plan.md).
   Struktur und Komponenten stammen aus P9/P10, die Flaeche ist ab hier hell
   nach Vorbild Finova: sehr heller Grund, reinweisse Karten mit grossem Radius
   und fast unsichtbarem Schatten, Pillen-Badges, gestrichelte Trennlinien.
   Marke fuehrt weiter: Fraunces und Plus Jakarta Sans unveraendert, Rose und
   Kirsche tragen jede Aktion und den aktiven Navigationseintrag. Das
   Periwinkle-Blau des Vorbilds wird NICHT uebernommen.

   Genau EINE Palette. Kein Umschalter, keine dunkle Variante, keine zweite
   Token-Menge (Owner-Entscheid 07.08.2026, ersetzt den P10-Entscheid).

   Serienfarben mit dem Validator des dataviz-Skills gegen die helle Flaeche
   geprueft: Lightness band, Chroma floor, CVD-Trennung (schlechtestes
   benachbartes Paar dE 9,4), Normalsicht-Untergrenze 24,6 und Kontrast
   >= 3:1 bestehen alle. Slot 3 wurde dafuer von #c98500 auf #bd7d00
   abgedunkelt, gleicher Farbton. Reihenfolge ist fest: Farbe haengt an der
   Serie, nicht an ihrem Rang.

   Randbedingung: CSP mit script-src 'none' und style-src 'self'. Kein JS,
   kein style-Attribut im Markup, keine externe Quelle. */

/* ---------- Schriften (selbst gehostet, relativ zur CSS-URL) ---------- */
@font-face { font-family: 'Plus Jakarta Sans'; src: url('../fonts/jakarta-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('../fonts/jakarta-500.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('../fonts/jakarta-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Plus Jakarta Sans'; src: url('../fonts/jakarta-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url('../fonts/fraunces-normal.woff2') format('woff2'); font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url('../fonts/fraunces-italic.woff2') format('woff2'); font-weight: 300 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'DM Serif Display'; src: url('../fonts/dm-serif-display-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  /* Der Browser rendert Datumsfelder und Auswahllisten sonst dunkel. */
  color-scheme: light;

  /* Flaechen, warmes Hellgrau mit Pflaumen-Hauch statt des kuehlen
     Grau-Lavendels des Vorbilds */
  --bg: #f1eef3;
  --bg-soft: #f7f5f8;
  --bg-sunk: #f4f1f5;
  --surface: #ffffff;
  --surface-2: #faf8fb;
  --sidebar: #ffffff;
  --surface-glass: rgba(241, 238, 243, 0.92);

  /* Text */
  --text: #1f1a24;
  --text-muted: #7d7387;
  --text-soft: #a69dae;
  /* De-Emphasis fuer Linien, die nur den Verlauf andeuten (Sparkline). Eine
     Stufe der bestehenden Grauskala, kein neuer Farbwert. */
  --deemphasis: var(--text-muted); /* 4,5:1 auf Weiss; --text-soft erreichte nur 2,6:1 (Review T7a) */

  /* Linien */
  --border: #ece8ef;
  --border-strong: #ddd6e1;

  /* Marke */
  --rose: #d93a5e;
  --rose-deep: #a11a30;
  --rose-bright: #c22950;  /* Rose als TEXT, nur diese Stufe traegt auf hell */
  --rose-bg: rgba(217, 58, 94, 0.10);
  --rose-glow: rgba(217, 58, 94, 0.30);
  --cherry: #8f1426;

  /* Zustaende, reserviert. Nie als Serienfarbe verwenden.
     Flaechen sind deckende Pastellstufen nach Finova-Muster, kein Alpha. */
  --ok: #1b8a48;         --ok-bg: #e7f6ec;   --ok-border: #c4e8d1;
  --warn: #a06c07;       --warn-bg: #fbf3df; --warn-border: #eddfb8;
  --info: #2a6fc2;       --info-bg: #e8f1fb; --info-border: #c6dcf3;
  --error: #ce3a30;      --error-bg: #fcebe9;--error-border: #f3cbc7;

  /* Serienfarben, feste Reihenfolge, validiert gegen --surface.
     Rose fuehrt (Marke), danach Blau, Bernstein, Violett, Petrol, Orange.
     Bewusst KEIN reines Gruen in der Reihe: Gruen ist als Zustandsfarbe
     ("Bezahlt") reserviert und waere in einer Grafik daneben mehrdeutig. */
  --serie-1: #d55181;
  --serie-2: #3987e5;
  --serie-3: #bd7d00;
  --serie-4: #9085e9;
  --serie-5: #199e70;
  --serie-6: #d95926;

  /* Schrift */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;

  /* Form: grosser Kartenradius und fast unsichtbarer, grossflaechiger
     Schatten sind die Traeger der Finova-Anmutung. */
  --radius-card: 18px; --radius-md: 10px; --radius-sm: 7px; --radius-pill: 999px;
  --shadow-xs: 0 2px 20px rgba(31, 26, 36, 0.05);
  --shadow-sm: 0 4px 28px rgba(31, 26, 36, 0.08);
  --shadow-lg: 0 24px 70px -30px rgba(31, 26, 36, 0.28);

  --sidebar-width: 252px;
}

/* ---------- Grundlage ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
.panel-body a, .card a, .empty a { color: var(--rose-bright); font-weight: 600; }
.panel-body a:hover, .card a:hover, .empty a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code { background: var(--bg-sunk); border-radius: 4px; padding: 1px 5px; font-size: 0.85em; }
::selection { background: var(--rose); color: #fff; }

:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Geruest ---------- */
.shell { display: flex; align-items: flex-start; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 20;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(140deg, var(--rose), var(--rose-deep));
  color: #fff;
  font-family: var(--font-serif); font-weight: 700; font-size: 19px;
  box-shadow: 0 8px 20px -10px var(--rose-glow);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14.5px; font-weight: 800; letter-spacing: -0.01em; }
.brand-text small { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.nav { flex: 1; overflow-y: auto; padding: 10px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  margin: 14px 10px 6px;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-soft);
}
.nav-group:first-child { margin-top: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  transition: background-color .18s ease, color .18s ease;
}
.nav-link:hover { background: var(--bg-soft); color: var(--text); }
/* Gefuellte Pille wie im Vorbild, nur in der Marken- statt der Vorbildfarbe. */
.nav-link.active {
  background: linear-gradient(120deg, var(--rose), var(--rose-deep));
  color: #fff; font-weight: 700;
  box-shadow: 0 10px 22px -14px var(--rose-glow);
}
.nav-icon { flex: none; width: 17px; height: 17px; opacity: 0.65; }
.nav-link:hover .nav-icon { opacity: 0.85; }
.nav-link.active .nav-icon { opacity: 1; }

.sidebar-foot { padding: 10px 14px; border-top: 1px solid var(--border); }

.content { flex: 1; min-width: 0; }

/* ---------- Seitenkopf ---------- */
.page-head {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 20px 30px 18px;
  background: var(--surface-glass);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}
.page-head-text { min-width: 0; }
.page-head h1 {
  font-family: var(--font-serif);
  font-size: 27px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15;
}
.page-sub { margin-top: 5px; font-size: 13px; color: var(--text-muted); }
.page-sub strong { color: var(--text); font-weight: 700; }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.container { max-width: 1400px; padding: 24px 30px 72px; }
/* Der Seitenkopf steht als erstes Kind im Inhalt, soll aber ueber die volle
   Breite laufen. Deshalb bricht er den Innenabstand des Containers auf. */
.container > .page-head:first-child { margin: -24px -30px 24px; }

/* ---------- Abschnitte und Karten ----------
   Finova-Anmutung: reinweisse Karte, kein sichtbarer Rahmen, die Trennung
   vom Grund kommt aus Kontrast und weichem Schatten. */
.panel { margin: 0 0 22px; }
.panel-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0 2px 10px; }
.panel-head h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.panel-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-muted); }
.panel-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.panel-body, .card {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}
.card { margin: 0 0 16px; }
.panel-flush > .panel-body { padding: 0; overflow: hidden; }
.panel-accent > .panel-body { border-color: var(--border); background: var(--surface-2); }
.scroll-x { overflow-x: auto; }

/* Freistehende Ueberschriften ausserhalb von panel() */
h2 { font-family: var(--font-serif); font-size: 17px; font-weight: 700; letter-spacing: -0.015em; margin: 24px 2px 10px; }
h3 { font-size: 12.5px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.01em; margin: 18px 2px 8px; }
/* Trennt gleichrangige Bloecke derselben Seite, z. B. je Creatorin. */
.section-title { font-size: 20px; margin: 36px 2px 4px; padding-top: 26px; border-top: 1px solid var(--border-strong); }
.section-title + .muted { margin: 0 2px 14px; display: block; }
.muted { color: var(--text-muted); font-weight: 400; font-size: 13px; }

/* ---------- Schaltflaechen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 700; font-size: 13px; line-height: 1.2;
  border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 9px 15px; cursor: pointer; white-space: nowrap;
  transition: box-shadow .18s ease, transform .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: #fff;
  box-shadow: 0 10px 24px -14px var(--rose-glow);
}
.btn-primary:hover { box-shadow: 0 16px 32px -14px var(--rose-glow); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--rose); color: var(--rose-bright); background: var(--rose-bg); }
.btn-danger { background: var(--surface); border-color: var(--border-strong); color: var(--error); }
.btn-danger:hover { border-color: var(--error); background: var(--error-bg); }
.btn-text {
  background: none; border: none; color: var(--text-muted);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 7px 10px; border-radius: var(--radius-md);
  transition: background-color .18s ease, color .18s ease;
}
.btn-text:hover { background: var(--bg-soft); color: var(--text); }
.btn-sm { font-size: 12px; padding: 5px 10px; border-radius: var(--radius-sm); }

/* ---------- Segmentierter Umschalter ---------- */
.segmented {
  display: inline-flex; gap: 2px;
  background: var(--bg-sunk); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 3px;
}
.segment {
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 700; color: var(--text-muted);
  transition: background-color .18s ease, color .18s ease;
}
.segment:hover { color: var(--text); }
.segment.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Marken ----------
   Pillen nach Finova-Muster: deckender Pastellgrund, farbiger Text,
   kein Rahmen. */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 700; line-height: 1.55;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-neutral { background: var(--bg-sunk); color: var(--text-muted); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-danger { background: var(--error-bg); color: var(--error); }

/* ---------- Anmeldung ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 78% 6%, rgba(217, 58, 94, 0.10), transparent 46%),
    radial-gradient(circle at 10% 94%, rgba(144, 133, 233, 0.08), transparent 44%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid transparent;
  border-radius: 20px; padding: 34px 30px 30px;
  box-shadow: var(--shadow-lg);
}
.login-title {
  font-family: var(--font-serif); font-size: 23px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--rose-bright); margin-bottom: 4px;
}
.login-hint { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }
.alert {
  background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error);
  font-size: 13px; font-weight: 600; border-radius: var(--radius-md);
  padding: 9px 12px; margin-bottom: 14px;
}
.login-card .btn { width: 100%; margin-top: 4px; }

/* ---------- Formulare ---------- */
form label { display: block; font-size: 12.5px; color: var(--text-muted); font-weight: 600; margin: 0 0 12px; }
form.inline label { display: inline-block; margin: 0 6px 4px 0; }
input, select {
  display: block; width: 100%; max-width: 26rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 8px 11px; font: inherit; font-size: 13.5px;
  margin-top: 5px; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
input::placeholder { color: var(--text-soft); }
input:hover, select:hover { border-color: #c9c1cf; }
input:focus, select:focus { border-color: var(--rose); background: var(--surface); box-shadow: 0 0 0 3px var(--rose-bg); }
input[type='date'] { max-width: 11rem; }
input[type='hidden'] { display: none; }

form.inline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 2px 8px 2px 0; vertical-align: middle; }
form.inline input, form.inline select, td input, td select {
  display: inline-block; width: auto; max-width: 11rem;
  font-size: 12px; padding: 4px 8px; margin: 0; vertical-align: middle;
}
td input[type='checkbox'] { width: auto; display: inline-block; margin: 0; accent-color: var(--rose); }

form.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 16px; align-items: end; }
form.form-grid label { margin: 0 0 10px; }
form.form-grid .btn { justify-self: start; margin-bottom: 10px; }

/* ---------- Tabellen ----------
   Finova-Anmutung: Spaltenkopf ohne Flaeche, darunter eine gestrichelte
   Trennlinie; die Zeilen selbst trennen sich ueber hauchzarte Linien und
   Abstand statt kraeftiger Borders. */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 10px 12px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-soft); font-weight: 800; text-align: left;
  background: transparent; border-bottom: 1px dashed var(--border-strong);
  white-space: nowrap;
}
td { padding: 11px 12px; border-top: 1px solid var(--bg-soft); vertical-align: top; }
tr:first-child td { border-top: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover, table tr:hover td { background: var(--surface-2); }
.panel-flush th:first-child, .panel-flush td:first-child { padding-left: 20px; }
.panel-flush th:last-child, .panel-flush td:last-child { padding-right: 20px; }

/* ---------- Hinweiszeilen ---------- */
.negativ { color: var(--error); font-weight: 700; }
.warnung, .hervorgehoben {
  display: block;
  border-radius: var(--radius-md);
  padding: 9px 13px; font-size: 13px; font-weight: 600;
  margin: 0 0 10px;
}
.warnung { background: var(--warn-bg); border: 1px solid var(--warn-border); border-left: 3px solid var(--warn); color: var(--warn); }
.warnung a { color: var(--rose-bright); text-decoration: underline; }
.hervorgehoben { background: var(--error-bg); border: 1px solid var(--error-border); border-left: 3px solid var(--error); color: var(--error); }
.drift { color: var(--warn); display: block; font-size: 11.5px; font-weight: 600; }

details.verlauf { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }
details.verlauf summary { cursor: pointer; font-weight: 600; }
details.verlauf ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Leerzustand ---------- */
.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-card);
  background: var(--bg-soft);
  padding: 34px 24px; text-align: center;
}
/* Steht der Leerzustand allein in einer Karte, traegt die Karte schon Rahmen
   und Flaeche. Dann keinen zweiten Rahmen zeichnen. */
.panel-body > .empty:only-child { border: none; background: transparent; padding: 20px 8px; }
.empty-title { font-family: var(--font-serif); font-size: 16px; font-weight: 700; }
.empty-text { margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.empty-action { margin-top: 14px; }

/* ---------- Monats-Navigation ---------- */
.month-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; }
.month-pill {
  padding: 6px 13px; border-radius: var(--radius-pill);
  font-size: 12.5px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-muted);
  transition: border-color .18s ease, color .18s ease, background-color .18s ease;
}
.month-pill:hover { border-color: var(--rose); color: var(--rose-bright); background: var(--rose-bg); text-decoration: none; }

/* ---------- Kennzahlen-Kacheln ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 0 0 22px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid transparent;
  border-radius: var(--radius-card); padding: 17px 19px 16px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s ease, transform .2s ease;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--rose), var(--rose-deep));
  opacity: 0; transition: opacity .2s ease;
}
.kpi:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kpi:hover::after { opacity: 1; }
.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-soft); font-weight: 800; }
.kpi-value {
  font-family: var(--font-serif); font-size: 26px; font-weight: 700;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.22;
}
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-arrow { font-size: 11px; }
.kpi-hint { font-size: 11.5px; color: var(--text-soft); }
.delta-plus { color: var(--ok); }
.delta-minus { color: var(--error); }

/* ---------- Grafiken (server-gerendertes SVG, kein JS) ---------- */
.chart {
  margin: 0 0 14px;
  background: var(--surface); border: 1px solid transparent;
  border-radius: var(--radius-card); padding: 16px 18px 14px;
  box-shadow: var(--shadow-xs);
}
.chart figcaption { font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 12px; letter-spacing: -0.005em; }
.chart-canvas { overflow-x: auto; }
/* Zwei Grafiken nebeneinander, sobald der Schirm es hergibt. */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); gap: 14px; margin: 0 0 14px; }
.chart-grid .chart { margin: 0; }
/* Das SVG skaliert auf die halbe Spaltenbreite herunter und nimmt die
   Beschriftung mit. Die Schriftgroesse wird deshalb im Quellmassstab
   angehoben, damit sie gerendert wieder lesbar ist. */
.chart-grid .axis-label { font-size: 14px; }
.chart svg { display: block; width: 100%; min-width: 420px; height: auto; }

/* Hilfslinien zurueckhaltend und gestrichelt (Vorbild-Anmutung). */
.gridline { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.zeroline { stroke: var(--border-strong); stroke-width: 1.5; }
.axis-label { font-family: var(--font-sans); font-size: 10px; fill: var(--text-soft); font-variant-numeric: tabular-nums; font-weight: 600; }
/* Flaechenfarbene Kontur trennt gestapelte Segmente um zwei Pixel, ohne die
   Geometrie in der Domain anzufassen. */
.bar { rx: 3; stroke: var(--surface); stroke-width: 1.5; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 13px 0 0; padding: 0; font-size: 12px; color: var(--text-muted); font-weight: 600; }
/* Getoente Zeile mit farbiger Kante, wie die Betragszeilen im Vorbild. */
.legend li {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 3px 11px 3px 8px;
}
.swatch { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* Sechs Serienfarben, feste Reihenfolge, danach wiederholend. Die Kante der
   Legendenzeile traegt dieselbe Farbe wie das Kaestchen. */
.serie-1 { fill: var(--serie-1); background: var(--serie-1); }
.serie-2 { fill: var(--serie-2); background: var(--serie-2); }
.serie-3 { fill: var(--serie-3); background: var(--serie-3); }
.serie-4 { fill: var(--serie-4); background: var(--serie-4); }
.serie-5 { fill: var(--serie-5); background: var(--serie-5); }
.serie-6 { fill: var(--serie-6); background: var(--serie-6); }
.legend li:has(.serie-1) { border-left-color: var(--serie-1); background: color-mix(in srgb, var(--serie-1) 10%, var(--surface)); }
.legend li:has(.serie-2) { border-left-color: var(--serie-2); background: color-mix(in srgb, var(--serie-2) 10%, var(--surface)); }
.legend li:has(.serie-3) { border-left-color: var(--serie-3); background: color-mix(in srgb, var(--serie-3) 10%, var(--surface)); }
.legend li:has(.serie-4) { border-left-color: var(--serie-4); background: color-mix(in srgb, var(--serie-4) 10%, var(--surface)); }
.legend li:has(.serie-5) { border-left-color: var(--serie-5); background: color-mix(in srgb, var(--serie-5) 10%, var(--surface)); }
.legend li:has(.serie-6) { border-left-color: var(--serie-6); background: color-mix(in srgb, var(--serie-6) 10%, var(--surface)); }

/* Zustandsfarben der Zahlstatus-Leiste. Reserviert, nie eine Serienfarbe. */
.zustand-offen { fill: var(--warn); background: var(--warn); }
.zustand-gestellt { fill: var(--info); background: var(--info); }
.zustand-bezahlt { fill: var(--ok); background: var(--ok); }
.legend li:has(.zustand-offen) { border-left-color: var(--warn); background: var(--warn-bg); }
.legend li:has(.zustand-gestellt) { border-left-color: var(--info); background: var(--info-bg); }
.legend li:has(.zustand-bezahlt) { border-left-color: var(--ok); background: var(--ok-bg); }

/* Sammelsegment "Uebrige" des Rings: keine Identitaet, deshalb neutral und
   nie eine Serienfarbe. */
.serie-rest { fill: var(--text-soft); background: var(--text-soft); }
.legend li:has(.serie-rest) { border-left-color: var(--text-soft); background: var(--bg-soft); }

/* ---------- Ring (P13) ----------
   Gestrichene Boegen auf dem Mittelkreis; die Farbe liegt deshalb auf
   stroke, nicht auf fill. Die Luecke zwischen zwei Segmenten ist eine
   Linie in Kartenfarbe, wie die Kontur gestapelter Balken. Kein 3D, kein
   Schatten, kein Verlauf. */
.ring-body { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.chart .ring-svg { flex: none; width: auto; min-width: 0; max-width: 100%; height: auto; }
.ring .segment { fill: none; stroke-linecap: butt; }
.ring .serie-1 { stroke: var(--serie-1); }
.ring .serie-2 { stroke: var(--serie-2); }
.ring .serie-3 { stroke: var(--serie-3); }
.ring .serie-4 { stroke: var(--serie-4); }
.ring .serie-5 { stroke: var(--serie-5); }
.ring .serie-6 { stroke: var(--serie-6); }
.ring .serie-rest { stroke: var(--text-soft); }
.ring .gap { stroke: var(--surface); stroke-width: 2; }
/* Legende mit Wert und Anteil: Text in Textfarbe, Farbe nur im Swatch. */
.legend-ring { flex: 1 1 200px; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.legend-ring li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; }
.legend-ring .legend-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-ring .legend-value { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend-ring .legend-share { color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.6em; text-align: right; white-space: nowrap; }

/* ---------- Sparkline (P13) ----------
   Keine Achsen, keine Gitterlinien. 2px Linie in De-Emphasis, der Endpunkt
   als Marker in der Akzentfarbe mit 2px Flaechenring. */
.spark { display: block; overflow: visible; flex: none; }
.spark .line { fill: none; stroke: var(--deemphasis); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .dot { fill: var(--deemphasis); }
.spark .end { fill: var(--serie-1); stroke: var(--surface); stroke-width: 2; } /* Daten-Rosé, nicht der Aktionsakzent */
.spark-leer { font-size: 11.5px; }

/* ---------- Kachel mit Sparkline (P13) ----------
   Label in Satzform, Wert in der Textschrift semibold mit proportionalen
   Ziffern (tabular-nums nur in Spalten und an Achsen), Fraunces bleibt den
   Seitentiteln vorbehalten. */
.kpi-spark .kpi-label { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.kpi-spark .kpi-value {
  /* Gleiche Wertschrift wie kpiTile (P11, Fraunces): eine Kachelsprache je Seite. */
  font-variant-numeric: normal;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.kpi-unit { font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; }
/* Betrag bricht nie im Wort um; die Vergleichsperiode steht auf eigener Zeile. */
.kpi-spark .kpi-delta { display: flex; flex-wrap: wrap; white-space: nowrap; }
.kpi-delta-label { flex-basis: 100%; font-weight: 500; color: var(--text-muted); white-space: normal; }
.delta-neutral { color: var(--text-muted); }
.kpi-trend { display: flex; align-items: center; gap: 10px; margin-top: 8px; min-width: 0; }
.kpi-range { font-size: 11.5px; color: var(--text-soft); font-weight: 500; }

.source-badge { font-weight: 600; }

/* ---------- Maloum-Seite (P13, T7b) ----------
   Quellenmarken als Zeile, Monatsstreifen unter dem Balken, Blocker-Liste im
   Festschreibe-Abschnitt, Hilfetext unter Formularfeldern. Keine neue Farbe. */
.quellen { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 18px; }
.panel .quellen, .card .quellen { margin: 14px 0 6px; }
.monatsstreifen { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.monatsstreifen .month-pill.active { border-color: var(--rose); color: var(--rose-bright); background: var(--rose-bg); }
.monatsstreifen .badge { margin-left: 4px; }
ul.blocker { margin: 0 0 12px 18px; padding: 0; font-size: 13px; color: var(--warn); }
ul.blocker li { margin: 2px 0; }
.hilfe { grid-column: 1 / -1; margin: -4px 0 12px; font-size: 12px; color: var(--text-muted); }
.drift { white-space: nowrap; }
/* Maloum, Spalte "Aktuell laut Ledger": genau zwei Zeilen (Verkaeufe, Provision),
   jede am Stueck; sonst bricht die Zelle in der engen Tabelle zeichenweise um (T8). */
td.live-stand .live-zeile { display: block; white-space: nowrap; }

.offener-punkt {
  display: inline-flex; align-items: center;
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn);
  border-radius: var(--radius-pill); padding: 2px 10px;
  font-size: 11.5px; font-weight: 700; margin: 2px 4px 2px 0;
}

/* ---------- Zeilenaktionen eingeklappt ---------- */
details.zeilen-aktionen { display: inline-block; }
details.zeilen-aktionen summary {
  cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-muted);
  list-style: none; padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .18s ease, color .18s ease;
}
details.zeilen-aktionen summary::-webkit-details-marker { display: none; }
details.zeilen-aktionen summary:hover { border-color: var(--rose); color: var(--rose-bright); }
details.zeilen-aktionen[open] summary { margin-bottom: 8px; }

/* ---------- Accounts und Mitglieder (P13, T7c) ----------
   Karten-Raster: eine Spalte, ab 1100 px zwei; jede Karte ist ein panel ohne
   Aussenabstand. Laufzeit in Tabellenziffern. Matrix: zwei Waehrungszeilen je
   Zelle (USD oben, EUR darunter in Zweitfarbe), Summenzeile und Summenspalte
   abgesetzt, Einzelposten kompakt in <details>. Keine neue Farbe. */
.karten-raster { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 0 0 22px; }
.karten-raster > .panel { margin: 0; min-width: 0; }
.karten-raster .kpi-grid { margin-bottom: 14px; }
.karten-raster .chart { margin: 0 0 14px; box-shadow: none; border-color: var(--border); }
@media (min-width: 1100px) {
  .karten-raster { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.laufzeit { font-variant-numeric: tabular-nums; white-space: nowrap; }

.matrix { font-variant-numeric: tabular-nums; }
.matrix th[scope="row"] {
  text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 700;
  color: var(--text); white-space: nowrap; border-top: 1px solid var(--bg-soft); border-bottom: none;
}
.matrix tr:first-child th[scope="row"] { border-top: none; }
.matrix th[scope="row"] .badge { margin-left: 4px; }
.matrix td.num { white-space: normal; }
.matrix .zelle-usd, .matrix .zelle-eur { display: block; white-space: nowrap; }
.matrix .zelle-eur { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.matrix .matrix-leer { color: var(--text-soft); }
.matrix .matrix-summe { border-left: 1px dashed var(--border-strong); font-weight: 700; }
.matrix tr.summen th, .matrix tr.summen td {
  border-top: 2px solid var(--border-strong); background: var(--surface-2); font-weight: 700;
}
.matrix tr.summen .zelle-eur { font-weight: 600; }
details.posten { margin-top: 4px; font-size: 11.5px; color: var(--text-muted); text-align: left; }
details.posten summary {
  cursor: pointer; list-style: none; font-weight: 700; color: var(--rose-bright); white-space: nowrap;
}
details.posten summary::-webkit-details-marker { display: none; }
details.posten summary:hover { text-decoration: underline; }
details.posten ul { margin: 4px 0 0; padding: 0; list-style: none; }
details.posten li { margin: 3px 0; white-space: nowrap; }
details.posten .badge { margin-left: 4px; }

/* ---------- Bildlaufleisten ---------- */
.nav::-webkit-scrollbar, .scroll-x::-webkit-scrollbar, .chart-canvas::-webkit-scrollbar { height: 8px; width: 8px; }
.nav::-webkit-scrollbar-thumb, .scroll-x::-webkit-scrollbar-thumb, .chart-canvas::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: var(--radius-pill);
}
.nav::-webkit-scrollbar-track, .scroll-x::-webkit-scrollbar-track, .chart-canvas::-webkit-scrollbar-track { background: transparent; }

/* ---------- Schmale Schirme ----------
   Ohne JavaScript gibt es kein Ausklappmenue. Die Seitenleiste wird deshalb
   zu einer waagerecht scrollbaren Leiste ueber dem Inhalt. */
@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: 100%; flex: none; height: auto;
    border-right: none; border-bottom: 1px solid var(--border);
    flex-direction: row; align-items: center; gap: 8px;
    padding-right: 8px;
  }
  .brand { border-bottom: none; padding: 12px 14px; flex: none; }
  .nav { flex-direction: row; align-items: center; gap: 4px; padding: 8px 0; overflow-x: auto; }
  .nav-group { display: none; }
  .nav-link { white-space: nowrap; }
  .sidebar-foot { border-top: none; padding: 8px 4px; margin-left: auto; flex: none; }
  .content { width: 100%; }
  /* Die Leiste steht hier ueber dem Inhalt und scrollt mit. Ein zusaetzlich
     klebender Seitenkopf wuerde sie ohne JavaScript ueberdecken. */
  .page-head { position: static; padding: 14px 16px 12px; }
  .page-head h1 { font-size: 22px; }
  .container { padding: 18px 16px 56px; }
  .container > .page-head:first-child { margin: -18px -16px 18px; }
  .panel-actions, .page-actions { margin-left: 0; }
}

/* ---------- Druck ----------
   Die Flaeche ist bereits drucknah hell; der Zweig blendet Navigation und
   Aktionen aus und ersetzt Schatten durch schlichte Rahmen. */
/* ---------- P15 Live-Seite ----------
   Filterzeile, Quellen-Ampel, Insights, Linie mit Hover-Spalten und die
   gestapelte Umsatzarten-Leiste. Keine neue Farbe: alles nutzt die sechs
   Serienfarben und die Zustandsfarben von oben. Tooltips laufen ueber
   :hover und :focus-within, damit die CSP script-src 'none' bleiben kann. */

.filterzeile { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 0 0 18px; }
.filter-feld { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.export-links { display: flex; flex-wrap: wrap; gap: 8px; }

.quellen { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.quellen .quelle { display: flex; align-items: center; gap: 8px; }
.ampel-grund { color: var(--text-muted); font-size: 13px; }

.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.insights .insight { border-left: 3px solid var(--border-strong); padding: 6px 12px; border-radius: var(--radius-sm); background: var(--bg-soft); }
.insights .insight-gut { border-left-color: var(--ok); background: var(--ok-bg); }
.insights .insight-schlecht { border-left-color: var(--warn); background: var(--warn-bg); }

.hinweise { margin: 12px 0 0; padding-left: 18px; color: var(--text-muted); font-size: 13px; }
.fussnote { margin: 10px 0 0; color: var(--text-muted); font-size: 12px; }

.tagestabelle { margin: 16px 0 0; }
.tagestabelle summary { cursor: pointer; font-weight: 600; }
.tagestabelle table, .chatter { width: 100%; border-collapse: collapse; margin: 10px 0 0; }
.tagestabelle td, .chatter td { font-variant-numeric: tabular-nums; }

/* Linie: die Pfade tragen nie eine Flaeche, die Serienfarbe faerbt den Strich. */
.chart-line .line, .chart-line .line-open, .chart-line .line-compare { fill: none; stroke-width: 2; }
.chart-line .line-open { stroke-dasharray: 3 4; }
.chart-line .line-compare { stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart-line .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.chart-line .zero { stroke: var(--border-strong); stroke-width: 1.5; }
.chart-line .axis-x, .chart-line .axis-y { font-family: var(--font-sans); font-size: 10px; fill: var(--text-soft); font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-line .line-end-label { font-family: var(--font-sans); font-size: 11px; font-weight: 700; }
.chart-line svg { overflow: visible; }
.chart-line .serie-1 { stroke: var(--serie-1); }
.chart-line .serie-2 { stroke: var(--serie-2); }
.chart-line .serie-3 { stroke: var(--serie-3); }
.chart-line .serie-4 { stroke: var(--serie-4); }
.chart-line .serie-5 { stroke: var(--serie-5); }
.chart-line .serie-6 { stroke: var(--serie-6); }
.chart-line .line-dot { stroke: var(--surface); stroke-width: 1; }
.chart-line .line-end-label.serie-1, .chart-line .line-dot.serie-1 { fill: var(--serie-1); }
.chart-line .line-end-label.serie-2, .chart-line .line-dot.serie-2 { fill: var(--serie-2); }
.chart-line .line-end-label.serie-3, .chart-line .line-dot.serie-3 { fill: var(--serie-3); }
.chart-line .line-end-label.serie-4, .chart-line .line-dot.serie-4 { fill: var(--serie-4); }
.chart-line .line-end-label.serie-5, .chart-line .line-dot.serie-5 { fill: var(--serie-5); }
.chart-line .line-end-label.serie-6, .chart-line .line-dot.serie-6 { fill: var(--serie-6); }

/* Hover-Spalte: das Rechteck faengt den Zeiger, das Fadenkreuz erscheint. */
.chart-line .hover-col .crosshair { stroke: var(--border-strong); stroke-width: 1; opacity: 0; }
.chart-line .hover-col:hover .crosshair, .chart-line .hover-col:focus-within .crosshair, .chart-line .hover-col:focus .crosshair { opacity: 1; }
.chart-line .hover-col:focus { outline: none; }

/* Tabellen-Zwilling: dieselben Zahlen ohne Zeigegeraet, unter der Grafik. */
.chart-twin { width: 100%; border-collapse: collapse; margin: 14px 0 0; font-size: 13px; }
.chart-twin caption { text-align: left; color: var(--text-muted); font-size: 12px; padding: 0 0 6px; }
.chart-twin th, .chart-twin td { border-bottom: 1px solid var(--border); padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.chart-twin th[scope="row"], .chart-twin thead th:first-child { text-align: left; }

.chart-stack .bar-label { font-family: var(--font-sans); font-size: 11px; font-weight: 700; fill: var(--surface); }

.glossar { margin: 0; }
.glossar dt { font-weight: 700; margin: 14px 0 4px; }
.glossar dt:first-child { margin-top: 0; }
.glossar dd { margin: 0; color: var(--text-muted); }

@media print {
  .sidebar, .page-actions, .panel-actions, .month-nav, details.zeilen-aktionen { display: none; }
  body { background: #fff; color: #1a1a1a; }
  .page-head { position: static; backdrop-filter: none; background: #fff; padding-left: 0; }
  .container { padding: 0; }
  .panel-body, .card, .kpi, .chart { background: #fff; border-color: #ccc; box-shadow: none; }
  th { color: #444; }
  .axis-label { fill: #555; }
  .bar { stroke: #fff; }
  /* Ring und Sparkline bleiben ohne Farbe lesbar: Werte und Anteile stehen
     in der Legende und im Titel, die Marken werden schwarz. */
  .ring .gap { stroke: #fff; }
  .ring .serie-rest { stroke: #999; }
  .spark .line { stroke: #555; }
  .spark .dot, .spark .end { fill: #1a1a1a; }
  .spark .end { stroke: #fff; }
  .legend-ring li { background: #fff; border-color: #ccc; }
  /* Accounts und Mitglieder: Karten untereinander ohne Seitenumbruch in der
     Karte. Geschlossene Posten bleiben geschlossen (ohne JavaScript kann
     der Druck sie nicht oeffnen); die Zellensummen stehen auch so. */
  .karten-raster { display: block; }
  .karten-raster > .panel { margin: 0 0 14px; break-inside: avoid; }
  .matrix tr.summen th, .matrix tr.summen td { background: #fff; border-top-color: #444; }
}

/* ---------- Bewegungsempfindlichkeit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
