/* Trading Demo – mobile-first, dunkel als Standard, hell nach Systemeinstellung */
:root {
  --bg: #0b1015; --panel: #121a22; --panel-2: #18222c; --line: #24313d; --text: #e7eef5; --muted: #8fa1b3;
  --accent: #2ee6a6; --accent-ink: #062018; --pos: #3ddc97; --neg: #ff6b6b; --warn: #ffc857; --info: #5aa9ff;
  --radius: 14px; --shadow: 0 6px 24px rgba(0, 0, 0, .25);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6f8; --panel: #ffffff; --panel-2: #f0f3f6; --line: #dde3e9; --text: #101820; --muted: #5d6b78;
    --accent: #0d9f6e; --accent-ink: #ffffff; --pos: #0a8a5a; --neg: #d63c3c; --warn: #a76a00; --info: #1f6fd1;
    --shadow: 0 4px 18px rgba(16, 24, 32, .08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.busy { cursor: progress; }
a { color: var(--info); }
h1 { font-size: 1.5rem; margin: 18px 0 12px; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
.card h2 { margin-top: 0; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn-text { color: var(--warn); }
.danger-text { color: var(--neg) !important; }
.r { text-align: right; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty { color: var(--muted); padding: 12px 0; }
.foot { color: var(--muted); font-size: .78rem; margin-top: 22px; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; border-radius: 6px; }

/* Kopfzeile */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.brand.big { font-size: 1.6rem; justify-content: center; margin-bottom: 8px; }
.logo { color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status.ok .dot { background: var(--pos); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 25%, transparent); }
.status.warn .dot { background: var(--warn); }
.status.bad .dot { background: var(--neg); }
.status.bad { color: var(--neg); }
@media (max-width: 520px) { .status-text, .hide-xs { display: none; } }
.icon-btn { position: relative; background: none; border: 0; color: var(--text); padding: 8px; border-radius: 10px; cursor: pointer; min-width: 44px; min-height: 44px; }
.icon-btn:hover { background: var(--panel-2); }
.badge { position: absolute; top: 4px; right: 4px; background: var(--neg); color: #fff; font-size: .7rem; border-radius: 10px; padding: 0 5px; min-width: 18px; }
.kill { border: 2px solid var(--neg); background: transparent; color: var(--neg); font-weight: 700; border-radius: 10px; padding: 8px 12px; min-height: 44px; cursor: pointer; white-space: nowrap; }
.kill:hover { background: var(--neg); color: #fff; }
.kill.on { border-color: var(--accent); color: var(--accent); }
.kill.on:hover { background: var(--accent); color: var(--accent-ink); }

/* Hinweise */
.banner { padding: 10px 16px; font-size: .9rem; border-left: 4px solid var(--info); background: color-mix(in srgb, var(--info) 12%, var(--panel)); margin: 0; }
.banner.preview { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--panel)); }
.banner.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-radius: 8px; margin: 10px 0; }
.banner.danger { border-color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, var(--panel)); }
.chip { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.chip.demo { background: var(--warn); color: #2a1d00; border-color: transparent; }
.chip.live { background: var(--neg); color: #fff; border-color: transparent; }
.live-card { border-color: var(--neg); border-width: 2px; }
.usd { display: block; font-size: .72em; font-weight: 500; color: var(--muted); }
.item-side .usd, .kv .usd { display: inline; margin-left: 4px; }
.chip.ok { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 50%, transparent); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.chip.bad { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 50%, transparent); }

/* Aufbau: unten Navigation (Handy), links Seitenleiste (PC) */
.layout { max-width: 1180px; margin: 0 auto; }
main { padding: 0 16px 24px; outline: none; min-width: 0; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around; background: var(--panel);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: .7rem; border-radius: 10px; min-height: 48px; }
.nav a.active { color: var(--accent); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .layout { display: grid; grid-template-columns: 210px 1fr; gap: 24px; padding: 0 16px; }
  .nav { position: sticky; top: 72px; align-self: start; flex-direction: column; justify-content: flex-start; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 18px; padding: 8px; }
  .nav a { flex-direction: row; gap: 10px; font-size: .95rem; padding: 10px 12px; min-height: 0; }
  .nav a.active { background: var(--panel-2); }
  main { padding: 0 0 40px; }
}

/* Karten */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
section.card { margin: 14px 0; }
.card.big { grid-column: 1 / -1; }
.card.big .value { font-size: 2rem; }
.card.info { background: var(--panel-2); box-shadow: none; }
.label { color: var(--muted); font-size: .8rem; }
.value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }

/* Autopilot */
.autopilot { margin: 0 0 12px; border-width: 2px; }
.autopilot.on { border-color: var(--accent); }
.ap-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-head .row-btns { margin-top: 0; }
.radio > span { display: block; }

/* Listen */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.item { display: flex; justify-content: space-between; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.item-main { min-width: 0; flex: 1; }
.item-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; flex-shrink: 0; }
.item-side.col { justify-content: flex-start; }
@media (max-width: 520px) { .item.rule { flex-direction: column; } .item.rule .item-side { flex-direction: row; flex-wrap: wrap; align-items: center; } }

/* Tabellen */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-top: 12px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .75rem; color: var(--muted); font-weight: 600; text-align: left; }
.table th.r { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table td.r { white-space: nowrap; }
.show-s { display: none; }
@media (max-width: 600px) {
  .hide-s { display: none; } .show-s { display: block; }
  .table th, .table td { padding: 8px 4px; font-size: .8rem; }
  .table .btn.small { padding: 6px 8px; font-size: .8rem; }
}
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.log { list-style: none; padding: 0; margin: 12px 0; }
.log li { padding: 8px 10px; border-left: 3px solid var(--line); margin-bottom: 6px; background: var(--panel); border-radius: 0 8px 8px 0; font-size: .9rem; }
.log li.warn { border-color: var(--warn); }
.log li.error { border-color: var(--neg); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tabs button { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap; min-height: 40px; }
.tabs button.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* Knöpfe und Formulare */
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 44px; font-size: .95rem; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--neg); color: #fff; }
.link { background: none; border: 0; color: var(--info); cursor: pointer; padding: 8px 0; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.row-btns.end { justify-content: flex-start; }
.row-btns.rev { flex-direction: row-reverse; justify-content: flex-start; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .dlg label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
label.check, label.radio { flex-direction: row !important; align-items: center; gap: 8px; color: var(--text) !important; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { padding: 0 6px; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* Dialoge */
.dlg { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(0, 0, 0, .55); }
.dlg h2 { margin-top: 0; }
.dlg-body { display: flex; flex-direction: column; gap: 10px; }
.dlg ul { padding-left: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.inbox { list-style: none; padding: 0 !important; margin: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60dvh; overflow: auto; }
.inbox li { padding: 10px; border-radius: 10px; background: var(--panel-2); }
.inbox li.unread { border-left: 3px solid var(--accent); }

/* Passwort mit Auge */
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted);
  width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
.pw-eye:hover, .pw-eye[aria-pressed="true"] { color: var(--text); }

/* Anmeldung */
.login { max-width: 420px; margin: 0 auto; padding: 48px 16px; text-align: center; }
.login .form { text-align: left; margin-top: 18px; }

/* Meldung unten */
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--pos); padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px); transition: .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-left-color: var(--neg); }
@media (min-width: 900px) { .toast { bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
