@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap");

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  --bg-base: #09090d;
  --bg-panel: #0f0f14;
  --bg-surface: #16161d;
  --bg-elevated: #1e1e27;
  --bg-hover: #262630;
  --bg-input: #12121a;

  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #eeedf3;
  --text-secondary: #9494a8;
  --text-muted: #5e5e72;

  --accent: #6c4dff;
  --accent-hover: #5838e8;
  --accent-bright: #8b6fff;
  --accent-glow: rgba(108, 77, 255, 0.28);
  --accent-subtle: rgba(108, 77, 255, 0.12);

  --success: #00c8a0;
  --success-bg: rgba(0, 200, 160, 0.14);
  --danger: #ff4d6a;
  --danger-bg: rgba(255, 77, 106, 0.14);
  --danger-surface: #2a1520;
  --danger-text: #ffb3c0;
  --warning: #f5a623;
  --warning-bg: rgba(245, 166, 35, 0.12);
  --profit: #b47aff;
  --profit-bg: rgba(180, 122, 255, 0.12);

  --chart-bg: #0f0f14;
  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-text: #eeedf3;
  --chart-success-alpha: rgba(0, 200, 160, 0.45);
  --chart-danger-alpha: rgba(255, 77, 106, 0.45);
  --chart-grid-line: rgba(148, 148, 168, 0.22);
  --chart-grid-line-strong: rgba(148, 148, 168, 0.55);

  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 0 0 1px var(--border-subtle), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition: 0.15s ease;

  /* Horizontal page padding for marketing/profile/legal. Dashboard uses its own gutters.
     Breakpoints (custom properties cannot be used in @media — keep these numbers in sync):
       Phone:   max-width 760px
       Tablet:  761px–1100px
       Desktop: min-width 1101px
     Visibility: .phone-only / .tablet-only / .mobile-only (phone+tablet) / .desktop-only / .tablet-up */
  --page-pad-x: 32px;
  --touch-min: 36px;
}

/* ── Reset & Base ────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(body:not(.app-shell)) {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

html.app-height-sync {
  /* Gesetzt via dashboard.js — zuverlässiger als 100dvh mit offenen DevTools */
  height: var(--app-height, 100dvh);
}

/* Dashboard: volle Viewport-Höhe, Scroll nur in Unterbereichen */
body.app-shell {
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

body.app-shell .header,
body.app-shell .balance-row,
body.app-shell .alert-banner,
body.app-shell .mobile-pair-bar,
body.app-shell .mobile-bot-bar {
  flex-shrink: 0;
}

html,
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* Profil, Login, Landing, Legal: ganze Seite scrollbar */
body.profile-page,
body.login-page,
body.landing-page {
  min-height: 100vh;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

#set-mode option[value="live"][hidden],
#set-mode option[value="live"]:disabled {
  display: none;
}

.muted {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 13px;
}

/* ── Alert ───────────────────────────────────────────────────────── */
.alert-banner {
  background: var(--danger-surface);
  color: var(--danger-text);
  padding: 10px 24px;
  font-size: 13px;
  white-space: pre-wrap;
  border-bottom: 1px solid rgba(255, 77, 106, 0.2);
}

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px 12px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #3d9eff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 18px;
  height: 18px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mode-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mode-badge.paper {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(0, 200, 160, 0.25);
}

.mode-badge.live {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 77, 106, 0.25);
}

.badge {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-weight: 500;
}

.badge.ok { color: var(--success); }
.badge.err { color: var(--danger); }
.badge.warn { color: var(--warning); }
.badge.muted { color: var(--text-muted); }

/* ── Balance Cards ───────────────────────────────────────────────── */
.balance-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 24px 12px;
}

.balance-row.pair-selected {
  grid-template-columns: repeat(3, 1fr);
}

.balance-card.hidden {
  display: none;
}

.balance-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.balance-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-default);
  transition: background var(--transition);
}

.balance-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-card);
}

.balance-card.accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-bright)); }
.balance-card.success::before { background: var(--success); }
.balance-card.warning::before { background: var(--warning); }
.balance-card.profit::before { background: var(--profit); }

.balance-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.balance-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.balance-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.balance-base-split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.balance-base-col {
  min-width: 0;
}

.balance-base-eur {
  text-align: right;
}

.balance-base-eur .balance-value {
  font-size: 18px;
  color: var(--text-secondary);
}

/* ── Layout ──────────────────────────────────────────────────────── */
.main {
  display: flex;
  gap: 12px;
  padding: 0 24px 12px;
  flex: 1 1 0%;
  min-height: 0;
  height: 0;
  overflow: hidden;
  align-items: stretch;
}

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  align-self: stretch;
}

.sidebar-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pair-list {
  list-style: none;
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pair-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px 8px 6px;
  border-radius: var(--radius-sm);
  cursor: grab;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition),
    opacity 0.15s ease, box-shadow 0.15s ease;
  font-family: var(--font-mono);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pair-item-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pair-status-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.pair-status-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.pair-status-icon.is-running {
  color: var(--success);
}

.pair-status-icon.is-starting {
  color: #f59e0b;
  animation: pair-status-spin 0.9s linear infinite;
}

.pair-status-icon.is-stopped {
  color: var(--danger);
}

.pair-status-icon.is-error {
  color: var(--danger);
}

.pair-status-icon.is-pending,
.pair-status-icon.is-untradable {
  color: var(--text-muted);
}

@keyframes pair-status-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .pair-status-icon.is-starting {
    animation: none;
  }
}

.pair-item-label {
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.2;
  word-break: break-word;
}

.pair-item-meta {
  margin: -1px 0 0 23px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pair-item.running .pair-item-meta {
  color: color-mix(in srgb, var(--success) 65%, var(--text-muted));
}

#pair-list.is-sorting {
  cursor: grabbing;
}

#pair-list.is-sorting .pair-item {
  cursor: grabbing;
}

.pair-item.is-dragging {
  visibility: hidden;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border-width: 0 !important;
  overflow: hidden;
  pointer-events: none;
}

.pair-drop-slot {
  list-style: none;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 75%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  box-sizing: border-box;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.pair-drop-slot-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent-bright) 85%, var(--text-muted));
  opacity: 0.9;
  pointer-events: none;
}

.pair-drop-slot.is-active {
  border-color: color-mix(in srgb, var(--accent) 95%, white);
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
    0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.pair-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  pointer-events: none;
  margin: 0;
  padding: 0;
  opacity: 0.96;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transform: rotate(1.25deg) scale(1.03);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--bg-elevated);
  will-change: left, top;
}

.pair-drag-ghost > .pair-item {
  cursor: grabbing;
  height: 100%;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border-default));
}

.pair-spark-block {
  height: 28px;
  border-radius: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 3px 4px;
  box-sizing: border-box;
  overflow: hidden;
}

.pair-spark-block.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pair-spark-block.is-empty::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  background: rgba(148, 163, 184, 0.22);
}

.pair-spark {
  width: 100%;
  height: 100%;
  display: block;
}

