/* Depot-PWA v2 – Farben nach Dataviz-Referenzpalette (validiert 2026-11-04, hell/dunkel). */
:root {
  color-scheme: light;
  --seite: #f1f1ee; --flaeche: #fcfcfb; --flaeche-2: #f5f5f2;
  --ink: #0b0b0b; --ink-2: #52514e; --ink-3: #898781;
  --gitter: #e1e0d9; --achse: #c3c2b7; --rand: rgba(11,11,11,.10);
  --akzent: #2a78d6; --akzent-ink: #ffffff; --akzent-wash: rgba(42,120,214,.10);
  --gewinn: #2a78d6; --verlust: #e34948;              /* divergierendes Paar */
  --gut-text: #006300; --schlecht-text: #d03b3b;       /* Delta-Text */
  --s-gut: #0ca30c; --s-warn: #fab219; --s-ernst: #ec835a; --s-krit: #d03b3b;
  --r1: #2a78d6; --r2: #eb6834; --r3: #1baf7a; --r4: #eda100; --r5: #e87ba4; --r6: #008300;
  --r4-ink: #0b0b0b;
  --radius: 18px; --schatten: 0 1px 2px rgba(11,11,11,.04), 0 8px 24px -12px rgba(11,11,11,.12);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --seite: #0d0d0d; --flaeche: #1a1a19; --flaeche-2: #222220;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #898781;
    --gitter: #2c2c2a; --achse: #383835; --rand: rgba(255,255,255,.10);
    --akzent: #3987e5; --akzent-ink: #0b0b0b; --akzent-wash: rgba(57,135,229,.14);
    --gewinn: #3987e5; --verlust: #e66767;
    --gut-text: #0ca30c; --schlecht-text: #e66767;
    --r1: #3987e5; --r2: #d95926; --r3: #199e70; --r4: #c98500; --r5: #d55181; --r6: #008300;
    --r4-ink: #ffffff;
    --schatten: none;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* sonst überstimmen display-Regeln (z. B. .login) das hidden-Attribut */
html, body { margin: 0; background: var(--seite); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
h1 { font-size: 1.7rem; margin: .4rem 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .8rem; letter-spacing: -.005em; }
h3 { font-size: 1rem; margin: 0; }
p { margin: .5rem 0; }
.leise { color: var(--ink-2); }
.klein { font-size: .85rem; }
.fehler { color: var(--schlecht-text); min-height: 1.2em; }
.tab-zahl { font-variant-numeric: tabular-nums; }
svg { flex: none; }
button svg, .icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Knöpfe & Eingaben */
button { font: inherit; border-radius: 12px; border: 1px solid var(--rand); padding: .65rem 1rem; cursor: pointer; background: var(--flaeche); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
button.primaer { background: var(--akzent); color: var(--akzent-ink); border-color: transparent; font-weight: 600; }
button.zweit { background: transparent; }
button.ghost { background: transparent; border: 0; padding: .2rem .5rem; color: var(--ink-3); }
button.rund { border-radius: 999px; padding: .55rem 1rem .55rem .8rem; }
button.breit { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
input, select, textarea { font: inherit; width: 100%; padding: .65rem .75rem; border-radius: 12px; border: 1px solid var(--rand); background: var(--flaeche-2); color: var(--ink); margin-top: .35rem; }
label { display: block; margin-bottom: 1rem; font-size: .9rem; color: var(--ink-2); }
label.haken { display: flex; gap: .55rem; align-items: center; color: var(--ink); }
label.haken input { width: auto; margin: 0; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }

/* Anmeldung */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(120% 60% at 50% 0%, var(--akzent-wash), transparent 70%), var(--seite); }
.login-karte { width: min(380px, 100%); text-align: center; padding: 28px 22px; }
.login-karte label { text-align: left; }
.login-logo { border-radius: 14px; }

/* Kopf, Navigation */
.kopf { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--seite) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--rand); }
.kopf-marke { display: flex; gap: .7rem; align-items: center; }
.kopf-marke img { border-radius: 9px; }
.kopf-titel { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
main { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr); z-index: 5;
  background: color-mix(in srgb, var(--flaeche) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--rand); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { border: 0; border-radius: 14px; padding: .45rem .2rem; font-size: .74rem; color: var(--ink-3); background: transparent; flex-direction: column; gap: .2rem; }
.tabs button.aktiv { color: var(--akzent); font-weight: 600; background: var(--akzent-wash); }
.tabs svg { width: 22px; height: 22px; }

/* Karten */
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--schatten); }
.karte-kopf { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .9rem; }
.karte-kopf h2 { margin: 0; }
.leer { text-align: center; padding: 2.5rem 1rem; }
.leer .icon { width: 40px; height: 40px; color: var(--ink-3); }

