/* ================================================================
   Finanzen Dashboard – Custom Styles
   Ergänzt Pico CSS 2 mit einem professionellen Finanz-Look.
   ================================================================ */

:root {
  --color-primary: #1a56db;
  --color-primary-hover: #1e429f;
  --color-success: #057a55;
  --color-warning: #b45309;
  --color-danger: #c81e1e;
  --color-surface: #f9fafb;
  --color-border: #e5e7eb;
  --color-positive: #065f46;
  --color-negative: #991b1b;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}

[data-theme="dark"] {
  --color-surface: #1f2937;
  --color-border: #374151;
}

/* ---- Typografie ---- */
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ---- Navigation ---- */
nav.container {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

nav a {
  font-weight: 500;
  text-decoration: none;
  color: inherit;
  opacity: 0.8;
  transition: opacity 0.15s;
}

nav a:hover {
  opacity: 1;
}

nav ul li strong {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--color-primary);
}

/* Aktive Seite in der Navigation hervorheben */
nav a.nav-active {
  opacity: 1;
  color: var(--color-primary);
  font-weight: 600;
}

/* Hamburger-Button: nur auf schmalen Screens sichtbar */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: inherit;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  margin: 0;
  padding: 0.4rem 0.8rem;
  width: auto;
}

@media (max-width: 768px) {
  nav.container {
    flex-wrap: wrap;
  }

  .nav-toggle {
    display: block;
  }

  /* Menü als ausklappbare, vertikale Liste über die volle Breite */
  .nav-menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    margin: 0.5rem 0 0;
    padding: 0;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-menu li {
    width: 100%;
    padding: 0;
  }

  /* Große Touch-Ziele (min. 44px) mit sichtbarer Trennung */
  .nav-menu li a,
  .nav-menu li #dark-toggle,
  .nav-menu li .btn-nav {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
  }

  .nav-menu li #dark-toggle {
    border: none;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.1rem;
  }

  .nav-menu li:last-child .btn-nav {
    border-bottom: none;
  }

  .nav-menu li form {
    width: 100%;
  }
}

/* ---- Dark Mode Toggle ---- */
#dark-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
  margin: 0;
}

/* ---- Karten-Grid ---- */
.karten-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.karte {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.karte:hover {
  box-shadow: var(--shadow-md);
}

.karte-bank {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 0.1rem;
}

.karte-name {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.karte-betrag {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.karte-datum {
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 0.2rem;
}

/* ---- Gesamtsumme-Banner ---- */
.gesamt-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1e429f 100%);
  color: white;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.gesamt-banner h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.85;
  margin-bottom: 0.3rem;
  color: white;
}

.gesamt-banner .gesamt-wert {
  font-size: 1.9rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}

/* ---- Charts ---- */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .chart-grid { grid-template-columns: 1fr; }
  .karten-grid { grid-template-columns: 1fr 1fr; }
  .gesamt-banner .gesamt-wert { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .karten-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chart-card h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 1rem;
}

/* ---- Toast-Nachrichten ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #111827;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error   { border-left: 4px solid #ef4444; }

@keyframes toast-in  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; } }

/* ---- Login-Seite ---- */
.login-card {
  max-width: 22rem;
  margin: 5rem auto 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ---- Verlauf & Tabellen ---- */
table {
  font-size: 0.9rem;
}

.betrag-positiv { color: var(--color-positive); font-weight: 600; }
.betrag-negativ { color: var(--color-negative); font-weight: 600; }

/* ---- Verlauf kompakt ---- */
.verlauf-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.8rem;
  box-shadow: var(--shadow-sm);
}

.verlauf-block > h2 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.verlauf-block table { font-size: 0.82rem; margin: 0; }
.verlauf-block th,
.verlauf-block td { padding: 0.25rem 0.4rem; }

/* kompakte Inline-Edit-Felder (Verlauf, Konten) */
.row-edit { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0; }
.row-edit input,
.row-edit select {
  margin: 0;
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  height: auto;
}
.row-edit button,
.btn-mini {
  padding: 0.1rem 0.5rem;
  margin: 0;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ---- Ausgaben / Fixkosten ---- */
.fixkosten-card {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.fixkosten-card .fk-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
}
.fixkosten-card .fk-wert {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Hinweis-Karten (Klumpenrisiko, liquide Mittel) – gefüllt wie die KPI-Kacheln */
.hinweis-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  color: white;
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
}
.hinweis-card.hinweis-warnung { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); }
.hinweis-card.hinweis-info { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); }
.hinweis-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.2);
}
.hinweis-text { padding-top: 0.15rem; }
.hinweis-text em { opacity: 0.85; }

