/* Shadow Trader Dashboard – Graphite Dark Mode */
:root {
  --bg:       #1a1a2e;
  --surface:  #16213e;
  --card:     #0f3460;
  --border:   #2a3f5f;
  --text:     #e0e0e0;
  --muted:    #8899aa;
  --green:    #00d4aa;
  --red:      #ff4d6d;
  --orange:   #ffa500;
  --blue:     #4dabf7;
  --yellow:   #ffd43b;
  --radius:   8px;
  --shadow:   0 2px 8px rgba(0,0,0,.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 40px;
  width: 100%;
}

/* ── Header Banner ── */
#header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.6);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

#equity-display {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.5px;
}

#equity-change {
  font-size: 1rem;
  margin-left: 8px;
  font-weight: 500;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.status-dot.green  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); animation: blink 1s infinite; }
.status-dot.red    { background: var(--red); box-shadow: 0 0 6px var(--red); animation: blink 0.6s infinite; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

#header-time { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

#kill-switch-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  letter-spacing: 0.3px;
}
#kill-switch-btn:hover { opacity: 0.85; }
#kill-switch-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Offline Banner ── */
#offline-banner {
  background: rgba(255, 77, 109, 0.15);
  border: 1px solid var(--red);
  color: var(--red);
  text-align: center;
  padding: 10px;
  font-weight: 700;
  display: none;
  animation: blink 1.2s infinite;
}

/* ── Error Toasts ── */
#toast-container {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slideIn .2s ease;
}
.toast.error  { border-left: 4px solid var(--red); }
.toast.warn   { border-left: 4px solid var(--orange); }
.toast.info   { border-left: 4px solid var(--blue); }
.toast-msg { flex: 1; font-size: 0.85rem; }
.toast-close { cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Sections ── */
section {
  margin-top: 20px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── KPI Cards ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.kpi-card.stale .kpi-label::after {
  content: " ⚠ veraltet";
  color: var(--orange);
}

/* ── Risk Tier ── */
.risk-tier-box {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.risk-tier-indicator {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.risk-tier-box.green { border-color: var(--green); }
.risk-tier-box.orange { border-color: var(--orange); }
.risk-tier-box.red { border-color: var(--red); }

.risk-label { font-size: 1rem; font-weight: 700; }
.risk-detail { color: var(--muted); font-size: 0.85rem; }

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.streak-win  { background: rgba(0,212,170,.15); color: var(--green); }
.streak-loss { background: rgba(255,77,109,.15); color: var(--red); }
.streak-pause { background: rgba(255,165,0,.15); color: var(--orange); }

/* ── Chart ── */
#chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  height: 300px;
}

#equity-chart { width: 100%; height: 100%; }

/* ── Tables ── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text); }

tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: 7px 12px; vertical-align: middle; }

.row-profit { color: var(--green); }
.row-loss   { color: var(--red); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-long  { background: rgba(0,212,170,.15); color: var(--green); }
.badge-short { background: rgba(255,77,109,.15); color: var(--red); }
.badge-win   { background: rgba(0,212,170,.12); color: var(--green); }
.badge-loss  { background: rgba(255,77,109,.12); color: var(--red); }
/* [P4 Option B] Break-Even-Badge: neutrales Blau – zeigt Schutz-Exit an */
.badge-be      { background: rgba(64,158,255,.18);  color: #4aa3ff; font-weight:700; }
.badge-neutral { background: rgba(160,160,160,.12); color: var(--text-muted); }

/* ── Filter Tabs ── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--blue); color: var(--text); }
.filter-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.export-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.export-btn:hover { border-color: var(--green); color: var(--green); }

/* ── Alerts Panel ── */
.alerts-list { display: flex; flex-direction: column; gap: 6px; }

.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: opacity .15s;
}
.alert-item.unread { border-left: 3px solid var(--orange); }
.alert-item.unread.critical { border-left-color: var(--red); }
.alert-item.read { opacity: 0.5; }
.alert-icon { font-size: 1rem; flex-shrink: 0; }
.alert-meta { flex: 1; }
.alert-msg { font-size: 0.85rem; }
.alert-time { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

/* ── Tooltips ── */
[data-tooltip] { position: relative; cursor: help; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 50;
  max-width: 220px;
  white-space: normal;
  text-align: center;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: 0.9rem;
}

/* ── Progress Bar ── */
.pbar-wrap {
  width: 60px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.pbar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #equity-display { font-size: 1.3rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  #chart-container { height: 220px; }
  .header-inner { gap: 12px; }
}

/* ── Utility ── */
.text-green  { color: var(--green) !important; }
.text-red    { color: var(--red) !important; }
.text-orange { color: var(--orange) !important; }
.text-muted  { color: var(--muted) !important; }
.text-right  { text-align: right; }
.nowrap      { white-space: nowrap; }
.hidden      { display: none !important; }

/* ── Confirmation Dialog ── */
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
#confirm-dialog {
  background: var(--surface);
  border: 2px solid var(--red);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px;
  width: 90%;
  text-align: center;
}
#confirm-dialog h3 { color: var(--red); margin-bottom: 12px; font-size: 1.1rem; }
#confirm-dialog p { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 12px; justify-content: center; }
.btn-cancel {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
}
.btn-confirm {
  background: var(--red);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
}
