/* =====================================================================
   Dashboard (Reiter „Dashboard“): Gestaltung im Stil der Vorlage Sightline in XB-Farben, übernommen aus dem Dashboard-Projekt (seite.py, _css und FARBEN).
   Alles ist auf .dashboard begrenzt und mit d- benannt, damit der Rest der App unberührt bleibt. Karte, Linie, Text und gedämpfter Text kommen aus den
   Farben der App (hell und dunkel wie überall); Akzent, Ampel, Ringfarben und Balken aus dem Dashboard (Kontrast mindestens 4,5 zu 1).
   Keine Seitenleiste in der App: Der Reiter steht in der Navigation oben, die Budgetkarte liegt unten (am Handy wie am Rechner).
   Breiten und Lagen der Grafiken stehen in SVG-Attributen, hier nur Farben und Abstände. Kein style-Attribut.
   ===================================================================== */

/* Farben hell (Standard) */
.dashboard {
  --d-akzent: #a64200; --d-gruen: #176b30; --d-gelb: #7a5000; --d-rot: #b3261e;
  --d-gruen-grund: #e8f6ee; --d-gelb-grund: #fdf3dc; --d-rot-grund: #fdecea; --d-akzent-grund: #fff0e6; --d-akzent-rand: #f7cfb3;
  --d-balken: #e8590c;
  --d-r0: #e8590c; --d-r1: #3e5bf6; --d-r2: #12b76a; --d-r3: #f59e0b; --d-r4: #8b5cf6; --d-r5: #98a2b3;
  --d-a: 16px; --d-innen: 20px; --d-rund: 16px; --d-ph: 160px;
  --d-schatten: 0 1px 2px rgba(16, 24, 40, .04);
}
/* Farben dunkel: wie die App (Systemeinstellung, sofern nicht ausdrücklich hell gewählt; oder ausdrücklich dunkel) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .dashboard {
    --d-akzent: #ffb066; --d-gruen: #63d68f; --d-gelb: #f2c24f; --d-rot: #ff8f86;
    --d-gruen-grund: #15271d; --d-gelb-grund: #2a2414; --d-rot-grund: #2e1c1b; --d-akzent-grund: #3a2415; --d-akzent-rand: #6b4325;
    --d-balken: #ff8a3d;
    --d-r0: #ff8a3d; --d-r1: #7b93ff; --d-r2: #3ddc97; --d-r3: #f7b955; --d-r4: #b18cff; --d-r5: #8a94a6;
    --d-schatten: none;
  }
}
:root[data-theme='dark'] .dashboard {
  --d-akzent: #ffb066; --d-gruen: #63d68f; --d-gelb: #f2c24f; --d-rot: #ff8f86;
  --d-gruen-grund: #15271d; --d-gelb-grund: #2a2414; --d-rot-grund: #2e1c1b; --d-akzent-grund: #3a2415; --d-akzent-rand: #6b4325;
  --d-balken: #ff8a3d;
  --d-r0: #ff8a3d; --d-r1: #7b93ff; --d-r2: #3ddc97; --d-r3: #f7b955; --d-r4: #b18cff; --d-r5: #8a94a6;
  --d-schatten: none;
}
@media (min-width: 760px) { .dashboard { --d-a: 20px; --d-innen: 24px; --d-ph: 220px; } }
@media (min-width: 1100px) { .dashboard { --d-a: 24px; } }

.dashboard { display: flex; flex-direction: column; gap: var(--d-a); padding: 8px 0 40px; font-variant-numeric: tabular-nums; color: var(--text); min-width: 0; }
.dashboard > * { min-width: 0; }
.dashboard p { margin: 0; }
.dashboard h1 { font-size: 26px; line-height: 1.15; font-weight: 650; letter-spacing: -.02em; margin: 2px 0 0; }
.dashboard h2 { font-size: 15px; line-height: 1.3; font-weight: 600; color: var(--muted); margin: 0; }
.dashboard h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.dashboard svg { display: block; max-width: 100%; }
.dashboard button:focus-visible, .dashboard summary:focus-visible { outline: 2px solid var(--d-akzent); outline-offset: 2px; }
@media (min-width: 760px) { .dashboard h1 { font-size: 32px; } }

/* Karten */
.dashboard section, .dashboard article, .dashboard details.d-system-detail, .dashboard .d-fehler-abschnitt {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--d-rund); padding: var(--d-innen); margin: 0; box-shadow: var(--d-schatten); min-width: 0; }
.dashboard .d-ampel { background: none; border: 0; padding: 0; box-shadow: none; }
.d-karten-kopf { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-width: 0; }
.d-karten-kopf h2 { flex: 1; min-width: 0; }
.d-karten-kopf--kachel { margin-bottom: 4px; flex-wrap: wrap; row-gap: 12px; }
.d-karten-kopf--kachel .d-symbol-kasten { order: 1; } .d-karten-kopf--kachel .d-zeitraum { order: 2; margin-left: auto; }
.d-karten-kopf--kachel h2 { order: 3; flex: 1 1 100%; }
.d-zeitraum { font-size: 13px; color: var(--muted); white-space: nowrap; }
.d-symbol-kasten { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--d-akzent-grund); color: var(--d-akzent); }
.d-symbol-kasten svg { width: 18px; height: 18px; }