.ausgaben-summe {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--color-warning) 0%, #92400e 100%);
  color: white;
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}
.ausgaben-summe .as-label {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; opacity: 0.85;
}
.ausgaben-summe .as-wert {
  font-size: 1.7rem; font-weight: 800; font-family: var(--font-mono);
}

.kat-gruppe { margin-bottom: 1.2rem; }
.kat-gruppe > h3 {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #6b7280; margin: 0 0 0.4rem;
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
}
.kat-summe {
  font-family: var(--font-mono); text-transform: none; letter-spacing: 0;
}

/* Ausgaben als aufklappbare Listeneinträge */
.ausgabe-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 0.35rem;
}
.ausgabe-item > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
}
.ausgabe-item > summary::-webkit-details-marker { display: none; }
.ausgabe-item > summary::before {
  content: "▸";
  color: #9ca3af;
  margin-right: 0.4rem;
  font-size: 0.8rem;
}
.ausgabe-item[open] > summary::before { content: "▾"; }
.ausgabe-item .ag-name { font-weight: 600; }
.ausgabe-item .ag-betrag { font-family: var(--font-mono); white-space: nowrap; }
.ausgabe-item .ag-betrag small { color: #9ca3af; font-weight: 400; }
.ausgabe-item .ag-details {
  padding: 0.4rem 0.75rem 0.7rem;
  border-top: 1px solid var(--color-border);
}
.ausgabe-item.inaktiv > summary { opacity: 0.55; }
.ag-pausiert {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  color: var(--color-warning); border: 1px solid var(--color-warning);
  border-radius: 9999px; padding: 0 0.4rem; margin-left: 0.3rem;
}

/* ---- Monatliche Veränderung ---- */
.delta {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  margin-left: 0.4rem;
}
.delta.positiv { background: #d1fae5; color: #065f46; }
.delta.negativ { background: #fee2e2; color: #991b1b; }
.delta.neutral { background: #f3f4f6; color: #6b7280; }

/* ---- Sicherheits-Badges ---- */
.badge-2fa-aktiv {
  display: inline-block;
  background: #d1fae5;
  color: #065f46;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ================================================================
   Wiederverwendbare Klassen (statt Inline-Styles)
   ================================================================ */

/* ---- Meldungen / Alerts (dark-mode-fähig) ---- */
.alert {
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
}
.alert-error {
  border-left-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
}
.alert-success {
  border-left-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 12%, transparent);
}
.alert-warning {
  border-left-color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 14%, transparent);
}

/* ---- Seiten-Kopf: kleine Linkzeile unter <h1> ---- */
.page-sub {
  font-size: 0.9rem;
  color: #6b7280;
  margin: -0.3rem 0 1.2rem;
}
/* ---- Seiten-Fuß: abschließende Linkzeile (z. B. „← Zurück") ---- */
.page-foot {
  margin-top: 1.5rem;
  font-size: 0.9rem;
}
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.va-mid { vertical-align: middle; }
.w-full { width: 100%; }

/* ---- Schmaler, zentrierter Auth-Container (2FA-Login) ---- */
.auth-narrow { max-width: 25rem; margin-top: 4rem; }

/* ---- QR-Code-Bild (2FA-Setup) ---- */
.qr-img { width: 200px; height: 200px; }
/* ---- Code-Block (Recovery-Codes, immer hell für Lesbarkeit) ---- */
.code-block {
  background: #ffffff;
  color: #111111;
  padding: 0.75rem;
  border-radius: 0.4rem;
}

/* ---- Delta-Textfarben (statt Inline-Ternär-Hex) ---- */
.text-pos { color: var(--color-success); }
.text-neg { color: var(--color-danger); }
[data-theme="dark"] .text-pos { color: #34d399; }
[data-theme="dark"] .text-neg { color: #f87171; }

/* ---- Utilities ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-base { font-size: 1rem; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.muted { color: #6b7280; }
.ms-auto { margin-left: auto; }
.self-center { align-self: center; }
.form-inline { display: inline; margin: 0; }
.input-betrag { text-align: right; }
.nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }
.table-scroll { overflow-x: auto; }

/* ---- Dashboard: Delta-Texte & Chart-Zeitraumfilter ---- */
.gesamt-delta { font-size: 0.95rem; margin-top: 0.25rem; }
.karte-delta { font-size: 0.8rem; font-weight: 600; margin-top: 0.15rem; }
.chart-range { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; }
.chart-range button { padding: 0.1rem 0.6rem; margin: 0; }
/* ---- Kompakter Button in der Navigation (Logout) ---- */
.btn-nav { padding: 0.25rem 0.75rem; margin: 0; }

/* ---- Audit-Log: Filter + Pagination ---- */
.audit-filter {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.audit-filter select {
  width: auto;
  margin: 0;
}

.pagination {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
}

/* ---- Verlauf: Link zur vollen/kompakten Ansicht ---- */
.verlauf-mehr {
  font-size: 0.85rem;
  margin: 0.3rem 0 0;
}

/* ================================================================
   Dashboard-Redesign: KPI-Kacheln, Sektionen, gruppierte Konten
   ================================================================ */
.kpi-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}
/* Voll breite, gefüllte Farbkarten im Stil des Gesamtvermögen-Banners */
.kpi-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  color: white;
  border-radius: var(--radius);
  padding: 0.85rem 1.4rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.kpi-tile:hover { transform: translateY(-2px); }
.kpi-main { min-width: 0; }
.kpi-tile .kpi-value { text-align: right; }
.kpi-accent-1 { background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%); }
.kpi-accent-2 { background: linear-gradient(135deg, #059669 0%, #047857 100%); }
.kpi-accent-3 { background: linear-gradient(135deg, #d97706 0%, #b45309 100%); }
.kpi-accent-4 { background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); }
.kpi-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}
.kpi-icon { font-size: 1rem; line-height: 1; }
.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: white;
  opacity: 0.9;
}
.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.kpi-trend {
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 0.4rem;
  white-space: nowrap;
  opacity: 0.95;
}
.kpi-sub {
  font-size: 0.78rem;
  color: white;
  opacity: 0.85;
  margin-top: 0.3rem;
}

.dash-section { margin: 2rem 0; }
.dash-h2 { font-size: 1.15rem; margin-bottom: 0.8rem; }

/* Konten je Asset-Klasse: Überschrift mit Zwischensumme + Kachel-Raster */
.gruppe-block { margin-bottom: 1.4rem; }
.gruppe-titel {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.1rem 0.5rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}
.kg-klasse { font-weight: 600; display: flex; align-items: center; }
.kg-summe { font-family: var(--font-mono); font-weight: 700; white-space: nowrap; }
/* Farbpunkt je Gruppe — passend zur Chart-Palette */
.kg-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.45rem;
  background: #9ca3af;
}
.kg-dot-0 { background: #1a56db; }
.kg-dot-1 { background: #f59e0b; }
.kg-dot-2 { background: #10b981; }
.kg-dot-3 { background: #a855f7; }
.kg-dot-4 { background: #64748b; }
.kg-dot-5 { background: #ec4899; }

/* ---- Inline-Checkbox mit Label (z. B. „aktiv") ---- */
.check-inline {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0;
  font-size: 0.78rem;
}
.check-inline input { margin: 0; }
