/* MetaTrader 5–inspired terminal: charcoal greys, flat panels; blue/red only for accents. */
:root {
  --bg: #1a1a1c;
  --panel: #242424;
  --panel-raised: #2d2d30;
  --toolbar: #323232;
  --accent: #0ea5e9;
  --accent-hover: #38bdf8;
  --accent-dim: rgba(14, 165, 233, 0.28);
  --text: #c8c8c8;
  --muted: #8a8a8a;
  --border: #3f3f46;
  --border-highlight: #505058;
  --danger: #ff4757;
  --danger-dim: rgba(255, 71, 87, 0.24);
  --ok: #7a9d7a;
  --warn: #b89a5a;
  --radius: 2px;
  --font-ui: Tahoma, "Segoe UI", "Arial Unicode MS", sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;
  /* Shared structure tokens (dark defaults) */
  --chrome-line: #0d0d0e;
  --chrome-inset: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --surface-veil: rgba(255, 255, 255, 0.02);
  --surface-hover: rgba(255, 255, 255, 0.04);
  --surface-hover-strong: rgba(255, 255, 255, 0.06);
  --footer-input-bg: rgba(0, 0, 0, 0.2);
  --ghost-accent-hover: rgba(14, 165, 233, 0.1);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --chip-bg: rgba(255, 255, 255, 0.04);
  --input-surface: rgba(31, 31, 32, 0.88);
  --rule-item-bg: rgba(255, 255, 255, 0.03);
  --rule-divider: rgba(255, 255, 255, 0.08);
  --rule-divider-soft: rgba(255, 255, 255, 0.06);
  --rule-subrow-bg: rgba(0, 0, 0, 0.18);
  --rule-subrow-border: rgba(255, 255, 255, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.theme-light {
  --bg: #e6e9ef;
  --panel: #f4f5f8;
  --panel-raised: #ffffff;
  --toolbar: #dce0e8;
  --text: #101218;
  --muted: #4b5160;
  --border: #b8becd;
  --border-highlight: #8b9bc9;
  --accent: #2f55c7;
  --accent-hover: #4169e1;
  --accent-dim: rgba(47, 85, 199, 0.2);
  --danger: #be123c;
  --danger-dim: rgba(190, 18, 60, 0.14);
  --ok: #166534;
  --warn: #854d0e;
  --chrome-line: #c5cad6;
  --chrome-inset: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  --surface-veil: rgba(0, 0, 0, 0.03);
  --surface-hover: rgba(0, 0, 0, 0.045);
  --surface-hover-strong: rgba(0, 0, 0, 0.07);
  --footer-input-bg: rgba(255, 255, 255, 0.96);
  --ghost-accent-hover: rgba(47, 85, 199, 0.11);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.98);
  --chip-bg: rgba(0, 0, 0, 0.04);
  --input-surface: #ffffff;
  --rule-item-bg: rgba(0, 0, 0, 0.025);
  --rule-divider: rgba(0, 0, 0, 0.08);
  --rule-divider-soft: rgba(0, 0, 0, 0.06);
  --rule-subrow-bg: rgba(0, 0, 0, 0.04);
  --rule-subrow-border: rgba(0, 0, 0, 0.08);
}

/* Light: replace hardcoded cyan UI with royal blue (matches body.theme-light --accent). */
body.theme-light .trading-line-chart-card__switch input:checked + .trading-line-chart-card__switch-track {
  background: rgba(47, 85, 199, 0.2);
  border-color: rgba(47, 85, 199, 0.45);
}

body.theme-light .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track {
  background: rgba(47, 85, 199, 0.38);
  border-color: rgba(47, 85, 199, 0.72);
}

body.theme-light .strategy-card--selected .strategy-card__pick {
  border-color: rgba(47, 85, 199, 0.45);
  background: rgba(47, 85, 199, 0.07);
}

body.theme-light .strategy-card.strategy-card--selected {
  box-shadow: inset 0 0 0 1px rgba(47, 85, 199, 0.25);
}

body.theme-light .positions-closed-toolbar__select:hover {
  border-color: rgba(47, 85, 199, 0.35);
}

body.theme-light .positions-closed-toolbar__select:focus-visible {
  box-shadow: 0 0 0 2px rgba(47, 85, 199, 0.22);
}

body.theme-light .ea-kill-toggle__switch input:checked + .ea-kill-toggle__track {
  background: rgba(47, 85, 199, 0.38);
  border-color: rgba(47, 85, 199, 0.72);
}

body.theme-light .button-row button.primary#btnBuy {
  border-color: rgba(47, 85, 199, 0.55);
}

