/* Conviction – Finanzdashboard. Farben als Rollen-Tokens, Hell/Dunkel getrennt gewählt. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --s1: #2a78d6; /* blau */
  --s2: #eb6834; /* orange */
  --s3: #1baf7a; /* aqua */
  --s7: #6250d6; /* violett */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #0a8f0a;
  --down: #d03b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --text: #f0efec; --text-2: #c3c2b7;
    --muted: #898781; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s7: #9085e9;
    --good-text: #0ca30c; --up: #0ca30c; --down: #e66767; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232322; --text: #f0efec; --text-2: #c3c2b7;
  --muted: #898781; --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s7: #9085e9;
  --good-text: #0ca30c; --up: #0ca30c; --down: #e66767; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--text); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sec { color: var(--text-2); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- Layout */
.topbar {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--page) 85%, transparent);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand svg { width: 22px; height: 22px; }
.topbar .meta { margin-left: auto; font-size: 12.5px; color: var(--muted); text-align: right; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 10px; padding: 6px 9px; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
main { max-width: 1240px; margin: 0 auto; padding: 16px; }
.banner { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid var(--border); background: var(--surface); }
.banner.demo { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }
.banner.err { border-color: var(--critical); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11.5px; color: var(--muted); padding: 4px 0; border-radius: 10px; text-decoration: none;
}
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--accent); }

h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.005em; }
h3 { font-size: 14.5px; margin: 0 0 8px; }
.section { margin: 22px 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 .span2 { grid-column: span 2; } }

