/* ====================================================================
   Celestial Ledger / Aether Aurora – Design System
   Colors, typography, glass effects, aurora backgrounds
   ==================================================================== */

/* ---- CSS Variables ---- */

:root {
  /* Foundation */
  --surface: #0a0e14;
  --surface-dim: #0a0e14;
  --surface-container-lowest: #000000;
  --surface-container-low: #0f141b;
  --surface-container: #141a22;
  --surface-container-high: #19202a;
  --surface-container-highest: #1e2632;
  --surface-variant: #1e2632;
  --surface-bright: #242d3a;

  /* Aurora Accents */
  --primary: #b5ffc2;
  --primary-container: #3fff8b;
  --primary-dim: #24f07e;
  --secondary: #3cd7ff;
  --secondary-container: #002a35;
  --tertiary: #e9b3ff;
  --tertiary-container: #e1a0ff;
  --error: #ff716c;
  --error-container: #8a1a1e;

  /* Text */
  --on-surface: #dee6f6;
  --on-surface-variant: #a4abba;
  --on-primary-fixed: #004820;
  --outline: #6e7684;
  --outline-variant: #414855;

  /* Semantic */
  --positive: #3fff8b;
  --positive-dim: rgba(63, 255, 139, 0.15);
  --negative: #ff716c;
  --negative-dim: rgba(255, 113, 108, 0.15);
}

/* ---- Reset & Base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--on-surface);
  margin-top: 0;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; margin-bottom: 12px; }

a {
  color: var(--secondary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--primary);
}

/* ---- App Layout: Sidebar + Main ---- */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface-container-low);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(65, 72, 85, 0.15);
}

.sidebar-brand {
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand .brand-logo {
  width: 100%;
  max-width: 160px;
  height: auto;
  object-fit: contain;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  flex: 1;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--on-surface-variant);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 12px;
  transition: background 0.2s, color 0.2s;
}

.sidebar-link .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

.sidebar-link.active {
  background: rgba(63, 255, 139, 0.1);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(63, 255, 139, 0.08);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(65, 72, 85, 0.15);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  position: relative;
}

.theme-toggle:hover {
  background: var(--surface-container-high);
  color: var(--primary);
}

.theme-icon {
  width: 20px;
  height: 20px;
  position: absolute;
  transition: opacity 0.2s;
}

/* Always dark - hide light icon */
.theme-icon-light {
  opacity: 0;
  pointer-events: none;
}

/* ---- Main Area ---- */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Aurora background on main area */
.main-area::before {
  content: '';
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 15% 20%, rgba(60, 215, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(181, 255, 194, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(233, 179, 255, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Top Tabs ---- */

.top-tabs {
  display: flex;
  gap: 0;
  background: var(--surface-container-low);
  border-bottom: 1px solid rgba(65, 72, 85, 0.2);
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--on-surface-variant);
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: -0.01em;
}

.tab-link .tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tab-link:hover {
  color: var(--on-surface);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---- Content ---- */

.content {
  max-width: 1100px;
  padding: 28px 28px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ---- Card (Glass) ---- */

.card {
  background: rgba(30, 38, 50, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(65, 72, 85, 0.15);
  transition: border-color 0.3s;
}

.card:hover {
  border-color: rgba(65, 72, 85, 0.3);
}

/* ---- Grid ---- */

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

/* ---- Metrics ---- */

.metrics > div {
  background: var(--surface-container-high);
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(65, 72, 85, 0.1);
}

.metrics > div strong {
  display: block;
  font-size: 0.75rem;
  color: var(--on-surface-variant);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  font-family: 'Inter', sans-serif;
}

/* ---- Forms ---- */

label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  gap: 6px;
  color: var(--on-surface);
  font-size: 0.88rem;
}

input,
select {
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--outline-variant);
  border-radius: 8px 8px 0 0;
  background: var(--surface-container-high);
  color: var(--on-surface);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}

input:focus,
select:focus {
  border-bottom-color: var(--secondary);
  box-shadow: 0 1px 0 0 var(--secondary);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  border-radius: 4px;
}

.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* ---- Buttons ---- */

.primary {
  background: var(--primary-container);
  color: var(--on-primary-fixed);
  border: none;
  padding: 12px 24px;
  border-radius: 14px;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  transition: box-shadow 0.3s, transform 0.15s, brightness 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 20px rgba(63, 255, 139, 0.2);
}

.primary:hover {
  box-shadow: 0 0 30px rgba(63, 255, 139, 0.35);
  filter: brightness(1.1);
}

.primary:active {
  transform: scale(0.97);
}

.primary .btn-icon {
  width: 18px;
  height: 18px;
}

/* ---- Tables ---- */

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  color: var(--on-surface);
  font-size: 0.85rem;
}

th {
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  border-bottom: 1px solid rgba(65, 72, 85, 0.3);
}

td {
  border-bottom: 1px solid rgba(65, 72, 85, 0.1);
}

tr:hover td {
  background: rgba(30, 38, 50, 0.4);
}

/* ---- Warning ---- */

.warning {
  background: rgba(255, 113, 108, 0.08);
  border: 1px solid rgba(255, 113, 108, 0.2);
  padding: 14px 18px;
  border-radius: 14px;
  margin-bottom: 18px;
  color: var(--on-surface);
  font-size: 0.88rem;
}

.warning ul {
  margin: 0;
  padding-left: 18px;
}

/* ---- Scrollable trades ---- */

.trades-scroll {
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 14px;
}

.trades-scroll::-webkit-scrollbar {
  width: 6px;
}

.trades-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.trades-scroll::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 3px;
}

.trades-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--surface-container-high);
  z-index: 1;
}