body.theme-light table.data-grid .action-cell .trade-action--primary {
  border-color: rgba(47, 85, 199, 0.5);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 10px;
  background: var(--toolbar);
  border-bottom: 1px solid rgba(47, 85, 199, 0.5);
  box-shadow: var(--chrome-inset);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header__lead {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.app-header__brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-header__brand-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  padding: 4px;
  border: none;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  max-width: 100%;
}

.app-header__brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.app-header__brand-home:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-header__pnl {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 10px;
  border: none;
  border-radius: 2px;
  background: transparent;
  flex-shrink: 0;
}

.app-header__pnl-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.app-header__pnl-value {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.app-header__pnl-value.metric-positive {
  color: #4ade80;
}

.app-header__pnl-value.metric-negative {
  color: #f87171;
}

.app-header__pnl-open {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.app-header__pnl-open.metric-positive {
  color: #4ade80;
}

.app-header__pnl-open.metric-negative {
  color: #f87171;
}

.app-header__live-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  flex-shrink: 0;
  max-width: min(280px, 38vw);
}

.app-header__live-with-badge {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.app-header__smart-stop-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #78350f;
  background: linear-gradient(180deg, #fde68a, #fbbf24);
  border: 1px solid rgba(180, 83, 9, 0.5);
  border-radius: 4px;
  padding: 2px 8px;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
}

body.theme-light .app-header__smart-stop-badge {
  color: #713f12;
}

.app-header__live {
  flex-shrink: 0;
  align-items: center;
  padding: 4px 0;
}

.strategy-live-toggle .strategy-multi-toggle__switch {
  cursor: pointer;
  margin: 0;
}

.app-header__live-msg {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}

.app-header .version {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Light theme: flat toolbar-grey header with royal blue accents (no gradient). */
body.theme-light .app-header {
  background: var(--toolbar);
  color: var(--text);
  box-shadow: var(--chrome-inset);
}

body.theme-light .app-header .app-header__brand-home {
  color: var(--text);
}

body.theme-light .app-header .app-header__pnl-label {
  color: var(--muted);
}

body.theme-light .app-header .app-header__pnl-value {
  color: var(--text);
}

body.theme-light .app-header .app-header__pnl-open {
  color: var(--muted);
}

body.theme-light .app-header .app-header__pnl-value.metric-positive {
  color: #15803d;
}

body.theme-light .app-header .app-header__pnl-value.metric-negative {
  color: #b91c1c;
}

body.theme-light .app-header .app-header__pnl-open.metric-positive {
  color: #15803d;
}

body.theme-light .app-header .app-header__pnl-open.metric-negative {
  color: #b91c1c;
}

body.theme-light .app-header .header-nav__menu-btn {
  background: var(--panel-raised);
  border-color: var(--border);
  color: var(--text);
}

body.theme-light .app-header .header-nav__menu-btn:hover {
  border-color: rgba(47, 85, 199, 0.45);
  background: var(--ghost-accent-hover);
  color: var(--text);
}

body.theme-light .app-header .tabs-main {
  border-bottom-color: rgba(47, 85, 199, 0.2);
}

body.theme-light .app-header .tabs-settings {
  border-left-color: rgba(47, 85, 199, 0.22);
}

body.theme-light .app-header .tabs .tab {
  color: var(--muted);
}

body.theme-light .app-header .tabs .tab:hover {
  color: var(--accent);
  background: var(--ghost-accent-hover);
}

body.theme-light .app-header .tabs .tab.active {
  color: var(--text);
  border-color: rgba(47, 85, 199, 0.35);
  border-bottom-color: var(--bg);
  background: var(--bg);
  box-shadow: inset 0 2px 0 rgba(47, 85, 199, 0.55);
}

body.theme-light .app-header .strategy-live-toggle .strategy-multi-toggle__track {
  background: rgba(0, 0, 0, 0.06);
  border-color: var(--border);
}

body.theme-light .app-header .strategy-live-toggle .strategy-multi-toggle__track::after {
  background: var(--text);
}

body.theme-light .app-header .strategy-live-toggle .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track {
  background: rgba(47, 85, 199, 0.38);
  border-color: rgba(147, 171, 234, 0.9);
}

body.theme-light .app-header .strategy-live-toggle .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track::after {
  background: var(--accent);
}

body.theme-light .app-header .strategy-live-toggle.is-pending-stop .strategy-multi-toggle__track {
  background: rgba(253, 224, 71, 0.22);
  border-color: rgba(253, 224, 71, 0.55);
}

body.theme-light .app-header .strategy-live-toggle.is-pending-stop .strategy-multi-toggle__track::after {
  background: #fde047;
}

body.theme-light .app-header .strategy-live-toggle.is-pending-stop .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track {
  background: rgba(253, 224, 71, 0.28);
  border-color: rgba(253, 224, 71, 0.6);
}

body.theme-light .app-header .strategy-live-toggle.is-pending-stop .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track::after {
  background: #facc15;
}

.header-nav {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.header-nav__menu-btn {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.header-nav__menu-btn:hover {
  border-color: var(--border-highlight);
  background: var(--surface-hover-strong);
  color: var(--text);
}

.header-nav__menu-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

body.trading-chart-fullscreen .header-nav__menu-btn {
  display: none !important;
}

.header-nav__burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 20px;
  pointer-events: none;
}

.header-nav__burger > span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.header-nav--open .header-nav__burger > span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.header-nav--open .header-nav__burger > span:nth-child(2) {
  opacity: 0;
}

.header-nav--open .header-nav__burger > span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.header-nav__burger > span {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.header-nav__panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0;
  flex: 1;
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  align-items: flex-end;
}

.tabs-main {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tabs-settings {
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.tabs .tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 12px;
  margin-right: 2px;
  border-radius: 0;
  cursor: pointer;
  font-size: 12px;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.tabs .tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tabs .tab.active {
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-color: var(--bg);
  background: var(--bg);
  margin-bottom: -1px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tabs .tab.tab-settings {
  font-weight: 500;
}

/* Compact tabs when the header is tight but still horizontal */
@media (max-width: 1100px) and (min-width: 961px) {
  .tabs .tab {
    padding: 7px 10px;
    font-size: 0.82rem;
  }

  .tabs-settings {
    margin-left: 12px;
    padding-left: 12px;
  }
}

/* Narrow screens: hamburger + dropdown panel */
@media (max-width: 960px) {
  .app-header {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .app-header__lead {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-nav {
    flex: 0 0 auto;
    align-self: center;
  }

  .header-nav__menu-btn {
    display: inline-flex;
  }

  .header-nav__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(calc(100vw - 24px), 300px);
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    padding: 10px;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    z-index: 150;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition:
      opacity 0.18s ease,
      transform 0.18s ease,
      visibility 0.18s;
  }

  body.theme-light .header-nav__panel {
    background: var(--toolbar);
    border: 1px solid rgba(47, 85, 199, 0.22);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.12);
  }

  .header-nav--open .header-nav__panel {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .header-nav__panel .tabs {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    width: 100%;
  }

  .header-nav__panel .tabs .tab {
    width: 100%;
    text-align: left;
  }

  .header-nav__panel .tabs-settings {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 2px;
    width: 100%;
  }
}

.tab-panel {
  display: none;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.tab-panel.active {
  display: block;
}

.trading-line-chart-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 10px;
}

.chart-card__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.chart-card__toggle:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.theme-light .chart-card__toggle:hover {
  background: rgba(0, 0, 0, 0.04);
}

.chart-card__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chart-card__chevron {
  display: inline-block;
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.trading-line-chart-card--expanded .chart-card__chevron,
.spread-chart-card--expanded .chart-card__chevron,
.pnl-chart-card--expanded .chart-card__chevron {
  transform: rotate(90deg);
}

.trading-line-chart-card__head h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.trading-line-chart-card__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  flex-shrink: 0;
}

.trading-line-chart-card:not(.trading-line-chart-card--expanded) .trading-line-chart-card__toolbar {
  display: none;
}

.trading-line-chart-card__fullscreen-btn {
  box-sizing: border-box;
  padding: 8px 12px;
  min-height: 36px;
  margin-left: auto;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.trading-line-chart-card__fullscreen-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(14, 165, 233, 0.35);
}

.trading-line-chart-card__fullscreen-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-light .trading-line-chart-card__fullscreen-btn {
  background: #fff;
}

body.theme-light .trading-line-chart-card__fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(47, 85, 199, 0.38);
}

.trading-line-chart-card--fullscreen {
  position: fixed;
  z-index: 8500;
  left: 10px;
  right: 10px;
  top: 10px;
  bottom: 10px;
  margin: 0;
  max-width: none;
  width: auto;
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

body.trading-chart-fullscreen {
  overflow: hidden;
}

.trading-line-chart-card--fullscreen .trading-line-chart-card__head {
  flex-shrink: 0;
}

.trading-line-chart-card--fullscreen .summary-hint {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.trading-line-chart-card--fullscreen .trading-chart-meta-row,
.trading-line-chart-card--fullscreen .trading-chart-meta,
.trading-line-chart-card--fullscreen .trading-chart-meta-detail {
  flex-shrink: 0;
}

.trading-line-chart-card--fullscreen .trading-line-chart-wrap {
  flex: 1;
  min-height: 0;
  height: auto;
  min-height: 320px;
}

.trading-chart-meta-detail {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  min-height: 1.2em;
}

.trading-line-chart-card__view-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
}

.trading-line-chart-card__view-select {
  min-width: 11.5rem;
  max-width: min(100%, 22rem);
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(31, 31, 32, 0.8);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.35;
  min-height: 38px;
  cursor: pointer;
}

.trading-line-chart-card__view-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.theme-light .trading-line-chart-card__view-select {
  background: #fff;
}

.trading-line-chart-card__trade-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

body.theme-light .trading-line-chart-card__trade-toggle-wrap {
  background: rgba(0, 0, 0, 0.03);
}

.trading-line-chart-card__trade-toggle-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}

.trading-line-chart-card__switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.trading-line-chart-card__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.trading-line-chart-card__switch-track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 2px;
  border: 1px solid var(--border);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.trading-line-chart-card__switch-track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.trading-line-chart-card__switch input:checked + .trading-line-chart-card__switch-track {
  background: rgba(14, 165, 233, 0.2);
  border-color: rgba(14, 165, 233, 0.45);
}

.trading-line-chart-card__switch input:checked + .trading-line-chart-card__switch-track::after {
  transform: translate(20px, -50%);
  background: var(--accent);
}

.trading-line-chart-card__switch input:focus-visible + .trading-line-chart-card__switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.trading-chart-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  margin: 0 0 8px;
}

.trading-chart-live-quote {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--text);
  min-height: 1.2em;
}

body.theme-light .trading-chart-live-quote {
  color: var(--text);
}

.trading-chart-meta {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
  min-height: 1.2em;
}

.trading-line-chart-wrap {
  width: 100%;
  height: 260px;
  border: 1px solid #0d0d0e;
  border-radius: var(--radius);
  background: #121214;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body.theme-light .trading-line-chart-wrap {
  background: #fdfdfd;
  border-color: var(--border);
}

#tradingLineChart {
  display: block;
  width: 100%;
  height: 100%;
}

.spread-chart-card__head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.spread-chart-card__head h2 {
  margin: 0;
  margin-right: auto;
}

.spread-chart-card__mode-btn {
  box-sizing: border-box;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.spread-chart-card__mode-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(14, 165, 233, 0.35);
}

.spread-chart-card__mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-light .spread-chart-card__mode-btn {
  background: #fff;
}

body.theme-light .spread-chart-card__mode-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(47, 85, 199, 0.38);
}

.spread-chart-card:not(.spread-chart-card--expanded) .spread-chart-card__mode-btn {
  display: none;
}

.spread-chart-card__stats {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.spread-chart-card__sep {
  margin: 0 8px;
  color: var(--muted);
}

.spread-chart-wrap {
  width: 100%;
  height: 220px;
  border: 1px solid #0d0d0e;
  border-radius: var(--radius);
  background: #121214;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body.theme-light .spread-chart-wrap {
  background: #fdfdfd;
  border-color: var(--border);
}

#spreadChartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pnl-chart-card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.pnl-chart-card__head h2 {
  margin: 0;
  margin-right: auto;
}

.pnl-chart-card__mode-btn {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.pnl-chart-card__mode-btn:hover {
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.06);
}

.pnl-chart-card__mode-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.theme-light .pnl-chart-card__mode-btn {
  background: var(--panel-raised);
}

body.theme-light .pnl-chart-card__mode-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(47, 85, 199, 0.35);
}

.pnl-chart-card:not(.pnl-chart-card--expanded) .pnl-chart-card__mode-btn,
.pnl-chart-card:not(.pnl-chart-card--expanded) .pnl-chart-card__range-select {
  display: none;
}

.pnl-chart-card__range-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.pnl-chart-card__range-select {
  min-width: 9rem;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(31, 31, 32, 0.8);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.35;
  min-height: 36px;
}

.pnl-chart-card__range-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.theme-light .pnl-chart-card__range-select {
  background: #fff;
}

.pnl-chart-wrap {
  width: 100%;
  height: 240px;
  border: 1px solid #0d0d0e;
  border-radius: var(--radius);
  background: #121214;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.pnl-chart-card__total {
  margin: 0 0 8px 0;
  font-weight: 600;
}

.pnl-chart-card__total.metric-positive {
  color: #4ade80;
}

.pnl-chart-card__total.metric-negative {
  color: #f87171;
}

body.theme-light .pnl-chart-wrap {
  background: #fdfdfd;
  border-color: var(--border);
}

#pnlChartCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.strategies-live-lock-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(242, 196, 80, 0.12);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
}

body.theme-light .strategies-live-lock-banner {
  background: rgba(180, 120, 0, 0.12);
}

.strategies-attributed-pnl-total {
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}

.strategy-multi-row {
  margin: 14px 0 18px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.strategy-bulk-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.strategy-bulk-select__btn {
  min-width: 102px;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.1;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.strategy-bulk-select__btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--text);
}

.strategy-bulk-select__btn:active {
  transform: translateY(1px);
}

.strategy-bulk-select__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-light .strategy-bulk-select__btn {
  background: rgba(0, 0, 0, 0.04);
}

body.theme-light .strategy-bulk-select__btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.strategy-backtest-dialog {
  max-width: min(96vw, 920px);
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--panel, #1a1a1b);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

body.theme-light .strategy-backtest-dialog {
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.strategy-backtest-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.strategy-backtest-dialog__inner {
  padding: 16px 18px 20px;
  max-height: min(88vh, 900px);
  overflow: auto;
}

.strategy-backtest-dialog__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.strategy-backtest-dialog__head .strategy-backtest-report__title {
  margin: 0;
}

.strategy-multi-toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.strategy-multi-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.strategy-multi-toggle__caption {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.strategy-multi-hint {
  margin: 10px 0 0;
  max-width: 42rem;
}

.conn-market-closed {
  color: #ff4757;
  font-weight: 600;
}

body.theme-light .conn-market-closed {
  color: #e11d48;
}

.algo-trading-card {
  position: relative;
}

.algo-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.algo-card-head__title {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  flex: 1;
  min-width: min(100%, 12rem);
}

.algo-trading-intro {
  margin-top: 4px;
}

/* Algo trading: one card per rule (toggle + optional sub-row + description) */
.algo-rule-mode-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0 6px;
  max-width: 52rem;
}

.algo-rule-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--rule-item-bg);
  padding: 12px 14px 14px;
  box-sizing: border-box;
}

.algo-rule-item .strategy-multi-toggle {
  gap: 14px;
}

.algo-rule-item .strategy-multi-toggle__caption {
  font-size: 0.92rem;
}

.algo-rule-item .algo-rule-mode-hint {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--rule-divider);
  max-width: none;
  font-size: 0.8rem;
  line-height: 1.52;
  color: var(--muted);
}

.algo-rule-item__status {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule-divider-soft);
}

