/* Konto-Übersicht als Dashboard (konto/index.html): ergänzt konto.css, bewegung.css und uebersicht.css.
   Präfix d-. Gleiche Bausteine wie die Gast-Startseite (Untitled UI): ruhige Karten mit 1-px-Rand,
   runde Symbole im hellen Markenton, Kennzahlen zuerst, darunter 2 : 1 „Als Nächstes“ und Einrichtung bzw. Backup,
   dann „Letzte Rechnungen“ in voller Breite. Symbole aus konto/js/ikonen.js (Lucide).
   Kein Layout-Springen: Platzhalter in echter Größe, feste Mindesthöhen für Kacheln und Zeilen.
   Bewegung nur bei prefers-reduced-motion: no-preference (150 bis 400 ms). */

.d-raster { gap: 24px; }

/* ---------- Gemeinsame Bausteine ---------- */
/* Karte: 1 px Rand, Radius 12, nur ein Hauch Schatten (kein „Schweben“) */
.d-karte, .d-raster .ei-karte {
  display: flex; flex-direction: column; gap: 16px; min-width: 0; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
/* Kartenkopf (Untitled UI Card header): Titel links, Link rechts auf derselben Linie, nie umbrechen */
.d-karte-kopf { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 24px; }
.d-karte-titel { min-width: 0; }
.d-karte-titel { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.d-klein-link { flex: none; display: inline-flex; align-items: center; min-height: 24px; margin-block: -10px; padding: 10px 2px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.d-klein-link:focus-visible { outline: none; box-shadow: var(--ring); }

/* Rundes Symbol (Untitled UI „Featured icon“): hell Markenton, dunkel 10 % Deckkraft mit hellerem Symbol */
.d-ikon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-soft-2); color: var(--primary);
}
.d-ikon .k-ikon { width: 20px; height: 20px; }
.d-ikon--warnung { background: color-mix(in srgb, var(--warning-text) 12%, var(--surface)); color: var(--warning-text); }
.d-ikon--neutral { background: var(--surface-2); color: var(--text-2); }
.d-ikon--fertig { background: var(--success-soft); color: var(--success-text); }
:root[data-theme="dark"] .d-ikon:not(.d-ikon--warnung, .d-ikon--neutral, .d-ikon--fertig) { background: var(--primary-soft); color: var(--teal-300); }

/* ---------- Kopf: Gruß mit Tarif, ein Satz, Hauptknopf „Neue Rechnung“ ---------- */
.d-kopf { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 8px; }
.d-kopf-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 280px; }
.d-titelzeile { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-width: 0; }
/* H1 wie .k-titel auf allen Konto-Seiten: 24 px (bausteine-oberflaeche.test.js) */
.d-gruss { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 32px; overflow-wrap: anywhere; }
.d-plan { flex: none; }
.d-satz { font-size: 16px; line-height: 24px; color: var(--text-3); min-height: 24px; overflow-wrap: anywhere; }
.d-kopf-knoepfe { margin: 0; flex: none; }
.d-kopf-knoepfe .k-knopf { min-height: 40px; }

/* ---------- Kennzahlen: drei Karten mit Symbol, Label, großer Zahl, Nebenzeile ---------- */
.d-kacheln { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.d-kachel {
  position: relative; display: grid; min-width: 0; padding: 24px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "ikon pfeil" "titel titel" "betrag betrag" "unter unter";
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
  color: var(--text); text-decoration: none;
}
.d-kachel .d-ikon { grid-area: ikon; margin-bottom: 16px; }
.d-kachel-pfeil { grid-area: pfeil; width: 20px; height: 20px; color: var(--text-3); opacity: 0; }
.d-kachel:hover { border-color: var(--border-strong); background: var(--surface-2); }
.d-kachel:hover .d-kachel-pfeil, .d-kachel:focus-visible .d-kachel-pfeil { opacity: 1; }
.d-kachel:focus-visible { outline: none; box-shadow: var(--ring); }
.d-kachel-titel { grid-area: titel; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-3); }
.d-kachel-betrag {
  grid-area: betrag; margin-top: 4px; min-height: 38px;
  font-size: 30px; line-height: 38px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.d-kachel-unter { grid-area: unter; margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--text-3); }