.pair-spark-line {
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pair-spark-area {
  stroke: none;
  opacity: 0.18;
}

.pair-spark-block.is-up .pair-spark-line {
  stroke: var(--success);
}

.pair-spark-block.is-up .pair-spark-area {
  fill: var(--success);
}

.pair-spark-block.is-down .pair-spark-line {
  stroke: var(--danger);
}

.pair-spark-block.is-down .pair-spark-area {
  fill: var(--danger);
}

.pair-spark-block.is-flat .pair-spark-line {
  stroke: var(--text-muted);
}

.pair-spark-block.is-flat .pair-spark-area {
  fill: var(--text-muted);
}

.pair-item.running,
.pair-item.starting,
.pair-item.stopped {
  color: var(--text);
}
.pair-item.selected {
  background: var(--accent-subtle);
  border-color: rgba(108, 77, 255, 0.35);
  color: var(--accent-bright);
}
.pair-item.pending,
.pair-item.untradable {
  color: var(--text-muted);
}
.pair-item.untradable {
  font-style: italic;
}
.pair-item:hover:not(.selected) { background: var(--bg-hover); }

.pair-item-enter {
  animation: pair-item-pop 0.35s ease-out;
}

@keyframes pair-item-pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pair-item-enter {
    animation: none;
  }
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-note {
  font-size: 10px;
  color: var(--text-muted);
  margin: 2px 0 8px;
}

.version {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 8px;
}

.content {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  position: relative;
  transition: color var(--transition);
  font-family: var(--font-ui);
}

.tab::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  background: transparent;
  border-radius: 2px 2px 0 0;
  transition: background var(--transition);
}

.tab.active {
  color: var(--accent-bright);
}

.tab.active::after {
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
}

.tab:hover:not(.active) {
  color: var(--text-primary);
}

.panel {
  display: none;
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 18px;
  background: var(--bg-panel);
  scrollbar-width: thin;
  scrollbar-color: var(--bg-hover) transparent;
  -webkit-overflow-scrolling: touch;
}

.panel.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
}

/* Chart-Tab: Inhalt füllt Bereich, kein Panel-Scroll */
#panel-chart.active,
#panel-overview.active {
  overflow: hidden;
}

.panel-head,
.chart-toolbar,
.tf-row,
.chart-legend,
.backtest-bar,
.filter-bar,
.history-actions,
.section-head,
.preview-row,
.settings-grid,
.billing-summary,
.billing-controls,
.billing-actions,
.overview-stats {
  flex-shrink: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head-actions .status-pill {
  margin-left: 0;
}

.status-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  margin-left: 10px;
  border: 1px solid var(--border-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.running {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(0, 200, 160, 0.2);
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 14px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 0 8px;
}

.section-head .section-title {
  margin: 0;
}

.pairs-sort-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pairs-sort-label select {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font: inherit;
  min-width: 9.5rem;
}

.pairs-sort-label select:focus {
  outline: none;
  border-color: var(--accent, #7c6cff);
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sortable-th:hover {
  color: var(--text);
}

.sortable-th.sort-active::after {
  content: " ▾";
  font-size: 0.75em;
  opacity: 0.8;
}

.sortable-th.sort-active.sort-asc::after {
  content: " ▴";
}

.mono-block {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  align-items: stretch;
}

.overview-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  min-width: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.overview-block::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-default);
}

.overview-block:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-card);
}

.overview-block-accent::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
}

.overview-block-market::before {
  background: var(--warning);
}

.overview-block-profit::before {
  background: var(--profit);
}

.overview-block-danger::before {
  background: var(--danger);
}

.overview-block-wide {
  grid-column: 1 / -1;
}

.overview-block-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 2px 0 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.overview-block-dl {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  flex: 1;
}

.overview-block-hero .overview-block-dl {
  justify-content: center;
}

.overview-kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.overview-kv dt,
.overview-kv dd {
  min-width: 0;
}

.overview-kv-total {
  background: var(--accent-subtle);
  border-color: rgba(108, 77, 255, 0.22);
}

.overview-block-hero .overview-kv {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overview-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.overview-stat-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
  margin: 0;
  text-align: right;
}

.overview-block-hero .overview-stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: left;
  line-height: 1.2;
}

.overview-kv-total .overview-stat-value {
  font-size: 14px;
  font-weight: 700;
}