.algo-rule-item__subrow {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--rule-subrow-bg);
  border: 1px solid var(--rule-subrow-border);
  box-sizing: border-box;
}

.algo-rule-item__subrow-label {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.algo-rule-item__subrow-input {
  width: 5rem;
  min-width: 4rem;
  max-width: 9rem;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}

.algo-rule-item__subrow-input--wide {
  width: 7rem;
  max-width: 11rem;
}

.algo-rule-item__subrow .strategy-win-rate-editor__input,
.algo-rule-item__subrow input[type="number"] {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--input-surface);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.3;
}

.algo-rule-item__subrow .strategy-win-rate-editor__input:focus-visible,
.algo-rule-item__subrow input[type="number"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.algo-settings-fields--locked {
  opacity: 0.52;
  pointer-events: none;
  user-select: none;
}

.algo-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 40rem;
  margin-top: 4px;
}

.algo-settings-fields .form-row {
  display: grid;
  grid-template-columns: minmax(10.5rem, 12rem) minmax(10rem, 18rem);
  gap: 6px 18px;
  align-items: center;
  margin-bottom: 0;
}

.algo-settings-fields .form-row > label:first-child {
  min-width: 0;
  margin: 0;
  justify-self: end;
  text-align: right;
  padding-right: 2px;
}

.algo-settings-fields .form-row input[type="number"] {
  width: 100%;
  min-width: 0;
  max-width: 18rem;
  flex: none;
  box-sizing: border-box;
  font-variant-numeric: tabular-nums;
}

.algo-settings-fields .form-row .algo-field-hint {
  grid-column: 1 / -1;
  margin: 0;
  max-width: 36rem;
}

.algo-settings-fields .form-row.form-row--checkbox {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.algo-settings-fields .form-row.form-row--checkbox .ai-checkbox-label {
  margin: 0;
}

.algo-settings-fields .form-row.algo-master-toggles-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 1.5rem;
  align-items: start;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

@media (max-width: 640px) {
  .algo-settings-fields .form-row.algo-master-toggles-row {
    grid-template-columns: 1fr;
  }
}

.algo-settings-fields .algo-master-toggle .strategy-multi-toggle {
  margin-bottom: 0;
}

.algo-settings-fields .algo-master-toggle .algo-field-hint {
  margin-top: 6px;
}

.strategy-multi-toggle__switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.strategy-multi-toggle__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.strategy-multi-toggle__track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 3px;
  transition: background 0.2s ease;
  border: 1px solid var(--border);
}

.strategy-multi-toggle__track::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track {
  background: rgba(14, 165, 233, 0.38);
  border-color: rgba(14, 165, 233, 0.72);
}

.strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track::after {
  transform: translate(22px, -50%);
  background: var(--accent);
}

.strategy-multi-toggle__switch input:focus-visible + .strategy-multi-toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.strategy-live-toggle.is-pending-stop .strategy-multi-toggle__track {
  background: rgba(184, 154, 90, 0.35);
  border-color: rgba(184, 154, 90, 0.9);
}

.strategy-live-toggle.is-pending-stop .strategy-multi-toggle__track::after {
  background: var(--warn);
}

/* Live stays checked while opens drain; input:checked rules must not override amber. */
.strategy-live-toggle.is-pending-stop .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track {
  background: rgba(214, 165, 50, 0.38);
  border-color: rgba(214, 165, 50, 0.92);
}

.strategy-live-toggle.is-pending-stop .strategy-multi-toggle__switch input:checked + .strategy-multi-toggle__track::after {
  transform: translate(22px, -50%);
  background: var(--warn);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.strategy-list-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}

.strategy-grid--active {
  margin-top: 8px;
}

.strategy-section-block {
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.strategy-section-block--reliable,
.strategy-section-block--unreliable {
  background: rgba(0, 0, 0, 0.08);
}

body.theme-light .strategy-section-block--reliable,
body.theme-light .strategy-section-block--unreliable {
  background: rgba(0, 0, 0, 0.02);
}

.strategy-section-block--soon {
  background: rgba(0, 0, 0, 0.12);
}

body.theme-light .strategy-section-block--soon {
  background: rgba(0, 0, 0, 0.03);
}

.strategy-section-block__summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  list-style: none;
  user-select: none;
}

