:root {
  --bg: #080c14;
  --bg-elev: #0f1624;
  --bg-card: #131c2e;
  --bg-card-hover: #18233a;
  --border: #22304a;
  --border-soft: #1b263c;
  --text: #eef2ff;
  --text-muted: #8ea0bf;
  --text-dim: #64748b;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.14);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --blue: #38bdf8;
  --blue-bg: rgba(56, 189, 248, 0.14);
  --indigo: #818cf8;
  --indigo-bg: rgba(129, 140, 248, 0.15);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, #111b33 0%, var(--bg) 48%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }

/* ---------------- Login Screen ---------------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.login-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.login-sub {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--indigo);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover { background: var(--bg-card-hover); border-color: #34476d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-color: #6366f1;
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-green { background: var(--green-bg); border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.btn-green:hover { background: rgba(16, 185, 129, 0.25); }

.btn-amber { background: var(--amber-bg); border-color: rgba(245, 158, 11, 0.45); color: #fbbf24; }
.btn-amber:hover { background: rgba(245, 158, 11, 0.26); }

.btn-red { background: var(--red-bg); border-color: rgba(239, 68, 68, 0.45); color: #f87171; }
.btn-red:hover { background: rgba(239, 68, 68, 0.26); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; }

.error-box {
  background: var(--red-bg);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* ---------------- App Shell ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 12, 20, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-title {
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.pill.green { background: var(--green-bg); border-color: rgba(16, 185, 129, 0.4); color: #34d399; }
.pill.green .pill-dot { background: #10b981; box-shadow: 0 0 8px #10b981; }
.pill.amber { background: var(--amber-bg); border-color: rgba(245, 158, 11, 0.45); color: #fbbf24; }
.pill.amber .pill-dot { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.pill.red { background: var(--red-bg); border-color: rgba(239, 68, 68, 0.45); color: #f87171; }
.pill.red .pill-dot { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.pill.indigo { background: var(--indigo-bg); border-color: rgba(129, 140, 248, 0.4); color: #a5b4fc; }
.pill.blue { background: var(--blue-bg); border-color: rgba(56, 189, 248, 0.35); color: #7dd3fc; }

/* Tabs */
.nav-tabs {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 10px 15px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active {
  color: #fff;
  border-bottom-color: var(--indigo);
}

/* Main Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 18px 60px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { padding: 10px 14px; }
  .container { padding: 14px 12px 50px; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-sub {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

.text-green { color: #34d399; }
.text-red { color: #f87171; }
.text-amber { color: #fbbf24; }
.text-blue { color: #7dd3fc; }
.text-muted { color: var(--text-muted); }

/* KI Hero Card */
.ai-hero {
  background: linear-gradient(145deg, rgba(30, 41, 78, 0.85), rgba(15, 22, 36, 0.95));
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 18px;
  position: relative;
}

.ai-hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ai-hero-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
}

.ai-fazit {
  font-size: 15px;
  line-height: 1.65;
  color: #f1f5f9;
  margin: 0 0 14px;
}

.ai-memory {
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.ai-memory summary {
  cursor: pointer;
  font-weight: 600;
  color: #c7d2fe;
}

.ai-memory p {
  margin: 8px 0 0;
  line-height: 1.55;
}

/* Coin Cards */
.coin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}
.coin-card:hover { border-color: #364c76; }
.coin-card.action-buy { border-color: rgba(16, 185, 129, 0.65); }
.coin-card.action-crash { border-color: rgba(239, 68, 68, 0.7); }
.coin-card.action-hold { border-color: rgba(56, 189, 248, 0.6); }

.coin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.coin-symbol {
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.coin-price {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

.action-badge {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.action-badge.WAIT { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }
.action-badge.BUY_NOW { background: var(--green-bg); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.5); }
.action-badge.HOLD { background: var(--blue-bg); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.5); }
.action-badge.TAKE_PROFIT { background: var(--amber-bg); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.5); }
.action-badge.CUT_LOSS_CRASH { background: var(--red-bg); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.55); }

.conv-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.conv-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.conv-bar-track {
  position: relative;
  height: 8px;
  background: var(--bg-elev);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.conv-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.conv-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 68%;
  width: 2px;
  background: rgba(255, 255, 255, 0.55);
}

.reason-box {
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 12px;
}

.reason-headline {
  font-weight: 700;
  font-size: 13px;
  color: #e2e8f0;
  margin-bottom: 4px;
}

.reason-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 7px 9px;
}

.metric-chip-label {
  font-size: 10.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-chip-val {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}

.candle-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
}

.candles-mini {
  display: flex;
  align-items: center;
  gap: 4px;
}

.c-block {
  width: 14px;
  height: 18px;
  border-radius: 3px;
  position: relative;
}
.c-block.g { background: rgba(16, 185, 129, 0.85); }
.c-block.r { background: rgba(239, 68, 68, 0.85); }

/* Open Positions Banner */
.cash-banner {
  background: rgba(16, 185, 129, 0.08);
  border: 1px dashed rgba(16, 185, 129, 0.35);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #a7f3d0;
  font-size: 13.5px;
}

/* Charts */
.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.seg-group {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--indigo);
  color: #fff;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  background: #0a101d;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
}

.chart-hover-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 9px 13px;
  background: rgba(15, 22, 36, 0.85);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-muted);
}

/* KI Chat */
.chat-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 16px;
}
@media (max-width: 980px) {
  .chat-layout { grid-template-columns: 1fr; }
}

.chat-box {
  display: flex;
  flex-direction: column;
  height: 580px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #0a101d;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.msg {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: #312e81;
  border: 1px solid #4f46e5;
  color: #eef2ff;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: #e2e8f0;
}
.msg-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chat-form {
  display: flex;
  gap: 8px;
}

/* Timeline / Journal */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.tl-item {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 11px 13px;
}

.tl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.tl-fazit {
  font-size: 12.5px;
  color: #e2e8f0;
  line-height: 1.5;
  margin-bottom: 7px;
}

.tl-coins {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Rules & Reports */
.rule-item {
  background: var(--bg-elev);
  border-left: 3px solid var(--indigo);
  border-radius: 0 9px 9px 0;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #cbd5e1;
  margin-bottom: 9px;
}

.report-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.report-row:hover { border-color: var(--indigo); }

/* News */
.news-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin-bottom: 9px;
}
.news-item a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
}
.news-item a:hover { color: var(--blue); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

th {
  background: var(--bg-elev);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.78);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-box {
  width: 100%;
  max-width: 760px;
  max-height: 84vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 120;
  background: #1e293b;
  border: 1px solid var(--indigo);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
