:root {
  --bg: #0d1016; --surface: #161a22; --surface2: #1d222c; --border: #2a303c;
  --text: #e8ebf0; --muted: #8d96a6; --accent: #f0b90b; --accent-text: #1a1400;
  --pos: #2ebd85; --neg: #f6465d; --warn: #f0b90b; --radius: 14px; --series-1: #3987e5;
  color-scheme: dark;
}
/* Hell: Systemeinstellung (außer explizit „dunkel“ gewählt) oder explizite Wahl „hell“ (theme.js) */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f4f5f7; --surface: #fff; --surface2: #f0f2f5; --border: #dfe3ea;
    --text: #151a23; --muted: #5d6676; --accent: #f0b90b; --pos: #0e9f6e; --neg: #d9304a; --warn: #9a6b00; --series-1: #2a78d6;
    color-scheme: light; }
}
:root[data-theme="light"] { --bg: #f4f5f7; --surface: #fff; --surface2: #f0f2f5; --border: #dfe3ea;
    --text: #151a23; --muted: #5d6676; --accent: #f0b90b; --pos: #0e9f6e; --neg: #d9304a; --warn: #9a6b00; --series-1: #2a78d6;
    color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code { background: var(--surface2); padding: .1em .35em; border-radius: 6px; font-size: .9em; word-break: break-all; }
small { color: var(--muted); font-size: .82rem; display: block; font-weight: 400; }
.muted { color: var(--muted); } .center { text-align: center; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
body.app main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Kopfzeile + Navigation (mobil: Leiste unten) */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px 8px;
  text-decoration: none; color: var(--muted); font-size: .75rem; min-height: 56px; }
.nav a[aria-current] { color: var(--warn); } /* im hellen Design dunkler als --accent → lesbar auf Weiß */
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 760px) {
  body.app main { padding-bottom: 40px; }
  .nav { position: static; border: 0; background: none; padding: 0; gap: 4px; }
  .nav a { flex: none; flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 10px; font-size: .95rem; min-height: 0; }
  .nav a[aria-current] { background: var(--surface2); color: var(--text); }
  .nav svg { width: 18px; height: 18px; }
}

/* Hell/Dunkel-Umschalter (theme.js), rechts in der Kopfzeile: zeigt das Ziel – Sonne im dunklen, Mond im hellen Design */
.themetoggle { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 0;
  border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: .95rem; cursor: pointer; }