/* ---- Utility ---- */

.muted {
  color: var(--on-surface-variant);
  font-size: 0.88rem;
}

/* ---- Delete button ---- */

.btn-delete {
  background: none;
  border: none;
  color: var(--error);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: var(--negative-dim);
}

.btn-delete .btn-icon {
  width: 14px;
  height: 14px;
}

/* ---- Card title with icon ---- */

.card-title-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
}

.card-title-with-icon .title-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--secondary);
}

.link-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.link-with-icon:hover {
  background: rgba(60, 215, 255, 0.1);
  color: var(--primary);
}

.link-with-icon .btn-icon {
  width: 14px;
  height: 14px;
}

/* ---- Charts ---- */

.chart-wrap {
  margin-bottom: 24px;
  max-width: 100%;
  background: var(--surface-container-high);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(65, 72, 85, 0.1);
}

/* ---- Weekly performance calendar ---- */

.weekly-calendar {
  margin-bottom: 24px;
}

.weekly-year-block {
  margin-bottom: 20px;
}

.weekly-year-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 10px 0;
  color: var(--on-surface);
  font-family: 'Manrope', sans-serif;
}

.weekly-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.week-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
}

.week-tile__label {
  opacity: 0.85;
  margin-bottom: 2px;
}

.week-tile__pct {
  font-weight: 700;
}

.week-tile__pnl {
  font-size: 0.68rem;
  opacity: 0.85;
}

.week-tile--pos {
  background: var(--positive-dim);
  color: var(--primary);
}

.week-tile--neg {
  background: var(--negative-dim);
  color: var(--error);
}

/* ---- Settings Summary (Ergebnisseite) ---- */

.settings-summary {
  margin-bottom: 20px;
  border-radius: 16px;
}

.settings-summary summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
}

.settings-summary summary::-webkit-details-marker {
  display: none;
}

.settings-summary__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px 20px;
  margin-top: 14px;
  font-size: 0.88rem;
}

.settings-summary__label {
  display: block;
  color: var(--on-surface-variant);
  font-weight: 500;
  font-size: 0.75rem;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- Backtest Loading Overlay ---- */

.backtest-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.backtest-loading-overlay[hidden] {
  display: none;
}

.backtest-loading-overlay__box {
  background: rgba(30, 38, 50, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(65, 72, 85, 0.3);
  border-radius: 24px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  min-width: 300px;
}

.backtest-loading-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 3px solid var(--outline-variant);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: backtest-spin 0.8s linear infinite;
  box-shadow: 0 0 12px rgba(63, 255, 139, 0.15);
}

@keyframes backtest-spin {
  to {
    transform: rotate(360deg);
  }
}

.backtest-loading-overlay__title {
  margin: 0 0 8px 0;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--on-surface);
}

.backtest-loading-overlay__status {
  margin: 0;
  font-size: 0.88rem;
  color: var(--on-surface-variant);
  min-height: 1.4em;
}

