/* Mein Depot – grosse Schrift, hoher Kontrast, hell/dunkel ueber Tokens.
   Status nie nur ueber Farbe: jede Hervorhebung hat zusaetzlich Text + Symbol. */

:root {
  --c-hg: #f6f5f1;
  --c-flaeche: #ffffff;
  --c-text: #141414;
  --c-leise: #4a4a4a;
  --c-linie: #c9c6bd;
  --c-akzent: #0b4f8a;
  --c-akzent-text: #ffffff;
  --c-fokus: #e0a100;

  --c-stop: #b3141b;
  --c-stop-bg: #fde8e7;
  --c-stop-zone: #e35d5b;
  --c-ziel: #106b2c;
  --c-ziel-bg: #e3f4e6;
  --c-ziel-zone: #3fa45b;
  --c-warn: #7a4b00;
  --c-warn-bg: #fff3d6;

  --c-spur: #d8d5cc;
  --c-punkt: #141414;
  --c-kurs: #0b4f8a;
  --c-einstand: #555555;
  --c-raster: #e4e1d9;

  --radius: 10px;
  --abstand: 1rem;
  font-size: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-hg: #121314;
    --c-flaeche: #1d1f21;
    --c-text: #f2f2f2;
    --c-leise: #b9b9b9;
    --c-linie: #3c3f43;
    --c-akzent: #6cb2f2;
    --c-akzent-text: #0b1520;
    --c-fokus: #ffcc4d;

    --c-stop: #ff8a85;
    --c-stop-bg: #3a1716;
    --c-stop-zone: #d9534f;
    --c-ziel: #7fdc95;
    --c-ziel-bg: #13301c;
    --c-ziel-zone: #3fa45b;
    --c-warn: #ffd27a;
    --c-warn-bg: #3a2c0c;

    --c-spur: #44484d;
    --c-punkt: #f2f2f2;
    --c-kurs: #6cb2f2;
    --c-einstand: #b0b0b0;
    --c-raster: #2c2f33;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--c-hg);
  color: var(--c-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

a { color: var(--c-akzent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--c-fokus); outline-offset: 2px; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.75rem; }
h2 { font-size: 1.3rem; margin: 1.5rem 0 0.75rem; }
h1 + h2, .karte > h2:first-child { margin-top: 0; }

.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }
.gross { font-size: 1.15rem; font-weight: 700; }
.klein { font-size: 0.85rem; }
.leise { color: var(--c-leise); }
.warn-text { color: var(--c-warn); font-weight: 600; }
.unsichtbar {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--c-flaeche); padding: 0.5rem 1rem; z-index: 10; }

/* ---------- Kopf / Fuss ---------- */

.kopf {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--c-flaeche);
  border-bottom: 1px solid var(--c-linie);
}
.marke { font-size: 1.3rem; font-weight: 800; color: var(--c-text); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1.25rem; }
.nav a { font-weight: 600; text-decoration: none; padding: 0.4rem 0; }
.nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 3px; }
.inline { display: inline; margin: 0; }

