:root {
  --bg: #0e1117;
  --panel: #161b22;
  --panel2: #1f2630;
  --border: #2a3340;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #2ea043;
  --red: #f85149;
  --yellow: #d29922;
  --blue: #388bfd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: normal; }
.error { color: var(--red); min-height: 1.2em; }
.ok { color: var(--green); }

/* ---- Login ---- */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 320px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 8px; }

input, select, button {
  font: inherit;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}
input:focus, select:focus { outline: 1px solid var(--blue); }

button { cursor: pointer; border: 1px solid var(--border); }
button:hover { filter: brightness(1.15); }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.warn { background: var(--yellow); border-color: var(--yellow); color: #000; }
button.danger { background: var(--red); border-color: var(--red); color: #fff; }
button.ghost { background: transparent; }

/* ---- Layout ---- */
#app { max-width: 1100px; margin: 0 auto; padding: 16px; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.brand { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 10px; }

.badge {
  padding: 4px 10px; border-radius: 20px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--border);
}
.badge.live { background: var(--red); color: #fff; }
.badge.paper { background: var(--blue); color: #fff; }
.badge.running { background: var(--green); color: #fff; }
.badge.paused { background: var(--yellow); color: #000; }
.badge.stopped { background: var(--panel2); }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.dot.on { background: var(--green); }

.alert {
  background: rgba(248,81,73,.15); border: 1px solid var(--red);
  color: var(--red); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px;
}

.controls { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.cards {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 10px; margin-bottom: 16px;
}
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 6px;
}
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 18px; font-weight: 600; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-bottom: 16px;
}
.panel h2 { font-size: 14px; margin-bottom: 12px; color: var(--muted); }
.panel h3 { font-size: 13px; margin: 12px 0 8px; color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

canvas { width: 100%; display: block; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th:first-child, td:first-child,
th:last-child, td:last-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }

#config-form { display: flex; flex-direction: column; gap: 8px; }
#config-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
#config-form label input, #config-form label select { color: var(--text); }
.field-row { display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 8px; }
.field-row span { color: var(--muted); font-size: 12px; }

#position .pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#position .pos-grid span:nth-child(odd) { color: var(--muted); }

#log {
  background: #0a0d12; border-radius: 6px; padding: 10px;
  max-height: 240px; overflow-y: auto; font-size: 12px;
  font-family: "Consolas", monospace; white-space: pre-wrap;
}

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---- Panel-Kopf mit Auswahl ---- */
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.panel-head h2 { margin-bottom: 0; }
.panel-head select { padding: 6px 10px; }

/* ---- Chart ---- */
canvas {
  background: #0a0d12; border-radius: 6px;
}
.legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.lg { display: flex; align-items: center; }
.lg::before {
  content: ""; width: 14px; height: 3px; margin-right: 6px; border-radius: 2px;
}
.lg-price::before { background: #c9d1d9; }
.lg-fast::before  { background: var(--blue); }
.lg-slow::before  { background: var(--yellow); }
.lg-buy  { color: var(--green); }
.lg-sell { color: var(--red); }
.lg-be   { color: var(--muted); }
.lg-buy::before, .lg-sell::before, .lg-be::before { display: none; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- Signal-Pille ---- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.sig-buy  { background: rgba(46,160,67,.20);  color: var(--green); }
.sig-sell { background: rgba(248,81,73,.20);  color: var(--red); }
.sig-hold { background: var(--panel2);        color: var(--muted); }

@media (max-width: 800px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
