/* Finanzen · Farbschema „Saphir“: tiefes Mitternachtsblau, klares Saphirblau als Akzent */
:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --flaeche: #ffffff;
  --flaeche-2: #f0f3f8;
  --flaeche-3: #e7ecf4;
  --linie: #e1e6ef;
  --text: #0a1226;
  --text-2: #475169;
  --text-3: #8a93a8;
  --akzent: #2a5cff;
  --akzent-2: #1739c9;
  --akzent-weich: #e9efff;
  --kopf-a: #070d1f;
  --kopf-b: #0f1d47;
  --held-a: #1a3fd9;
  --held-b: #0d1f6e;
  --gut: #0c8a5f;
  --schlecht: #cf3e3e;
  --warn: #b7791f;
  --warn-bg: #fdf3e1;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6;
  --sek-ein: #1baf7a; --sek-fix: #2a5cff; --sek-var: #6250d6;
  --gitter: #e9edf3;
  --schatten: 0 1px 2px rgba(10, 18, 38, .04), 0 6px 24px rgba(10, 18, 38, .05);
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #070b14; --flaeche: #0e1422; --flaeche-2: #141c2e; --flaeche-3: #1a2440; --linie: #1f2a40;
    --text: #eef2fb; --text-2: #b4bdd3; --text-3: #7c869e;
    --akzent: #5b82ff; --akzent-2: #8aa6ff; --akzent-weich: #16234a;
    --kopf-a: #04070f; --kopf-b: #0b1638; --held-a: #2347e0; --held-b: #0f1e66;
    --gut: #3fcf8e; --schlecht: #f07272; --warn: #f0b350; --warn-bg: #2e2410;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
    --sek-ein: #199e70; --sek-fix: #5b82ff; --sek-var: #9085e9;
    --gitter: #18213a;
    --schatten: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b14; --flaeche: #0e1422; --flaeche-2: #141c2e; --flaeche-3: #1a2440; --linie: #1f2a40;
  --text: #eef2fb; --text-2: #b4bdd3; --text-3: #7c869e;
  --akzent: #5b82ff; --akzent-2: #8aa6ff; --akzent-weich: #16234a;
  --kopf-a: #04070f; --kopf-b: #0b1638; --held-a: #2347e0; --held-b: #0f1e66;
  --gut: #3fcf8e; --schlecht: #f07272; --warn: #f0b350; --warn-bg: #2e2410;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9;
  --sek-ein: #199e70; --sek-fix: #5b82ff; --sek-var: #9085e9;
  --gitter: #18213a;
  --schatten: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 28px; }
h2 { font-size: 17px; }
a { color: inherit; }
code { font-size: .92em; }
.leise { color: var(--text-2); }
.klein { font-size: 13px; }
.gut { color: var(--gut); }
.schlecht { color: var(--schlecht); }
[hidden] { display: none !important; }