/* ---- TradingView Chart ---- */

.tradingview-chart-container {
  min-height: min(80vh, 900px);
  height: min(80vh, 900px);
  width: 100%;
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
}

.tradingview-chart-container .tradingview-widget-container,
.tradingview-chart-container .tradingview-widget-container__widget {
  width: 100%;
  height: 100%;
  min-height: min(80vh, 900px);
}

.tradingview-chart-iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(80vh, 900px);
  border: none;
}

.tradingview-page .content {
  max-width: none;
}

/* ---- Login Page & Aurora Animation ---- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.aurora-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.aurora-layer {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}

.aurora-layer-1 {
  width: 60vw;
  height: 55vh;
  top: -15%;
  left: -10%;
  background: radial-gradient(ellipse, rgba(60, 215, 255, 0.18) 0%, transparent 70%);
  animation: aurora-drift-1 12s ease-in-out infinite alternate;
}

.aurora-layer-2 {
  width: 55vw;
  height: 60vh;
  bottom: -20%;
  right: -10%;
  background: radial-gradient(ellipse, rgba(181, 255, 194, 0.14) 0%, transparent 70%);
  animation: aurora-drift-2 15s ease-in-out infinite alternate;
}

.aurora-layer-3 {
  width: 40vw;
  height: 45vh;
  top: 25%;
  left: 35%;
  background: radial-gradient(ellipse, rgba(233, 179, 255, 0.12) 0%, transparent 70%);
  animation: aurora-drift-3 18s ease-in-out infinite alternate;
}

@keyframes aurora-drift-1 {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.6; }
  33%  { transform: translate(8vw, 5vh) scale(1.2); opacity: 1; }
  66%  { transform: translate(-3vw, 8vh) scale(1.05); opacity: 0.8; }
  100% { transform: translate(5vw, -3vh) scale(1.15); opacity: 0.9; }
}

@keyframes aurora-drift-2 {
  0%   { transform: translate(0, 0) scale(1); opacity: 0.5; }
  50%  { transform: translate(-6vw, -4vh) scale(1.25); opacity: 0.9; }
  100% { transform: translate(4vw, 6vh) scale(1.1); opacity: 0.7; }
}

@keyframes aurora-drift-3 {
  0%   { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 0.4; }
  50%  { transform: translate(-5vw, 3vh) scale(1.3) rotate(10deg); opacity: 0.8; }
  100% { transform: translate(3vw, -5vh) scale(1.1) rotate(-5deg); opacity: 0.6; }
}

.login-card {
  background: rgba(30, 38, 50, 0.6);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: 28px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(65, 72, 85, 0.2);
  z-index: 1;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
  display: block;
  margin: 0 auto 8px;
  max-width: 220px;
  height: auto;
}

.login-card h1 {
  text-align: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  color: var(--primary);
  margin: 0 0 4px;
  letter-spacing: -0.03em;
}

.login-card .subtitle {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 0.9rem;
  margin: 0 0 28px;
}

.login-card label {
  margin-bottom: 16px;
}

.login-btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 14px;
  font-size: 1rem;
}

.login-footer {
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 0.85rem;
  margin-top: 20px;
  margin-bottom: 0;
}

/* ---- Flash Messages ---- */

.flash {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  font-weight: 500;
}

.flash-error {
  background: rgba(255, 113, 108, 0.1);
  border: 1px solid rgba(255, 113, 108, 0.25);
  color: var(--error);
}

.flash-success {
  background: rgba(63, 255, 139, 0.1);
  border: 1px solid rgba(63, 255, 139, 0.25);
  color: var(--primary);
}

/* ---- Badges ---- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-active {
  background: var(--positive-dim);
  color: var(--positive);
}

.badge-inactive {
  background: var(--negative-dim);
  color: var(--negative);
}

.badge-pending {
  background: rgba(233, 179, 255, 0.12);
  color: var(--tertiary);
}

.badge-admin {
  background: rgba(60, 215, 255, 0.12);
  color: var(--secondary);
}

.badge-user {
  background: rgba(164, 171, 186, 0.1);
  color: var(--on-surface-variant);
}

/* ---- Sidebar User & Admin ---- */

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--on-surface-variant);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0;
  padding: 6px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.sidebar-user:hover {
  background: var(--surface-container-high);
  color: var(--primary);
}