/* ---------------------------------------------------------------- Markt-Leiste */
.market { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.tile .label { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.tile .hint { font-size: 12px; color: var(--muted); min-height: 1.2em; }
.tile svg { display: block; width: 100%; height: 26px; margin-top: 4px; }
.fg-bar { height: 6px; border-radius: 3px; margin-top: 6px; position: relative;
  background: linear-gradient(90deg, var(--critical), var(--serious) 25%, var(--axis) 50%, #7dc97d 75%, var(--good)); }
.fg-bar i { position: absolute; top: -3px; width: 4px; height: 12px; border-radius: 2px; background: var(--text); border: 1px solid var(--surface); transform: translateX(-2px); }

/* ---------------------------------------------------------------- Filter */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.toolbar select, .field input, .field select, .field textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
}
.toolbar .spacer { flex: 1; }

/* ---------------------------------------------------------------- Karten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s;
}
.card:hover { text-decoration: none; border-color: var(--axis); }
.card-head { display: flex; gap: 12px; align-items: flex-start; }
.card-title { min-width: 0; flex: 1; }
.card-title .name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-title .sym { font-size: 12px; color: var(--muted); }
.card-price { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.card-price .p { font-size: 19px; font-weight: 600; }
.chg.up { color: var(--good-text); } .chg.down { color: var(--down); }
.card-spark { display: block; width: 100%; height: 38px; margin: 8px 0 6px; }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.minibars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 10px; }
.minibars div { height: 4px; border-radius: 2px; background: var(--grid); position: relative; overflow: hidden; }
.minibars div i { position: absolute; inset: 0 auto 0 0; border-radius: 2px; }
.minibars-l { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Score-Ring */
.ring { position: relative; width: 58px; height: 58px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .v { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.ring.lg { width: 108px; height: 108px; } .ring.lg .v { font-size: 32px; }

/* Empfehlung & Flags */
.rec { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 13px; font-weight: 650; }
.rec svg { width: 12px; height: 12px; }
.rec.buy { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); }
.rec.hold { background: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--text); }
.rec.sell { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }
.rec.na { background: var(--surface-2); color: var(--muted); }
.flag { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 1px 7px; font-size: 12px; border: 1px solid var(--border); color: var(--text-2); }
.flag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.flag.good::before { background: var(--good); } .flag.critical::before { background: var(--critical); }
.flag.serious::before { background: var(--serious); } .flag.warning::before { background: var(--warning); }
.flag.info::before { background: var(--s1); }
.conf { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- Detail */
.back { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; margin-bottom: 10px; }
.hero { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: center; }
@media (min-width: 760px) { .hero { grid-template-columns: 1fr auto; } }
.hero .price { font-size: 28px; font-weight: 650; letter-spacing: -.01em; }
.hero-score { display: flex; gap: 16px; align-items: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--text-2); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.drivers { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .drivers { grid-template-columns: 1fr 1fr; } }
.drivers ul { list-style: none; margin: 0; padding: 0; }
.drivers li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 14px; }
.drivers li:last-child { border-bottom: 0; }
.drivers .d-pos { color: var(--good-text); } .drivers .d-neg { color: var(--down); }

/* Baustein-Balken */
.gbars { display: flex; flex-direction: column; gap: 10px; }
.gbar { display: grid; grid-template-columns: 150px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
@media (max-width: 520px) { .gbar { grid-template-columns: 110px 1fr 40px; font-size: 13px; } }
.gbar .track { position: relative; height: 12px; background: var(--surface-2); border-radius: 4px; }
.gbar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--s1); }
.gbar .tick { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.gbar .w { font-size: 11.5px; color: var(--muted); }

/* Akkordeon */
details.group { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
details.group > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .chev { transition: transform .15s; color: var(--muted); }
details.group[open] > summary .chev { transform: rotate(90deg); }
details.group > summary .gname { font-weight: 650; flex: 1; }
.gscore { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.ind { border-top: 1px solid var(--grid); }
.ind > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 110px; gap: 10px; align-items: center; padding: 9px 14px; font-size: 14px; }
.ind > summary::-webkit-details-marker { display: none; }
.ind > summary:hover { background: var(--surface-2); }
.ind .iname { min-width: 0; }
.ind .iname .c { font-size: 11px; color: var(--s7); margin-left: 4px; }
.ind .ival { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ind.missing .ival { color: var(--muted); font-style: italic; }
.pbar { position: relative; height: 8px; background: var(--surface-2); border-radius: 3px; }
.pbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.pbar .mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.pbar-wrap { display: flex; align-items: center; gap: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.pbar-wrap .pbar { flex: 1; }
.pbar-wrap span { width: 24px; text-align: right; color: var(--text-2); }
.ind .body { padding: 4px 14px 12px; font-size: 13px; color: var(--text-2); display: grid; gap: 4px; }
.ind .body b { color: var(--text); font-weight: 600; }
.ind .note { color: var(--s7); }
@media (max-width: 520px) { .ind > summary { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 70px; font-size: 13px; } }

/* Charts */
.chart-box { position: relative; width: 100%; height: 380px; }
.chart-box.sm { height: 150px; }
.chart-legend { position: absolute; left: 10px; top: 8px; z-index: 5; font-size: 12px; pointer-events: none; color: var(--text-2);
  background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 2px 6px; border-radius: 6px; }
.chart-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 10px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; cursor: pointer; user-select: none; }
.toggle input { margin: 0; accent-color: var(--accent); }
.swatch { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px); height: 2px; }

/* Fair-Value-Skala */
.fv-scale svg { width: 100%; height: 84px; display: block; overflow: visible; }

/* Tabellen */
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.t td.r, table.t th.r { text-align: right; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.news li { padding: 8px 0; border-bottom: 1px solid var(--grid); list-style: none; }
.news { margin: 0; padding: 0; }
.news .src { font-size: 12px; color: var(--muted); }

/* Balken-SVG (Quartale) */
.bars svg { width: 100%; height: 170px; display: block; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .15); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; max-width: 260px; }

/* Formulare */
.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13.5px; }
.field label { color: var(--text-2); }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 550; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { color: var(--critical); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1; min-width: 140px; }
.status-msg { font-size: 13px; margin-top: 6px; }
.wl-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.wl-item .grow { flex: 1; min-width: 0; }
.pos-advice { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.legend-row span { display: inline-flex; align-items: center; gap: 5px; }
.disclaimer { font-size: 12px; color: var(--muted); margin: 30px 0 10px; text-align: center; }
.grid2 > *, .section > * { min-width: 0; }
.news a { overflow-wrap: anywhere; }
table.t td.r { white-space: nowrap; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; }
.row > .field { min-width: 120px; }
@media (max-width: 520px) {
  .market { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .tile { padding: 8px 9px; }
  .tile .value { font-size: 17px; }
  .tile .label, .tile .hint { font-size: 11px; }
  .tile svg { height: 18px; }
}
