/* ===========================================================
   Krypto-Trading-Bot Dashboard - gemuetliches, responsives Layout
   =========================================================== */

:root {
  --bg: #f7f3ec;
  --bg-elevated: #fffcf7;
  --sidebar-bg: #2a2826;
  --sidebar-fg: #f0ebe3;
  --text: #2a2826;
  --text-muted: #7a736a;
  --border: #e8e0d4;
  --accent: #2f6f98;
  --accent-soft: rgba(47, 111, 152, 0.08);
  --accent-contrast: #ffffff;
  --positive: #34785d;
  --negative: #c45c4a;
  --card-shadow: 0 1px 2px rgba(42, 40, 38, 0.06), 0 5px 16px rgba(42, 40, 38, 0.035);
  --radius: 8px;
  --radius-sm: 5px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --content-max: 1280px;
  --space-page: clamp(16px, 3vw, 32px);
  --blur-surface: blur(20px) saturate(180%);
}

:root[data-theme="dark"] {
  --bg: #1a1917;
  --bg-elevated: #242220;
  --sidebar-bg: #121110;
  --sidebar-fg: #ece8e2;
  --text: #f0ebe3;
  --text-muted: #a39d94;
  --border: #3a3632;
  --accent: #65a9d1;
  --accent-soft: rgba(101, 169, 209, 0.1);
  --accent-contrast: #0f1a16;
  --positive: #5fbf97;
  --negative: #e07a6a;
  --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.35), 0 8px 28px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #1a1917;
    --bg-elevated: #242220;
    --sidebar-bg: #121110;
    --sidebar-fg: #ece8e2;
    --text: #f0ebe3;
    --text-muted: #a39d94;
    --border: #3a3632;
    --accent: #65a9d1;
    --accent-soft: rgba(101, 169, 209, 0.1);
    --accent-contrast: #0f1a16;
    --positive: #5fbf97;
    --negative: #e07a6a;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.35), 0 8px 28px rgba(0, 0, 0, 0.2);
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body.nav-open {
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

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

.sidebar {
  width: clamp(220px, 26vw, 260px);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  backdrop-filter: var(--blur-surface);
  -webkit-backdrop-filter: var(--blur-surface);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.06);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--accent);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

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

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--sidebar-fg);
  opacity: 0.72;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.15s ease;
  min-height: 44px;
}

.nav-item:hover {
  background: rgba(127, 127, 127, 0.12); /* Fallback fuer Browser ohne color-mix() */
  background: color-mix(in srgb, var(--sidebar-fg) 8%, transparent);
  opacity: 1;
}

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  opacity: 1;
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.current-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.permission-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.permission-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.16); /* Fallback fuer Browser ohne color-mix() */
  background: color-mix(in srgb, var(--sidebar-fg) 12%, transparent);
  color: var(--text-muted);
}

.paper-badge {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.signature {
  font-size: 11px;
  text-align: center;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: 4px;
}

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.12); /* Fallback fuer Browser ohne color-mix() */
  background: color-mix(in srgb, var(--sidebar-fg) 8%, transparent);
}

.theme-switch-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--sidebar-fg);
  opacity: 0.55;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease, color 0.2s ease;
}

.theme-switch-option svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-switch-option:hover {
  opacity: 0.85;
}

.theme-switch-option.is-active {
  background: var(--bg-elevated);
  color: var(--accent);
  opacity: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

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

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

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 20px);
  padding: 14px var(--space-page);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated); /* Fallback fuer Browser ohne color-mix() */
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.dot.is-live { background: var(--positive); }
.dot.is-error { background: var(--negative); }

.sep { opacity: 0.5; }

.topbar-metrics {
  display: flex;
  gap: clamp(12px, 3vw, 24px);
  margin-left: auto;
  flex-wrap: wrap;
}