/* Statusleiste */
.statusleiste { margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--radius); background: var(--flaeche); border: 1px solid var(--rand); max-width: 728px; }
@media (min-width: 792px) { .statusleiste { margin: 12px auto 0; } }
.status-zeile { display: flex; gap: .6rem; align-items: center; }
.status-zeile #status-text { flex: 1; }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--s-warn); flex: none; animation: puls 1.2s infinite; }
.punkt.fertig { background: var(--s-gut); animation: none; } .punkt.fehler { background: var(--s-krit); animation: none; }
@keyframes puls { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .punkt { animation: none; } }
.code-form { display: flex; gap: .5rem; margin-top: .6rem; } .code-form input { margin: 0; }
details { margin-top: .4rem; } details ol { padding-left: 1.2rem; margin: .4rem 0 0; }
summary { cursor: pointer; color: var(--ink-2); }

/* Held: Depotwert */
.held { padding: 20px 18px 12px; background:
  radial-gradient(140% 90% at 100% 0%, var(--akzent-wash), transparent 60%), var(--flaeche); }
.held-bez { font-size: .85rem; color: var(--ink-2); }
.held-wert { font-size: clamp(2.6rem, 11vw, 3.4rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.05; margin: .2rem 0 .5rem; }
.delta { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; font-size: .92rem; padding: .2rem .55rem; border-radius: 999px; background: var(--flaeche-2); }
.delta .icon { width: 16px; height: 16px; }
.delta.gut { color: var(--gut-text); } .delta.schlecht { color: var(--schlecht-text); }
.sparkline { margin-top: 12px; position: relative; }
.sparkline svg { display: block; width: 100%; overflow: visible; }
.sparkline-leg { display: flex; justify-content: space-between; font-size: .75rem; color: var(--ink-3); margin-top: 4px; }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 16px; padding: 12px 14px; }
.kpi-bez { font-size: .78rem; color: var(--ink-2); }
.kpi-wert { font-size: 1.25rem; font-weight: 650; margin-top: .15rem; }
.kpi-unter { font-size: .78rem; margin-top: .1rem; }
.gut-text { color: var(--gut-text); } .schlecht-text { color: var(--schlecht-text); }

/* Segmentierter Balken (Aufteilung) */
.segmente { display: flex; gap: 2px; height: 28px; margin: .2rem 0 .9rem; }
.segment { position: relative; border-radius: 4px; min-width: 3px; display: flex; align-items: center; padding-left: 6px; font-size: .78rem; font-weight: 650; color: #fff; white-space: nowrap; overflow: visible; cursor: default; transition: filter .15s; }
.segment:hover, .segment:focus-visible { filter: brightness(1.12); }
.segment.r4 { color: var(--r4-ink); }
.segment .anteil[hidden] { display: none; }
.r1 { background: var(--r1); } .r2 { background: var(--r2); } .r3 { background: var(--r3); }
.r4 { background: var(--r4); } .r5 { background: var(--r5); } .r6 { background: var(--r6); }
.legende { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .82rem; color: var(--ink-2); }
.legende span { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Positionsliste */
.position { display: grid; grid-template-columns: auto 1fr auto; gap: .1rem .75rem; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--gitter); }
.position:last-child { border-bottom: 0; padding-bottom: 2px; }
.position .swatch { width: 12px; height: 34px; border-radius: 4px; grid-row: span 2; }
.position .name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.25; }
.position .unter { font-size: .8rem; color: var(--ink-3); }
.position .rechts { text-align: right; font-variant-numeric: tabular-nums; }
.position .wert { font-weight: 600; }
.position .diff { font-size: .82rem; }

/* Divergierende Balken (Ergebnis je Wertpapier) */
.div-zeile { padding: 6px 0 2px; border-bottom: 1px solid var(--gitter); }
.div-zeile:last-of-type { border-bottom: 0; }
.div-name { font-size: .84rem; line-height: 1.2; overflow-wrap: anywhere; display: flex; gap: .5rem; align-items: baseline; }
.div-name small { color: var(--ink-3); font-size: .72rem; }
.div-spur { position: relative; height: 34px; }
.div-spur::before { content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 1px; background: var(--achse); }
.div-balken { position: absolute; top: 9px; height: 16px; }
.div-balken.plus { left: 50%; background: var(--gewinn); border-radius: 0 4px 4px 0; }
.div-balken.minus { right: 50%; background: var(--verlust); border-radius: 4px 0 0 4px; }
.div-wert { position: absolute; top: 8px; font-size: .78rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.div-treffer { position: absolute; inset: 0; cursor: default; border-radius: 6px; }
.div-treffer:hover, .div-treffer:focus-visible { background: var(--akzent-wash); }
.div-legende { display: flex; justify-content: space-between; font-size: .76rem; color: var(--ink-3); margin-top: .5rem; }
.div-legende span { display: inline-flex; align-items: center; gap: .35rem; }

/* Automatiken */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 12px; background: var(--flaeche-2); border: 1px solid var(--rand); font-size: .86rem; }
.chip .icon { width: 18px; height: 18px; color: var(--akzent); }
.chip b { font-weight: 650; }