/* ---------- Kopf */
.kopf {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(120deg, var(--kopf-a), var(--kopf-b));
  color: #eef2fb; padding: 0 24px; display: flex; align-items: center; gap: 28px; min-height: 60px;
  border-bottom: 1px solid rgba(120, 150, 255, .12);
}
.marke { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  background: none; border: 0; color: #9eabcf; font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.nav button:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav button[aria-current="page"] { color: #fff; background: rgba(91, 130, 255, .22); box-shadow: inset 0 0 0 1px rgba(140, 170, 255, .28); }
.kopf-rechts { display: flex; gap: 8px; }
.kopf-rechts button { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.08); color: #dfe6fb; border-radius: 9px; padding: 7px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.kopf-rechts button:hover { background: rgba(255,255,255,.14); }

main.inhalt { max-width: 1240px; margin: 0 auto; padding: 30px 24px 120px; }
.seitenkopf { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.seitenkopf p { margin: 5px 0 0; }

/* ---------- Karten */
.raster { display: grid; gap: 16px; }
.raster.k4 { grid-template-columns: repeat(4, 1fr); }
.raster.k3 { grid-template-columns: repeat(3, 1fr); }
.raster.k2 { grid-template-columns: repeat(2, 1fr); }
.raster.k21 { grid-template-columns: 2fr 1fr; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--schatten); min-width: 0; }
.karte-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.karte-kopf p { margin: 3px 0 0; color: var(--text-2); font-size: 13px; }
.abstand { margin-top: 16px; }

.kpi .label { font-size: 13px; color: var(--text-2); }
.kpi .wert { font-size: 27px; font-weight: 650; margin: 6px 0 3px; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.kpi .zusatz { font-size: 13px; color: var(--text-2); }
.kpi.held { background: linear-gradient(135deg, var(--held-a), var(--held-b)); color: #fff; border-color: transparent; position: relative; overflow: hidden; }
.kpi.held::after { content: ""; position: absolute; right: -40px; top: -60px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%); }
.kpi.held .label, .kpi.held .zusatz { color: #c9d5ff; }
.kpi.held .wert { font-size: 34px; }
.kpi.held .gut { color: #8ef0c0; }
.kpi.held .schlecht { color: #ffb3b3; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--text-2); cursor: pointer; font: inherit; font-size: 13px; }
.chip b { color: var(--text); font-weight: 600; }
.chip.offen { border-color: var(--akzent); color: var(--akzent); background: var(--akzent-weich); }

/* ---------- Diagramme */
.diagramm { position: relative; width: 100%; }
.diagramm svg { display: block; width: 100%; overflow: visible; }
.diagramm text { fill: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.diagramm .gitter { stroke: var(--gitter); stroke-width: 1; }
.diagramm .achse { stroke: var(--linie); }
.diagramm .fadenkreuz { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.diagramm .ziel-linie { stroke: var(--akzent); stroke-width: 1; stroke-dasharray: 4 4; opacity: .7; }
.diagramm text.ziel-text { fill: var(--akzent); font-weight: 600; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 8px 28px rgba(10,18,38,.16); min-width: 150px; }
.tooltip .tt-kopf { font-weight: 650; margin-bottom: 4px; }
.tooltip .tt-zeile { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.tooltip .tt-zeile span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .tt-summe { border-top: 1px solid var(--linie); margin-top: 4px; padding-top: 4px; font-weight: 650; }
.punkt { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 0 0 10px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende .strich { width: 16px; height: 0; border-top: 2px dashed var(--text-3); display: inline-block; }

.hbalken { display: grid; gap: 11px; }
.hb-zeile { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hb-zeile .name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-spur { height: 10px; background: var(--flaeche-2); border-radius: 4px; overflow: hidden; }
.hb-fuell { height: 100%; border-radius: 0 4px 4px 0; }
.hb-zeile .wert { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hb-zeile .wert small { color: var(--text-3); margin-left: 6px; }

/* ---------- Steuerelemente */
.knopf { font: inherit; font-size: 14px; font-weight: 600; border-radius: 10px; padding: 9px 15px; border: 1px solid var(--linie); background: var(--flaeche); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.knopf:hover { border-color: var(--text-3); }
.knopf.primaer { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.knopf.primaer:hover { background: var(--akzent-2); }
.knopf.klein { padding: 6px 10px; font-size: 13px; }
.knopf.geist { border-color: transparent; background: none; color: var(--akzent); padding: 4px 6px; }
.knopf[aria-pressed="true"] { background: var(--akzent-weich); border-color: var(--akzent); color: var(--akzent); }
.segment { display: inline-flex; background: var(--flaeche-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segment button { border: 0; background: none; font: inherit; font-size: 13px; padding: 6px 11px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.segment button[aria-pressed="true"] { background: var(--flaeche); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.werkzeuge { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, input[type="text"], input[type="date"], input[type="password"] {
  font: inherit; font-size: 14px; color: var(--text); background: var(--flaeche);
  border: 1px solid var(--linie); border-radius: 9px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--akzent); outline-offset: -1px; border-color: transparent; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
label.haken { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }

/* ---------- Tabellen-Raster (Excel-artig, direkt bearbeitbar) */
.raster-huelle { overflow-x: auto; overflow-y: visible; margin: 0 -22px -20px; border-top: 1px solid var(--linie); border-radius: 0 0 var(--radius) var(--radius); }
.blatt { border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-variant-numeric: tabular-nums; min-width: 100%; }
.blatt th, .blatt td { padding: 0 12px; height: 36px; white-space: nowrap; text-align: right; border-bottom: 1px solid var(--linie); }
.blatt thead th { position: sticky; top: 0; z-index: 3; background: var(--flaeche-2); color: var(--text-3); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; height: 40px; }
.blatt th:first-child, .blatt td:first-child { position: sticky; left: 0; z-index: 2; text-align: left; background: var(--flaeche); min-width: 230px; max-width: 280px; border-right: 1px solid var(--linie); }
.blatt thead th:first-child { z-index: 4; background: var(--flaeche-2); }
.blatt td.z { cursor: cell; min-width: 84px; }
.blatt td.z:hover { background: var(--akzent-weich); }
.blatt td.z:focus { outline: 2px solid var(--akzent); outline-offset: -2px; background: var(--akzent-weich); }
.blatt td.z.leer { color: var(--text-3); }
.blatt td.z.vorschlag { color: var(--text-3); font-style: italic; }
.blatt td.z input { width: 100%; border: 0; outline: 0; background: transparent; font: inherit; text-align: right; padding: 0; color: var(--text); }
.blatt td.z.bearbeiten { outline: 2px solid var(--akzent); outline-offset: -2px; background: var(--flaeche); }
.blatt .spalte-neu { background: color-mix(in srgb, var(--akzent) 6%, transparent); }
.blatt thead th.spalte-neu { color: var(--akzent); background: var(--akzent-weich); }
.blatt th.offen { color: var(--text-3); opacity: .55; }
.blatt td.offen { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--flaeche-2) 6px 7px); }
.kopf-knopf { border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.kopf-knopf:hover { background: var(--flaeche-3); color: var(--text); }
.kopf-knopf small { display: block; font-size: 10px; font-weight: 500; letter-spacing: 0; opacity: .8; }

.blatt .name-zelle { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.blatt .name-zelle span { overflow: hidden; text-overflow: ellipsis; }
.blatt .mehr { border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 6px; opacity: 0; }
.blatt tr:hover .mehr, .blatt .mehr:focus { opacity: 1; }
.blatt .mehr:hover { background: var(--flaeche-3); color: var(--text); }
@media (hover: none) { .blatt .mehr { opacity: .6; } }
.blatt tr.inaktiv td:first-child { color: var(--text-3); }
.blatt tr.inv td:first-child span::after { content: "Investition"; margin-left: 8px; font-size: 10.5px; color: var(--akzent); background: var(--akzent-weich); padding: 1px 6px; border-radius: 5px; vertical-align: 1px; }

/* Abschnitte & Gruppen */
.blatt tr.sektion td { height: 44px; font-weight: 700; color: var(--text); background: color-mix(in srgb, var(--sek) 13%, var(--flaeche)); border-bottom: 1px solid color-mix(in srgb, var(--sek) 30%, var(--linie)); }
.blatt tr.sektion td:first-child { box-shadow: inset 4px 0 0 var(--sek); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.blatt tr.sek-ein { --sek: var(--sek-ein); }
.blatt tr.sek-fix { --sek: var(--sek-fix); }
.blatt tr.sek-var { --sek: var(--sek-var); }
.blatt tr.gruppe td { font-weight: 600; color: var(--text-2); background: var(--flaeche-2); font-size: 13px; }
.blatt tr.gruppe td:first-child { padding-left: 18px; }
.blatt tr.posten td:first-child { padding-left: 30px; }
.blatt tr.klasse td { font-weight: 650; background: var(--flaeche-2); }
.blatt tr.klasse td:first-child { box-shadow: inset 4px 0 0 var(--kl); }
.blatt tr.konto td:first-child { padding-left: 22px; }
.blatt tr.neu-zeile td { height: 30px; border-bottom: 1px dashed var(--linie); }
.blatt tr.neu-zeile td:first-child { padding-left: 26px; }
.blatt tr.neu-zeile .knopf.geist { font-size: 12.5px; font-weight: 500; opacity: .45; }
.blatt tr.neu-zeile:hover .knopf.geist, .blatt tr.neu-zeile .knopf.geist:focus { opacity: 1; }
@media (hover: none) { .blatt tr.neu-zeile .knopf.geist { opacity: .8; } }
.blatt tr.neu-zeile input { padding: 5px 8px; font-size: 13px; }
.blatt tr.summe td { font-weight: 700; background: var(--flaeche-2); }
.blatt tr.held td { font-weight: 750; font-size: 14px; background: var(--akzent-weich); color: var(--text); }
.blatt tr.held td:first-child { box-shadow: inset 4px 0 0 var(--akzent); }
.blatt tr.unter td { color: var(--text-2); font-size: 12.5px; }
.blatt tr.trenner td { height: 12px; background: var(--bg); border-bottom: 0; }

/* Menü (Konto/Kategorie/Spalte) */
.menue { position: fixed; z-index: 60; width: 270px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; box-shadow: 0 18px 50px rgba(10,18,38,.25); padding: 14px; display: grid; gap: 12px; }
.menue h3 { font-size: 14px; }
.menue .zeile { display: flex; gap: 8px; }
.menue .gefahr { color: var(--schlecht); }

/* Speichern-Leiste */
.speicherleiste {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 18px;
  background: var(--kopf-b); color: #eef2fb; border-radius: 14px; box-shadow: 0 14px 40px rgba(7,13,31,.35);
  font-size: 14px; max-width: calc(100% - 32px);
}
.speicherleiste span { white-space: nowrap; }
.speicherleiste .knopf { white-space: nowrap; border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.08); color: #fff; }
.speicherleiste .knopf.primaer { background: var(--akzent); border-color: var(--akzent); }
.speicherleiste .punkt-live { width: 8px; height: 8px; border-radius: 50%; background: #ffb347; box-shadow: 0 0 0 4px rgba(255,179,71,.2); flex: none; }

.ziel { display: grid; grid-template-columns: 1fr 140px auto; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--linie); }
.ziel:last-child { border-bottom: 0; }
.ziel .info { grid-column: 1 / -1; display: grid; gap: 6px; }
.fortschritt { height: 8px; background: var(--flaeche-2); border-radius: 4px; overflow: hidden; }
.fortschritt div { height: 100%; background: linear-gradient(90deg, var(--akzent), var(--s7)); border-radius: 0 4px 4px 0; }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; }
.status.ok { color: var(--gut); }
.status.nein { color: var(--schlecht); }

.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--kopf-b); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast.fehler { background: var(--schlecht); }
.lokal-banner { background: var(--warn-bg); color: var(--warn); padding: 8px 24px; font-size: 13px; text-align: center; }

/* ---------- Login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #16307a, var(--kopf-a) 60%); padding: 16px; }
.login-karte { background: var(--flaeche); border-radius: 20px; padding: 30px; width: min(380px, 100%); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-karte .marke { margin-bottom: 20px; color: var(--text); }
.login-karte form { display: grid; gap: 14px; }
.login-karte .knopf { justify-content: center; }
.fehler { color: var(--schlecht); font-size: 13px; margin: 0; min-height: 1em; }

/* ---------- Handy */
@media (max-width: 900px) {
  .raster.k4 { grid-template-columns: repeat(2, 1fr); }
  .raster.k3, .raster.k21, .raster.k2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { font-size: 14px; }
  .kopf { padding: 8px 12px 0; gap: 8px; flex-wrap: wrap; }
  .kopf .marke span { display: none; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -12px; padding: 4px 8px 8px; }
  .kopf-rechts { margin-left: auto; }
  main.inhalt { padding: 18px 16px 110px; }
  h1 { font-size: 23px; }
  .karte { padding: 16px; }
  .raster-huelle { margin: 0 -16px -16px; }
  .blatt th:first-child, .blatt td:first-child { min-width: 150px; max-width: 170px; }
  .kpi .wert { font-size: 21px; }
  .kpi.held .wert { font-size: 27px; }
  .raster.k4 { gap: 10px; }
  .hb-zeile { grid-template-columns: 90px 1fr auto; }
  .ziel { grid-template-columns: 1fr 100px auto; }
}