.strategy-section-block__lead {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  flex: 1;
  min-width: 0;
}

.strategy-section-block__pnl {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.strategy-section-block__pnl.metric-positive {
  color: var(--positive, #6ecf8b);
}

.strategy-section-block__pnl.metric-negative {
  color: var(--negative, #f07178);
}

.strategy-section-block__pnl.metric-neutral {
  color: var(--muted);
}

.strategy-section-block__summary:focus {
  outline: none;
}

.strategy-section-block__summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.strategy-section-block__summary::-webkit-details-marker {
  display: none;
}

.strategy-section-block__summary::after {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.strategy-section-block[open] .strategy-section-block__summary::after {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.strategy-section-block__title {
  flex-shrink: 0;
}

.strategy-section-block__count {
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
}

.strategy-grid.strategy-grid--section {
  margin-top: 0;
  padding: 8px 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.theme-light .strategy-grid.strategy-grid--section {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.strategy-card--grid-span-full {
  grid-column: 1 / -1;
}

.strategy-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 10px 10px 10px 12px;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.strategy-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.strategy-card__body--no-input {
  gap: 8px;
}

.strategy-card__top {
  flex-shrink: 0;
}

.strategy-card__metrics {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px 8px;
  align-items: baseline;
}

.strategy-card__metrics--na .strategy-card__metric {
  color: var(--muted);
}

.strategy-card__metric {
  min-width: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted);
}

.strategy-card__metric-label {
  display: inline-block;
  margin-right: 4px;
  font-weight: 600;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.strategy-card__metric strong {
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}

.strategy-card__footer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  align-items: stretch;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

body.theme-light .strategy-card__footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.strategy-card__footer--inactive,
.strategy-card__footer--soon {
  grid-template-columns: 1fr;
}

.strategy-card__na-chip--full {
  width: 100%;
  justify-content: center;
}

.strategy-card__pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 4px 6px;
  min-height: 28px;
  box-sizing: border-box;
  font: inherit;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.strategy-card__pick:hover {
  color: var(--text);
  border-color: var(--border-highlight);
}

.strategy-card__pick:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.strategy-card__pick input {
  margin: 0;
  flex-shrink: 0;
  width: 0.95rem;
  height: 0.95rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.strategy-card__pick-label {
  pointer-events: none;
  user-select: none;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.strategy-card--selected .strategy-card__pick {
  border-color: rgba(14, 165, 233, 0.45);
  background: rgba(14, 165, 233, 0.07);
}

body.theme-light .strategy-card__pick {
  background: rgba(0, 0, 0, 0.04);
}

.strategy-card__footer .strategy-card__settings,
.strategy-card__footer .strategy-card__logs {
  width: 100%;
  min-height: 28px;
  box-sizing: border-box;
}

.strategy-card__settings,
.strategy-card__logs {
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.strategy-card__settings:hover,
.strategy-card__logs:hover {
  color: var(--text);
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.06);
}

.strategy-card__settings:focus-visible,
.strategy-card__logs:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-light .strategy-card__settings,
body.theme-light .strategy-card__logs {
  background: rgba(0, 0, 0, 0.04);
}

.strategy-card__logs {
  font-weight: 500;
}

.algo-trading-log-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.02);
}

body.theme-light .algo-trading-log-row {
  background: rgba(0, 0, 0, 0.02);
}

.algo-trading-log-row .button-row button,
.algo-trading-log-row button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.algo-trading-log-hint {
  flex-basis: 100%;
  min-width: 0;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
}

.algo-trading-log-block {
  margin: 8px 0 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.algo-trading-log-block__summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  user-select: none;
  list-style: none;
}

.algo-trading-log-block__summary::-webkit-details-marker {
  display: none;
}

.algo-trading-log-block__summary::after {
  content: "▶";
  float: right;
  color: var(--muted);
  font-size: 0.72rem;
  transform: rotate(0deg);
  transition: transform 0.2s ease;
}

.algo-trading-log-block[open] .algo-trading-log-block__summary::after {
  transform: rotate(90deg);
}

.app-log-viewer {
  width: min(920px, calc(100vw - 24px));
  max-height: min(88vh, 720px);
}

.app-log-viewer__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.app-log-viewer__filter {
  margin: 0;
}

.app-log-viewer__pre {
  margin: 0;
  padding: 12px;
  max-height: min(58vh, 520px);
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(0, 0, 0, 0.28);
}

body.theme-light .app-log-viewer__pre {
  scrollbar-color: rgba(0, 0, 0, 0.35) rgba(0, 0, 0, 0.06);
}

.app-log-viewer__pre::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.app-log-viewer__pre::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.app-log-viewer__pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.app-log-viewer__pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid transparent;
  background-clip: padding-box;
}

body.theme-light .app-log-viewer__pre::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-light .app-log-viewer__pre::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
}

body.theme-light .app-log-viewer__pre::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
}

body.theme-light .app-log-viewer__pre {
  background: rgba(0, 0, 0, 0.04);
}

.strategy-settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

/* Author `display: flex` below would otherwise beat the HTML `hidden` attribute. */
.strategy-settings-backdrop[hidden],
.strategy-settings-panel[hidden] {
  display: none !important;
  pointer-events: none;
}

.strategy-settings-panel {
  position: fixed;
  z-index: 9001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 24px));
  max-height: min(82vh, 780px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #0d0d0e;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.strategy-settings-panel--wide {
  width: min(880px, calc(100vw - 20px));
  max-height: min(88vh, 900px);
}

body.theme-light .strategy-settings-panel {
  background: rgba(255, 255, 255, 0.98);
}

.strategy-settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.strategy-settings-panel__header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  line-height: 1.3;
  padding-right: 8px;
}

.strategy-settings-live-readonly-hint {
  margin: 0;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255, 170, 0, 0.08);
}

body.theme-light .strategy-settings-live-readonly-hint {
  background: rgba(200, 120, 0, 0.06);
}

.strategy-settings-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 2px;
  cursor: pointer;
}

.strategy-settings-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.strategy-settings-close--save {
  width: auto;
  min-width: 6.25rem;
  max-width: 42%;
  height: auto;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  text-align: center;
  color: var(--text);
  background: var(--panel-raised);
  border: 1px solid var(--border-highlight);
}

.strategy-settings-force-order {
  flex-shrink: 0;
  min-width: 8.25rem;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: pointer;
}

.strategy-settings-force-order:hover {
  background: rgba(255, 255, 255, 0.14);
}

.strategy-settings-force-order:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.strategy-settings-close--save:hover {
  color: var(--text);
  background: var(--accent-dim);
  border-color: var(--accent);
}

body.theme-light .strategy-settings-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

body.theme-light .strategy-settings-close--save:hover {
  color: var(--text);
  background: var(--accent-dim);
  border-color: var(--accent);
}

.strategy-settings-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px 18px;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(0, 0, 0, 0.28);
}

body.theme-light .strategy-settings-panel__body {
  scrollbar-color: rgba(0, 0, 0, 0.35) rgba(0, 0, 0, 0.06);
}

.strategy-settings-panel__body::-webkit-scrollbar {
  width: 9px;
}

.strategy-settings-panel__body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.strategy-settings-panel__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.strategy-settings-panel__body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid transparent;
  background-clip: padding-box;
}

body.theme-light .strategy-settings-panel__body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-light .strategy-settings-panel__body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
}

body.theme-light .strategy-settings-panel__body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
}

.strategy-settings-panel__body p {
  margin: 0 0 12px;
}

.strategy-settings-panel__body p:last-child {
  margin-bottom: 0;
}

.strategy-settings-panel__body > .strategy-settings-save-status {
  margin-top: 16px;
  margin-bottom: 0;
}

.strategy-settings-panel__body .strategy-settings-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Strategy settings: scan rows (label left, inputs/selects aligned right; matches Settings tab fields). */
.strategy-settings-panel__body .strategy-win-rate-editor__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(10rem, 38%);
  align-items: center;
  column-gap: 14px;
  row-gap: 2px;
  margin-top: 6px;
}