/* Tipps */
.lagebild { background: radial-gradient(140% 90% at 0% 0%, var(--akzent-wash), transparent 60%), var(--flaeche); }
.zaehler { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.zaehler span { font-size: .78rem; padding: .25rem .6rem; border-radius: 999px; background: var(--flaeche-2); border: 1px solid var(--rand); color: var(--ink-2); }
.tipp { display: grid; grid-template-columns: auto 1fr; gap: 0 .85rem; }
.tipp-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--flaeche-2); color: var(--ink-2); }
.tipp-icon .icon { width: 22px; height: 22px; }
.tipp-icon.kaufen, .tipp-icon.nachkaufen { background: color-mix(in srgb, var(--s-gut) 16%, transparent); color: var(--gut-text); }
.tipp-icon.verkaufen, .tipp-icon.reduzieren { background: color-mix(in srgb, var(--s-krit) 14%, transparent); color: var(--schlecht-text); }
.tipp-icon.beobachten { background: color-mix(in srgb, var(--s-warn) 20%, transparent); color: var(--ink); }
.tipp-icon.sparplan_anpassen { background: var(--akzent-wash); color: var(--akzent); }
.tipp-kopf { display: flex; justify-content: space-between; gap: .6rem; align-items: start; }
.tipp-kopf h3 { line-height: 1.25; }
.aktion { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); white-space: nowrap; margin-top: .15rem; }
.tipp-meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .8rem; color: var(--ink-3); margin: .25rem 0 .2rem; }
.tipp-meta b { color: var(--ink); font-weight: 650; }
.tipp-text { grid-column: 1 / -1; }
.stufen { display: inline-flex; align-items: center; gap: .35rem; }
.stufen i { display: inline-flex; gap: 2px; }
.stufen i span { width: 10px; height: 6px; border-radius: 2px; background: var(--gitter); }
.stufen i span.an { background: var(--ink-2); }
.gegen { background: var(--flaeche-2); border-radius: 12px; padding: .6rem .8rem; color: var(--ink-2); font-size: .92rem; }
.gegen b { color: var(--ink); }
.quellen { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .6rem; }
.quellen a { font-size: .76rem; padding: .2rem .55rem; border-radius: 999px; background: var(--akzent-wash); color: var(--akzent); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quellen-liste { padding-left: 1.1rem; font-size: .85rem; }
.quellen-liste a { color: var(--akzent); overflow-wrap: anywhere; }

/* Bilanz */
.bilanz-zeile { display: grid; grid-template-columns: 1fr auto auto; gap: .2rem .9rem; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--gitter); font-size: .9rem; }
.bilanz-zeile:last-child { border-bottom: 0; }
.bilanz-zeile .zahl { text-align: right; font-variant-numeric: tabular-nums; min-width: 4.2rem; }
.bilanz-zeile .zahl small { display: block; color: var(--ink-3); font-size: .72rem; }
.urteil { font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; background: var(--flaeche-2); color: var(--ink-3); display: inline-flex; gap: .25rem; align-items: center; }
.urteil.richtig { color: var(--gut-text); } .urteil.falsch { color: var(--schlecht-text); }
.meter { height: 8px; border-radius: 999px; background: var(--akzent-wash); overflow: hidden; margin-top: .5rem; }
.meter span { display: block; height: 100%; background: var(--akzent); border-radius: 999px; }

/* Tooltip */
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--flaeche); color: var(--ink); border: 1px solid var(--rand); border-radius: 10px; padding: .45rem .65rem; font-size: .8rem; box-shadow: 0 8px 24px -8px rgba(0,0,0,.35); max-width: 240px; }
.tooltip b { display: block; font-size: .95rem; }
.tooltip .zeile { display: flex; align-items: center; gap: .4rem; color: var(--ink-2); }
.tooltip .key { width: 12px; height: 2px; border-radius: 1px; }

/* Dialog */
dialog { border: 1px solid var(--rand); border-radius: var(--radius); background: var(--flaeche); color: var(--ink); width: min(420px, calc(100% - 32px)); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
.knoepfe { display: flex; gap: .6rem; justify-content: flex-end; }