.overview-stat-value.is-ok,
.overview-stat-value.is-warn,
.overview-stat-value.is-muted {
  width: fit-content;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.overview-stat-value.is-ok {
  color: var(--success);
  background: var(--success-bg);
}

.overview-stat-value.is-warn {
  color: var(--warning);
  background: var(--warning-bg);
}

.overview-stat-value.is-muted {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.overview-stat-value.is-profit {
  color: var(--profit);
}

.overview-stat-value.is-neg {
  color: var(--danger);
}

.overview-stat-value a {
  color: var(--accent-bright);
}

#panel-pnl.active {
  min-height: 0;
}

.pnl-empty {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.pnl-empty.hidden {
  display: none;
}

.pnl-range.hidden {
  display: none;
}

.pnl-range {
  font-size: 13px;
  white-space: nowrap;
}

.pnl-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.pnl-section.hidden {
  display: none;
}

.pnl-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pnl-metrics[hidden] {
  display: none !important;
}

.pnl-metrics strong {
  color: var(--text-primary);
  font-weight: 600;
}

.pnl-metrics .pos {
  color: var(--success);
}

.pnl-metrics .neg {
  color: var(--danger);
}

.pnl-chart {
  width: 100%;
  flex: 1;
  min-height: 320px;
  height: min(60vh, 520px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* ── Shared wait spinner (Trade-Republic style) ─────────────────── */
.bp-wait-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bp-wait-wrap.bp-wait-stacked {
  flex-direction: column;
  gap: 12px;
}

.bp-wait-caption {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  text-align: center;
  max-width: 28ch;
  line-height: 1.35;
}

.bp-wait-wrap.bp-wait-host {
  width: 100%;
  min-height: 120px;
  height: 100%;
}

.bp-wait {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.bp-wait-sm { width: 28px; height: 28px; }
.bp-wait-md { width: 48px; height: 48px; }
.bp-wait-lg { width: 64px; height: 64px; }

.bp-wait-svg {
  width: 100%;
  height: 100%;
  animation: bp-wait-spin 1.1s linear infinite;
}

.bp-wait-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 3;
}

.bp-wait-arc {
  fill: none;
  stroke: #22c55e;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 70 113;
  transform-origin: 24px 24px;
  animation: bp-wait-dash 1.1s ease-in-out infinite;
}

@keyframes bp-wait-spin {
  to { transform: rotate(360deg); }
}

@keyframes bp-wait-dash {
  0% { stroke-dasharray: 18 113; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 70 113; stroke-dashoffset: -28; }
  100% { stroke-dasharray: 18 113; stroke-dashoffset: -113; }
}

.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;
}

.overview-table-wrap {
  overflow: auto;
  flex: 1 1 0;
  min-height: 100px;
}

.tab.tab-admin {
  color: var(--accent-bright);
}

.tab.tab-admin.active::after {
  background: linear-gradient(90deg, #ffc107, var(--accent-bright));
}

.admin-header-btn {
  border-color: rgba(108, 77, 255, 0.45);
  color: var(--accent-bright);
}

.admin-header-btn:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.log-block {
  overflow-y: auto;
  font-size: 10px;
}

.log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-view {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  padding: 8px 0;
  font-family: var(--font-mono);
  line-height: 1.5;
}

.log-line {
  display: grid;
  grid-template-columns: 132px 62px 140px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 4px 12px;
  border-left: 2px solid transparent;
  transition: background var(--transition);
}

.log-line:hover {
  background: var(--bg-hover);
}

.log-line.log-info { border-left-color: var(--accent); }
.log-line.log-warning { border-left-color: var(--warning); }
.log-line.log-error { border-left-color: var(--danger); }
.log-line.log-debug { border-left-color: var(--text-muted); }
.log-line.log-muted {
  color: var(--text-muted);
  display: block;
  padding: 10px 12px;
}

.log-ts {
  color: var(--text-muted);
  white-space: nowrap;
}

.log-level {
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.log-info .log-level { color: var(--accent-bright); }
.log-warning .log-level { color: var(--warning); }
.log-error .log-level { color: var(--danger); }
.log-debug .log-level { color: var(--text-muted); }

.log-module {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-msg {
  color: var(--text-primary);
  word-break: break-word;
}

.log-msg-error {
  color: var(--danger-text);
}

.log-tag {
  font-weight: 600;
  border-radius: 3px;
  padding: 0 2px;
}

.log-tag-paper {
  color: var(--warning);
}

.log-tag-symbol {
  color: var(--accent-bright);
}

.log-tag-price {
  color: var(--success);
}

.log-tag-profit {
  color: var(--profit);
}

.billing-hint {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.billing-controls {
  margin-bottom: 14px;
}

.billing-month-field {
  max-width: 220px;
  margin-bottom: 0;
}

.billing-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.billing-card-accent .preview-value {
  color: var(--profit);
}

.billing-card-accent {
  border-color: rgba(180, 122, 255, 0.25);
}

.billing-payment-info {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12px;
}

.billing-actions {
  margin-bottom: 14px;
}

.billing-status-pending {
  color: var(--text-muted);
}

.billing-status-open {
  background: rgba(245, 166, 35, 0.14);
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
}

.billing-status-paid {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(0, 200, 160, 0.2);
}

.billing-status-overdue {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(255, 77, 106, 0.25);
}

.billing-status-reported {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
  border: 1px solid rgba(255, 193, 7, 0.35);
}

.billing-status-waived {
  color: var(--text-muted);
}

.payment-lock {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}

.payment-lock-card {
  width: min(520px, 92vw);
  padding: 28px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  margin: auto 0;
}

.payment-lock-card h2 {
  margin-bottom: 10px;
  color: var(--danger-text);
}

.payment-lock-lead {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap {
  overflow: auto;
  min-height: 0;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

#panel-history .table-wrap,
#panel-billing .table-wrap,
#panel-admin .table-wrap {
  flex: 1 1 auto;
  min-height: 160px;
}

.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.history-subnav {
  margin-top: 2px;
}

.admin-subtab {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
}

.admin-subtab:hover {
  color: var(--text-primary);
  border-color: var(--border-strong, var(--border-default));
}

.admin-subtab.active {
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

#panel-admin.active {
  overflow: hidden;
}

.admin-pane-alerts {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.admin-alerts-log {
  flex: 1 1 0;
  min-height: 160px;
  overflow-y: auto;
}

.admin-pane-diagnose {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-diag-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-diag-summary {
  margin: 0;
  font-size: 13px;
}

.admin-diag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.admin-diag-filter {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
}

.admin-diag-filter:hover {
  color: var(--text-primary);
}

.admin-diag-filter.active {
  color: var(--text-primary);
  border-color: var(--accent);
}

.admin-diag-known {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.admin-diag-known ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.admin-diag-list {
  flex: 1 1 0;
  min-height: 120px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-diag-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border-left: 3px solid var(--text-muted);
}

.admin-diag-card.is-error {
  border-left-color: var(--danger);
}

.admin-diag-card.is-warn {
  border-left-color: var(--warning);
}

.admin-diag-card.is-info {
  border-left-color: var(--accent);
}

.admin-diag-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.admin-diag-sev {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-diag-card.is-error .admin-diag-sev { color: var(--danger); }
.admin-diag-card.is-warn .admin-diag-sev { color: var(--warning); }
.admin-diag-card.is-info .admin-diag-sev { color: var(--accent); }

.admin-diag-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1 1 auto;
}

.admin-diag-copy-one {
  margin-left: auto;
}

.admin-diag-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.admin-diag-detail,
.admin-diag-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-diag-hint {
  color: var(--text-muted);
}

.admin-diag-notes-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.admin-diag-notes {
  width: 100%;
  resize: vertical;
  min-height: 64px;
  margin-bottom: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-ui);
  font-size: 13px;
}

.admin-load-meta {
  margin: 0 0 12px;
  font-size: 12px;
}

.admin-load-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.admin-load-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.admin-load-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.admin-load-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.admin-load-bar {
  height: 6px;
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}

.admin-load-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease, background 0.3s ease;
}

.admin-load-bar.is-ok > span {
  background: var(--success);
}

.admin-load-bar.is-warn > span {
  background: var(--warning);
}

.admin-load-bar.is-high > span {
  background: var(--danger);
}

.admin-load-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: center;
  padding: 10px 8px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
}

.data-table td {
  text-align: center;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 12px;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.data-table tr.buy td:nth-child(2) { color: var(--success); }
.data-table tr.sell td:nth-child(2) { color: var(--danger); }
.data-table tr.profit-pos td:last-child { color: var(--profit); }
.data-table tr.profit-neg td:last-child { color: var(--danger); }
.data-table td.pos { color: var(--success); font-weight: 600; }
.data-table td.neg { color: var(--danger); font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn.danger {
  background: var(--danger-surface);
  border-color: rgba(255, 77, 106, 0.3);
  color: var(--danger-text);
}

.btn.danger:hover {
  background: rgba(255, 77, 106, 0.18);
  border-color: rgba(255, 77, 106, 0.45);
}

/* ── Chart Tab ───────────────────────────────────────────────────── */
.chart-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.chart-head-left h2 {
  font-size: 20px;
  font-weight: 700;
  display: inline;
  margin-right: 12px;
  letter-spacing: -0.02em;
}

.change {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.change.up { color: var(--success); }
.change.down { color: var(--danger); }

.ohlc {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.ohlc b {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.price-row {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.live-price {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}

.clock {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.tf-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border-subtle);
  width: fit-content;
  position: relative;
  z-index: 3;
}

.tf {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  touch-action: manipulation;
  transition: background var(--transition), color var(--transition);
}

.tf.active {
  background: var(--accent-subtle);
  color: var(--accent-bright);
}

.tf:hover:not(.active) {
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 8px;
  font-size: 11px;
}

.legend-item {
  font-weight: 600;
}

.legend-buy { color: var(--success); }
.legend-next-buy { color: color-mix(in srgb, var(--success) 55%, var(--text-muted)); }
.legend-sell { color: var(--danger); }
.legend-grid { color: var(--text-muted); }
.legend-trade { color: var(--warning); }

.chart-archive-status {
  margin: 0 0 6px;
  font-size: 12px;
}

.error {
  background: var(--danger-surface);
  color: var(--danger-text);
  padding: 8px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border: 1px solid rgba(255, 77, 106, 0.2);
}

.chart-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.chart-wait {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 55%, rgba(34, 197, 94, 0.06), transparent 70%),
    var(--chart-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.chart-wait.hidden {
  display: none;
}

.chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  background: var(--chart-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.chart-trade-hover {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, 0);
  pointer-events: none;
  color: #ffe566;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* ── Settings ──────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.settings-col {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--border-subtle);
}

.settings-col h3 {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.field input,
.field select {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-ui);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.field.checkbox-field input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.field.checkbox-field.is-locked,
.field.is-locked {
  opacity: 0.48;
}

.field.checkbox-field.is-locked .checkbox-label,
.field.is-locked {
  cursor: not-allowed;
}

.field.is-locked input:disabled,
.field.checkbox-field.is-locked input:disabled {
  cursor: not-allowed;
}

.buy-mode-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 8px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--text-muted, #94a3b8) 28%, transparent);
  border-radius: 8px;
}

.buy-mode-group > legend {
  padding: 0 6px;
  font-size: 0.82rem;
  color: var(--text-secondary, #cbd5e1);
}

.buy-mode-hint {
  margin: 0 0 4px;
}

.checkbox-with-info {
  position: relative;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.checkbox-with-info .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
}

.info-tip-btn {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--text-muted, #94a3b8) 55%, transparent);
  background: color-mix(in srgb, var(--surface-2, #1a2030) 80%, transparent);
  color: var(--text-secondary, #cbd5e1);
  font: 700 0.72rem/1 var(--font-mono, "JetBrains Mono", monospace);
  padding: 0;
  cursor: help;
  flex-shrink: 0;
}

.info-tip-btn:hover,
.info-tip-btn:focus-visible,
.info-tip-btn[aria-expanded="true"] {
  color: var(--accent, #00c8a0);
  border-color: color-mix(in srgb, var(--accent, #00c8a0) 55%, transparent);
  outline: none;
}

.info-tip-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 20;
  width: min(100%, 340px);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--text-muted, #94a3b8) 28%, transparent);
  background: var(--surface-1, #121722);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  color: var(--text-secondary, #cbd5e1);
  font-size: 0.82rem;
  line-height: 1.45;
}

.info-tip-panel[hidden] {
  display: none !important;
}

.info-tip-panel p {
  margin: 0 0 0.55em;
}

.info-tip-panel p:last-child {
  margin-bottom: 0;
}

.info-tip-panel strong {
  color: var(--text-primary, #e8eaef);
  font-weight: 600;
}

.preview-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.preview-badge {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  border: 1px solid var(--border-subtle);
  transition: border-color var(--transition);
}

.preview-badge:hover {
  border-color: var(--border-default);
}

.preview-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.preview-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-bright);
}

#prev-spacing.preview-value {
  font-size: 16px;
  line-height: 1.3;
  word-break: break-word;
}

/* ── Backtest ──────────────────────────────────────────────────────── */
.backtest-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 8px;
  font-size: 13px;
}

.bt-capital {
  margin: 0 0 12px;
  font-size: 13px;
}

.bt-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 14px;
}

.bt-summary:empty {
  display: none;
}

.bt-summary-loading,
.bt-summary-empty {
  padding: 14px 16px;
  border-radius: var(--radius-md, 10px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
}

.bt-summary.is-loading {
  opacity: 1;
}

.bt-summary.bt-result-enter {
  animation: bt-result-fade 0.35s ease-out;
}

@keyframes bt-result-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bt-loading-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bt-loading-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md, 10px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.bt-loading-status .bp-wait-wrap {
  flex-shrink: 0;
}

.bt-loading-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bt-loading-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.bt-loading-detail {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.bt-ph {
  display: inline-block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.12) 0%,
    rgba(148, 163, 184, 0.22) 50%,
    rgba(148, 163, 184, 0.12) 100%
  );
  background-size: 200% 100%;
  animation: bt-ph-shimmer 1.4s ease-in-out infinite;
  vertical-align: middle;
}

.bt-ph-lg {
  width: min(180px, 55%);
  height: 1.1em;
}

.bt-ph-md {
  width: min(110px, 45%);
  height: 0.95em;
}

.bt-ph-sm {
  width: min(72px, 35%);
  height: 0.75em;
}

.bt-ph-line {
  width: 100%;
  height: 10px;
  border-radius: 4px;
}

.bt-verdict-card.is-placeholder,
.bt-cap-card.is-placeholder,
.bt-metric.is-placeholder {
  pointer-events: none;
}

.bt-verdict-card.is-placeholder .bt-value,
.bt-cap-card.is-placeholder .bt-value,
.bt-metric.is-placeholder .bt-value {
  min-height: 1.15em;
}

.bt-table-wrap.is-loading {
  position: relative;
  min-height: 120px;
}

.bt-table-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.bt-table-loading .bp-wait {
  width: 28px;
  height: 28px;
}

@keyframes bt-ph-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bt-summary.bt-result-enter,
  .bt-ph {
    animation: none;
  }
}

.bt-verdict {
  display: block;
  width: 100%;
}

.bt-verdict-card {
  padding: 18px 20px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  width: 100%;
  box-sizing: border-box;
}

.bt-verdict-card .bt-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.bt-verdict-card .bt-value {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.bt-verdict-card .bt-sub {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.bt-verdict-card.pos {
  background: var(--success-bg);
  border-color: rgba(0, 200, 160, 0.28);
}

.bt-verdict-card.pos .bt-value {
  color: var(--success);
}

.bt-verdict-card.neg {
  background: var(--danger-bg);
  border-color: rgba(255, 77, 106, 0.28);
}

.bt-verdict-card.neg .bt-value {
  color: var(--danger);
}

.bt-verdict-card.flat .bt-value {
  color: var(--text-primary);
}

.bt-body {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(0, 2.2fr) minmax(160px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.bt-cap-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  min-width: 0;
  min-height: 100%;
  box-sizing: border-box;
}

.bt-cap-card .bt-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 0;
  font-weight: 500;
}

.bt-cap-card .bt-value {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  word-break: break-word;
  margin-top: auto;
  padding-top: 12px;
}

.bt-cap-card .bt-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono, "JetBrains Mono", monospace);
}

.bt-base-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: 6px 10px;
}

.bt-base-amt {
  color: var(--text-secondary);
}

.bt-base-eur {
  color: var(--text-muted);
  font-weight: 500;
}

.bt-base-note {
  color: var(--text-muted);
  font-family: var(--font-ui, inherit);
  font-size: 11px;
}

.bt-cap-end {
  text-align: left;
}

.bt-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.bt-metric {
  padding: 12px 12px 10px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.bt-metric .bt-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bt-metric .bt-value {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.bt-metric .bt-value.pos {
  color: var(--success);
}

.bt-metric .bt-value.neg {
  color: var(--danger);
}

.bt-metric .bt-value.muted {
  color: var(--text-secondary);
  font-weight: 500;
}

.bt-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px 12px;
  margin: 0 0 14px;
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.bt-meta-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  flex: 1 1 12rem;
  min-width: 0;
}

.bt-meta-row strong {
  color: var(--text-primary);
  font-weight: 600;
}

.bt-meta-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.bt-gear-btn {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--text-muted, #94a3b8) 55%, transparent);
  background: color-mix(in srgb, var(--surface-2, #1a2030) 80%, transparent);
  color: var(--text-secondary, #cbd5e1);
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.bt-gear-btn svg {
  width: 1.05rem;
  height: 1.05rem;
}

.bt-gear-btn:hover,
.bt-gear-btn:focus-visible,
.bt-gear-btn.is-active {
  color: var(--accent, #00c8a0);
  border-color: color-mix(in srgb, var(--accent, #00c8a0) 55%, transparent);
  outline: none;
}

.bt-info-tip {
  left: auto;
  right: 0;
  width: min(340px, 78vw);
}

.bt-hint {
  padding: 10px 12px;
  border-radius: var(--radius-sm, 8px);
  background: var(--warning-bg);
  border: 1px solid rgba(245, 166, 35, 0.25);
  color: var(--warning);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .bt-body {
    grid-template-columns: 1fr 1fr;
  }

  .bt-stats {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 560px) {
  .bt-body {
    grid-template-columns: 1fr;
  }

  .bt-verdict-card .bt-value {
    font-size: 26px;
  }

  .bt-stats {
    grid-template-columns: 1fr 1fr;
  }
}

.backtest-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 500;
}

.backtest-bar input,
.backtest-bar select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
}

.bt-table-wrap {
  max-height: min(320px, 40vh);
  margin: 10px 0;
  overflow: auto;
}

.bt-chart-wrap {
  flex: 0 1 auto;
  min-height: 200px;
  max-height: min(420px, 45vh);
  margin-top: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

/* ── History ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.filter-bar label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: color var(--transition);
}

.filter-bar label:hover {
  color: var(--text-primary);
}

.filter-bar input[type="radio"] {
  accent-color: var(--accent);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-tax-note {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 12px;
  max-width: 72rem;
}

.history-source-note {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 10px;
  max-width: 72rem;
}

.history-source-note strong {
  color: var(--text-primary);
  font-weight: 600;
}

.history-year-label {
  margin-left: auto;
  gap: 8px;
}

.history-year-label select {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
}

.history-year-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.history-year-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.history-year-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.history-year-card p {
  margin: 0 0 4px;
  font-size: 12px;
}

.data-table td.tax-free {
  color: var(--success);
  font-weight: 600;
}

.data-table td.tax-taxable {
  color: var(--text-secondary);
}

.data-table td.mode-paper {
  color: var(--warning);
}

.data-table tr.hist-warn td {
  background: var(--warning-bg);
}

.data-table tr.hist-warn td:first-child {
  box-shadow: inset 3px 0 0 var(--warning);
}

.hist-anomaly {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  color: var(--warning);
  font-size: 15px;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
  line-height: 1;
}

.warn {
  color: var(--warning);
  font-size: 11px;
  margin-bottom: 8px;
}

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-elevated);
  backdrop-filter: blur(8px);
}

.toast.ok {
  background: rgba(10, 40, 32, 0.92);
  color: var(--success);
  border: 1px solid rgba(0, 200, 160, 0.25);
}

.toast.err {
  background: rgba(42, 21, 32, 0.92);
  color: var(--danger-text);
  border: 1px solid rgba(255, 77, 106, 0.25);
}

.sidebar-new-pair {
  width: 100%;
  margin-top: 8px;
  flex-shrink: 0;
}

#btn-settings-add-pair {
  margin-top: 4px;
  align-self: flex-start;
}

.phone-only,
.tablet-only,
.mobile-only {
  display: none !important;
}

.desktop-only {
  /* visible by default; hidden at max-width 1100px */
}

.tablet-up {
  /* visible by default; hidden at max-width 760px */
}

.title-short {
  display: none;
}

.tab-label-short {
  display: none;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-sheet-handle {
  display: none;
}

.btn-icon {
  min-width: 36px;
  padding-left: 10px;
  padding-right: 10px;
}

.sidebar-backdrop {
  display: none;
}

.mobile-more-wrap {
  position: relative;
}

.mobile-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  z-index: 2200;
}

.mobile-more-menu.hidden {
  display: none !important;
}

.mobile-more-meta {
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.mobile-more-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  text-decoration: none;
  cursor: pointer;
}

.mobile-more-item:hover {
  background: var(--bg-hover);
}

.mobile-pair-bar {
  display: none;
}

.mobile-bot-bar {
  display: none;
}

/* ── Action loading overlay ─────────────────────────────────────── */
.action-loading {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 9, 13, 0.72);
  backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity 0.4s ease;
}

.action-loading.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.action-loading.hidden {
  display: none;
}

.action-loading-card {
  width: min(300px, 86vw);
  padding: 28px 24px 24px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-elevated);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transform: translateY(0);
  transition: transform 0.38s ease, opacity 0.38s ease;
}

.action-loading.is-leaving .action-loading-card {
  transform: translateY(8px);
  opacity: 0.75;
}

.action-loading-label {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.action-loading-card .bp-wait-wrap {
  margin: 0;
}

/* Boot: brand-first, calm full-screen cover */
.action-loading--boot {
  background: var(--bg-base);
  backdrop-filter: none;
}

.action-loading--boot .action-loading-card {
  display: none;
}

.action-loading:not(.action-loading--boot) .boot-stage {
  display: none;
}

.boot-stage {
  position: relative;
  width: min(380px, 90vw);
  padding: 36px 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  z-index: 1;
}

.boot-stage-bg {
  position: absolute;
  inset: -40% -30% -20%;
  background:
    radial-gradient(ellipse 55% 45% at 50% 28%, rgba(108, 77, 255, 0.16), transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 78%, rgba(0, 200, 160, 0.07), transparent 65%);
  pointer-events: none;
  z-index: 0;
  animation: boot-ambient 7s ease-in-out infinite alternate;
}

.boot-brand {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.boot-brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, rgba(139, 111, 255, 0.95), rgba(88, 56, 232, 0.88));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 12px 36px rgba(108, 77, 255, 0.28);
  animation: boot-mark-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.boot-brand-mark svg {
  width: 28px;
  height: 28px;
}

.boot-brand-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: boot-text-in 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.boot-wordmark {
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(1.75rem, 5vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.1;
}

.boot-tagline {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.boot-progress {
  position: relative;
  z-index: 1;
  width: min(220px, 70vw);
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 6px;
}

.boot-progress-bar {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--success));
  animation: boot-progress-slide 1.35s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.action-loading--boot .action-loading-label {
  position: relative;
  z-index: 1;
  margin-top: 2px;
  min-height: 1.35em;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  animation: boot-text-in 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
}

.boot-asset-strip {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  max-width: 100%;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.boot-asset-strip.is-visible {
  opacity: 1;
  transform: translateY(0);
  margin-top: 4px;
}

.boot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  animation: boot-chip-in 0.45s ease both;
  animation-delay: var(--chip-delay, 0ms);
}

.boot-chip img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
}

.boot-chip-text {
  padding-left: 10px;
}

.boot-stage.is-finishing .boot-progress-bar {
  animation: none;
  width: 100%;
  transition: width 0.35s ease;
}

.boot-stage.is-finishing .boot-brand-mark {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 28px rgba(0, 200, 160, 0.25);
}

@keyframes boot-ambient {
  from { opacity: 0.85; transform: scale(1); }
  to { opacity: 1; transform: scale(1.04); }
}

@keyframes boot-mark-in {
  from {
    opacity: 0;
    transform: scale(0.86) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes boot-text-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes boot-progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

@keyframes boot-chip-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Soft reveal after boot overlay dismisses */
body.app-shell.app-booting {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .action-loading,
  .action-loading-card,
  .boot-stage-bg,
  .boot-brand-mark,
  .boot-brand-text,
  .action-loading--boot .action-loading-label,
  .boot-progress-bar,
  .boot-chip {
    animation: none !important;
    transition: none !important;
  }

  .boot-progress-bar {
    width: 55%;
    transform: none;
  }

  .action-loading.is-leaving .action-loading-card {
    transform: none;
    opacity: 1;
  }
}

/* ── Modals ──────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 2000;
  padding: 24px 16px;
  overflow-y: auto;
}

#local-closed-modal {
  z-index: 5000;
  align-items: center;
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(440px, 92vw);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-elevated);
  margin: auto 0;
}

.modal-card-wide {
  width: min(920px, 96vw);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

#bt-settings-modal .modal-card {
  width: min(520px, 92vw);
}

.local-closed-card {
  text-align: center;
  width: min(400px, 92vw);
}

.local-closed-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent-bright);
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.local-closed-icon svg {
  width: 24px;
  height: 24px;
}

.local-closed-card h3 {
  margin-bottom: 8px;
}

.local-closed-card p {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.local-closed-card .modal-actions {
  justify-content: center;
}

.local-closed-card .modal-actions .btn {
  min-width: 120px;
}

.paper-reset-card {
  width: min(440px, 92vw);
}

.paper-reset-icon {
  width: 48px;
  height: 48px;
  margin: 0 0 14px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
}

.paper-reset-icon svg {
  width: 24px;
  height: 24px;
}

.paper-reset-card h3 {
  margin-bottom: 8px;
}

.paper-reset-card > p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
}

.paper-reset-list {
  list-style: none;
  margin: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.paper-reset-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.paper-reset-list li::before {
  content: "";
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.live-checklist,
.onboarding-steps {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.live-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.live-check.is-ok {
  color: var(--success);
}

.live-check.is-bad {
  color: var(--danger);
}

.live-check-mark::before {
  content: "○";
  font-size: 12px;
}

.live-check.is-ok .live-check-mark::before {
  content: "●";
}

.live-check.is-bad .live-check-mark::before {
  content: "●";
}

.live-check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  color: var(--text-primary);
}

.live-check-label input {
  margin-top: 2px;
}

.onboarding-step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
}

.onboarding-step strong {
  color: var(--text-primary);
  font-size: 13px;
}

.onboarding-step.is-active {
  border-color: var(--accent, var(--border-default));
  background: var(--bg-hover);
  color: var(--text-primary);
}

.onboarding-step.is-done {
  opacity: 0.75;
}

.onboarding-status {
  min-height: 1.2em;
  margin: 0 0 8px;
  font-size: 13px;
}

.bt-headline {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-size: 14px;
  line-height: 1.45;
}

.bt-headline strong {
  font-weight: 600;
}

.hotfix-notes {
  margin: 0 0 16px;
  padding: 14px 16px;
  max-height: min(60vh, 520px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-secondary, #cbd5e1);
  background: var(--bg-muted, rgba(15, 23, 42, 0.55));
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 8px);
}

.new-pair-intro {
  margin: 0 0 16px;
}

.new-pair-intro a {
  color: var(--accent);
  text-decoration: none;
}

.new-pair-intro a:hover {
  text-decoration: underline;
}

.new-pair-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(260px, 1.2fr) minmax(200px, 1fr);
  gap: 18px;
}

.new-pair-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.np-exchange-badge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
}

.np-exchange-badge strong {
  font-size: 18px;
  font-weight: 700;
}

.np-asset-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}

.np-asset-results.hidden {
  display: none;
}

.np-asset-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle, var(--border-default));
}

.np-asset-item:last-child {
  border-bottom: none;
}

.np-asset-item:hover,
.np-asset-item:focus {
  background: var(--bg-hover, rgba(255, 255, 255, 0.04));
}

.np-asset-sym {
  font-weight: 700;
  min-width: 3.5rem;
  font-family: var(--font-mono);
}

.np-asset-name {
  color: var(--text-muted);
  font-size: 13px;
}

.np-selected-asset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft, rgba(99, 102, 241, 0.12));
  border: 1px solid var(--border-default);
}

.np-selected-asset.hidden {
  display: none;
}

.np-asset-pick {
  font-weight: 600;
  font-size: 14px;
}

.np-asset-clear {
  min-width: 2rem;
  padding: 2px 8px;
}

.np-asset-list {
  width: 100%;
  min-height: 280px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
}

.np-preview {
  padding: 14px;
  margin-top: 4px;
}

.np-preview-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.np-preview-symbol {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.np-preview-meta {
  margin-top: 4px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .new-pair-grid {
    grid-template-columns: 1fr;
  }

  .np-asset-list {
    min-height: 200px;
  }
}

.modal-card h3 {
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-card input[type="text"] {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 14px;
}

.modal-card input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* ── Login Page ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(108, 77, 255, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(61, 158, 255, 0.06) 0%, transparent 50%),
    var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 40px 36px;
  text-align: center;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand .brand-icon {
  width: 48px;
  height: 48px;
}

.login-brand .brand-icon svg {
  width: 26px;
  height: 26px;
}

.login-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-secondary);
  margin: 0 0 28px;
  line-height: 1.6;
  font-size: 14px;
}

.microsoft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 18px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 1px solid var(--border-default);
  transition: background var(--transition), border-color var(--transition);
}

.microsoft-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.microsoft-btn.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.login-error {
  color: var(--danger-text);
  margin-top: 18px;
  font-size: 0.9rem;
}

.login-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 24px;
  line-height: 1.5;
}

.ready-pill {
  display: inline-block;
  margin: 0 0 16px;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
}

.ready-pill.pending {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.ready-pill.ok {
  background: var(--success-bg);
  color: var(--success);
}

.ready-pill.fail {
  background: var(--danger-surface);
  color: var(--danger-text);
}

.ready-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.terms-card {
  width: 100%;
  max-width: 720px;
  padding: 36px 32px;
}

.terms-sections {
  max-height: min(52vh, 520px);
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 8px;
  text-align: left;
}

.terms-section {
  margin-bottom: 18px;
}

.terms-section h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text-primary);
}

.terms-section p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 14px;
}

.terms-accept-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  margin-bottom: 18px;
  color: var(--text-secondary);
  font-size: 14px;
}

.terms-accept-field input {
  margin-top: 3px;
}

.terms-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Header Right ────────────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.user-link {
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.user-link:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* ── Profile Page ────────────────────────────────────────────────── */
.profile-page {
  min-height: 100vh;
  background: var(--bg-base);
}

.profile-back {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  margin-right: 16px;
  transition: color var(--transition);
}

.profile-back:hover {
  color: var(--accent-bright);
}

.profile-title {
  font-size: 1.1rem;
}

.profile-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-card {
  padding: 24px 28px;
}

.profile-section-title {
  margin: 0 0 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.profile-fields {
  margin: 0;
  display: grid;
  gap: 14px;
}

.profile-field {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: baseline;
}

.profile-field dt {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.profile-field dd {
  margin: 0;
  font-size: 0.95rem;
  word-break: break-all;
}

.profile-field dd.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.profile-hint {
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.profile-hint-top {
  margin: 0 0 18px;
}

.profile-api-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.api-status {
  font-size: 0.85rem;
}

.api-status.ok {
  color: var(--success);
}

.api-status.warn {
  color: var(--warning);
}

.settings-api-hint {
  margin: 0 0 14px;
}

.settings-api-hint a {
  color: var(--accent);
  text-decoration: none;
}

.settings-api-hint a:hover {
  text-decoration: underline;
}

.settings-api-status-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  vertical-align: middle;
}

.api-clear-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.api-clear-btn:hover {
  color: var(--danger);
  border-color: rgba(255, 77, 106, 0.45);
  background: var(--danger-bg);
}

.profile-exchange-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.exchange-active-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 18px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-input) 100%);
  box-shadow: var(--shadow-card);
}

.exchange-active-card .api-clear-btn {
  margin-left: auto;
}

.exchange-active-card--empty {
  border-color: var(--border-subtle);
  opacity: 0.92;
}

.exchange-active-card--active {
  border-color: rgba(0, 200, 160, 0.35);
  background: linear-gradient(135deg, rgba(0, 200, 160, 0.12) 0%, var(--bg-elevated) 55%);
  box-shadow: 0 0 0 1px rgba(0, 200, 160, 0.08), var(--shadow-card);
}

.exchange-active-card--warn {
  border-color: rgba(245, 166, 35, 0.35);
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.1) 0%, var(--bg-elevated) 55%);
}

.exchange-active-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.exchange-active-card--active .exchange-active-icon {
  color: var(--success);
  border-color: rgba(0, 200, 160, 0.25);
  background: rgba(0, 200, 160, 0.1);
}

.exchange-active-card--warn .exchange-active-icon {
  color: var(--warning);
  border-color: rgba(245, 166, 35, 0.25);
  background: rgba(245, 166, 35, 0.08);
}

.exchange-active-icon svg {
  width: 22px;
  height: 22px;
}

.exchange-active-body {
  min-width: 0;
}

.exchange-active-kicker {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.exchange-active-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.25;
}

.exchange-active-card--active .exchange-active-name {
  color: var(--success);
}

.exchange-active-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

#bt-result {
  max-height: none;
  overflow: visible;
  flex-shrink: 0;
}

.bt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.panel::-webkit-scrollbar {
  width: 8px;
}

.panel::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 4px;
}

@media (max-width: 1100px) {
  :root {
    --page-pad-x: 20px;
    --touch-min: 44px;
  }

  .mobile-only {
    display: flex !important;
  }

  .mobile-only.btn,
  .mobile-only.btn-sm,
  button.mobile-only,
  a.mobile-only {
    display: inline-flex !important;
  }

  .desktop-only {
    display: none !important;
  }

  body.app-shell .header,
  body.app-shell .mobile-pair-bar,
  body.app-shell .balance-row,
  body.app-shell .alert-banner {
    flex-shrink: 0;
  }

  body.app-shell .main {
    flex: 1 1 0%;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 0;
    height: 0;
  }

  .header {
    padding: 10px 16px;
    gap: 10px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .header-left,
  .header-right {
    gap: 8px;
  }

  .header-left {
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-right {
    flex-shrink: 0;
  }

  .balance-row,
  .balance-row.pair-selected {
    grid-template-columns: repeat(2, 1fr);
    padding: 10px 16px 12px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .overview-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-block-profit,
  .overview-block-danger,
  .overview-block-wide {
    grid-column: 1 / -1;
  }

  .mobile-pair-bar {
    display: flex !important;
    flex-direction: column;
    gap: 6px;
    padding: 8px 16px 10px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-pair-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-ui);
    cursor: pointer;
    text-align: left;
    min-height: var(--touch-min);
  }

  .mobile-pair-chip:active {
    background: var(--bg-elevated);
  }

  .mobile-pair-chip-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .mobile-pair-symbol {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
  }

  .mobile-pair-chevron {
    color: var(--text-muted);
    font-size: 12px;
  }

  .mobile-pair-status {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
  }

  .mobile-pair-status.running {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(0, 200, 160, 0.25);
  }

  .mobile-bot-bar {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1800;
    gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 15, 20, 0.94);
    border-top: 1px solid var(--border-default);
    backdrop-filter: blur(10px);
  }

  .mobile-bot-bar .btn {
    flex: 1 1 0;
    min-height: var(--touch-min);
    font-size: 13px;
  }

  .content {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    margin: 0;
  }

  .main > .content.card {
    box-shadow: none;
  }

  .pair-item {
    touch-action: pan-y;
    cursor: pointer;
    min-height: var(--touch-min);
  }

  /* Tablet default: left drawer. Phone overrides to a bottom sheet. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    bottom: 0;
    width: min(320px, 88vw);
    max-height: none;
    height: auto;
    z-index: 2100;
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2050;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 2px;
    padding: 6px 10px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-surface);
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    padding: 11px 14px;
    white-space: nowrap;
    min-height: var(--touch-min);
  }

  .panel {
    padding: 14px 16px calc(84px + env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
  }

  #panel-chart.active {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .panel-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .tf {
    min-width: var(--touch-min);
    min-height: var(--touch-min);
  }

  .chart-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar,
  .history-actions,
  .billing-actions,
  .bt-actions,
  .section-head,
  .backtest-bar {
    flex-wrap: wrap;
  }

  .table-wrap {
    margin-left: -4px;
    margin-right: -4px;
    padding-bottom: 4px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
    min-height: var(--touch-min);
  }

  .payment-lock {
    padding: 12px;
    align-items: stretch;
  }

  .payment-lock-card {
    width: 100%;
    max-height: none;
    padding: 24px 20px;
  }

  .alert-banner {
    padding: 8px 16px;
    font-size: 12px;
  }

  .landing-header,
  .landing-hero,
  .landing-section,
  .landing-footer {
    padding-left: var(--page-pad-x);
    padding-right: var(--page-pad-x);
  }

  .legal-page .legal-main {
    margin-left: var(--page-pad-x);
    margin-right: var(--page-pad-x);
    padding: 24px 22px;
  }

  .profile-main {
    padding-left: var(--page-pad-x);
    padding-right: var(--page-pad-x);
  }

  .profile-actions .btn,
  .microsoft-btn {
    min-height: var(--touch-min);
  }

  .login-page {
    padding: 28px var(--page-pad-x);
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .tablet-only {
    display: flex !important;
  }

  .tablet-only.btn,
  .tablet-only.btn-sm,
  button.tablet-only,
  a.tablet-only {
    display: inline-flex !important;
  }

  .tab {
    font-size: 13px;
  }

  .landing-hero {
    gap: 24px;
    padding-top: 40px;
    padding-bottom: 32px;
  }

  .landing-grid {
    gap: 14px;
  }
}

@media (max-width: 760px) {
  :root {
    --page-pad-x: 16px;
  }

  .tablet-only {
    display: none !important;
  }

  .phone-only {
    display: flex !important;
  }

  .phone-only.btn,
  .phone-only.btn-sm,
  button.phone-only,
  a.phone-only {
    display: inline-flex !important;
  }

  .tablet-up {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  .mobile-only.btn,
  .mobile-only.btn-sm,
  button.mobile-only,
  a.mobile-only {
    display: inline-flex !important;
  }

  .desktop-only {
    display: none !important;
  }

  .title-full {
    display: none;
  }

  .title-short {
    display: inline;
  }

  .tab-label-full {
    display: none;
  }

  .tab-label-short {
    display: inline;
  }

  body.app-shell {
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
  }

  body.app-shell .header,
  body.app-shell .mobile-pair-bar,
  body.app-shell .alert-banner {
    flex-shrink: 0;
  }

  body.app-shell .main {
    flex: 1 1 0%;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 0;
    height: 0;
  }

  .header {
    padding: 8px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .header-left {
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }

  .app-title {
    font-size: 15px;
  }

  .brand-icon {
    width: 26px;
    height: 26px;
  }

  .mode-badge {
    padding: 3px 7px;
    font-size: 8px;
  }

  /* Kompakte Pair-Leiste statt großer Balance-Karten */
  .mobile-pair-bar {
    display: flex !important;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px 10px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-pair-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-ui);
    cursor: pointer;
    text-align: left;
    min-height: 48px;
  }

  .mobile-pair-chip:active {
    background: var(--bg-elevated);
  }

  .mobile-pair-chip-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .mobile-pair-symbol {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
  }

  .mobile-pair-chevron {
    color: var(--text-muted);
    font-size: 12px;
  }

  .mobile-pair-status {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
  }

  .mobile-pair-status.running {
    background: var(--success-bg);
    color: var(--success);
    border-color: rgba(0, 200, 160, 0.25);
  }

  .mobile-balance-strip {
    display: flex !important;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
  }

  .mobile-bal-profit {
    color: var(--profit);
    font-weight: 600;
  }

  /* Sticky Bot-Steuerung unten */
  .mobile-bot-bar {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1800;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(15, 15, 20, 0.94);
    border-top: 1px solid var(--border-default);
    backdrop-filter: blur(10px);
  }

  .mobile-bot-bar .btn {
    flex: 1 1 0;
    min-height: 44px;
    font-size: 13px;
  }

  .content {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    margin: 0;
  }

  .main > .content.card {
    box-shadow: none;
  }

  /* Paar-Auswahl als Bottom-Sheet */
  .sidebar {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(78dvh, 620px);
    z-index: 2100;
    border-radius: 16px 16px 0 0;
    transform: translateY(110%);
    transition: transform 0.25s ease;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  }

  body.sidebar-open .sidebar {
    transform: translateY(0);
  }

  .sidebar-sheet-handle {
    display: block !important;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
    margin: 4px auto 10px;
  }

  .sidebar-head {
    margin-bottom: 2px;
  }

  .pair-item {
    padding: 12px 12px;
    font-size: 14px;
    min-height: 0;
  }

  .pair-spark-block {
    height: 44px;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2050;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 2px;
    padding: 6px 8px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-surface);
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    padding: 11px 12px;
    font-size: 12px;
    white-space: nowrap;
    min-height: 42px;
  }

  .tab::after {
    left: 10px;
    right: 10px;
  }

  .panel {
    padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
  }

  #panel-chart.active {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  .panel-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-head h2 {
    font-size: 15px;
  }

  .overview-stats {
    grid-template-columns: 1fr 1fr;
  }

  .overview-block-profit,
  .overview-block-danger,
  .overview-block-wide {
    grid-column: 1 / -1;
  }

  .preview-row {
    grid-template-columns: 1fr 1fr;
  }

  .billing-summary {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .log-line {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 8px 10px;
  }

  .log-ts,
  .log-level,
  .log-module {
    white-space: normal;
  }

  .log-module {
    color: var(--text-muted);
    font-size: 9px;
  }

  .admin-alerts-log {
    min-height: 120px;
  }

  .pnl-chart {
    min-height: 220px;
    height: min(48vh, 360px);
  }

  .chart-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
  }

  .chart-head-left h2 {
    font-size: 15px;
    margin-right: 8px;
  }

  .ohlc,
  .chart-legend,
  .price-row .clock {
    display: none;
  }

  .price-row {
    margin-top: 4px;
  }

  .live-price {
    font-size: 18px;
  }

  .tf-row {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 6px;
  }

  .tf {
    flex: 1 0 auto;
    min-width: 44px;
    padding: 8px 10px;
  }

  .chart-wrap {
    min-height: 0;
    flex: 1 1 auto;
  }

  .backtest-bar {
    gap: 10px;
  }

  .backtest-bar label {
    flex-wrap: wrap;
    width: 100%;
  }

  .filter-bar,
  .history-actions,
  .billing-actions,
  .bt-actions,
  .section-head {
    flex-wrap: wrap;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  .table-wrap {
    margin-left: -4px;
    margin-right: -4px;
    padding-bottom: 4px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    text-align: center;
  }

  .payment-lock {
    padding: 12px;
    align-items: stretch;
  }

  .payment-lock-card {
    width: 100%;
    max-height: none;
    padding: 20px 16px;
  }

  .profile-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .profile-main {
    padding: 16px 12px 40px;
  }

  .profile-card {
    padding: 18px 16px;
  }

  .login-card {
    padding: 28px 20px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .settings-col {
    padding: 14px;
  }

  .alert-banner {
    padding: 8px 12px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  :root {
    --page-pad-x: 12px;
  }

  .preview-row {
    grid-template-columns: 1fr;
  }

  .overview-stats {
    grid-template-columns: 1fr;
  }

  .mobile-bot-bar .btn.danger {
    flex: 0.75 1 0;
  }
}

@media (max-width: 760px) and (max-height: 500px) {
  .header {
    padding: 4px 10px;
  }

  .mobile-pair-bar {
    padding: 4px 10px 6px;
  }

  .mobile-balance-strip {
    display: none !important;
  }

  .mobile-bot-bar {
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .panel {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Scrollbar (Webkit) ──────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Landing Page ─────────────────────────────────────────────────── */
.landing-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(108, 77, 255, 0.18), transparent),
    var(--bg-base);
  color: var(--text-primary);
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--page-pad-x);
  border-bottom: 1px solid var(--border-subtle);
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-logo {
  font-size: 1.05rem;
  font-weight: 600;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.landing-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.92rem;
}

.landing-nav a:hover {
  color: var(--text-primary);
}

.landing-hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px var(--page-pad-x) 40px;
}

.landing-eyebrow {
  color: var(--accent-bright);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.landing-hero h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.15;
  margin-bottom: 16px;
}

.landing-lead {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 52ch;
}

.landing-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.landing-cta-primary {
  min-width: 220px;
}

.landing-cta-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
}

.landing-cta-hint {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.landing-hero-card {
  padding: 24px;
}

.landing-hero-card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.landing-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.landing-feature-list li {
  color: var(--text-secondary);
  padding-left: 18px;
  position: relative;
}

.landing-feature-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
}

.landing-section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px var(--page-pad-x) 40px;
}

.landing-section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.landing-tile {
  padding: 20px;
}

.landing-tile h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.landing-tile p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
}

.landing-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
  counter-reset: step;
}

.landing-steps li {
  counter-increment: step;
  padding: 18px 18px 18px 56px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  position: relative;
}

.landing-steps li::before {
  content: counter(step);
  position: absolute;
  left: 18px;
  top: 18px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.landing-steps strong {
  display: block;
  margin-bottom: 4px;
}

.landing-steps span {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.landing-risk {
  padding: 20px 24px;
  border-color: var(--warning-bg);
}

.landing-risk p {
  color: var(--text-secondary);
  line-height: 1.55;
}

.landing-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px var(--page-pad-x) 40px;
  color: var(--text-muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--border-subtle);
  max-width: 1120px;
  margin: 0 auto;
}

.landing-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.landing-footer a:hover {
  color: var(--text);
}

.landing-footer-nav {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.landing-section-intro {
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 52rem;
  margin: 0 0 1.5rem;
}

.landing-logo {
  text-decoration: none;
  color: inherit;
}

.legal-page .legal-main {
  max-width: 720px;
  margin: 24px auto 48px;
  padding: 28px 32px;
}

.legal-page .legal-main h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
}

.legal-page .legal-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.75rem;
}

.legal-page .legal-main section {
  margin-bottom: 1.35rem;
}

.legal-page .legal-main h2 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
}

.legal-page .legal-main p {
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 760px) {
  .landing-hero {
    grid-template-columns: 1fr;
  }

  .landing-grid {
    grid-template-columns: 1fr;
  }

  .landing-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .landing-footer-nav {
    flex-wrap: wrap;
  }

  .landing-cta-primary {
    min-width: 0;
    width: 100%;
    text-align: center;
  }

  .legal-page .legal-main {
    margin: 16px var(--page-pad-x) 40px;
    padding: 22px 20px;
  }
}

@media (max-width: 480px) {
  .landing-header {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .landing-hero {
    padding-top: 32px;
    padding-bottom: 28px;
  }

  .landing-hero h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  .landing-lead {
    font-size: 0.98rem;
  }
}


.conn-badge.ok { color: var(--success); }
.conn-badge.warn { color: var(--warning, #f5a623); }
.conn-badge.err { color: var(--danger); }
.conn-badge.muted { color: var(--text-muted); }