.strategy-settings-panel__body .strategy-win-rate-editor__row > label {
  margin: 0;
  padding: 2px 0;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.35;
}

.strategy-settings-panel__body .strategy-win-rate-editor__row > input[type="text"],
.strategy-settings-panel__body .strategy-win-rate-editor__row > input[type="number"],
.strategy-settings-panel__body .strategy-win-rate-editor__row > select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(31, 31, 32, 0.8);
  color: var(--text);
  font: inherit;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.strategy-settings-panel__body .strategy-win-rate-editor__row > select {
  min-height: 38px;
  cursor: pointer;
}

.strategy-settings-panel__body .strategy-win-rate-editor__row > input:focus-visible,
.strategy-settings-panel__body .strategy-win-rate-editor__row > select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.theme-light .strategy-settings-panel__body .strategy-win-rate-editor__row > input[type="text"],
body.theme-light .strategy-settings-panel__body .strategy-win-rate-editor__row > input[type="number"],
body.theme-light .strategy-settings-panel__body .strategy-win-rate-editor__row > select {
  background: #fff;
}

@media (max-width: 460px) {
  .strategy-settings-panel__body .strategy-win-rate-editor__row {
    grid-template-columns: 1fr;
    row-gap: 6px;
    align-items: stretch;
  }

  .strategy-settings-panel__body .strategy-win-rate-editor__row > label {
    padding-bottom: 0;
  }
}

.strategy-settings-lead {
  margin: 0 0 14px !important;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.strategy-settings-panel__body > .strategy-settings-lead:first-child {
  padding: 12px 14px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

body.theme-light .strategy-settings-panel__body > .strategy-settings-lead:first-child {
  background: rgba(0, 0, 0, 0.03);
}

.strategy-settings-section--win-rate {
  margin-top: 18px;
}

.strategy-settings-overview {
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  max-height: min(42vh, 320px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(0, 0, 0, 0.28);
}

body.theme-light .strategy-settings-overview {
  scrollbar-color: rgba(0, 0, 0, 0.35) rgba(0, 0, 0, 0.06);
}

.strategy-settings-overview::-webkit-scrollbar {
  width: 9px;
}

.strategy-settings-overview::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.strategy-settings-overview::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.strategy-settings-overview::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid transparent;
  background-clip: padding-box;
}

body.theme-light .strategy-settings-overview::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

body.theme-light .strategy-settings-overview::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
}

body.theme-light .strategy-settings-overview::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32);
}

.strategy-settings-panel__body > .strategy-settings-section.strategy-settings-overview {
  margin-top: 14px;
}

.strategy-settings-panel__body > .strategy-settings-section.strategy-settings-overview:first-child {
  margin-top: 0;
}

body.theme-light .strategy-settings-overview {
  background: rgba(0, 0, 0, 0.03);
}

.strategy-settings-overview .strategy-settings-section__title {
  font-size: 0.78rem;
}

.strategy-settings-overview__body {
  font-size: 0.92rem !important;
  line-height: 1.55 !important;
  margin-bottom: 0 !important;
}

.strategy-settings-pref-row {
  display: block;
  margin: 10px 0 6px;
  line-height: 1.45;
}

.strategy-settings-panel__body > .strategy-settings-section:not(.strategy-settings-overview) {
  margin-top: 14px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
}

.strategy-settings-panel__body > .strategy-settings-section:not(.strategy-settings-overview):first-child {
  margin-top: 0;
}

.strategy-settings-section--intro .strategy-settings-lead {
  margin: 0 0 10px !important;
}

.strategy-settings-section--intro .strategy-settings-lead:last-child {
  margin-bottom: 0 !important;
}

body.theme-light .strategy-settings-panel__body > .strategy-settings-section:not(.strategy-settings-overview) {
  background: rgba(0, 0, 0, 0.02);
}

.strategy-settings-section {
  margin-top: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
}

.strategy-settings-section__title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.strategy-settings-section .summary-hint.subtle {
  margin: 0 0 10px;
  font-size: 0.8rem;
}

.strategy-win-rate-editor .strategy-playbook__title {
  margin-top: 4px;
}

.strategy-playbook {
  max-width: 42rem;
}

.strategy-playbook__title {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.strategy-playbook__list {
  margin: 0.25rem 0 0.5rem 1.15rem;
  padding: 0;
  list-style: disc;
}

.strategy-playbook__list li {
  margin: 0.4rem 0;
}

.strategy-playbook__note {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.strategy-win-rate-editor {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.strategy-win-rate-readonly {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  border: 1px solid var(--border);
}

body.theme-light .strategy-win-rate-readonly {
  background: rgba(0, 0, 0, 0.04);
}

.strategy-win-rate-editor__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 8px;
}

.strategy-win-rate-editor__row label {
  font-size: 0.9rem;
  color: var(--text);
}

.strategy-win-rate-editor__row input[type="number"] {
  width: 6.5rem;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.strategy-win-rate-editor__row .primary {
  flex-shrink: 0;
}

.major-market-dashboard {
  margin-bottom: 8px;
}

.major-market-dashboard__cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 520px) {
  .major-market-dashboard__cards {
    grid-template-columns: 1fr;
  }
}

.major-market-dash-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.03);
}

body.theme-light .major-market-dash-card {
  background: rgba(0, 0, 0, 0.03);
}

.major-market-dash-card__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.major-market-dash-card__value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.major-market-dashboard__meta {
  margin-bottom: 14px !important;
}

.major-market-dashboard__sources-title {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.major-market-dashboard__table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
  margin-bottom: 10px;
}

.major-market-dashboard__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.major-market-dashboard__table th,
.major-market-dashboard__table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.major-market-dashboard__table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.major-market-dashboard__table tr:last-child td {
  border-bottom: none;
}

.major-market-dashboard__table td:nth-child(4) {
  font-variant-numeric: tabular-nums;
}

.major-market-auth-block {
  margin-top: 1.25rem;
  padding: 1rem 1rem 0.75rem;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

body.theme-light .major-market-auth-block {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.03);
}

.major-market-auth-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin: 0.75rem 0 0.25rem;
}

.major-market-auth-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.major-market-auth-label input {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
}

.strategy-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.strategy-card.strategy-card--selected {
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.25);
}

.strategy-card.strategy-card--placeholder {
  opacity: 0.78;
}

.strategy-card.strategy-card--coming-soon {
  opacity: 0.88;
  cursor: default;
  pointer-events: none;
  border-style: dashed;
  border-color: rgba(160, 160, 160, 0.45);
}

.strategy-card__body.strategy-card__body--coming-soon {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 0;
  cursor: default;
}

.strategy-card__soon-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bg);
  background: rgba(160, 160, 170, 0.85);
  border-radius: 2px;
  vertical-align: middle;
}

body.theme-light .strategy-card__soon-badge {
  color: #fff;
  background: rgba(90, 90, 100, 0.85);
}

.strategy-card__title {
  display: block;
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.3;
  color: var(--text);
}

.strategy-card__wr {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--muted);
}

.strategy-card__wr--compact {
  font-size: 0.68rem;
  line-height: 1.2;
}

.strategy-card__wr strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.strategy-card__wr-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 500;
}

.strategy-card__wr-sub strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.strategy-card__wr strong.metric-positive,
.strategy-card__wr-sub strong.metric-positive {
  color: #22c55e;
}

.strategy-card__wr strong.metric-negative,
.strategy-card__wr-sub strong.metric-negative {
  color: #ef4444;
}

.strategy-card__metric strong.metric-positive {
  color: #22c55e;
}

.strategy-card__metric strong.metric-negative {
  color: #ef4444;
}

.strategy-card__status {
  margin: 0;
  min-width: 0;
}

.strategy-card__status-summary {
  margin: 0;
  font-size: 0.66rem;
  line-height: 1.35;
  color: var(--muted);
}

.strategy-card__status-parts {
  margin: 4px 0 0;
  padding-left: 1.1em;
  font-size: 0.65rem;
  line-height: 1.35;
  color: var(--muted);
  list-style-type: disc;
}

.strategy-card__status-parts li {
  margin: 2px 0 0;
}