.metric {
  display: flex;
  flex-direction: column;
  min-width: 90px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 16px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-label {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 90px;
}

.content {
  flex: 1;
  padding: var(--space-page) var(--space-page) 72px;
  overflow-y: auto;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ---------------- Views ---------------- */

.view {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.view.is-active {
  display: flex;
}

/* Unteransichten innerhalb eines zusammengefassten Tabs (z. B. "Aktivitaet"
   = Entscheidungen/Marktereignisse/News, "Auswertung" = Trades/Backtesting) */
.subview {
  display: none;
  flex-direction: column;
  gap: 20px;
}

.subview.is-active {
  display: flex;
}

#activity-subnav,
#analysis-subnav {
  max-width: 480px;
  margin-bottom: 4px;
}

.dashboard-greeting {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-cards {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}

@media (max-width: 1100px) {
  .grid-cards {
    grid-template-columns: 1fr;
  }
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  padding: 7px 11px;
  cursor: pointer;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 17, 16, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 199;
}

.sidebar-overlay.is-visible { display: block; }

@media (max-width: 900px) {
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }

  .topbar-status {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    line-height: 1.4;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .topbar-status #session-label,
  .topbar-status .sep:last-of-type {
    display: none;
  }

  .topbar-metrics {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .metric { min-width: 0; flex: 1 1 30%; }

  .metric-label { font-size: 10px; }

  .metric-value {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    width: min(280px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.2);
  }

  .sidebar.is-open { transform: translateX(0); }

  .content {
    max-width: none;
  }

  /* Auf Mobil soll der Header beim Scrollen mitlaufen statt fixiert zu
     bleiben - spart Platz beim Lesen, Not-Aus bleibt per Hoch-Scrollen
     jederzeit einen Wisch entfernt. */
  .topbar {
    position: static;
  }
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 2.5vw, 22px) clamp(18px, 3vw, 24px);
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.25s ease;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.card canvas,
.modal-box canvas {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header-row h3 { margin: 0; }

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -6px 0 12px;
}

/* ---------------- Stat list ---------------- */

.stat-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-list > div {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}

.stat-list dt { color: var(--text-muted); }
.stat-list dd { margin: 0; font-weight: 700; }

.stat-list-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 16px;
}

.stat-list-inline > div {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border-bottom: none;
  padding-bottom: 0;
}

/* ---------------- Segmented control (z. B. Einsatz-Auswahl) ---------------- */

.segmented-control {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  max-width: 420px;
}

.segmented-option {
  flex: 1;
  background: var(--bg-elevated);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  padding: 9px 8px;
  font-size: 13px;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  white-space: normal;
}

.segmented-option:last-child { border-right: none; }

.segmented-option:hover { background: var(--bg); }

.segmented-option.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

/* ---------------- Stat tiles (Statistiken) ---------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.stat-tile-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: help;
}

.stat-tile-value {
  font-size: 17px;
  font-weight: 700;
}

/* ---------------- Table ---------------- */

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

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

.table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: rgba(47, 123, 196, 0.06);
}

.empty-hint {
  color: var(--text-muted);
  font-size: 13px;
  padding: 10px 2px;
  display: none;
}

.pos, .positive { color: var(--positive); font-weight: 700; }
.neg, .negative { color: var(--negative); font-weight: 700; }

/* ---------------- Decision list ---------------- */

.decision-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

.decision-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

.decision-item .decision-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.decision-item .decision-pair {
  font-weight: 700;
  color: var(--text);
}

.trade-number-badge {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.trade-number-badge:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.trade-number-filter-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 10px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}

.trade-number-filter-chip button {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-icon {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0;
  transform: translateY(0.5px);
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(147, 51, 234, 0.15);
  color: #9333ea;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .ai-badge { color: #c084fc; }
}
:root[data-theme="dark"] .ai-badge { color: #c084fc; }

.value-flash {
  animation: value-flash-anim 900ms ease-out;
}

/* "Was bedeutet das?"-Knopf + Antwortbox (Issue #27, KI-Erklaerungen) */
.explain-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  margin-left: 2px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.explain-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.explain-box {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(147, 51, 234, 0.06);
  border: 1px solid rgba(147, 51, 234, 0.18);
  font-size: 13px;
  line-height: 1.5;
}

.explain-box .ai-badge {
  margin-right: 6px;
}

.explain-box.is-loading {
  color: var(--text-muted);
  font-style: italic;
}

.explain-box.is-error {
  color: var(--negative);
  background: rgba(224, 57, 62, 0.06);
  border-color: rgba(224, 57, 62, 0.2);
}

@keyframes value-flash-anim {
  0% { background-color: rgba(74, 144, 226, 0.35); }
  100% { background-color: transparent; }
}

.badge-buy,
.badge-buy_add { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-sell,
.badge-stop_loss { background: rgba(209, 69, 61, 0.15); color: var(--negative); }
.badge-take_profit { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-manual_stop,
.badge-manual_sell { background: rgba(209, 69, 61, 0.15); color: var(--negative); }
.badge-manual_buy { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-hold,
.badge-ignored_autobuy_off,
.badge-ignored_already_open,
.badge-ignored_no_position,
.badge-ignored_pair_disabled,
.badge-ignored_insufficient_balance,
.badge-ignored_negative_news { background: rgba(155, 149, 140, 0.18); color: var(--text-muted); }
.badge-auto_tune { background: rgba(76, 155, 232, 0.18); color: #4c9be8; }

.badge-volatility_spike { background: rgba(230, 159, 63, 0.18); color: #c97f1f; }
.badge-rsi_extreme_high { background: rgba(209, 69, 61, 0.15); color: var(--negative); }
.badge-rsi_extreme_low { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-new_local_high { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-new_local_low { background: rgba(209, 69, 61, 0.15); color: var(--negative); }
.badge-news_sentiment_positive { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-news_sentiment_negative { background: rgba(209, 69, 61, 0.15); color: var(--negative); }

.badge-on { background: rgba(47, 143, 91, 0.15); color: var(--positive); }
.badge-off { background: rgba(209, 69, 61, 0.15); color: var(--negative); }
.badge-neutral { background: rgba(155, 149, 140, 0.18); color: var(--text-muted); }

/* ---------------- Pairs management ---------------- */

.pairs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pair-row {
  border: 1px solid var(--border);
  border-left: 3px solid var(--positive);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(47, 143, 91, 0.06);
}

.pair-row.is-disabled {
  border-left-color: var(--text-muted);
  background: transparent;
  opacity: 0.75;
}

.pair-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pair-row-main .pair-name {
  font-weight: 700;
  font-size: 13px;
  min-width: 100px;
}

.pair-row-main .pair-remove-btn {
  margin-left: auto;
}

.pair-row-reasoning {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}

.pair-row.has-recommendation .pair-row-reasoning {
  display: block;
}

/* ---------------- Pair picker (Suche) ---------------- */

.pair-picker {
  position: relative;
  margin-bottom: 12px;
}

.pair-picker input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 11px 12px;
}

.pair-picker input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pair-suggestions {
  display: none;
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--card-shadow);
  max-height: 340px; /* passt alle max. 8 Vorschlaege ohne Scrollen (vorher 220px = nur ~5 sichtbar) */
  overflow-y: auto;
}

.pair-suggestions.is-visible {
  display: block;
}

.pair-suggestion {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}

.pair-suggestion:hover,
.pair-suggestion.is-active {
  background: var(--accent-soft);
}

.pair-suggestion.is-empty {
  color: var(--text-muted);
  cursor: default;
}

.pair-suggestion.is-empty:hover {
  background: transparent;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Auto-Tune ---------------- */

.auto-tune-result {
  display: none;
  margin-top: 14px;
}

.auto-tune-result.is-visible {
  display: block;
}

.mode-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 14, 13, 0.55);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.is-visible {
  display: flex;
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--card-shadow);
}

.modal-box h3 {
  margin: 0 0 10px;
}

.modal-box-wide {
  max-width: 760px;
}

.trade-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0 4px;
  font-size: 12px;
}

/* ---------------- Interaktive Charts: Zeitrahmen + Live-Preis ---------------- */

.chart-header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.timeframe-select {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px;
}

.timeframe-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font);
}

.timeframe-btn:hover {
  color: var(--text);
}

.timeframe-btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.live-price-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--positive);
  min-width: 0;
}

.live-price-tag::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  margin-right: 5px;
  vertical-align: middle;
}

.live-price-tag:empty::before {
  display: none;
}

.trade-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trade-chart-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.trade-chart-reasoning {
  margin: 4px 0 10px;
  padding: 10px 12px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.trade-chart-reasoning strong {
  color: var(--text);
  margin-right: 4px;
}

.news-story-sources {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.decision-item.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.decision-item.is-clickable:hover {
  border-color: var(--accent);
}

/* ---------------- Decision PnL ---------------- */

.decision-pnl {
  font-weight: 700;
  font-size: 13px;
  margin-left: 8px;
}

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

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 12px;
  color: var(--text-muted);
}

.form-row input,
.form-row select,
select#pair-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 13px;
}

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

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }

  .table { font-size: 12px; }
  .table th,
  .table td { padding: 10px 8px; }

  .topbar-controls {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .segmented-control { max-width: none; }

  .topbar {
    gap: 8px;
    padding-block: 8px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-actions .btn {
    margin-left: auto;
  }

  .card-header-row,
  .chart-header-controls {
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }

  .card-header-row > .btn,
  .card-header-row > select {
    width: 100%;
  }

  .form-actions > .btn {
    flex: 1 1 auto;
  }

  .stat-list > div {
    gap: 12px;
  }

  .stat-list dd {
    text-align: right;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .view { gap: 16px; }
  .grid { gap: 16px; }
  .hold-confirm-btn { font-size: 13px; padding: 16px; }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-message {
  font-size: 13px;
}

.form-message.is-ok { color: var(--positive); }
.form-message.is-error { color: var(--negative); }

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

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
  min-height: 40px;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(0.95); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.btn-danger {
  background: var(--negative);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ---------------- Halten-zum-Bestaetigen-Knopf (Kaufen/Verkaufen) ---------------- */

.hold-confirm-btn {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  margin: 14px 0;
  border: none;
  border-radius: 5px;
  background: var(--negative);
  color: #fff;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.hold-confirm-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.hold-confirm-label {
  position: relative;
}

.hold-confirm-btn.is-holding {
  filter: brightness(0.95);
}

.hold-confirm-btn.is-buy {
  background: var(--accent);
}

/* ---------------- Switch ---------------- */

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: 0.2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: var(--bg-elevated);
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.switch input:checked + .slider {
  background: var(--positive);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}