/* Kopf: Brotkrume, Begrüßung, Stand, Ampel, Zeitraumwahl */
.d-kopf { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.d-kopf-zeile { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; }
.d-brotkrume { font-size: 13px; color: var(--muted); }
.d-kopf-rechts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; position: relative; min-width: 0; }
.d-stand { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; line-height: 42px; white-space: nowrap; flex: none; }
.d-stand--alt { color: var(--d-rot); background: var(--d-rot-grund); border-color: var(--d-rot); }
.d-zr { display: flex; gap: 2px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; width: 100%; }
.d-zr-knopf { flex: 1 1 0; min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.d-zr-knopf:hover { color: var(--text); }
.d-zr-knopf[aria-pressed='true'] { background: var(--d-akzent-grund); border-color: var(--d-akzent-rand); color: var(--d-akzent); font-weight: 650; }
.d-ampel { position: relative; }
.d-ampel details { padding: 0; }
.d-ampel summary { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 650; list-style: none; padding: 0 14px 0 16px; border-radius: 999px; border: 1px solid; font-size: 14px; }
.d-ampel summary::-webkit-details-marker { display: none; }
.d-ampel summary::after { content: '›'; margin-left: 2px; font-size: 1.2rem; line-height: 1; transform: rotate(90deg); transition: transform .15s; }
.d-ampel details[open] > summary::after { transform: rotate(-90deg); }
.d-ampel--gruen summary { background: var(--d-gruen-grund); color: var(--d-gruen); border-color: color-mix(in srgb, var(--d-gruen) 35%, transparent); }
.d-ampel--gelb summary { background: var(--d-gelb-grund); color: var(--d-gelb); border-color: color-mix(in srgb, var(--d-gelb) 35%, transparent); }
.d-ampel--rot summary { background: var(--d-rot-grund); color: var(--d-rot); border-color: color-mix(in srgb, var(--d-rot) 35%, transparent); }
.d-symbol { font-size: 1rem; line-height: 1; }
.d-ampel-panel { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line); border-radius: var(--d-rund); padding: var(--d-innen); box-shadow: 0 12px 32px rgba(16, 24, 40, .14); }
.d-ampel-panel > .d-klein { margin-bottom: 12px; }
.d-warnung { border: 1px solid var(--d-rot); border-left-width: 5px; color: var(--d-rot); background: var(--d-rot-grund); border-radius: var(--d-rund); padding: 14px var(--d-innen); font-weight: 650; }
.d-warnung[hidden] { display: none; }