.inhalt { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.fuss { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 2rem; color: var(--c-leise); font-size: 0.85rem; }
.zurueck { margin: 0 0 0.75rem; }

/* ---------- Bausteine ---------- */

.karte {
  background: var(--c-flaeche);
  border: 1px solid var(--c-linie);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 0 0 1.25rem;
}
.schmal { max-width: 34rem; margin-left: auto; margin-right: auto; }
.formular { max-width: 46rem; }
.leer { text-align: center; padding: 2.5rem 1.25rem; }
.leer p { max-width: 36rem; margin-left: auto; margin-right: auto; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 3rem; padding: 0.6rem 1.25rem;
  font: inherit; font-weight: 700;
  color: var(--c-text); background: var(--c-flaeche);
  border: 2px solid var(--c-linie); border-radius: var(--radius);
  text-decoration: none; cursor: pointer;
}
.knopf:hover { border-color: var(--c-akzent); }
.knopf-haupt { background: var(--c-akzent); border-color: var(--c-akzent); color: var(--c-akzent-text); }
.knopf-gefahr { background: var(--c-stop); border-color: var(--c-stop); color: var(--c-flaeche); }
.knopf[aria-pressed="true"] { background: var(--c-akzent); border-color: var(--c-akzent); color: var(--c-akzent-text); }
.breit { width: 100%; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }

button.link {
  font: inherit; font-weight: 600; color: var(--c-akzent);
  background: none; border: 0; padding: 0.4rem 0; cursor: pointer; text-decoration: underline;
}

.meldung { padding: 0.75rem 1rem; border-radius: var(--radius); font-weight: 600; }
.meldung-fehler { background: var(--c-stop-bg); color: var(--c-stop); border: 2px solid var(--c-stop); }

.hilfe { color: var(--c-leise); font-size: 0.9rem; margin: 0.3rem 0 0; }

/* ---------- Formular ---------- */

.feld { margin: 0 0 1.1rem; border: 0; padding: 0; min-width: 0; }
fieldset.feld { border: 1px solid var(--c-linie); border-radius: var(--radius); padding: 0.75rem 1rem 1rem; }
legend { font-weight: 700; padding: 0 0.35rem; }
label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
label.wahl { display: flex; align-items: center; gap: 0.6rem; font-weight: 500; min-height: 2.75rem; }
.wahlen { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }
input[type="radio"] { width: 1.4rem; height: 1.4rem; margin: 0; accent-color: var(--c-akzent); }

input:not([type="radio"]), textarea {
  width: 100%; min-height: 3rem;
  padding: 0.55rem 0.75rem;
  font: inherit; font-size: 1.05rem;
  color: var(--c-text); background: var(--c-hg);
  border: 2px solid var(--c-linie); border-radius: var(--radius);
}
input[readonly] { color: var(--c-leise); }
input[aria-invalid="true"] { border-color: var(--c-stop); }
.feldfehler { color: var(--c-stop); font-weight: 700; margin: 0.35rem 0 0; }
.feldfehler::before { content: "✖ "; }
.zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.marke-feld-stop { border-left: 6px solid var(--c-stop); }
.marke-feld-ziel { border-left: 6px solid var(--c-ziel); }

/* ---------- Wertpapiersuche (nur "Neue Position") ---------- */

.suche { margin: 0 0 0.75rem; }
.suchzeile { display: flex; gap: 0.6rem; align-items: stretch; }
.suchzeile input { flex: 1 1 auto; min-width: 0; }
.suchzeile .knopf { flex: 0 0 auto; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="search"]::-webkit-search-cancel-button { width: 1.25rem; height: 1.25rem; }

#treffer { margin: 0 0 1.25rem; }
.such-hinweis {
  margin: 0; padding: 0.75rem 1rem;
  background: var(--c-warn-bg); color: var(--c-text);
  border: 2px solid var(--c-warn); border-radius: var(--radius);
}
.trefferliste {
  list-style: none; margin: 0; padding: 0;
  border: 2px solid var(--c-linie); border-radius: var(--radius);
  overflow: hidden; background: var(--c-flaeche);
}
.trefferliste li + li { border-top: 1px solid var(--c-linie); }
.treffer {
  display: flex; flex-direction: column; justify-content: center; gap: 0.15rem;
  min-height: 3.5rem; padding: 0.7rem 1rem;
  color: var(--c-text); text-decoration: none;
}
.treffer:hover, .treffer:focus-visible { background: var(--c-hg); }
.treffer:focus-visible { outline-offset: -3px; }
.treffer-name { font-weight: 700; font-size: 1.05rem; color: var(--c-akzent); text-decoration: underline; text-underline-offset: 0.15em; }
.treffer-info { color: var(--c-leise); font-size: 0.85rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.auswahl {
  margin: 0 0 1.1rem; padding: 0.75rem 1rem; font-weight: 700;
  background: var(--c-ziel-bg); color: var(--c-text);
  border: 2px solid var(--c-ziel); border-left-width: 6px; border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.auswahl::before { content: "✓ "; color: var(--c-ziel); }

/* ---------- Kennzahlen / Banner ---------- */

.kennzahlen {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem;
  margin: 0 0 1.25rem;
}
.kennzahl {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.9rem 1rem;
  background: var(--c-flaeche); color: var(--c-text);
  border: 2px solid var(--c-linie); border-radius: var(--radius);
  text-decoration: none;
}
a.kennzahl:hover { border-color: var(--c-akzent); }
.kennzahl-titel { font-size: 0.9rem; font-weight: 600; color: var(--c-leise); }
.kennzahl-wert { font-size: 1.5rem; font-weight: 800; }
.kennzahl-fuss { font-size: 0.8rem; color: var(--c-leise); }
.kennzahl-stop { border-left: 6px solid var(--c-stop); }
.kennzahl-ziel { border-left: 6px solid var(--c-ziel); }
.kennzahl.gewaehlt { outline: 3px solid var(--c-akzent); }
.plus { color: var(--c-ziel); }
.minus { color: var(--c-stop); }

.banner {
  padding: 0.9rem 1.1rem; margin: 0 0 1.25rem;
  background: var(--c-warn-bg); color: var(--c-text);
  border: 2px solid var(--c-warn); border-radius: var(--radius);
}
.filterzeile { font-weight: 600; }
.stand { color: var(--c-leise); font-size: 0.85rem; }

/* ---------- Tabelle ---------- */

.tabelle {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--c-flaeche);
  border: 1px solid var(--c-linie); border-radius: var(--radius);
  overflow: hidden;
}
.tabelle th, .tabelle td { padding: 0.75rem 0.9rem; vertical-align: top; text-align: left; }
.tabelle thead th {
  font-size: 0.85rem; color: var(--c-leise); font-weight: 700;
  border-bottom: 2px solid var(--c-linie); white-space: nowrap;
}
.tabelle tbody tr + tr > * { border-top: 1px solid var(--c-linie); }
.tabelle .r { text-align: right; }
.tabelle .mitte { text-align: center; }
.tabelle td > span, .tabelle th.pos > span, .tabelle th.pos > a { display: block; }
.pos { font-weight: 400; min-width: 12rem; }
.pos-name { font-weight: 700; font-size: 1.05rem; }
.pos-isin { color: var(--c-leise); font-size: 0.8rem; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; }
.spanne { vertical-align: middle !important; text-align: center; }

.status-text { font-weight: 800; margin-top: 0.2rem; }
.zeile { border-left: 0; }
.zeile > :first-child { border-left: 6px solid transparent; }

.status-stop_ausgeloest > :first-child { border-left-color: var(--c-stop); }
.status-stop_ausgeloest { background: var(--c-stop-bg); }
.status-nahe_stop > :first-child { border-left-color: var(--c-stop); }
.status-stop_ausgeloest .status-text, .status-nahe_stop .status-text { color: var(--c-stop); }

.status-ziel_ausgeloest > :first-child { border-left-color: var(--c-ziel); }
.status-ziel_ausgeloest { background: var(--c-ziel-bg); }
.status-nahe_ziel > :first-child { border-left-color: var(--c-ziel); }
.status-ziel_ausgeloest .status-text, .status-nahe_ziel .status-text { color: var(--c-ziel); }

.status-ohne_kurs .status-text { color: var(--c-leise); }
.ist-veraltet .gross { color: var(--c-leise); }

.detail-kopf { padding: 0.75rem 1rem; border-radius: var(--radius); border-left: 6px solid var(--c-linie); }
.detail-kopf p { margin: 0.25rem 0; }
.detail-kopf.status-stop_ausgeloest, .detail-kopf.status-nahe_stop { border-left-color: var(--c-stop); }
.detail-kopf.status-ziel_ausgeloest, .detail-kopf.status-nahe_ziel { border-left-color: var(--c-ziel); }

/* ---------- Spannweiten-Balken (app/svg.py) ---------- */

.bar { display: inline-block; vertical-align: middle; overflow: visible; }
.bar-track { fill: var(--c-spur); }
.bar-offen { stroke: var(--c-spur); fill: none; }
.bar-stop { fill: var(--c-stop-zone); }
.bar-ziel { fill: var(--c-ziel-zone); }
.bar-dot { fill: var(--c-punkt); stroke: var(--c-flaeche); stroke-width: 2; }
.bar-dot--ausgeloest { stroke-width: 3; }
.status-stop_ausgeloest .bar-dot--ausgeloest { fill: var(--c-stop); }
.status-ziel_ausgeloest .bar-dot--ausgeloest { fill: var(--c-ziel); }

/* ---------- Chart ---------- */

.umschalter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.chart { width: 100%; min-height: 320px; }
.legende { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.9rem; margin: 0.5rem 0 0; }
.leg::before {
  content: ""; display: inline-block; width: 1.8rem; height: 0; margin-right: 0.4rem;
  vertical-align: middle; border-top: 3px solid currentColor;
}
.leg-kurs::before { border-top-color: var(--c-kurs); }
.leg-stop::before { border-top-color: var(--c-stop); }
.leg-ziel::before { border-top-color: var(--c-ziel); }
.leg-einstand::before { border-top: 3px dashed var(--c-einstand); }
.chart .u-legend { font-size: 0.9rem; color: var(--c-text); }
.chart .u-select { background: rgba(127, 127, 127, 0.15); }

/* ---------- Schmal: Tabelle wird zu Karten ---------- */

@media (max-width: 760px) {
  :root { font-size: 18px; }
  .inhalt { padding: 0.75rem; }
  .kennzahlen { grid-template-columns: 1fr 1fr; }
  .zwei { grid-template-columns: 1fr; }

  .tabelle, .tabelle tbody, .tabelle tr, .tabelle th, .tabelle td { display: block; width: 100%; }
  .tabelle { background: none; border: 0; }
  .tabelle thead { display: none; }
  .tabelle tbody tr {
    background: var(--c-flaeche);
    border: 1px solid var(--c-linie); border-left: 6px solid var(--c-linie);
    border-radius: var(--radius);
    margin: 0 0 0.9rem; padding: 0.4rem 0;
  }
  .tabelle tbody tr + tr > * { border-top: 0; }
  .zeile > :first-child { border-left: 0; }
  .status-stop_ausgeloest, .status-nahe_stop { border-left-color: var(--c-stop) !important; }
  .status-stop_ausgeloest { background: var(--c-stop-bg) !important; }
  .status-ziel_ausgeloest, .status-nahe_ziel { border-left-color: var(--c-ziel) !important; }
  .status-ziel_ausgeloest { background: var(--c-ziel-bg) !important; }

  .tabelle th, .tabelle td { padding: 0.4rem 0.9rem; }
  .tabelle .r { text-align: left; }
  .tabelle td[data-label]::before {
    content: attr(data-label);
    display: block; font-size: 0.8rem; font-weight: 700; color: var(--c-leise);
  }
  .tabelle td > span { display: inline; margin-right: 0.5rem; }
  .spanne { text-align: left; }
  .bar { width: 100%; height: auto; max-width: 22rem; }
}

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

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