.strategy-card__desc {
  margin: 4px 0 0;
  min-height: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.strategy-card__desc--soon {
  font-size: 0.7rem;
  line-height: 1.35;
  margin-top: 2px;
}

.strategy-card--inactive-profile {
  border-style: dashed;
  opacity: 0.92;
}

.strategy-card__wr--na {
  color: var(--muted);
}

.strategy-card__na-k {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
}

.strategy-card__na-v {
  font-weight: 500;
}

.strategy-card__desc--inactive {
  font-style: italic;
}

.strategy-card__actions--na {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  pointer-events: none;
  user-select: none;
}

.strategy-card__na-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--chip-bg);
  border: 1px dashed var(--border);
  border-radius: 2px;
  opacity: 0.75;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--card-inset);
}

.card h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.status-card p, .manual-order p {
  margin: 6px 0;
  font-size: 0.9rem;
}

.status-card,
.manual-order {
  padding: 0;
  overflow: hidden;
}

.status-card__toggle,
.manual-order__toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  box-sizing: border-box;
  border: none;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  line-height: 1.45;
}

.status-card__toggle:hover,
.manual-order__toggle:hover {
  background: var(--surface-hover);
}

.status-card__toggle:focus-visible,
.manual-order__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.status-card__chevron,
.manual-order__chevron {
  flex-shrink: 0;
  display: inline-block;
  width: 1rem;
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.status-card--expanded .status-card__chevron,
.manual-order--expanded .manual-order__chevron {
  transform: rotate(90deg);
}

.status-card__summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 20px;
}

.status-card__conn-line {
  flex: 0 1 auto;
  min-width: 5.5rem;
  font-size: 0.9rem;
}

.status-card__balance-line {
  flex: 1 1 220px;
  min-width: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.status-card__balance-line strong {
  font-weight: 600;
  color: var(--muted);
  margin-right: 6px;
}

.manual-order__summary {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.manual-order__headline {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.manual-order__meta {
  font-weight: 500;
  color: var(--muted);
}

.status-card__panel,
.manual-order__panel {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.status-card__panel h2,
.manual-order__panel h2 {
  margin-top: 12px;
}

.connected { color: var(--ok); font-weight: 600; }
.stale { color: #e6c35c; font-weight: 600; }
.disconnected { color: var(--danger); font-weight: 600; }

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

.form-row label {
  min-width: 120px;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-row input[type="text"],
.form-row input[type="number"] {
  flex: 1;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--input-surface);
  color: var(--text);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.button-row--ea-toggle {
  align-items: center;
}

/* Past closed trades: strategy filter row */
.button-row.positions-closed-toolbar {
  align-items: stretch;
  justify-content: space-between;
  margin-top: 10px;
  margin-bottom: 12px;
  padding: 12px 14px;
  gap: 12px 16px;
  background: rgba(35, 35, 35, 0.55);
  border: 1px solid var(--border);
  border-radius: 2px;
}

body.theme-light .button-row.positions-closed-toolbar {
  background: rgba(255, 255, 255, 0.65);
}

.positions-closed-toolbar__view {
  align-self: center;
  flex-shrink: 0;
}

.positions-closed-toolbar__filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  flex: 1 1 260px;
  justify-content: flex-end;
  min-width: 0;
}

.positions-closed-toolbar__label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.2;
}

.positions-closed-toolbar__select {
  flex: 1 1 200px;
  min-width: min(100%, 200px);
  max-width: 320px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(31, 31, 32, 0.9);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.positions-closed-toolbar__select:hover {
  border-color: rgba(14, 165, 233, 0.35);
}

.positions-closed-toolbar__select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.22);
}

body.theme-light .positions-closed-toolbar__select {
  background: #fff;
}

/* Past closed trades: PnL column by sign */
#positionsClosedTradesTable tbody td.metric-positive {
  color: #22c55e;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#positionsClosedTradesTable tbody td.metric-negative {
  color: #ef4444;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#positionsClosedTradesTable tbody td.metric-neutral {
  font-variant-numeric: tabular-nums;
}

/* Open positions: Float PnL column by sign */
#openTradesTable tbody td.metric-positive,
#tradingOpenTradesTable tbody td.metric-positive {
  color: #22c55e;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#openTradesTable tbody td.metric-negative,
#tradingOpenTradesTable tbody td.metric-negative {
  color: #ef4444;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#openTradesTable tbody td.metric-neutral,
#tradingOpenTradesTable tbody td.metric-neutral {
  font-variant-numeric: tabular-nums;
}

/* Sticky footer */
body {
  padding-bottom: 44px;
}

.sticky-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 4px 12px;
  background: var(--toolbar);
  border-top: 1px solid var(--chrome-line);
  box-shadow: var(--chrome-inset);
  z-index: 1001;
}

.sticky-footer__spacer {
  flex: 1 1 auto;
  min-width: 8px;
  height: 1px;
  pointer-events: none;
}

.sticky-footer__theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 34px;
  height: 28px;
  margin-left: 0;
  margin-right: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.sticky-footer__theme:hover {
  border-color: var(--border-highlight);
  background: var(--surface-hover);
  color: var(--text);
}

.sticky-footer__theme:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.sticky-footer__theme-svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sticky-footer__theme-svg[hidden] {
  display: none !important;
}

.sticky-footer__theme-svg path,
.sticky-footer__theme-svg circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sticky-footer__btn {
  min-height: 24px;
  padding: 2px 6px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
  cursor: pointer;
}

.sticky-footer__btn:hover {
  color: var(--text);
  background: var(--ghost-accent-hover);
}

.sticky-footer__btn:active {
  opacity: 1;
}

.sticky-footer__btn:focus-visible {
  outline: none;
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

@media (max-width: 520px) {
  .button-row.positions-closed-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .positions-closed-toolbar__filter {
    justify-content: stretch;
    flex-direction: column;
    align-items: stretch;
  }

  .positions-closed-toolbar__select {
    max-width: none;
  }
}

.ea-kill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ea-kill-toggle__label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.ea-kill-toggle__state {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 4.5rem;
}

.ea-kill-toggle__switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.ea-kill-toggle__switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.ea-kill-toggle__track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 3px;
  transition: background 0.2s ease;
  border: 1px solid var(--border);
}

.ea-kill-toggle__track::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.ea-kill-toggle__switch input:checked + .ea-kill-toggle__track {
  background: rgba(14, 165, 233, 0.38);
  border-color: rgba(14, 165, 233, 0.72);
}

.ea-kill-toggle__switch input:checked + .ea-kill-toggle__track::after {
  transform: translate(22px, -50%);
  background: var(--accent);
}

.ea-kill-toggle__switch input:focus-visible + .ea-kill-toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

button.btn,
.button-row button,
button.warn {
  box-sizing: border-box;
  padding: 10px 16px;
  min-height: 38px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.9);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.25;
}

button.btn-primary, .button-row button.primary {
  border-color: var(--border-highlight);
  color: var(--text);
  background: var(--panel-raised);
}

.button-row button.primary#btnBuy {
  border-color: rgba(14, 165, 233, 0.55);
  color: var(--accent);
}

.button-row button.primary#btnBuy:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.button-row button.primary#btnSell {
  border-color: rgba(255, 71, 87, 0.55);
  color: var(--danger);
}

.button-row button.primary#btnSell:hover {
  background: var(--danger-dim);
  border-color: var(--danger);
}

button.warn {
  border-color: rgba(184, 154, 90, 0.55);
  color: var(--warn);
  background: rgba(184, 154, 90, 0.08);
}

button.btn:hover,
.button-row button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.button-row button.primary:hover:not(#btnBuy):not(#btnSell) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

button.warn:hover {
  background: rgba(230, 195, 92, 0.16);
  border-color: #e6c35c;
}

button.warn:focus-visible {
  outline: 2px solid #e6c35c;
  outline-offset: 2px;
}

body.theme-light button.warn {
  background: rgba(230, 195, 92, 0.12);
  color: #8a6a12;
  border-color: rgba(138, 106, 18, 0.45);
}

body.theme-light button.warn:hover {
  background: rgba(230, 195, 92, 0.22);
}

.ack-line {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
}

.diag-actions {
  margin-top: 8px;
}

.button-row button.secondary {
  font-size: 0.8rem;
  opacity: 0.95;
}

.ack-line.subtle {
  margin-top: 4px;
  font-size: 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 2px;
  border: 1px solid var(--border);
}

table.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

table.data-grid th {
  text-align: left;
  padding: 8px 10px;
  background: var(--toolbar);
  border-bottom: 1px solid #0d0d0e;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

body.theme-light table.data-grid th {
  background: var(--toolbar);
  color: var(--muted);
}

table.data-grid th:last-child {
  border-right: none;
}

table.data-grid td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(58, 58, 60, 0.5);
}

table.data-grid tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.12);
}