ul.d-liste { list-style: none; margin: 0; padding: 0; }
ul.d-liste li { padding: 12px 0; border-top: 1px solid var(--line); }
ul.d-liste li:first-child { border-top: 0; padding-top: 0; }
ul.d-liste li:last-child { padding-bottom: 0; }
.d-teil--gruen .d-st { color: var(--d-gruen); } .d-teil--gelb .d-st { color: var(--d-gelb); } .d-teil--rot .d-st { color: var(--d-rot); }
.d-st { font-weight: 650; }

/* Kennzahl-Karten */
.d-inhalt { display: flex; flex-direction: column; gap: var(--d-a); min-width: 0; }
.d-kacheln { display: grid; grid-template-columns: 1fr; gap: var(--d-a); }
.d-kachel { display: flex; flex-direction: column; gap: 8px; }
.d-gross { font-size: 34px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.d-klein, .d-hinweis { color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.d-hinweis { margin-top: 16px; font-size: 13px; }
.d-hinweis-quelle { color: var(--d-gelb); font-weight: 650; font-size: 13px; }
.d-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.d-vs { color: var(--muted); font-size: 13px; }
.d-badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 650; line-height: 20px; white-space: nowrap; }
.d-badge--gut { background: var(--d-gruen-grund); color: var(--d-gruen); }
.d-badge--schlecht { background: var(--d-rot-grund); color: var(--d-rot); }
.d-badge--neutral { background: var(--bg-2); color: var(--muted); }
svg.d-linie { width: 100%; height: 44px; color: var(--d-balken); margin-top: auto; }
svg.d-linie polyline, svg.d-plot polyline { stroke: var(--d-balken); }
.d-s0 { stop-color: var(--d-balken); stop-opacity: .28; } .d-s1 { stop-color: var(--d-balken); stop-opacity: 0; }
svg.d-balken { width: 100%; height: 8px; }
.d-kachel svg.d-balken { margin-top: auto; }
.dashboard svg .d-bg { fill: var(--bg-2); } .dashboard svg .d-fg { fill: var(--d-balken); } .dashboard svg .d-marke { stroke: var(--text); stroke-width: 1.5; }

/* Flächendiagramm: Achsen als Text außerhalb der Grafik, damit die Schrift nie gestreckt wird */
.d-diagramm-karte .d-kennzahl { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 16px; }
.d-legende-pille { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: 13px; color: var(--text); }
.d-diagramm { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; }
.d-y-achse { display: flex; flex-direction: column; justify-content: space-between; height: calc(var(--d-ph) + 12px); margin: -6px 0; font-size: 12px; line-height: 12px; color: var(--muted); text-align: right; }
.d-x-achse { grid-column: 2; display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--muted); }
svg.d-plot { width: 100%; height: var(--d-ph); overflow: visible; }
svg.d-plot .d-gitter, svg.d-plot .d-nullachse { stroke: var(--line); }
svg.d-plot .d-einzelpunkt { stroke: var(--d-balken); }

/* Ring und Legende */
.d-ring-box { position: relative; width: 190px; max-width: 100%; aspect-ratio: 1; margin: 4px auto 20px; }
.d-ring-box svg { width: 100%; height: 100%; }
.d-ring-mitte { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.d-ring-mitte .d-gross { font-size: 30px; }
.d-ring-grund { stroke: var(--bg-2); }
.d-f0 { --d-c: var(--d-r0); } .d-f1 { --d-c: var(--d-r1); } .d-f2 { --d-c: var(--d-r2); } .d-f3 { --d-c: var(--d-r3); } .d-f4 { --d-c: var(--d-r4); } .d-f5 { --d-c: var(--d-r5); }
.d-ring { stroke: var(--d-c); }
.d-punkt { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--d-c, var(--d-balken)); }
ul.d-legende { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
ul.d-legende li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; }
ul.d-legende .d-name { font-weight: 500; overflow-wrap: anywhere; }
ul.d-legende .d-proz { color: var(--muted); min-width: 3.4em; text-align: right; }
ul.d-legende .d-anz { font-weight: 650; min-width: 2.2em; text-align: right; }