.sidebar-user-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-logout {
  display: inline;
}

.sidebar-link--admin {
  margin-top: auto;
  border-top: 1px solid rgba(65, 72, 85, 0.15);
  padding-top: 12px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
    overflow: hidden;
  }

  .sidebar-link span {
    display: none;
  }

  .sidebar-brand {
    padding: 12px 8px;
  }

  .sidebar-brand .brand-logo {
    max-width: 40px;
  }

  .sidebar-link {
    justify-content: center;
    padding: 12px;
  }

  .main-area::before {
    left: 60px;
  }

  .content {
    padding: 16px;
  }
}

/* ====================================================================
   Strategy Editor — MD Docs + AI Chat Drawer
   ==================================================================== */

/* Editor-Seite nutzt volle Breite */
.content--wide {
  max-width: none;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.editor-header__titles h2 {
  margin-bottom: 4px;
}

.editor-header__subtitle {
  color: var(--on-surface-variant);
  font-size: 0.9rem;
  margin: 0;
}

.editor-header__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.editor-header__status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.status-draft {
  color: var(--tertiary);
  background: rgba(233, 179, 255, 0.08);
  border-color: rgba(233, 179, 255, 0.25);
}

.status-finalized {
  color: var(--secondary);
  background: rgba(60, 215, 255, 0.08);
  border-color: rgba(60, 215, 255, 0.25);
}

.status-synced {
  color: var(--primary);
  background: rgba(63, 255, 139, 0.08);
  border-color: rgba(63, 255, 139, 0.25);
}

/* Zwei-Spalten: Editor links, Chat rechts */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  align-items: start;
}

.editor-layout.editor-layout--collapsed {
  grid-template-columns: 1fr 56px;
}

.editor-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Validation-Card */
.validation-card {
  background: rgba(255, 113, 108, 0.06);
  border: 1px solid rgba(255, 113, 108, 0.25);
  border-radius: 16px;
  padding: 14px 18px;
}

.validation-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--error);
  margin-bottom: 8px;
}

.validation-card__list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--on-surface-variant);
}

.validation-card__list li {
  margin-bottom: 3px;
}

.validation-card__list code {
  background: rgba(255, 113, 108, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--on-surface);
}

/* MD-Card pro Datei */
.md-card {
  background: rgba(30, 38, 50, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  border: 1px solid rgba(65, 72, 85, 0.2);
  overflow: hidden;
  transition: border-color 0.3s;
}

.md-card:focus-within {
  border-color: rgba(60, 215, 255, 0.4);
  box-shadow: 0 0 0 2px rgba(60, 215, 255, 0.1);
}

.md-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(20, 26, 34, 0.7);
  border-bottom: 1px solid rgba(65, 72, 85, 0.2);
  cursor: pointer;
  user-select: none;
}

.md-card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--on-surface);
}

.md-card__title .md-icon {
  width: 16px;
  height: 16px;
  color: var(--secondary);
}

.md-card__meta {
  color: var(--on-surface-variant);
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

.md-card__body {
  transition: max-height 0.3s ease, padding 0.3s ease;
  overflow: hidden;
  max-height: 2000px;
}

.md-card.md-card--collapsed .md-card__body {
  max-height: 0;
}

.md-textarea {
  width: 100%;
  min-height: 260px;
  padding: 16px 18px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--on-surface);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  box-shadow: none;
  tab-size: 2;
}

.md-textarea:focus {
  box-shadow: none;
}

/* Sticky Action Bar */
.editor-actionbar {
  position: sticky;
  bottom: 16px;
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(15, 20, 27, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(65, 72, 85, 0.25);
  border-radius: 16px;
  margin-top: 8px;
  align-items: center;
  z-index: 2;
}

.editor-actionbar__spacer {
  flex: 1;
}

.editor-actionbar__hint {
  color: var(--on-surface-variant);
  font-size: 0.8rem;
}

/* Secondary Button */
.secondary {
  background: var(--surface-container-high);
  color: var(--on-surface);
  border: 1px solid rgba(65, 72, 85, 0.4);
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.secondary:hover:not(:disabled) {
  background: var(--surface-container-highest);
  border-color: var(--outline);
  color: var(--primary);
}

.secondary:disabled,
.primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ====================================================================
   Chat-Drawer
   ==================================================================== */

.chat-drawer {
  position: sticky;
  top: 20px;
  background: rgba(15, 20, 27, 0.6);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(65, 72, 85, 0.25);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 500px;
  overflow: hidden;
  transition: width 0.25s ease;
}

.editor-layout--collapsed .chat-drawer {
  align-items: center;
  padding-top: 14px;
}

.editor-layout--collapsed .chat-drawer__header,
.editor-layout--collapsed .chat-messages,
.editor-layout--collapsed .chat-input,
.editor-layout--collapsed .chat-empty {
  display: none;
}

.chat-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(65, 72, 85, 0.2);
  background: rgba(20, 26, 34, 0.5);
}

.chat-drawer__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-surface);
}