/* Überfällig über 0: nur Symbol-Kreis und Zahl im Warnton, der Rand bleibt ruhig */
.d-kachel.ist-warnung .d-ikon { background: color-mix(in srgb, var(--warning-text) 12%, var(--surface)); color: var(--warning-text); }
:root[data-theme="dark"] .d-kachel.ist-warnung .d-ikon { background: color-mix(in srgb, var(--warning-text) 12%, var(--surface)); color: var(--warning-text); }
.d-kachel.ist-warnung .d-kachel-betrag { color: var(--warning-text); }

/* ---------- 2 : 1: „Als Nächstes“ links, rechts Einrichtung (solange offen), sonst Cloud-Backup ----------
   Ab 900 px ist das Raster ein Grid; die Hüllen .d-zweispaltig und .d-seite lösen sich auf (display: contents).
   Ist die Einrichtung offen, rückt das Backup als flache Zeile unter „Letzte Rechnungen“. */
.d-zweispaltig, .d-seite { display: contents; }
@media (min-width: 900px) {
  /* dense: das Backup (order 1, hinten) füllt die freie rechte Zelle neben „Als Nächstes“, wenn die Einrichtung fehlt */
  .u-raster.d-raster { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); grid-auto-flow: row dense; align-items: stretch; }
  .d-raster #nutzung-karte { order: 1; }
  .d-raster > * { grid-column: 1 / -1; }
  .d-raster #schritte-karte { grid-column: 1; }
  .d-raster #einrichtung, .d-raster #nutzung-karte { grid-column: 2; }
  .d-raster #einrichtung { display: flex; flex-direction: column; }
  .d-raster #einrichtung[hidden] { display: none; }
  .d-raster #einrichtung > .ei-karte { flex: 1; }
  /* Als Nächstes leer oder weg: die rechte Karte nimmt die ganze Breite nicht, sie bleibt rechts */
  .d-raster:has(#schritte-karte:is([hidden], .d-weg)) :is(#einrichtung, #nutzung-karte),
  :root[data-d-aus~="schritte"] .d-raster :is(#einrichtung, #nutzung-karte) { grid-column: 1 / -1; }
  /* Rechts nichts (Einrichtung fertig, Backup unter „Anpassen“ aus): „Als Nächstes“ über die ganze Breite */
  :root[data-d-aus~="backup"] .d-raster:has(#einrichtung[hidden]) #schritte-karte { grid-column: 1 / -1; }
  /* Einrichtung offen: Backup als eine Zeile ganz unten */
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte {
    grid-column: 1 / -1;
    display: grid; align-items: center; column-gap: 24px; padding: 16px 24px;
    grid-template-columns: auto auto minmax(80px, 1fr) auto auto;
    grid-template-areas: "titel zahl balken zeile link";
  }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-karte-kopf { display: contents; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-karte-titel { grid-area: titel; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-klein-link { grid-area: link; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-backup-zahl { grid-area: zahl; font-size: 16px; line-height: 24px; min-height: 24px; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-backup-balken { grid-area: balken; margin: 0; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .d-backup-zeile { grid-area: zeile; }
  .d-raster:has(#einrichtung:not([hidden])) #nutzung-karte .skelett-zeile.d-skelett--kurz { height: 16px; margin: 4px 0; --b: 56px; }
}

/* ---------- Als Nächstes: höchstens drei Zeilen (56 px), Karte nur so hoch wie der Inhalt ---------- */
/* Listen in Karten: Zeilen reichen für die Hover-Fläche bis an den Rand, Trennlinien bleiben im Innenabstand */
.d-schritte, .d-liste { --rand: 24px; list-style: none; margin: -8px calc(-1 * var(--rand)) -12px; padding: 0; display: flex; flex-direction: column; }
.d-schritte > li, .d-liste > li { position: relative; }
.d-schritte > li + li::before, .d-liste > li + li::before {
  content: ""; position: absolute; top: 0; left: var(--rand); right: var(--rand); height: 1px; background: var(--border);
}
.d-schritt {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 24px;
  color: var(--text); text-decoration: none;
}
a.d-schritt:hover { background: var(--surface-2); }
a.d-schritt:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.d-schritt .d-ikon { width: 32px; height: 32px; }
.d-schritt .d-ikon .k-ikon { width: 16px; height: 16px; }
.d-schritt-text { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.d-schritt-aktion { flex: none; font-size: 14px; font-weight: 600; color: var(--primary); white-space: nowrap; }
a.d-schritt:hover .d-schritt-aktion { text-decoration: underline; text-underline-offset: 2px; }
/* Leer: kein Kasten, Häkchen im Kreis, Titel und eine Zeile, mittig */
.d-schritte-leer {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 24px 16px; text-align: center;
}
.d-schritte-leer .d-ikon { margin-bottom: 8px; }
.d-schritte-leer-titel { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); }
.d-schritte-leer-text { font-size: 14px; line-height: 20px; color: var(--text-3); max-width: 36ch; }

/* ---------- Cloud-Backup: Titel, große Zahl, Balken, eine Zeile ---------- */
.d-backup { gap: 8px; }
.d-backup .d-karte-kopf { margin-bottom: 8px; }
.d-backup-zahl { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.015em; min-height: 32px; font-variant-numeric: tabular-nums; color: var(--text); }
.u-balken.d-backup-balken { display: block; height: 8px; margin: 4px 0; border-radius: 4px; background: var(--surface-3); }
.d-backup-zeile { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: 14px; line-height: 20px; color: var(--text-3); }

/* ---------- Letzte Rechnungen: Kunde und Nummer, Datum, Betrag, Status ---------- */
.d-zeile {
  display: grid; align-items: center; column-gap: 24px; row-gap: 2px; min-height: 64px; padding: 12px 24px;
  grid-template-columns: minmax(0, 1fr) auto 112px 148px;
  grid-template-areas: "kunde datum betrag status" "nummer datum betrag status";
  color: var(--text); text-decoration: none;
}
a.d-zeile:hover { background: var(--surface-2); }
a.d-zeile:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--primary); }
.d-zeile-kunde { grid-area: kunde; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 500; overflow-wrap: anywhere; }
.d-zeile-nummer { grid-area: nummer; font-size: 13px; line-height: 18px; color: var(--text-3); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-zeile-datum { grid-area: datum; font-size: 14px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.d-zeile-betrag { grid-area: betrag; justify-self: end; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.d-zeile-status { grid-area: status; justify-self: start; display: flex; }
/* Status als Badge mit Punkt (22 px, 12/18): Überfällig warm statt rot, Entwurf grau gestrichelt */
.d-zeile .k-chip { min-height: 22px; padding: 0 8px; font-size: 12px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.d-zeile .k-chip--ueberfaellig { background: var(--warning-soft); color: var(--warning-text); }
.d-zeile .k-chip--ueberfaellig::before { background: var(--warning-text); }
.d-zeile .k-chip--entwurf { background: none; outline: 1px dashed var(--border-strong); outline-offset: -1px; }
.d-zeile .k-chip--offen, .d-zeile .k-chip--neutral { background: var(--surface-2); color: var(--text-2); }

/* Leer: kleine Illustration, Titel, eine Zeile, ein Knopf (kein gestrichelter Kasten).
   Gleiche Höhe wie der Platzhalter (vier Zeilen), damit beim Laden nichts springt. */
.k-leer.d-leer {
  border: 0; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 260px; padding: 0 0 4px; text-align: center;
}
.k-leer.d-leer[hidden] { display: none; }
.d-leer .k-leer-zeichen { width: auto; height: auto; margin: 0 0 8px; border-radius: 0; background: none; box-shadow: none; } /* Illustration statt Featured Icon */
.d-leer .k-leer-zeichen > .k-ikon { display: block; width: 120px; height: 96px; } /* Illustration 120 x 96 */
.d-leer-kreis { fill: none; stroke: var(--border); stroke-width: 1; }
.d-leer-blatt { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.d-leer-linie { fill: var(--primary); stroke: none; opacity: .2; }
.d-leer-plus-grund { fill: var(--primary-soft-2); stroke: var(--surface); stroke-width: 2; }
.d-leer-plus { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; }
:root[data-theme="dark"] .d-leer-linie { opacity: .35; }
:root[data-theme="dark"] .d-leer-plus-grund { fill: var(--primary-soft); }
.d-leer .k-leer-titel { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text); }
.d-leer .k-leer-text { max-width: 40ch; font-size: 14px; line-height: 20px; color: var(--text-3); }
.k-leer.d-leer > .k-knopf { margin-top: 12px; min-height: 40px; }

/* Fehler beim Laden: Bereiche mit Zahlen ausblenden, statt Platzhalter stehen zu lassen */
.d-weg { display: none !important; }

/* ---------- Ladeplatzhalter: .skelett-zeile aus bewegung.css, hier nur die Größen (gleich groß wie der Inhalt) ---------- */
.skelett-zeile.d-skelett--text { display: block; --b: min(320px, 80%); height: 16px; margin-top: 4px; }
.skelett-zeile.d-skelett--zahl { display: block; --b: 140px; height: 30px; margin-top: 4px; }
.skelett-zeile.d-skelett--kurz { display: block; --b: 96px; height: 24px; margin-top: 4px; }
.d-skelett-reihe { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 24px; }
.d-skelett-reihe--zeile { min-height: 64px; justify-content: space-between; }
.d-skelett-reihe .skelett-zeile { flex: none; }
.skelett-zeile.d-skelett--rund { width: 32px; height: 32px; border-radius: 50%; }
.skelett-zeile.d-skelett--zeile { --b: min(260px, 55%); height: 14px; }
.skelett-zeile.d-skelett--betrag { --b: 72px; height: 14px; }

/* ---------- Bewegung: Rand und Fläche 150 ms, Pfeil blendet ein, Balken füllt sich 400 ms ---------- */
@media (prefers-reduced-motion: no-preference) {
  .d-kachel { transition: border-color 150ms var(--kurve-standard), background-color 150ms var(--kurve-standard); }
  .d-kachel-pfeil { transition: opacity 150ms var(--kurve-standard), transform 200ms var(--kurve-raus); transform: translate(-2px, 2px); }
  .d-kachel:hover .d-kachel-pfeil, .d-kachel:focus-visible .d-kachel-pfeil { transform: none; }
  a.d-schritt, a.d-zeile { transition: background-color 150ms var(--kurve-standard); }
  .d-backup .u-balken-fuellung { transition: width 400ms var(--kurve-raus); }
}
@media (prefers-reduced-motion: reduce) {
  .d-backup .u-balken-fuellung { transition: none; }
}

/* ---------- Tablet und Handy (unter 900 px): eine Spalte, Kennzahlen als Zeilen in einer Karte ---------- */
@media (max-width: 899.98px) {
  .d-raster { gap: 16px; }
  .d-kopf { margin-bottom: 8px; }
  /* Reihenfolge: Kennzahlen, Als Nächstes, Einrichtung, Rechnungen, Backup */
  #nutzung-karte { order: 1; }
  .d-karte, .d-raster .ei-karte { padding: 20px; }
  .d-schritte, .d-liste { --rand: 20px; }
  .d-schritt, .d-skelett-reihe, .d-zeile { padding-inline: 20px; }

  .d-kacheln {
    grid-template-columns: minmax(0, 1fr); gap: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden;
  }
  .d-kachel {
    grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 12px;
    grid-template-areas: "ikon titel betrag" "ikon unter betrag";
    align-items: center; min-height: 72px; padding: 12px 20px;
    border: 0; border-radius: 0; box-shadow: none;
  }
  .d-kachel + .d-kachel { border-top: 1px solid var(--border); }
  .d-kachel .d-ikon { width: 32px; height: 32px; margin: 0; }
  .d-kachel .d-ikon .k-ikon { width: 16px; height: 16px; }
  .d-kachel-pfeil { display: none; }
  .d-kachel-titel { align-self: end; min-width: 0; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .d-kachel-unter { align-self: start; margin: 0; font-size: 13px; line-height: 18px; }
  .d-kachel-betrag { justify-self: end; margin: 0; min-height: 24px; font-size: 16px; line-height: 24px; letter-spacing: -.01em; text-align: right; white-space: nowrap; overflow-wrap: normal; }
  .d-kachel:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
  .skelett-zeile.d-skelett--zahl { --b: 88px; height: 18px; margin: 3px 0 3px auto; }

  /* Letzte Rechnungen zweizeilig: Name und Betrag oben, Nummer und Status unten */
  .d-zeile {
    grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px;
    grid-template-areas: "kunde betrag" "nummer status";
  }
  .d-zeile-datum { display: none; }
}
@media (max-width: 640px) {
  .d-satz { font-size: 15px; }
  /* Hauptknopf unter dem Satz in voller Breite (wie die Gast-Startseite) */
  .d-kopf-knoepfe { flex: 1 1 100%; }
  .d-kopf-knoepfe .k-knopf { flex: 1 1 auto; min-height: 44px; }
  .d-kachel-betrag { font-size: 15px; }
}
@media (max-width: 360px) {
  .d-karte, .d-raster .ei-karte { padding: 16px; }
  .d-schritte, .d-liste { --rand: 16px; }
  .d-schritt, .d-skelett-reihe, .d-zeile, .d-kachel { padding-inline: 16px; }
  .d-kachel { column-gap: 10px; }
  .d-kachel-titel { white-space: normal; } /* lieber zweizeilig als abgeschnitten */
  .d-schritt { gap: 10px; }
}
@media print {
  .d-kopf-knoepfe, #schritte-karte, #nutzung-karte, #einrichtung { display: none !important; }
}

/* Ab 900 px steht „Neue Rechnung“ oben in der Seitenleiste: im Kopf nicht doppelt */
@media (min-width: 900px) { #d-kopf-neu { display: none; } }

/* ---------- Anpassen: Bereiche ein- und ausblenden (konto/js/ansicht.js) ----------
   Ausgeblendetes steht als <html data-d-aus="…"> schon vor dem ersten Zeichnen fest (ansicht-platz.js). */
:root[data-d-aus~="kacheln"] #kacheln,
:root[data-d-aus~="schritte"] #schritte-karte,
:root[data-d-aus~="backup"] #nutzung-karte,
:root[data-d-aus~="rechnungen"] #rechnungen-karte { display: none !important; }

.d-anpassen[hidden] { display: none; }
.d-ansicht { gap: 12px; }
/* Zeilen wie Untitled UI „Toggle“: Symbol, Titel, Schalter; ab 640 px zwei, ab 1100 px drei Spalten */
.d-ansicht-liste {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 24px;
}
.d-ansicht-zeile { display: flex; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--border); }
.d-ansicht-zeile .d-ikon { width: 32px; height: 32px; }
.d-ansicht-zeile .d-ikon .k-ikon { width: 16px; height: 16px; }
.d-ansicht-titel { flex: 1; min-width: 0; font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text); cursor: pointer; }
.d-ansicht-meldung:empty { display: none; }
.d-ansicht-meldung { color: var(--error-text, var(--error)); }
@media (min-width: 640px) { .d-ansicht-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .d-ansicht-liste { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Handy: „Anpassen“ nur als Symbol neben „Neue Rechnung“ */
@media (max-width: 640px) {
  .d-kopf-knoepfe .k-knopf.d-anpassen { flex: none; width: 44px; padding: 0; justify-content: center; }
  .d-anpassen-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media print { .d-anpassen, .d-ansicht { display: none !important; } }
