/* NEXUS Dashboard v3 -- mobil zuerst, ruhig, zahlenorientiert.
   Farben als Rollen-Token; Dark und Light mit eigenen, gepruefen Stufen.
   Serienfarben (s1..s4) nur fuer Marken in Diagrammen, nie fuer Text.
   Gewinn/Verlust-Text nutzt die Status-Textstufen und traegt immer Vorzeichen + Pfeil. */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --flaeche: #ffffff;
  --flaeche-2: #f1f3f6;
  --flaeche-3: #e8ebef;
  --linie: #e2e5ea;
  --text-1: #0f1216;
  --text-2: #4a5059;
  --text-3: #7a808a;
  --akzent: #2a78d6;
  --akzent-weich: #e3eefb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --pos: #2a78d6; --neg: #e34948; --mitte: #e9ebef;
  --plus: #0a7a33; --minus: #c42b2b;
  --gut: #0ca30c; --warn: #fab219; --kritisch: #d03b3b;
  --gut-text: #0a7a33; --kritisch-text: #c42b2b; --warn-text: #8a5a00;
  --warn-flaeche: #fff6df; --kritisch-flaeche: #fdeaea;
  --schatten: 0 1px 2px rgba(16, 24, 40, .05);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0d0f; --flaeche: #15171a; --flaeche-2: #1c1f23; --flaeche-3: #24282d; --linie: #272a30;
    --text-1: #f3f4f6; --text-2: #aeb3bb; --text-3: #737983;
    --akzent: #3987e5; --akzent-weich: #16263a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --pos: #3987e5; --neg: #e66767; --mitte: #2a2e34;
    --plus: #3fcf74; --minus: #ff7373;
    --gut-text: #3fcf74; --kritisch-text: #ff7373; --warn-text: #f5b93a;
    --warn-flaeche: #2a2312; --kritisch-flaeche: #2c1516;
    --schatten: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0d0f; --flaeche: #15171a; --flaeche-2: #1c1f23; --flaeche-3: #24282d; --linie: #272a30;
  --text-1: #f3f4f6; --text-2: #aeb3bb; --text-3: #737983;
  --akzent: #3987e5; --akzent-weich: #16263a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --pos: #3987e5; --neg: #e66767; --mitte: #2a2e34;
  --plus: #3fcf74; --minus: #ff7373;
  --gut-text: #3fcf74; --kritisch-text: #ff7373; --warn-text: #f5b93a;
  --warn-flaeche: #2a2312; --kritisch-flaeche: #2c1516;
  --schatten: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text-1);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { padding: 0 var(--safe-r) calc(var(--safe-b) + 76px) var(--safe-l); }
button, input, select { font: inherit; color: inherit; }
a { color: var(--akzent); text-decoration: none; }
.zahl, .wert, .tab-num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Kopf */
.kopf { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  padding: calc(var(--safe-t) + 10px) 16px 10px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--linie); }
.marke { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .14em; font-size: 15px; }
.marke svg { width: 22px; height: 22px; }
.kopf .rechts { margin-left: auto; display: flex; gap: 10px; align-items: center; color: var(--text-2); font-size: 13px; }
.pille { font-size: 11px; font-weight: 700; letter-spacing: .06em; padding: 3px 8px; border-radius: 6px;
  background: var(--flaeche-2); color: var(--text-2); border: 1px solid var(--linie); }
.pille.demo { background: var(--akzent); color: #fff; border-color: transparent; }
.live { display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gut); }
.live.alt::before { background: var(--warn); }

main { max-width: 880px; margin: 0 auto; padding: 14px 16px 24px; }
.ansicht-titel { font-size: 22px; font-weight: 700; margin: 4px 2px 12px; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- Karten */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--schatten); min-width: 0; }
.karte.eng { padding: 12px 14px; }
.kh { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; }
.kh h2 { font-size: 15px; font-weight: 650; margin: 0; }
.kh .neben { margin-left: auto; font-size: 13px; color: var(--text-3); }
.kh button.neben { background: none; border: 0; color: var(--akzent); cursor: pointer; padding: 0; font-weight: 600; }
.leer { color: var(--text-3); font-size: 14px; margin: 0; }
.klein { font-size: 13px; color: var(--text-2); }
.sehrklein { font-size: 12px; color: var(--text-3); }
.raster2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.raster3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 720px) { .breit2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
  .breit2 > .karte { margin-bottom: 0; } }