.chat-drawer__title .sparkle {
  width: 18px;
  height: 18px;
  color: var(--primary);
  filter: drop-shadow(0 0 6px rgba(63, 255, 139, 0.5));
}

.chat-drawer__meta {
  font-size: 0.7rem;
  color: var(--on-surface-variant);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-drawer__toggle {
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.chat-drawer__toggle:hover {
  background: var(--surface-container-high);
  color: var(--on-surface);
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 3px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 92%;
  animation: chat-fade-in 0.25s ease;
}

@keyframes chat-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message__role {
  font-size: 0.7rem;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.chat-message__bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--on-surface);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-message__bubble code {
  background: rgba(60, 215, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  color: var(--secondary);
}

.chat-message--user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message--user .chat-message__bubble {
  background: linear-gradient(135deg, rgba(60, 215, 255, 0.12), rgba(60, 215, 255, 0.05));
  border: 1px solid rgba(60, 215, 255, 0.25);
}

.chat-message--assistant {
  align-self: flex-start;
}

.chat-message--assistant .chat-message__bubble {
  background: rgba(30, 38, 50, 0.8);
  border: 1px solid rgba(65, 72, 85, 0.3);
}

.chat-message--error .chat-message__bubble {
  background: rgba(255, 113, 108, 0.08);
  border-color: rgba(255, 113, 108, 0.3);
  color: var(--error);
}

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.5;
  animation: chat-typing 1.2s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px 24px;
  color: var(--on-surface-variant);
  gap: 12px;
}

.chat-empty__icon {
  width: 44px;
  height: 44px;
  color: var(--primary);
  opacity: 0.6;
}

.chat-empty__title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--on-surface);
}

