:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #14171c;
  --muted: #677080;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --up: #15803d;
  --down: #dc2626;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d222b;
    --border: #2a303b;
    --text: #e8ebf0;
    --muted: #8b94a3;
    --accent: #22c55e;
    --accent-ink: #06210f;
    --up: #34d399;
    --down: #f87171;
    --warn: #fbbf24;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.small { font-size: 0.85rem; }

/* Kopfzeile */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#nav a {
  padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap;
}
#nav a:hover { background: var(--surface-2); color: var(--text); }
#nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* Bausteine */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.stack { display: grid; gap: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); }
.grid-main { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat .value { font-size: 1.45rem; font-weight: 650; margin-top: 2px; }
.stat .sub { font-size: 0.85rem; margin-top: 2px; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent;
  padding: 9px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; }
button.ghost:hover { background: var(--surface-2); }
button.small { padding: 5px 10px; font-size: 0.85rem; }
button.danger { background: var(--down); color: #fff; }
button.sell { background: var(--down); color: #fff; }

input, select {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: transparent; color: var(--muted); padding: 6px 12px; font-weight: 500; border-radius: 8px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.seg.full { display: flex; }
.seg.full button { flex: 1; }
.seg button.on.buy { background: var(--accent); color: var(--accent-ink); }
.seg button.on.sell { background: var(--down); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.82rem; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
}
.badge.open { background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.badge.closed { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.bad { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); }

.sym { font-weight: 600; }
.name-cell { max-width: 280px; }
.name-cell .muted { display: block; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* Login */
.auth { max-width: 400px; margin: 8vh auto; }
.auth h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth form { display: grid; gap: 14px; margin-top: 20px; }
.error { color: var(--down); font-size: 0.9rem; min-height: 1.2em; }

/* Suche */
.search-results { margin-top: 8px; }
.search-results .item {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 8px; border-radius: 8px; cursor: pointer;
  text-decoration: none;
}
.search-results .item:hover { background: var(--surface-2); }

/* Chart */
.chart { position: relative; height: 280px; margin-top: 12px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .tip {
  position: absolute; top: 0; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 8px; font-size: 0.8rem; white-space: nowrap; box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.chart.small { height: 180px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 0.92rem; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; }
.kv .total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }
.note { font-size: 0.82rem; color: var(--muted); }
.price-big { font-size: 2rem; font-weight: 700; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--down); color: #fff; }

.podium td:first-child { font-weight: 700; width: 48px; }
.me td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

@media (max-width: 900px) {
  .grid-main { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  #topbar { flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  #nav { order: 3; flex-basis: 100%; }
  main { padding: 16px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .value { font-size: 1.15rem; }
  .hide-sm { display: none; }
}

/* ---------- Erweiterungen ---------- */
.user a { text-decoration: none; color: var(--muted); }
.user a:hover { color: var(--text); }
.bell { position: relative; display: inline-flex; padding: 6px; border-radius: 8px; }
.bell:hover { background: var(--surface-2); }
#unread {
  position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  background: var(--down); color: #fff; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.grid-5 { display: grid; gap: 16px; grid-template-columns: repeat(5, 1fr); }
.grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; align-items: start; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: transparent; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent;
  padding: 10px 14px; font-weight: 500; white-space: nowrap;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.feed { display: grid; gap: 2px; }
.feed .item { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.feed .item:last-child { border-bottom: none; }
.feed .ico { width: 26px; text-align: center; flex: none; }
.feed .when { color: var(--muted); font-size: 0.78rem; }
.ach-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.ach { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ach .icon { font-size: 1.8rem; width: 40px; text-align: center; }
.ach.locked { opacity: 0.45; filter: grayscale(1); }
.ach .t { font-weight: 600; }
.ach .d { font-size: 0.82rem; color: var(--muted); }
.notif { display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); text-decoration: none; }
.notif.unread { font-weight: 600; }
.notif:last-child { border-bottom: none; }
.inline-form { display: grid; gap: 10px; grid-template-columns: 1fr 1fr auto; align-items: end; }
.inline-form.three { grid-template-columns: 1fr 1fr 1fr auto; }
.banner {
  padding: 10px 14px; border-radius: 10px; font-size: 0.9rem;
  background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.podium-big { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 10px 0 20px; }
.podium-big div { text-align: center; padding: 12px; border-radius: 10px; background: var(--surface-2); min-width: 100px; }
.podium-big .p1 { padding-bottom: 36px; }
.podium-big .p2 { padding-bottom: 22px; }
.podium-big .medal { font-size: 2rem; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .inline-form, .inline-form.three { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .grid-5 { grid-template-columns: 1fr 1fr; gap: 10px; }
}