/* Trichter */
.d-zeile { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px 12px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); }
.d-zeile svg.d-balken { height: 10px; }
.d-trichter .d-zeile:first-of-type { border-top: 0; padding-top: 0; }
.d-zeile .d-name { font-weight: 600; }
.d-zeile .d-werte { color: var(--muted); font-size: 13px; line-height: 1.35; }
.d-zeile .d-werte b { color: var(--text); font-size: 15px; }
.d-quote { display: flex; flex-direction: column; gap: 6px; }
.d-quote .d-karten-kopf { margin-bottom: 8px; }
.d-quote svg.d-balken { margin-top: 10px; height: 10px; }
@media (min-width: 760px) { .d-zeile { grid-template-columns: minmax(0, 1fr) auto; } .d-zeile .d-werte { text-align: right; } .d-zeile svg.d-balken { grid-column: 1 / -1; } }

/* Tabellen */
.d-tabelle { overflow-x: auto; margin: 0 calc(var(--d-innen) * -1); padding: 0 var(--d-innen); }
.dashboard table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dashboard th, .dashboard td { text-align: left; padding: 14px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.dashboard th:first-child, .dashboard td:first-child { padding-left: 0; }
.dashboard th:last-child, .dashboard td:last-child { padding-right: 0; }
.dashboard thead th { border-top: 0; padding-top: 0; padding-bottom: 10px; font-size: 12px; font-weight: 500; color: var(--muted); }
.dashboard th { color: var(--muted); }
.dashboard tbody th { color: var(--text); font-weight: 600; }
table.d-zahlen { min-width: 560px; }
table.d-zahlen th:not(:first-child), table.d-zahlen td { text-align: right; }
.d-unterteil { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.d-technik { color: var(--muted); font-size: 12.5px; }
.d-system-detail table td { padding-left: 0; }
.d-system-detail td:first-child { white-space: nowrap; padding-right: 16px; }
.d-system-detail summary { min-height: 44px; display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 650; list-style: none; }
.d-system-detail summary::-webkit-details-marker { display: none; }
.d-system-detail summary::after { content: '›'; margin-left: auto; font-size: 1.4rem; line-height: 1; color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
.d-system-detail[open] > summary::after { transform: rotate(-90deg); }

/* Partnerportal als kleine Zahlenfelder */
ul.d-status { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
ul.d-status li { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; }
ul.d-status .d-lbl { color: var(--muted); font-size: 13px; }
ul.d-status .d-n { font-size: 22px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; }

/* Reihen */
.d-reihe, .d-zweispaltig, .d-paar { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--d-a); }
@media (min-width: 760px) {
  .d-zr { width: auto; align-self: flex-start; } .d-zr-knopf { flex: 0 0 auto; min-width: 84px; }
  .d-kacheln { grid-template-columns: repeat(2, 1fr); }
  .d-ampel-panel { left: auto; width: min(430px, calc(100vw - 48px)); right: 0; }
  .d-ring-box { width: 200px; }
}
@media (min-width: 1100px) {
  .d-kacheln { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .d-kachel { padding: 20px; } .d-gross { font-size: 30px; }
  .d-reihe, .d-zweispaltig { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .d-paar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1500px) { .d-gross { font-size: 34px; } .d-kachel { padding: var(--d-innen); } }

/* Budgetkarte (unten, am Handy wie am Rechner) und Fuß */
.d-budget-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.d-budget-kopf b { font-weight: 650; flex: 1; min-width: 0; } .d-budget-kopf span { white-space: nowrap; font-weight: 650; }
.d-budgetkarte svg.d-balken { height: 8px; }
.d-budgetkarte .d-klein { margin-top: 10px; }
.d-fuss { color: var(--muted); font-size: 13px; }
.d-fuss ul.d-quellen { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.d-fuss ul.d-quellen li { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