.chat-empty__hint {
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 280px;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.chat-suggestion {
  background: rgba(30, 38, 50, 0.6);
  border: 1px solid rgba(65, 72, 85, 0.25);
  color: var(--on-surface);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.83rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: 'Inter', sans-serif;
}

.chat-suggestion:hover {
  border-color: rgba(63, 255, 139, 0.4);
  color: var(--primary);
}

/* Input */
.chat-input {
  border-top: 1px solid rgba(65, 72, 85, 0.2);
  padding: 12px;
  background: rgba(20, 26, 34, 0.5);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input textarea {
  flex: 1;
  min-height: 38px;
  max-height: 160px;
  padding: 10px 12px;
  background: var(--surface-container-high);
  border: 1px solid rgba(65, 72, 85, 0.3);
  border-radius: 12px;
  color: var(--on-surface);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 2px rgba(60, 215, 255, 0.1);
}

.chat-send {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--primary-container);
  color: var(--on-primary-fixed);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.2s, transform 0.15s;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(63, 255, 139, 0.25);
}

.chat-send:hover:not(:disabled) {
  filter: brightness(1.1);
}

.chat-send:active {
  transform: scale(0.95);
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-send svg {
  width: 18px;
  height: 18px;
}

/* Responsive: Chat wird zu einem Bottom-Sheet-artigen Panel unterhalb */
@media (max-width: 1100px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .chat-drawer {
    position: static;
    height: auto;
    max-height: 520px;
    min-height: 420px;
  }
}

/* ====================================================================
   Account Settings (API-Key + User-Prompts)
   ==================================================================== */

.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stacked-form input[readonly] {
  color: var(--on-surface-variant);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.prompt-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.prompt-slot {
  background: rgba(20, 26, 34, 0.6);
  border: 1px solid rgba(65, 72, 85, 0.25);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.prompt-slot--active {
  border-color: rgba(63, 255, 139, 0.45);
  box-shadow: 0 0 0 2px rgba(63, 255, 139, 0.08), 0 0 24px rgba(63, 255, 139, 0.08);
}

.prompt-slot__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.prompt-slot__badge {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* --- Optimierungsmodul (Issue #22) --------------------------------- */

.flash-messages {
  margin-bottom: 16px;
}
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.flash-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; }
.flash-error   { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }
.flash-success { background: #d1e7dd; color: #0f5132; border: 1px solid #a3cfbb; }

.optimize-params table { width: 100%; }
.optimize-params input[type="number"] { width: 90px; }

.optimize-summary {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--surface-2, #f5f5f7);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 15px;
}
.optimize-summary strong { font-size: 22px; }

.actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 12px;
  background: #e8eef7;
  color: #2c4673;
  font-size: 12px;
  white-space: nowrap;
}
.tag-small { font-size: 11px; padding: 1px 6px; }

.best-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 12px 0 24px;
}
.best-card {
  padding: 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border: 1px solid #e3e8ef;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.best-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #5a6478;
  margin-bottom: 6px;
}
.best-card-icon { width: 16px; height: 16px; }
.best-card-value { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.best-card-params { display: flex; flex-wrap: wrap; }

.table-scroll { overflow-x: auto; }

table.heatmap th,
table.heatmap td {
  text-align: center;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
table.heatmap th.hm-axis { text-align: left; font-weight: 600; }
table.heatmap .hm-cell { font-weight: 600; }

.muted { color: #6b7280; font-size: 14px; }

.btn-delete {
  background: transparent;
  color: #b3261e;
  border: 1px solid #b3261e;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-delete:hover { background: #b3261e; color: #fff; }

/* Top/Flop Trade-Charts (mplfinance PNGs) */
.trade-charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 16px 0 24px;
}
@media (min-width: 1100px) {
  .trade-charts-grid { grid-template-columns: 1fr 1fr; }
}
.trade-charts-col { display: flex; flex-direction: column; gap: 12px; }
.trade-charts-heading {
  margin: 0 0 4px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.95rem;
}
.trade-charts-heading--win { background: rgba(63, 255, 139, 0.12); color: #3fff8b; }
.trade-charts-heading--loss { background: rgba(255, 113, 108, 0.12); color: #ff716c; }
.trade-chart-card {
  margin: 0;
  background: #1a1d24;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
  padding: 10px 12px;
}
.trade-chart-card figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}
.trade-chart-card .trade-chart-meta { color: #a4abba; font-size: 0.85rem; }
.trade-chart-card img { width: 100%; height: auto; display: block; border-radius: 4px; }
.trade-chart-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.trade-chart-trigger:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 3px;
}
.trade-chart-trigger img.trade-chart-img {
  transition: filter 0.15s ease, transform 0.15s ease;
}
.trade-chart-trigger:hover img.trade-chart-img,
.trade-chart-trigger:focus-visible img.trade-chart-img {
  filter: brightness(1.06) contrast(1.04);
}
.trade-chart-trigger__icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #07100c;
  background: rgba(181, 255, 194, 0.92);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.trade-chart-trigger__icon svg {
  width: 18px;
  height: 18px;
}
.trade-chart-trigger:hover .trade-chart-trigger__icon,
.trade-chart-trigger:focus-visible .trade-chart-trigger__icon {
  opacity: 1;
  transform: translateY(0);
}
.trade-chart-card .positive { color: #3fff8b; }
.trade-chart-card .negative { color: #ff716c; }

/* Modal für vergrößerten Trade-Chart */
.trade-chart-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.trade-chart-modal[hidden] { display: none; }
.trade-chart-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.85);
  backdrop-filter: blur(4px);
}
.trade-chart-modal__content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 95vh;
  background: #14171c;
  border: 1px solid #2a2f3a;
  border-radius: 10px;
  padding: 16px 20px 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}
.trade-chart-modal__close {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #d6dae1;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
}
.trade-chart-modal__close:hover { background: rgba(255, 255, 255, 0.08); }
.trade-chart-modal__caption {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  font-size: 0.95rem;
  color: #d6dae1;
  padding-right: 32px;
}
.trade-chart-modal__caption span { color: #a4abba; font-size: 0.88rem; }
.trade-chart-modal__content img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: 6px;
}
.trade-chart-modal-open { overflow: hidden; }