body.theme-light table.data-grid tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.03);
}

table.data-grid tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

table.data-grid .action-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  vertical-align: middle;
}

/* Match polished table actions (same family as closed-trades Delete record) */
table.data-grid .action-cell .trade-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-height: 36px;
  margin: 0;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: rgba(35, 35, 35, 0.92);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

table.data-grid .action-cell .trade-action:hover {
  background: rgba(255, 255, 255, 0.06);
}

table.data-grid .action-cell .trade-action--primary {
  border-color: rgba(14, 165, 233, 0.5);
  color: var(--accent);
}

table.data-grid .action-cell .trade-action--primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

table.data-grid .action-cell .trade-action--muted {
  border-color: rgba(154, 154, 154, 0.45);
  color: var(--muted);
  font-weight: 500;
}

table.data-grid .action-cell .trade-action--muted:hover {
  color: var(--text);
  border-color: var(--border);
}

table.data-grid .action-cell .trade-action--warn {
  border-color: #e6c35c;
  color: #e6c35c;
}

table.data-grid .action-cell .trade-action--warn:hover {
  background: rgba(230, 195, 92, 0.12);
  border-color: #f0d080;
}

body.theme-light table.data-grid .action-cell .trade-action {
  background: #f6f6f8;
  border-color: var(--border);
  color: var(--text);
}

body.theme-light table.data-grid .action-cell .trade-action--warn {
  border-color: #c9a227;
  color: #8a6d00;
}

body.theme-light table.data-grid .action-cell .trade-action--warn:hover {
  background: rgba(201, 162, 39, 0.12);
}

table.data-grid .action-cell .trade-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2px 8px;
}

.settings-page .settings-layout .card {
  margin-bottom: 0;
}