/* ---------------------------------------------------------------- Portfolio */
.portfolio .oben { display: flex; align-items: flex-start; gap: 12px; }
.portfolio .label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.held { font-size: 36px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.held .einheit { font-size: 16px; font-weight: 600; color: var(--text-3); margin-left: 4px; letter-spacing: 0; }
.deltazeile { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: 2px; }
.delta { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.plus { color: var(--plus); } .delta.minus { color: var(--minus); } .delta.null { color: var(--text-2); }
.delta.plus::before { content: "▲ "; font-size: .8em; } .delta.minus::before { content: "▼ "; font-size: .8em; }
.funke { margin: 10px -4px 4px; }
.funke svg { display: block; width: 100%; height: 64px; }
.funke .linie { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.funke .wash { fill: var(--s1); opacity: .10; stroke: none; }
.funke .basis { stroke: var(--linie); stroke-width: 1; }
.vergleich { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--linie);
  margin-top: 10px; padding-top: 10px; }
.vergleich > div { padding: 0 8px; border-left: 1px solid var(--linie); min-width: 0; }
.vergleich > div:first-child { border-left: 0; padding-left: 0; }
.vergleich .n { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.vergleich .w { font-size: 15px; font-weight: 650; margin-top: 2px; }

/* ---------------------------------------------------------------- Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--linie);
  border: 1px solid var(--linie); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.kpi { background: var(--flaeche); padding: 12px; min-width: 0; }
.kpi .n { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .w { font-size: 19px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .u { font-size: 11px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.schluessel { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.schluessel.s1 { background: var(--s1); } .schluessel.s2 { background: var(--s2); }
.schluessel.s3 { background: var(--s3); } .schluessel.s4 { background: var(--s4); }

/* ---------------------------------------------------------------- Phasen-Stepper */
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; margin: 4px 0 14px; }
.stepper::before { content: ""; position: absolute; left: 10%; right: 10%; top: 13px; height: 2px; background: var(--linie); }
.schritt { position: relative; text-align: center; }
.schritt .punkt { width: 28px; height: 28px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--flaeche-2); color: var(--text-3); border: 2px solid var(--linie);
  position: relative; z-index: 1; }
.schritt.fertig .punkt { background: var(--gut); border-color: var(--gut); color: #fff; }
.schritt.laeuft .punkt { background: var(--flaeche); border-color: var(--akzent); color: var(--akzent); }
.schritt .t { font-size: 11px; color: var(--text-2); margin-top: 6px; line-height: 1.2; }
.schritt.laeuft .t { color: var(--text-1); font-weight: 600; }
.fortschritt { display: grid; gap: 10px; }
.fz .kopfzeile { display: flex; font-size: 13px; gap: 8px; }
.fz .kopfzeile .r { margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; }
.balken { height: 6px; border-radius: 3px; background: var(--flaeche-3); overflow: hidden; margin-top: 6px; }
.balken > span { display: block; height: 100%; width: var(--fuell, 0%); background: var(--akzent); border-radius: 3px; }
.balken.gut > span { background: var(--gut); }

/* ---------------------------------------------------------------- Maerkte */
.markt-mini .k { display: flex; align-items: baseline; gap: 6px; }
.markt-mini .asset { font-weight: 700; font-size: 15px; }
.markt-mini .preis { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.markt-mini .zeilen { margin-top: 10px; border-top: 1px solid var(--linie); padding-top: 8px; display: grid; gap: 5px; }
.mz { display: flex; font-size: 12px; gap: 6px; }
.mz .l { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mz .v { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zpunkt { width: 6px; height: 6px; border-radius: 50%; display: inline-block; margin-left: 5px; vertical-align: middle;
  background: var(--mitte); }
.zpunkt.hoch { background: var(--pos); } .zpunkt.tief { background: var(--neg); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--flaeche-2); color: var(--text-2); border: 1px solid var(--linie); white-space: nowrap; font-weight: 500; }
.chip.long, .chip.short, .chip.flat { font-weight: 600; color: var(--text-1); }
.chip.long::before { content: "▲"; color: var(--pos); font-size: 10px; }
.chip.short::before { content: "▼"; color: var(--neg); font-size: 10px; }
.chip.flat::before { content: "■"; color: var(--text-3); font-size: 9px; }

/* ---------------------------------------------------------------- Status (Symbol + Text) */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 15px; height: 15px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; color: #fff; line-height: 15px; text-align: center; flex: none; }
.status.gut { color: var(--gut-text); } .status.gut::before { content: "✓"; background: var(--gut); }
.status.warn { color: var(--warn-text); } .status.warn::before { content: "!"; background: var(--warn); color: #000; }
.status.kritisch { color: var(--kritisch-text); } .status.kritisch::before { content: "✕"; background: var(--kritisch); }
.status.neutral { color: var(--text-2); } .status.neutral::before { content: "·"; background: var(--text-3); }

.banner { border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; display: flex; gap: 8px;
  align-items: flex-start; border: 1px solid transparent; }
.banner.warn { background: var(--warn-flaeche); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.kritisch { background: var(--kritisch-flaeche); border-color: color-mix(in srgb, var(--kritisch) 40%, transparent); }

/* ---------------------------------------------------------------- Listen */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: 11px 0; border-top: 1px solid var(--linie); }
.liste > li:first-child { border-top: 0; padding-top: 0; }
.liste > li:last-child { padding-bottom: 0; }
.liste > li.klickbar, .klickbar { cursor: pointer; }
.zeile { display: flex; align-items: center; gap: 8px; min-width: 0; }
.zeile .r { margin-left: auto; text-align: right; white-space: nowrap; }
.titel { font-weight: 650; }
.zeit { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 38px; }
.text2 { color: var(--text-2); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.text2.voll { -webkit-line-clamp: unset; display: block; }
.tagkopf { font-size: 12px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
  margin: 16px 2px 8px; }
.tagkopf:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- Segment-Umschalter */
.segment { display: flex; background: var(--flaeche-2); border: 1px solid var(--linie); border-radius: 10px; padding: 3px;
  gap: 2px; margin-bottom: 12px; overflow-x: auto; }
.segment button { flex: 1; border: 0; background: none; padding: 7px 10px; border-radius: 7px; font-size: 13px;
  font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.segment button.an { background: var(--flaeche); color: var(--text-1); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------------------------------------------------------------- Markt-Detail */
details.gruppe { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); margin-bottom: 10px;
  box-shadow: var(--schatten); }
details.gruppe > summary { list-style: none; padding: 13px 16px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-weight: 650; }
details.gruppe > summary::-webkit-details-marker { display: none; }
details.gruppe > summary::after { content: "›"; margin-left: 8px; color: var(--text-3); font-size: 20px; line-height: 1;
  transition: transform .15s; }
details.gruppe[open] > summary::after { transform: rotate(90deg); }
details.gruppe > summary .anz { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 500; }
details.gruppe .innen { padding: 0 16px 10px; }
.feat { display: grid; grid-template-columns: minmax(0, 1fr) 84px minmax(70px, auto); gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--linie); font-size: 13px; }
.feat .n { min-width: 0; }
.feat .n .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feat .w { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.feat .w .e { font-weight: 400; color: var(--text-3); font-size: 11px; margin-left: 2px; }
.zbar { position: relative; height: 8px; background: var(--mitte); border-radius: 4px; }
.zbar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--text-3); }
.zbar > span { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--pos);
  left: var(--links, 50%); width: var(--breite, 0%); }
.zbar.neg > span { background: var(--neg); }
.zbar.ohne { background: repeating-linear-gradient(135deg, var(--mitte) 0 4px, transparent 4px 8px); }
.markt-kopf .preis { font-size: 30px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Diagramme */
.diagramm { position: relative; width: 100%; }
.diagramm svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.diagramm .gitter { stroke: var(--linie); stroke-width: 1; }
.diagramm .achse { fill: var(--text-3); font-size: 11px; }
.diagramm .linie { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.diagramm .l1 { stroke: var(--s1); } .diagramm .l2 { stroke: var(--s2); }
.diagramm .l3 { stroke: var(--s3); } .diagramm .l4 { stroke: var(--s4); }
.diagramm .p1 { fill: var(--s1); } .diagramm .p2 { fill: var(--s2); } .diagramm .p3 { fill: var(--s3); } .diagramm .p4 { fill: var(--s4); }
.diagramm .punkt { stroke: var(--flaeche); stroke-width: 2; }
.diagramm .ref { stroke: var(--text-3); stroke-width: 1; opacity: .6; }
.diagramm .kreuz { stroke: var(--text-3); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--flaeche); border: 1px solid var(--linie);
  border-radius: 10px; padding: 7px 9px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: none;
  left: var(--tx, 0); top: var(--ty, 0); min-width: 150px; z-index: 3; }
.tip.an { display: block; }
.tip .tz { display: flex; gap: 6px; align-items: center; }
.tip .tz b { margin-left: auto; padding-left: 10px; }
.legende { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legende span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------------------------------------------------------- Tabellen */
.tabelle { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabelle th { text-align: left; color: var(--text-3); font-weight: 500; padding: 4px 8px 6px 0; font-size: 12px; white-space: nowrap; }
.tabelle td { padding: 8px 8px 8px 0; border-top: 1px solid var(--linie); vertical-align: top; }
.tabelle td.z, .tabelle th.z { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; padding-left: 8px;
  white-space: nowrap; }
.tabelle tr td:first-child { white-space: nowrap; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0; font-size: 13px; }
.kv > div { padding: 7px 0; border-top: 1px solid var(--linie); }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv > div:nth-child(odd) { color: var(--text-2); padding-right: 12px; }
.kv > div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Knoepfe */
.knopf { border: 1px solid var(--linie); background: var(--flaeche-2); border-radius: 10px; padding: 9px 14px;
  font-weight: 600; cursor: pointer; min-height: 40px; font-size: 14px; }
.knopf.haupt { background: var(--akzent); color: #fff; border-color: transparent; }
.knopf.gefahr { color: var(--kritisch-text); }
.knopf.klein { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.knopf:disabled { opacity: .5; cursor: default; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; }
input.feld { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--linie); background: var(--bg); }

/* ---------------------------------------------------------------- Tab-Leiste */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--flaeche) 92%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--linie); display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px var(--safe-r) calc(var(--safe-b) + 6px) var(--safe-l); }
.tabs button { background: none; border: 0; padding: 4px 0; font-size: 11px; color: var(--text-3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 500; }
.tabs button svg { width: 23px; height: 23px; }
.tabs button.an { color: var(--akzent); font-weight: 650; }
.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- Blatt */
.blatt { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: none; }
.blatt.an { display: block; }
.blatt .innen { position: absolute; left: 0; right: 0; bottom: 0; max-height: 90vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 10px 16px calc(var(--safe-b) + 24px);
  max-width: 880px; margin: 0 auto; }
.blatt .griff { width: 40px; height: 5px; border-radius: 3px; background: var(--flaeche-3); margin: 0 auto 12px; }
.blatt h3 { margin: 0; font-size: 18px; }
.vortext { white-space: pre-wrap; font-size: 13px; color: var(--text-2); background: var(--flaeche-2); border-radius: 10px;
  padding: 10px 12px; max-height: 320px; overflow-y: auto; }
.meldung { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-b) + 84px); z-index: 30; background: var(--text-1);
  color: var(--bg); padding: 11px 14px; border-radius: 12px; display: none; font-size: 14px; max-width: 560px; margin: 0 auto; }
.meldung.an { display: block; }

/* ---------------------------------------------------------------- Login */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }
.loginkarte { width: 100%; max-width: 360px; }
.loginkarte h2 { font-size: 18px; margin: 0 0 6px; }
.loginkarte label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 4px; }
.fehler { color: var(--kritisch-text); font-size: 14px; min-height: 20px; margin-top: 8px; }
.versteckt { display: none !important; }
