:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e3e6eb;
  --text: #0f172a; --muted: #5b6474; --accent: #2563eb; --accent-text: #fff;
  --pos: #15803d; --neg: #c2410c; --grid: #e8ebf0;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --radius: 14px;
  --c1:#2563eb; --c2:#d97706; --c3:#059669; --c4:#db2777; --c5:#7c3aed;
  --c6:#0891b2; --c7:#65a30d; --c8:#dc2626; --c9:#475569; --c10:#c026d3;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #22304d;
    --text: #e6eaf2; --muted: #93a0b8; --accent: #60a5fa; --accent-text: #0b1120;
    --pos: #4ade80; --neg: #fb923c; --grid: #1e2a44;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    --c1:#60a5fa; --c2:#fbbf24; --c3:#34d399; --c4:#f472b6; --c5:#a78bfa;
    --c6:#22d3ee; --c7:#a3e635; --c8:#f87171; --c9:#cbd5e1; --c10:#e879f9;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }

/* Buttons & Inputs */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px;
  padding: .55rem .9rem; font: inherit; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.icon { width: 38px; padding: .45rem 0; font-size: 1.1rem; }
.btn:focus-visible, input:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input { width: 100%; margin-top: .3rem; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-logo { border-radius: 14px; }
.login-card h1 { font-size: 1.5rem; }
.login-card label { font-size: .9rem; color: var(--muted); }
.error { color: var(--neg); min-height: 1.2em; margin: 0; font-size: .9rem; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand img { border-radius: 8px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.pill { font-size: .78rem; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap; }
.pill.open { color: var(--pos); }
.container { max-width: 1240px; margin: 0 auto; padding: 16px; }
.foot { font-size: .8rem; padding-top: 0; padding-bottom: 32px; }

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: .8rem; color: var(--muted); }
.tile .value { font-size: 1.45rem; font-weight: 700; margin-top: 2px; }
.tile .sub { font-size: .85rem; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .85rem; padding: .3rem .65rem;
  border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chart-wrap { position: relative; width: 100%; }
canvas.chart { width: 100%; height: 300px; display: block; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: .8rem; box-shadow: var(--shadow); min-width: 160px; z-index: 3; }
.tooltip .row { display: flex; justify-content: space-between; gap: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .82rem; }
.legend button { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; }
.legend button.off { opacity: .35; }
.sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* Bot-Karten */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: grid; gap: 8px; color: var(--text); position: relative; overflow: hidden; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.card .top { display: flex; justify-content: space-between; gap: 8px; }
.card .name { font-weight: 650; }
.card .trader { font-size: .8rem; color: var(--muted); }
.card .ret { font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.card .eq { font-size: .85rem; color: var(--muted); }
.card canvas { width: 100%; height: 46px; }
.card .meta { display: flex; gap: 12px; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.card .status { font-size: .78rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rank { font-size: .75rem; color: var(--muted); }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; }
td.r, th.r { text-align: right; }
td.wrap { white-space: normal; min-width: 240px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }

.back { display: inline-block; margin-bottom: 10px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.detail-head h1 { font-size: 1.5rem; }
.desc { font-size: .9rem; max-width: 80ch; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .86rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.log { max-height: 420px; overflow: auto; font-size: .82rem; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.log .t { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }
.log .error { color: var(--neg); }
.empty { color: var(--muted); font-size: .9rem; padding: 8px 0; }
.offline { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-size: .85rem; z-index: 10; }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
pre.json { font-size: .78rem; background: var(--surface-2); padding: 10px; border-radius: 10px; overflow: auto; max-height: 360px; }

@media (max-width: 520px) {
  .tile .value { font-size: 1.2rem; }
  canvas.chart { height: 240px; }
  .brand span { display: none; }
}