.settings-page > .settings-card--reset-pc {
  margin-top: 4px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

@media (min-width: 960px) {
  .settings-layout {
    grid-template-columns: 1fr minmax(260px, 320px);
  }
}

.settings-primary {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card--compact {
  padding: 14px 16px 16px;
}

.settings-card--reset-pc .settings-danger-lead {
  max-width: 62rem;
}

.settings-card__lead--tight {
  margin-bottom: 14px;
}

.settings-card__title {
  margin: 0 0 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.settings-card__title--danger {
  color: var(--danger);
}

.settings-card__lead {
  margin: 0 0 12px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.settings-divider--sidebar {
  margin: 6px 0 14px;
}

.settings-subsection {
  margin: 0;
}

.settings-subsection--tight {
  margin-top: 0;
}

.settings-subsection__title {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-subsection__hint {
  margin: 0 0 10px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
}

.settings-subsection__solo-btn {
  width: 100%;
  max-width: 20rem;
  box-sizing: border-box;
}

.settings-sidebar-block {
  margin: 0 0 2px;
}

.settings-sidebar-block--flush {
  margin-bottom: 0;
}

.settings-sidebar-block__title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-sidebar-block__text {
  margin: 0 0 10px;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--muted);
}

.settings-sidebar-block__text--muted {
  margin-top: -4px;
  margin-bottom: 10px;
  font-size: 0.72rem;
  line-height: 1.35;
  opacity: 0.95;
}

.settings-sidebar-block__label {
  display: block;
  margin: 0 0 5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.settings-sidebar-block__status {
  margin-top: 8px;
  margin-bottom: 0;
}

.settings-btn-row {
  margin-top: 8px;
}

.settings-btn-row--pair {
  flex-wrap: wrap;
}

.settings-btn-row--pair button {
  flex: 1 1 calc(50% - 4px);
  min-width: 7.5rem;
}

.settings-btn-full {
  width: 100%;
  margin-top: 10px;
  box-sizing: border-box;
}

/* Full-width sidebar actions (not inside .button-row): match control height and chrome */
.settings-sidebar-block > button.settings-btn-full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.settings-sidebar-block > button.settings-btn-full:hover {
  background: var(--surface-hover);
  border-color: var(--border-highlight);
}

.settings-sidebar-block > button.settings-btn-full:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.settings-field--full {
  grid-column: 1 / -1;
}

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

.settings-field label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.settings-beta-ai-row .settings-beta-ai-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
}

.settings-beta-ai-hint {
  margin-top: 6px;
  margin-bottom: 0;
}

.settings-field input[type="text"],
.settings-field input[type="number"],
.settings-field input[type="password"],
.settings-field select,
.settings-sidebar-block input[type="password"],
.settings-sidebar-block select,
.settings-readonly input[type="text"] {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--input-surface);
  color: var(--text);
  font: inherit;
  line-height: 1.3;
  min-height: 38px;
}

.settings-field input[type="text"]:focus-visible,
.settings-field input[type="number"]:focus-visible,
.settings-field input[type="password"]:focus-visible,
.settings-field select:focus-visible,
.settings-sidebar-block input[type="password"]:focus-visible,
.settings-sidebar-block select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.settings-field select {
  cursor: pointer;
}

.settings-sidebar-block select {
  cursor: pointer;
}

.settings-readonly label {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.settings-readonly label:first-of-type {
  margin-top: 0;
}

.settings-readonly input {
  font-size: 0.8rem;
  opacity: 0.92;
}

.settings-maint-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 1000px) {
  .settings-maint-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.settings-maint-item {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  min-height: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius, 2px);
  background: rgba(255, 255, 255, 0.02);
}

.settings-maint-item__title {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.settings-maint-item__hint {
  flex: 1;
  margin: 0 0 10px;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

.settings-maint-item__status {
  margin-top: auto;
  padding-top: 4px;
  min-height: 1.1em;
}

.settings-maint-item > button {
  width: 100%;
  max-width: 100%;
  margin-top: 0;
}

body.theme-light .settings-maint-item {
  background: rgba(0, 0, 0, 0.02);
}

.settings-theme-row {
  margin-top: 0;
}

.settings-theme-row .theme-btn {
  flex: 1;
  min-height: 32px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
}

.settings-theme-row .theme-btn:hover {
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.05);
}

body.theme-light .settings-theme-row .theme-btn {
  background: var(--panel-raised);
}

.settings-actions-stack {
  flex-direction: column;
  align-items: stretch;
  margin-top: 4px;
  gap: 8px;
}

.settings-sidebar-block .settings-actions-stack {
  margin-top: 0;
}

.settings-sidebar-block > .button-row.settings-btn-row {
  margin-top: 8px;
}

.settings-actions-stack button {
  width: 100%;
}

.settings-inline-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.settings-doc-open-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.settings-doc-open-row select {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 38px;
}

.settings-doc-open-row .secondary {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  min-width: 5.5rem;
  padding: 8px 16px;
  box-sizing: border-box;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.settings-doc-open-row .secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-highlight);
}

.settings-doc-open-row .secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .settings-doc-open-row {
    flex-wrap: wrap;
  }

  .settings-doc-open-row .secondary {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
  }
}

.settings-card--danger {
  border-color: rgba(255, 77, 99, 0.5);
  background: rgba(255, 77, 99, 0.07);
}

body.theme-light .settings-card--danger {
  background: rgba(255, 77, 99, 0.09);
}

.settings-danger-lead {
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  margin: 0 0 12px;
}

.settings-card--danger .button-row {
  margin-top: 0;
}

button.btn-danger,
.button-row button.btn-danger {
  background: rgba(255, 77, 99, 0.22);
  border-color: var(--danger);
  color: #ffd0d6;
  font-weight: 600;
}

body.theme-light button.btn-danger,
body.theme-light .button-row button.btn-danger {
  color: #be123c;
  background: rgba(255, 77, 99, 0.14);
}

button.btn-danger:hover,
.button-row button.btn-danger:hover {
  background: rgba(255, 77, 99, 0.38);
  color: var(--text);
}

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

.ai-card-title {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 600;
}

.ai-connection-fields {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ai-field-hint {
  margin-top: 6px;
}

.form-row--checkbox {
  margin-top: 6px;
}

.ai-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.ai-checkbox-label input {
  width: auto;
  accent-color: var(--accent);
}

.ai-status-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-status-label { font-size: 0.75rem; color: var(--muted); }
.ai-status-value { font-size: 0.9rem; }

.summary-hint { color: var(--muted); font-size: 0.9rem; }

.connection-hint {
  margin-top: 4px;
  margin-bottom: 0;
  max-width: 52rem;
  line-height: 1.35;
}

.algo-field-hint {
  margin-top: 4px;
  margin-bottom: 0;
}

.banner-warn {
  max-width: 1400px;
  margin: 12px auto 0;
  padding: 12px 16px;
  border-radius: 2px;
  border: 1px solid rgba(230, 195, 92, 0.45);
  background: rgba(230, 195, 92, 0.1);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

body.theme-light .banner-warn {
  background: rgba(230, 195, 92, 0.15);
}

.bridge-hint-banner {
  margin-top: 8px;
}

.settings-symbol-banner {
  grid-column: 1 / -1;
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 2px;
  border: 1px solid rgba(230, 195, 92, 0.45);
  background: rgba(230, 195, 92, 0.1);
  font-size: 0.9rem;
  line-height: 1.45;
}

.settings-symbol-banner__text {
  margin: 0 0 10px;
}

body.theme-light .settings-symbol-banner {
  background: rgba(230, 195, 92, 0.15);
}

/* Standalone chart tab (chart.html) */
body.chart-page {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg, #1a1a1c);
  color: var(--text, #e8e8ea);
}

.chart-page__header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #333);
}

.chart-page__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.chart-page__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #333);
}

.chart-page__field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.chart-page__field-label {
  color: var(--muted, #a0a0a8);
}

.chart-page__select {
  min-width: 10rem;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid var(--border, #444);
  background: rgba(31, 31, 32, 0.9);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

body.theme-light .chart-page__select {
  background: #fff;
}

.chart-page__trade-toggle {
  user-select: none;
  cursor: pointer;
}

.chart-page__trade-toggle input {
  margin: 0 8px 0 0;
  vertical-align: middle;
}

.chart-page__btn,
.chart-page__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 2px;
  border: 1px solid var(--border, #444);
  background: rgba(35, 35, 35, 0.85);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chart-page__btn:hover,
.chart-page__back:hover {
  border-color: var(--border-highlight, #505058);
  background: rgba(255, 255, 255, 0.06);
}

.chart-page__btn:focus-visible,
.chart-page__back:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

body.theme-light .chart-page__btn,
body.theme-light .chart-page__back {
  background: #fff;
}

.chart-page__back:visited {
  color: inherit;
}

.chart-page__meta {
  margin-left: auto;
  font-size: 0.82rem;
  max-width: min(100%, 36rem);
  text-align: right;
}

.chart-page__meta-block {
  padding: 6px 16px 0;
  flex-shrink: 0;
}

.chart-page__live {
  margin: 0 0 4px;
  font-size: 0.85rem;
}

.chart-page__detail {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted, #a0a0a8);
}

.chart-page__canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0 12px 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.chart-page__canvas-wrap canvas {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.chart-page__tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(22rem, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(28, 28, 32, 0.97);
  color: #eee;
  font-size: 0.8rem;
  line-height: 1.45;
  pointer-events: none;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

body.theme-light .chart-page__tooltip {
  background: rgba(252, 252, 254, 0.98);
  color: #222;
  border-color: rgba(0, 0, 0, 0.12);
}

/* --- Browser login landing (login.html): always light (see body.login-page.theme-light) --- */
body.login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  color-scheme: light;
  background: var(--bg, #e6e9ef);
}

.login-shell {
  width: 100%;
  max-width: 400px;
  padding: 28px 26px 26px;
  box-sizing: border-box;
}

body.login-page .login-shell.card {
  background: #ffffff;
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.login-brand__logo {
  display: block;
  width: min(220px, 78vw);
  max-height: min(220px, 32vh);
  height: auto;
  object-fit: contain;
  margin: 0 auto 12px;
  user-select: none;
  -webkit-user-drag: none;
}

.login-brand__subtitle {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.login-form .settings-field {
  margin-bottom: 12px;
}

.login-form .settings-field label {
  font-size: 0.78rem;
}

.login-actions {
  margin-top: 8px;
}

.login-submit {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
}

.login-error {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--danger, #ff6b7a);
}

/* --- Report tab (P&L calendar) --- */
.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin: 12px 0 16px;
}

.report-toolbar__year {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.report-toolbar__year select {
  min-width: 88px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
}

.report-toolbar__jump {
  margin-left: auto;
  flex-shrink: 0;
  padding: 6px 14px;
  min-height: 34px;
}

.report-toolbar__jump,
.report-cal-nav__arrow {
  box-sizing: border-box;
  font-family: inherit;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.report-cal-nav__arrow {
  min-width: 40px;
  padding: 6px 10px;
  min-height: 34px;
}

.report-toolbar__jump:hover,
.report-cal-nav__arrow:hover {
  background: var(--ghost-accent-hover);
  border-color: var(--border-highlight);
  color: var(--accent);
}

.report-toolbar__jump:focus-visible,
.report-cal-nav__arrow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.theme-light .report-toolbar__jump,
body.theme-light .report-cal-nav__arrow {
  background: var(--panel-raised);
  border-color: rgba(47, 85, 199, 0.28);
}

body.theme-light .report-toolbar__jump:hover,
body.theme-light .report-cal-nav__arrow:hover {
  background: var(--ghost-accent-hover);
  border-color: rgba(47, 85, 199, 0.48);
  color: var(--accent);
}

.report-cal-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 4px 0 14px;
}

.report-cal-nav__title {
  margin: 0;
  flex: 1 1 160px;
  min-width: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.report-calendar-host {
  display: flex;
  flex-direction: column;
  gap: 0;
  outline: none;
}

.report-calendar-host:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-dim);
  border-radius: 6px;
}

.report-month__title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.report-month__dow {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 4px;
}

.report-month__dow-cell {
  font-size: 0.65rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.report-month__pad {
  min-height: 44px;
}

.report-cal-day {
  min-height: 44px;
  padding: 4px 3px 3px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-raised);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  font: inherit;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}

.report-cal-day:hover {
  border-color: var(--accent);
}

.report-cal-day--selected {
  box-shadow: 0 0 0 2px var(--accent);
  border-color: var(--accent);
}

.report-cal-day__num {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.1;
}

.report-cal-day__sub {
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
  margin-top: 2px;
}

.report-cal-day--profit {
  background: rgba(46, 160, 67, 0.22);
  border-color: rgba(46, 160, 67, 0.45);
}

.report-cal-day--loss {
  background: rgba(218, 54, 51, 0.2);
  border-color: rgba(218, 54, 51, 0.45);
}

.report-cal-day--flat {
  background: rgba(210, 153, 34, 0.18);
  border-color: rgba(210, 153, 34, 0.35);
}

.report-cal-day--none {
  background: rgba(128, 128, 128, 0.12);
  border-color: var(--border);
  color: var(--muted);
}

body.theme-light .report-cal-day--none {
  background: #e8eaef;
  color: #6a6f7a;
}

.report-day-card {
  margin-top: 14px;
}

.report-day-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 10px 0 14px;
  align-items: flex-end;
}

.report-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.report-filter input,
.report-filter select {
  min-width: 120px;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.78rem;
}

.report-strategy-summary {
  margin-bottom: 12px;
}

.report-summary-table {
  width: 100%;
  max-width: 520px;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.report-summary-table th,
.report-summary-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.report-summary-table th {
  background: var(--toolbar);
  color: var(--muted);
  font-weight: 600;
}

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

.report-day-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
}

.report-day-table th,
.report-day-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

.report-day-table th {
  background: var(--toolbar);
  color: var(--muted);
  font-weight: 600;
}

.report-day-table__empty {
  text-align: center;
  color: var(--muted);
  white-space: normal;
}