.themetoggle:hover { color: var(--text); background: var(--surface2); }
.themetoggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.themetoggle .to-light, .themetoggle .to-dark { display: contents; }
.themetoggle .to-dark { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .themetoggle .to-light { display: none; }
  :root:not([data-theme="dark"]) .themetoggle .to-dark { display: contents; }
}
:root[data-theme="light"] .themetoggle .to-light { display: none; }
:root[data-theme="light"] .themetoggle .to-dark { display: contents; }

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin: 0 0 16px; }
.card.narrow { max-width: 560px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > * { margin: 0; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions.wrap { flex-wrap: wrap; } .actions.end { justify-content: flex-end; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 8px; padding: 6px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.stop { background: transparent; border-color: var(--neg); color: var(--neg); }
.btn.danger { color: var(--neg); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.wide { width: 100%; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; min-height: 46px; width: 100%; }
input[type=radio], input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); flex: none; padding: 0; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.unit { display: flex; align-items: stretch; }
.unit input { border-radius: 10px 0 0 10px; min-width: 0; }
.unit i { font-style: normal; display: flex; align-items: center; padding: 0 12px; background: var(--surface2);
  border: 1px solid var(--border); border-left: 0; border-radius: 0 10px 10px 0; color: var(--muted); font-weight: 400; white-space: nowrap; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); align-items: start; }
.otp { font-size: 1.5rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: .85rem; margin-right: 6px; }

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.choice { flex-direction: row; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; background: var(--bg); }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice b { display: block; }

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid var(--border); background: var(--surface); border-left: 4px solid var(--pos); }
.flash.err { border-left-color: var(--neg); } .flash.warn { border-left-color: var(--warn); }

.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge.live { color: #fff; background: var(--neg); border-color: var(--neg); }
.badge.on { color: var(--pos); border-color: var(--pos); }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; min-width: 0; }
.tile .label { color: var(--muted); font-size: .8rem; }
.tile .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .sub { font-size: .8rem; color: var(--muted); } .tile .sub.pos { color: var(--pos); } .tile .sub.neg { color: var(--neg); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); margin-bottom: 16px; }
.bot { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.botlink { text-decoration: none; display: block; flex: 1; }
.bot .btn { width: 100%; }
.cardactions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pnl { font-weight: 700; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.kv dt { color: var(--muted); font-size: .78rem; } .kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.status { color: var(--muted); font-size: .88rem; margin: 0; overflow-wrap: anywhere; }
.status.big { font-size: .95rem; margin-bottom: 14px; }

.scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; } .r { text-align: right; }
tr:last-child td { border-bottom: 0; }
.side { font-weight: 700; } .side.buy { color: var(--pos); } .side.sell { color: var(--neg); }

.chartcard { padding: 8px; } #chart, #bt-chart { height: 320px; } #chart-msg { padding: 0 10px; margin: 0; }
@media (min-width: 760px) { #chart, #bt-chart { height: 420px; } }

/* Simulation */
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline label { flex: 1 1 180px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 6px 10px 2px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; border-top: 2px solid var(--series-1); }
.legend i.ref { border-top: 2px dashed var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }

.log { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.log li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border: 0; } .log time { color: var(--muted); white-space: nowrap; }
.log .error span { color: var(--neg); } .log .warn span { color: var(--warn); }

.steps { padding-left: 1.2rem; margin: 0 0 1rem; } .steps li { margin-bottom: .5rem; } .steps.small { font-size: .9rem; color: var(--muted); }
.empty { text-align: left; max-width: 640px; }

/* Login / Setup */
.auth { max-width: 400px; margin: 6vh auto 0; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 2rem; margin-bottom: 18px; }
.qr { display: block; margin: 0 auto; background: #fff; border-radius: 10px; max-width: 100%; height: auto; }
.secret { display: block; text-align: center; padding: 10px; font-size: 1rem; }
.bigcode { font-size: 4rem; font-weight: 800; margin: 0; color: var(--muted); }
[hidden] { display: none !important; }

/* Plugin-Liste: umbrechende Einträge statt Tabelle, kein seitliches Scrollen */
.plist { list-style: none; margin: 0 0 12px; padding: 0; }
.plist li { padding: 12px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.plist li:first-child { border-top: 0; padding-top: 0; }
.plist .row { align-items: center; flex-wrap: nowrap; margin-bottom: 6px; }
.plist .row > div { min-width: 0; }
.plist p { margin: 0 0 4px; font-size: .92rem; }
.plist .meta { font-size: .82rem; margin: 0; }
.plist .pdel { margin-top: 8px; }
input[type=file] { padding: 8px; max-width: 100%; }
.plist .pacts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.notes { margin: 0; padding-left: 20px; } .notes li { margin: 0 0 8px; font-size: .92rem; }
.sym { color: var(--text); font-weight: 700; }

/* Bot-Karten der Übersicht: flach und ruhig – drei Zeilen Zahlen, eine Statuszeile, schmale Fußzeile */
.grid { gap: 10px; }
.bot { padding: 12px 14px 10px; gap: 8px; }
.bot h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.bot .row { flex-wrap: nowrap; align-items: baseline; gap: 10px; }
.bot .row > :first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot .row > :last-child { flex: none; font-variant-numeric: tabular-nums; }
.bot .row.sub { font-size: .86rem; color: var(--muted); margin-top: 2px; }
.bot .row.sub .pos { color: var(--pos); } .bot .row.sub .neg { color: var(--neg); }
.bot .worth { color: var(--text); font-weight: 600; }
.bot .status { font-size: .8rem; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border); margin-right: 7px; vertical-align: 1px; }
.dot.on { background: var(--pos); }
.bot h2 .badge { font-size: .62rem; padding: 1px 6px; vertical-align: 2px; }
.botfoot { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.botfoot .botmeta { flex: 1; min-width: 0; color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.botfoot .btn { width: auto; min-height: 30px; padding: 0 10px; font-size: .8rem; border-radius: 8px; background: transparent; }
.botfoot .btn.primary { background: var(--accent); }
.handtrade { display: flex; gap: 0; align-items: stretch; flex: 1 1 340px; min-width: 0; }
.handtrade .unit { flex: 1 1 120px; min-width: 0; }
.handtrade .unit input { width: 100%; }
.handtrade .btn { flex: none; }
.pencil { display: inline-flex; vertical-align: middle; padding: 6px; margin-left: 2px; border-radius: 8px; color: var(--muted); }
.pencil:hover { color: var(--text); background: var(--surface2); }
.pencil svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.renameform { margin: 0 0 14px; }
.badges { align-items: center; }
.inlinestatus { flex: 1 1 200px; min-width: 0; }
/* Betragsfeld, Währung und beide Knöpfe als eine zusammenhängende Gruppe */
.handtrade .unit i { border-radius: 0; }
.handtrade .btn { border-radius: 0; border-left: 0; min-height: 46px; }
.handtrade .btn:last-child { border-radius: 0 10px 10px 0; }
.poslist .row > div:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poslist a { text-decoration: none; }
.posnum { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.meta .pos { color: var(--pos); } .meta .neg { color: var(--neg); }

/* Steuer */
.ledger-filter label.check { flex: 1 1 260px; align-self: center; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
