/* Final Studio normalization. This file is re-appended after dynamic legacy CSS. */
.qv3-clone-root,
.qv8-clone-root,
.ats-v2-clone-root,
.mt5-optimizer-clone-root,
.mt5-terminal-clone-root,
.studio-tv-chart,
.studio-trading-chart-mount,
.qv3-chart-shell {
  --bg-0: var(--bg) !important;
  --bg-1: var(--surface) !important;
  --bg-2: var(--surface-muted) !important;
  --bg-3: var(--surface-raised) !important;
  --surface-1: var(--surface) !important;
  --surface-2: var(--surface-muted) !important;
  --surface-3: var(--surface-raised) !important;
  --text-primary: var(--text) !important;
  --text-secondary: var(--text-muted) !important;
  --text-muted: var(--text-subtle) !important;
  --positive: var(--success) !important;
  --negative: var(--danger) !important;
  --cta-gold: var(--primary) !important;
  --cta-gold-dark: var(--primary-hover) !important;
  --ui-sidebar-bg: var(--surface) !important;
  --ui-panel-bg: var(--surface) !important;
  --ui-panel-header-bg: var(--surface-muted) !important;
  --ui-input-bg: var(--surface-raised) !important;
  --ui-input-border: var(--border-strong) !important;
  --ui-border: var(--border) !important;
  --ui-border-strong: var(--border-strong) !important;
  --ui-text: var(--text) !important;
  --ui-text-secondary: var(--text-muted) !important;
  --ui-text-muted: var(--text-subtle) !important;
  --ui-accent-red: var(--danger) !important;
  --ui-accent-blue: var(--info) !important;
  --ui-app-bg: transparent !important;
  --ui-main-bg: transparent !important;
  --ui-app-text: var(--text) !important;
  --ui-surface-muted: var(--surface-muted) !important;
  --ui-elevated-bg: var(--surface-raised) !important;
  --ui-elevated-border: var(--border) !important;
  --ui-native-option-bg: var(--surface-raised) !important;
  --ui-native-option-text: var(--text) !important;
  --font-ui: var(--font-sans) !important;
  --font-display: var(--font-sans) !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: clip !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
  letter-spacing: 0 !important;
}

/* Mobile shell hard reset. This block intentionally comes last and wins over
   older mobile compatibility rules above. */
@media (max-width: 680px) {
  html,
  body {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  body.app-route {
    --studio-mobile-header: 56px;
  }

  body.app-route .app-shell,
  body.app-route .main-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
  }

  body.app-route .sidebar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    width: 100% !important;
    height: var(--studio-mobile-header) !important;
    min-height: var(--studio-mobile-header) !important;
    max-height: var(--studio-mobile-header) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: 1fr !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    overflow: visible !important;
    border: 0 !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: rgba(8, 7, 20, 0.98) !important;
    box-shadow: none !important;
  }

  :root[data-theme="light"] body.app-route .sidebar {
    background: rgba(255, 255, 255, 0.98) !important;
  }

  body.app-route .sidebar::after {
    content: none !important;
  }

  body.app-route .sidebar .brand-row {
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 30px minmax(0, 1fr) !important;
    gap: 8px !important;
    align-items: center !important;
  }

  body.app-route .sidebar .brand-mark {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }

  body.app-route .sidebar .brand-row strong {
    overflow: hidden !important;
    color: #ffffff !important;
    font-size: 16px !important;
    line-height: 1.1 !important;
    font-weight: 650 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  :root[data-theme="light"] body.app-route .sidebar .brand-row strong {
    color: var(--studio-text) !important;
  }

  body.app-route .sidebar .brand-row small {
    display: none !important;
  }

  body.app-route .mobile-nav-button {
    width: 76px !important;
    min-width: 76px !important;
    height: 36px !important;
    min-height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    background: #7c3aed !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    line-height: 1 !important;
  }

  body.app-route .mobile-nav-button::before {
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
  }

  body.app-route .mobile-nav-backdrop {
    position: fixed !important;
    inset: var(--studio-mobile-header) 0 0 !important;
    z-index: 980 !important;
    display: block !important;
    background: rgba(2, 6, 23, 0.48) !important;
    backdrop-filter: blur(3px) !important;
  }

  body.app-route .mobile-nav-backdrop[hidden] {
    display: none !important;
  }

  body.app-route .side-nav {
    position: fixed !important;
    inset: 64px 10px auto !important;
    z-index: 1010 !important;
    width: auto !important;
    height: auto !important;
    max-height: calc(100dvh - 76px) !important;
    display: grid !important;
    align-content: start !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    border: 1px solid var(--studio-border) !important;
    border-radius: 12px !important;
    color: var(--studio-text) !important;
    background: var(--studio-surface) !important;
    box-shadow: 0 18px 60px rgba(2, 6, 23, 0.42) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
    transition: opacity 140ms ease, transform 140ms ease !important;
  }

  body.app-route.mobile-nav-open .side-nav {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
  }

  body.app-route .side-nav section {
    display: grid !important;
    gap: 6px !important;
    margin: 0 !important;
  }

  body.app-route .side-nav section > span {
    padding: 4px 4px 0 !important;
    color: var(--studio-text-subtle) !important;
    font-size: 12px !important;
    font-weight: 650 !important;
  }

  body.app-route .side-nav a,
  body.app-route .side-nav .nav-disabled {
    width: 100% !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 0 10px !important;
    border: 1px solid var(--studio-border) !important;
    border-radius: 8px !important;
    color: var(--studio-text-muted) !important;
    background: var(--studio-surface-muted) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }

  body.app-route .side-nav a.active,
  body.app-route .side-nav a:hover {
    color: var(--studio-text) !important;
    background: var(--studio-primary-soft) !important;
    border-color: var(--studio-primary) !important;
  }

  body.app-route .topbar,
  body.app-route.chart-route-active .topbar {
    position: relative !important;
    top: auto !important;
    z-index: 20 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 84px !important;
    grid-auto-rows: 36px !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: var(--studio-surface) !important;
  }

  body.app-route.chart-route-active .topbar {
    display: none !important;
  }

  body.app-route .topbar .top-strategy,
  body.app-route .topbar #topSaveButton,
  body.app-route .topbar #topRunButton,
  body.app-route .topbar .theme-toggle,
  body.app-route .topbar .notifications-menu {
    display: none !important;
  }

  body.app-route .topbar > #projectSelect {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
  }

  body.app-route .topbar > .state-pill {
    grid-column: 1 !important;
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    justify-content: flex-start !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar > .profile-menu {
    grid-column: 2 !important;
    width: 100% !important;
    height: 34px !important;
    min-width: 0 !important;
  }

  body.app-route .topbar > .profile-menu > button {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 8px !important;
    border-radius: 8px !important;
  }

  body.app-route .topbar > .profile-menu .button-label {
    max-width: 48px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .route-outlet,
  body.app-route.chart-route-active .route-outlet {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    padding: 12px !important;
    gap: 12px !important;
    overflow-x: hidden !important;
  }

  body.app-route.chart-route-active .route-outlet {
    padding: 8px 8px 20px !important;
    gap: 8px !important;
  }

  body.app-route.chart-route-active .page-head {
    display: none !important;
  }

  body.app-route .page-head {
    margin: 0 0 10px !important;
  }

  body.app-route .page-head h1 {
    font-size: 20px !important;
    line-height: 1.15 !important;
  }

  body.app-route .page-head p {
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  body.app-route.chart-route-active #studioTradingChartMount,
  body.app-route.chart-route-active .studio-trading-chart-mount {
    min-height: calc(100dvh - var(--studio-mobile-header) - 28px) !important;
  }

  body.app-route.chart-route-active .studio-tv-chart {
    width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.app-route.chart-route-active .studio-tv-toolbar {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    min-height: 0 !important;
    padding: 8px !important;
    border-radius: 8px !important;
  }

  body.app-route.chart-route-active .studio-tv-toolbar select[aria-label="Symbol"] {
    grid-column: 1 / -1 !important;
  }

  body.app-route.chart-route-active .studio-tv-quick-tfs {
    grid-column: 1 / -1 !important;
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding-bottom: 2px !important;
  }

  body.app-route.chart-route-active .studio-tv-quick-tfs button {
    min-width: 44px !important;
    flex: 0 0 auto !important;
  }

  body.app-route.chart-route-active .studio-tv-layout-label,
  body.app-route.chart-route-active .studio-tv-toolbar button:disabled {
    display: none !important;
  }

  body.app-route.chart-route-active .studio-tv-applybar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 6px !important;
    margin-top: 6px !important;
    padding: 8px !important;
    border-radius: 8px !important;
  }

  body.app-route.chart-route-active .studio-tv-applybar > :first-child {
    grid-column: 1 / -1 !important;
  }

  body.app-route.chart-route-active .studio-tv-apply-status,
  body.app-route.chart-route-active .studio-tv-apply-warning {
    grid-column: 1 / -1 !important;
    min-height: 24px !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 440px !important;
    height: 440px !important;
    overflow: hidden !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host > * {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 440px !important;
    height: 440px !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host canvas,
  body.app-route.chart-route-active .studio-tv-chart-host svg {
    max-width: 100% !important;
  }
}

/* Native analyzer modules: copied Studio-owned DOM, not external iframes. */
body.app-route .analyzer-native-panel {
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 8px !important;
}

body.app-route .studio-native-analyzer {
  width: 100% !important;
  min-width: 0 !important;
  min-height: calc(100dvh - 190px) !important;
  color: var(--text) !important;
  background: transparent !important;
  font-size: var(--studio-type-md) !important;
  font-weight: var(--studio-weight-normal) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route .studio-native-analyzer,
body.app-route .studio-native-analyzer * {
  box-sizing: border-box !important;
  letter-spacing: 0 !important;
  font-style: normal !important;
}

body.app-route .studio-native-analyzer header {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  border-bottom: 1px solid var(--studio-border) !important;
  background: var(--studio-surface) !important;
  backdrop-filter: none !important;
}

body.app-route .studio-native-analyzer .wrap {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 16px !important;
}

body.app-route .studio-native-analyzer main.wrap {
  padding-top: 14px !important;
}

body.app-route .studio-native-analyzer h1 {
  margin: 0 !important;
  color: var(--text) !important;
  font-size: var(--studio-type-title) !important;
  font-weight: var(--studio-weight-strong) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route .studio-native-analyzer :is(h2, h3) {
  margin: 0 0 10px !important;
  color: var(--text) !important;
  font-size: var(--studio-type-lg) !important;
  font-weight: var(--studio-weight-strong) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route .studio-native-analyzer h3 {
  font-size: var(--studio-type-md) !important;
}

body.app-route .studio-native-analyzer :is(.sub, .muted, .k, .small) {
  color: var(--muted) !important;
  font-size: var(--studio-type-xs) !important;
  font-weight: var(--studio-weight-medium) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route .studio-native-analyzer :is(.tools, .tabs) {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 8px !important;
  margin-top: 12px !important;
}

body.app-route .studio-native-analyzer :is(input:not([type="checkbox"]):not([type="radio"]), select, button, a.button, .tab) {
  min-height: 38px !important;
  min-width: 0 !important;
  max-width: 100% !important;
  padding: 0 12px !important;
  border: 1px solid var(--studio-border) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  background: var(--studio-surface-muted) !important;
  box-shadow: none !important;
  font-size: var(--studio-type-sm) !important;
  font-weight: var(--studio-weight-medium) !important;
  line-height: var(--studio-line-tight) !important;
  text-decoration: none !important;
  text-transform: none !important;
}

body.app-route .studio-native-analyzer input:not([type="checkbox"]):not([type="radio"]) {
  width: min(360px, 100%) !important;
}

body.app-route .studio-native-analyzer :is(button, a.button, .tab) {
  cursor: pointer !important;
}

body.app-route .studio-native-analyzer :is(.tab.active, button.active) {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, var(--studio-surface-muted)) !important;
}

body.app-route .studio-native-analyzer :is(.grid4, .grid3, .grid2, .params) {
  display: grid !important;
  gap: 12px !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.app-route .studio-native-analyzer .grid4,
body.app-route .studio-native-analyzer .params {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

body.app-route .studio-native-analyzer .grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

body.app-route .studio-native-analyzer .grid2 {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

body.app-route .studio-native-analyzer :is(.panel, .metric, .param) {
  min-width: 0 !important;
  border: 1px solid var(--studio-border) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  background: var(--studio-surface) !important;
  box-shadow: none !important;
}

body.app-route .studio-native-analyzer .panel {
  margin-top: 12px !important;
  padding: 14px !important;
}

body.app-route .studio-native-analyzer :is(.metric, .param) {
  min-height: 76px !important;
  padding: 12px !important;
}

body.app-route .studio-native-analyzer .v,
body.app-route .studio-native-analyzer .param strong {
  display: block !important;
  margin-top: 4px !important;
  overflow-wrap: anywhere !important;
  color: var(--text) !important;
  font-size: var(--studio-type-xl) !important;
  font-weight: var(--studio-weight-strong) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route .studio-native-analyzer :is(.good, .pos) {
  color: #16a34a !important;
}

body.app-route .studio-native-analyzer :is(.warn) {
  color: #b7791f !important;
}

body.app-route .studio-native-analyzer :is(.bad, .neg) {
  color: #dc2626 !important;
}

body.app-route .studio-native-analyzer :is(.cyan, .rowlink) {
  color: #2563eb !important;
}

body.app-route .studio-native-analyzer .pill {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  max-width: 100% !important;
  margin: 3px 4px 3px 0 !important;
  padding: 5px 9px !important;
  border: 1px solid var(--studio-border) !important;
  border-radius: 999px !important;
  color: var(--text) !important;
  background: var(--studio-surface-muted) !important;
  font-size: var(--studio-type-xs) !important;
  font-weight: var(--studio-weight-medium) !important;
  line-height: var(--studio-line-tight) !important;
  white-space: normal !important;
}

body.app-route .studio-native-analyzer .scroll {
  width: 100% !important;
  max-height: min(720px, 70dvh) !important;
  overflow: auto !important;
  border: 1px solid var(--studio-border) !important;
  border-radius: 8px !important;
  -webkit-overflow-scrolling: touch !important;
}

body.app-route .studio-native-analyzer table {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: var(--studio-type-sm) !important;
}

body.app-route .studio-native-analyzer :is(th, td) {
  padding: 8px 9px !important;
  border-bottom: 1px solid var(--studio-border) !important;
  color: var(--text) !important;
  text-align: left !important;
  vertical-align: top !important;
  font-size: var(--studio-type-sm) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route .studio-native-analyzer th {
  position: sticky !important;
  top: 0 !important;
  z-index: 2 !important;
  color: var(--muted) !important;
  background: var(--studio-surface-muted) !important;
  font-size: var(--studio-type-xs) !important;
  font-weight: var(--studio-weight-strong) !important;
}

body.app-route .studio-native-analyzer .num {
  text-align: right !important;
  font-variant-numeric: tabular-nums !important;
  white-space: nowrap !important;
}

body.app-route .studio-native-analyzer .param .k {
  display: block !important;
}

body.app-route .studio-native-analyzer .hide {
  display: none !important;
}

body.app-route .studio-native-analyzer pre,
body.app-route .studio-native-analyzer .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: var(--studio-type-xs) !important;
}

@media (max-width: 900px) {
  body.app-route .analyzer-native-panel {
    border: 0 !important;
    background: transparent !important;
  }

  body.app-route .studio-native-analyzer {
    min-height: calc(100dvh - 120px) !important;
  }

  body.app-route .studio-native-analyzer .wrap {
    padding: 12px !important;
  }

  body.app-route .studio-native-analyzer :is(.grid4, .grid3, .grid2, .params) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.app-route .studio-native-analyzer :is(.tools, .tabs) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  body.app-route .studio-native-analyzer :is(input:not([type="checkbox"]):not([type="radio"]), select, button, a.button, .tab) {
    width: 100% !important;
    min-height: 44px !important;
    font-size: var(--studio-type-md) !important;
  }

  body.app-route .studio-native-analyzer table {
    min-width: 760px !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table {
    display: table !important;
    min-width: 980px !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table thead {
    display: table-header-group !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table tbody {
    display: table-row-group !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table tr {
    display: table-row !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table :is(th, td) {
    display: table-cell !important;
    width: auto !important;
    min-width: 0 !important;
    border-bottom: 1px solid var(--studio-border) !important;
    white-space: nowrap !important;
  }

  body.app-route .studio-native-analyzer table.mobile-card-table td::before {
    content: none !important;
    display: none !important;
  }

  body.app-route .studio-native-analyzer th {
    position: static !important;
  }
}

/* EOF override: mobile chart keeps the strategy selector visible. */
@media (max-width: 680px) {
  body.app-route.chart-route-active .topbar {
    position: relative !important;
    top: auto !important;
    z-index: 20 !important;
    min-height: 52px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-rows: 36px !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: var(--studio-surface) !important;
  }

  body.app-route.chart-route-active .topbar > #projectSelect {
    display: block !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
  }

  body.app-route.chart-route-active .topbar > :not(#projectSelect) {
    display: none !important;
  }

  body.app-route.chart-route-active #studioTradingChartMount,
  body.app-route.chart-route-active .studio-trading-chart-mount {
    min-height: calc(100dvh - var(--studio-mobile-header) - 52px - 20px) !important;
  }
}

/* Keep the strategy/project switcher visible on mobile chart routes. */
@media (max-width: 680px) {
  body.app-route.chart-route-active .topbar {
    position: relative !important;
    top: auto !important;
    z-index: 20 !important;
    min-height: 52px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-rows: 36px !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: var(--studio-surface) !important;
  }

  body.app-route.chart-route-active .topbar > #projectSelect {
    display: block !important;
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
  }

  body.app-route.chart-route-active .topbar > :not(#projectSelect) {
    display: none !important;
  }

  body.app-route.chart-route-active #studioTradingChartMount,
  body.app-route.chart-route-active .studio-trading-chart-mount {
    min-height: calc(100dvh - var(--studio-mobile-header) - 52px - 20px) !important;
  }
}

body.public-route #appView,
body.public-route .topbar,
body.public-route .sidebar,
body.public-route .mobile-nav-backdrop,
body.public-route .profile-popover,
body.public-route .notifications-panel,
body.login-route #appView,
body.login-route .topbar,
body.login-route .sidebar,
body.login-route .mobile-nav-backdrop {
  display: none !important;
}

.workflow-context {
  margin-bottom: 16px;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.workflow-grid label,
.workflow-grid .field-note {
  min-width: 0;
}

.workflow-grid select {
  width: 100%;
  min-height: 42px;
}

.workflow-warning strong {
  color: var(--warning);
}

.workflow-warning small,
.field-note small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.warning-line {
  border-color: color-mix(in srgb, var(--warning) 45%, var(--border));
  background: color-mix(in srgb, var(--warning) 10%, var(--surface));
  color: var(--text);
}

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

.capability-grid > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.capability-grid > div > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .workflow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .capability-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workflow-grid,
  .capability-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .workflow-context {
    margin-bottom: 12px;
  }
}

.qv3-clone-root *,
.qv8-clone-root *,
.ats-v2-clone-root *,
.mt5-optimizer-clone-root *,
.mt5-terminal-clone-root *,
.studio-tv-chart *,
.qv3-chart-shell * {
  font-family: inherit !important;
  letter-spacing: 0 !important;
}

.qv3-clone-root code,
.qv3-clone-root pre,
.qv3-clone-root .mono,
.qv8-clone-root code,
.qv8-clone-root pre,
.qv8-clone-root .mono,
.ats-v2-clone-root code,
.ats-v2-clone-root pre,
.ats-v2-clone-root .mono,
.mt5-optimizer-clone-root code,
.mt5-optimizer-clone-root pre,
.mt5-optimizer-clone-root .mono,
.mt5-terminal-clone-root code,
.mt5-terminal-clone-root pre,
.mt5-terminal-clone-root .mono {
  font-family: var(--font-mono) !important;
}

.qv3-clone-root .app,
.qv3-clone-root .app-shell,
.qv8-clone-root .app,
.qv8-clone-root .app-shell,
.ats-v2-clone-root .app,
.ats-v2-clone-root .app-shell,
.mt5-optimizer-clone-root .app,
.mt5-optimizer-clone-root .app-shell,
.mt5-terminal-clone-root #root,
.mt5-terminal-clone-root .mt5-terminal-react-root {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 auto !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

.qv3-clone-root .bg-glow,
.qv8-clone-root .bg-glow,
.ats-v2-clone-root .bg-glow,
.mt5-optimizer-clone-root .bg-glow,
.mt5-terminal-clone-root .bg-glow {
  display: none !important;
}

.qv3-clone-root .panel,
.qv3-clone-root .setup-card,
.qv3-clone-root .key-section,
.qv3-clone-root .params-summary-kpi,
.qv3-clone-root .ai-top-card,
.qv3-clone-root .kpi,
.qv3-clone-root .table-wrap,
.qv8-clone-root .panel,
.qv8-clone-root .setup-card,
.qv8-clone-root .side-bounds-card,
.qv8-clone-root .kpi,
.qv8-clone-root .table-wrap,
.ats-v2-clone-root .panel,
.ats-v2-clone-root .setup-card,
.ats-v2-clone-root .key-section,
.ats-v2-clone-root .params-summary-kpi,
.ats-v2-clone-root .ai-top-card,
.ats-v2-clone-root .kpi,
.ats-v2-clone-root .table-wrap,
.mt5-optimizer-clone-root .panel,
.mt5-optimizer-clone-root .setup-card,
.mt5-optimizer-clone-root .kpi,
.mt5-optimizer-clone-root .table-wrap,
.mt5-terminal-clone-root [class*="panel"],
.mt5-terminal-clone-root [class*="card"],
.mt5-terminal-clone-root [class*="toolbar"] {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  background: var(--surface) !important;
  background-color: var(--surface) !important;
  background-image: none !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-sm) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.qv3-clone-root .panel h2,
.qv3-clone-root .setup-card-title,
.qv8-clone-root .panel h2,
.qv8-clone-root .setup-card-title,
.ats-v2-clone-root .panel h2,
.ats-v2-clone-root .setup-card-title,
.mt5-optimizer-clone-root .panel h2,
.mt5-optimizer-clone-root .setup-card-title,
.mt5-terminal-clone-root h1,
.mt5-terminal-clone-root h2,
.mt5-terminal-clone-root h3 {
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  letter-spacing: 0 !important;
}

.qv3-clone-root .muted,
.qv3-clone-root .tiny,
.qv3-clone-root .field-hint,
.qv3-clone-root .panel-subtitle,
.qv8-clone-root .muted,
.qv8-clone-root .tiny,
.qv8-clone-root .field-hint,
.qv8-clone-root .panel-subtitle,
.ats-v2-clone-root .muted,
.ats-v2-clone-root .tiny,
.ats-v2-clone-root .field-hint,
.ats-v2-clone-root .panel-subtitle,
.mt5-optimizer-clone-root .muted,
.mt5-optimizer-clone-root .tiny,
.mt5-optimizer-clone-root .field-hint,
.mt5-optimizer-clone-root .panel-subtitle,
.mt5-terminal-clone-root small,
.mt5-terminal-clone-root [class*="muted"] {
  color: var(--text-muted) !important;
  font-size: 12px !important;
}

.qv3-clone-root button,
.qv8-clone-root button,
.ats-v2-clone-root button,
.mt5-optimizer-clone-root button,
.mt5-terminal-clone-root button {
  min-height: 36px !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-md) !important;
  background: var(--surface-raised) !important;
  background-color: var(--surface-raised) !important;
  background-image: none !important;
  color: var(--text) !important;
  box-shadow: none !important;
  text-transform: none !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.qv3-clone-root button.primary,
.qv3-clone-root .primary,
.qv3-clone-root .btn-run,
.qv8-clone-root button.primary,
.qv8-clone-root .primary,
.qv8-clone-root .btn-run,
.ats-v2-clone-root button.primary,
.ats-v2-clone-root .primary,
.ats-v2-clone-root .btn-run,
.mt5-optimizer-clone-root button.primary,
.mt5-optimizer-clone-root .primary,
.mt5-optimizer-clone-root .btn-run,
.mt5-terminal-clone-root button.primary {
  border-color: var(--primary) !important;
  background: var(--primary) !important;
  background-color: var(--primary) !important;
  color: #ffffff !important;
}

.qv3-clone-root .btn-danger,
.qv3-clone-root button.danger,
.qv8-clone-root .btn-danger,
.qv8-clone-root button.danger,
.ats-v2-clone-root .btn-danger,
.ats-v2-clone-root button.danger,
.mt5-optimizer-clone-root .btn-danger,
.mt5-optimizer-clone-root button.danger,
.mt5-terminal-clone-root button.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border)) !important;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface)) !important;
  color: var(--danger) !important;
}

.qv3-clone-root input,
.qv3-clone-root select,
.qv3-clone-root textarea,
.qv8-clone-root input,
.qv8-clone-root select,
.qv8-clone-root textarea,
.ats-v2-clone-root input,
.ats-v2-clone-root select,
.ats-v2-clone-root textarea,
.mt5-optimizer-clone-root input,
.mt5-optimizer-clone-root select,
.mt5-optimizer-clone-root textarea,
.mt5-terminal-clone-root input,
.mt5-terminal-clone-root select,
.mt5-terminal-clone-root textarea {
  min-height: 36px !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-md) !important;
  background: var(--surface-raised) !important;
  background-color: var(--surface-raised) !important;
  color: var(--text) !important;
  box-shadow: none !important;
  font-size: 13px !important;
}

.qv3-clone-root input[type="checkbox"],
.qv8-clone-root input[type="checkbox"],
.ats-v2-clone-root input[type="checkbox"],
.mt5-optimizer-clone-root input[type="checkbox"],
.mt5-terminal-clone-root input[type="checkbox"] {
  width: 20px !important;
  height: 20px !important;
  min-height: 20px !important;
  accent-color: var(--primary) !important;
}

.qv3-clone-root table,
.qv8-clone-root table,
.ats-v2-clone-root table,
.mt5-optimizer-clone-root table {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-collapse: collapse !important;
}

.qv3-clone-root th,
.qv3-clone-root td,
.qv8-clone-root th,
.qv8-clone-root td,
.ats-v2-clone-root th,
.ats-v2-clone-root td,
.mt5-optimizer-clone-root th,
.mt5-optimizer-clone-root td {
  border-color: var(--border) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

.qv3-clone-root th,
.qv8-clone-root th,
.ats-v2-clone-root th,
.mt5-optimizer-clone-root th {
  background: var(--surface-muted) !important;
  color: var(--text-muted) !important;
}

.qv3-clone-root .chip,
.qv3-clone-root .pill,
.qv3-clone-root .state-pill,
.qv8-clone-root .chip,
.qv8-clone-root .pill,
.qv8-clone-root .state-pill,
.ats-v2-clone-root .chip,
.ats-v2-clone-root .pill,
.ats-v2-clone-root .state-pill,
.mt5-optimizer-clone-root .chip,
.mt5-optimizer-clone-root .pill,
.mt5-optimizer-clone-root .state-pill,
.mt5-terminal-clone-root [class*="pill"],
.mt5-terminal-clone-root [class*="badge"] {
  min-height: 24px !important;
  border: 1px solid var(--border) !important;
  border-radius: 999px !important;
  background: var(--surface-muted) !important;
  color: var(--text-muted) !important;
  box-shadow: none !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

.qv3-clone-root .chip-on,
.qv3-clone-root .segment-on,
.qv3-clone-root .params-filter-btn.is-active,
.qv8-clone-root .chip-on,
.qv8-clone-root .segment-on,
.qv8-clone-root .params-filter-btn.is-active,
.ats-v2-clone-root .chip-on,
.ats-v2-clone-root .segment-on,
.ats-v2-clone-root .params-filter-btn.is-active,
.mt5-optimizer-clone-root .chip-on,
.mt5-optimizer-clone-root .segment-on,
.mt5-optimizer-clone-root .params-filter-btn.is-active {
  border-color: var(--primary) !important;
  background: color-mix(in srgb, var(--primary) 52%, var(--surface)) !important;
  color: #ffffff !important;
}

.qv3-clone-root .brand,
.qv8-clone-root .brand,
.ats-v2-clone-root .brand,
.mt5-optimizer-clone-root .brand,
.qv3-clone-root .title-brand-row,
.qv8-clone-root .title-brand-row,
.ats-v2-clone-root .title-brand-row,
.mt5-optimizer-clone-root .title-brand-row {
  display: none !important;
}

.qv3-clone-root .runbar,
.qv8-clone-root .runbar,
.ats-v2-clone-root .runbar,
.mt5-optimizer-clone-root .runbar,
.qv3-clone-root .setup-grid,
.qv8-clone-root .setup-grid,
.ats-v2-clone-root .setup-grid,
.mt5-optimizer-clone-root .setup-grid {
  max-width: 100% !important;
  min-width: 0 !important;
}

.qv3-clone-root .table-wrap,
.qv8-clone-root .table-wrap,
.ats-v2-clone-root .table-wrap,
.mt5-optimizer-clone-root .table-wrap {
  max-width: 100% !important;
  overflow-x: auto !important;
}

.mt5-terminal-clone-root .sidebar-expand-fab,
.mt5-terminal-clone-root .bthex-global-stepper {
  display: none !important;
}

@media (max-width: 760px) {
  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root,
  .mt5-terminal-clone-root {
    overflow-x: hidden !important;
  }

  .qv3-clone-root .setup-grid,
  .qv3-clone-root .params-panel-grid,
  .qv3-clone-root .setup-fields,
  .qv8-clone-root .setup-grid,
  .qv8-clone-root .params-panel-grid,
  .qv8-clone-root .setup-fields,
  .ats-v2-clone-root .setup-grid,
  .ats-v2-clone-root .params-panel-grid,
  .ats-v2-clone-root .setup-fields,
  .mt5-optimizer-clone-root .setup-grid,
  .mt5-optimizer-clone-root .params-panel-grid,
  .mt5-optimizer-clone-root .setup-fields {
    grid-template-columns: 1fr !important;
  }

  .qv3-clone-root button,
  .qv8-clone-root button,
  .ats-v2-clone-root button,
  .mt5-optimizer-clone-root button,
  .mt5-terminal-clone-root button {
    min-height: 40px !important;
  }
}

/* Final mobile module layout: separate tool sections instead of one compressed app. */
@media (max-width: 760px) {
  .studio-module-shell {
    display: grid !important;
    gap: 16px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .studio-module-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  .studio-module-header > .ghost.compact {
    display: none !important;
  }

  .studio-module-title {
    display: grid !important;
    gap: 6px !important;
  }

  .studio-module-title span {
    font-size: 12px !important;
  }

  .studio-module-title p {
    max-width: 32rem !important;
    line-height: 1.45 !important;
  }

  .studio-module-scope {
    min-height: 58px !important;
    padding: 12px 14px !important;
    border-radius: 16px !important;
  }

  .studio-module-steps {
    margin: 0 !important;
    padding: 2px 0 12px !important;
    border-bottom: 1px solid var(--border) !important;
  }

  .studio-module-steps a,
  .studio-module-steps span {
    min-height: 40px !important;
    padding-inline: 13px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
  }

  .studio-module-content {
    display: grid !important;
    gap: 18px !important;
    overflow-x: clip !important;
  }

  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root {
    --studio-mobile-gap: 16px;
  }

  .qv3-clone-root .app,
  .qv3-clone-root .app-shell,
  .qv8-clone-root .app,
  .qv8-clone-root .app-shell,
  .ats-v2-clone-root .app,
  .ats-v2-clone-root .app-shell,
  .mt5-optimizer-clone-root .app,
  .mt5-optimizer-clone-root .app-shell,
  .mt5-optimizer-clone-root #mt5OptimizerReactRoot,
  .mt5-optimizer-clone-root main,
  .mt5-optimizer-clone-root [class*="content"],
  .mt5-optimizer-clone-root [class*="layout"] {
    display: grid !important;
    gap: 18px !important;
  }

  .qv3-clone-root .panel,
  .qv3-clone-root .setup-card,
  .qv3-clone-root .key-section,
  .qv3-clone-root .params-summary-kpi,
  .qv3-clone-root .ai-top-card,
  .qv3-clone-root .kpi,
  .qv8-clone-root .panel,
  .qv8-clone-root .setup-card,
  .qv8-clone-root .side-bounds-card,
  .qv8-clone-root .results-shell,
  .qv8-clone-root .kpi,
  .ats-v2-clone-root .panel,
  .ats-v2-clone-root .setup-card,
  .ats-v2-clone-root .key-section,
  .ats-v2-clone-root .params-summary-kpi,
  .ats-v2-clone-root .ai-top-card,
  .ats-v2-clone-root .kpi,
  .mt5-optimizer-clone-root .panel,
  .mt5-optimizer-clone-root .setup-card,
  .mt5-optimizer-clone-root .side-bounds-card,
  .mt5-optimizer-clone-root .results-shell,
  .mt5-optimizer-clone-root .kpi {
    padding: 18px !important;
    margin: 0 0 16px !important;
    border-radius: 18px !important;
  }

  .qv3-clone-root details.panel,
  .qv3-clone-root details.setup-card,
  .qv8-clone-root details.panel,
  .qv8-clone-root details.setup-card,
  .ats-v2-clone-root details.panel,
  .ats-v2-clone-root details.setup-card,
  .mt5-optimizer-clone-root details.panel,
  .mt5-optimizer-clone-root details.setup-card {
    padding: 0 !important;
    overflow: hidden !important;
  }

  .qv3-clone-root details > summary,
  .qv8-clone-root details > summary,
  .ats-v2-clone-root details > summary,
  .mt5-optimizer-clone-root details > summary {
    min-height: 58px !important;
    padding: 16px 18px !important;
    border-radius: 18px !important;
  }

  .qv3-clone-root details[open] > summary,
  .qv8-clone-root details[open] > summary,
  .ats-v2-clone-root details[open] > summary,
  .mt5-optimizer-clone-root details[open] > summary {
    border-bottom: 1px solid var(--border) !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  .qv3-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .ai-top-grid, .results-kpis, .ai-kpis, .best-result-hero, .best-result-main, .best-result-metrics, .best-result-actions, .results-head, .results-actions, .result-grid, .apply-toolbar, .filter-row, .params-summary-strip, .robust-basket-inline),
  .qv8-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .results-kpis, .results-head, .results-actions, .filter-row, .ranges-grid, .compact-ranges),
  .ats-v2-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .ai-top-grid, .results-kpis, .ai-kpis, .best-result-hero, .best-result-main, .best-result-metrics, .best-result-actions, .results-head, .results-actions, .filter-row, .params-summary-strip, .robust-basket-inline),
  .mt5-optimizer-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .results-kpis, .results-head, .results-actions, .filter-row, .ranges-grid, .compact-ranges, .stack-card) {
    gap: 14px !important;
  }

  .qv3-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .qv8-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .ats-v2-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .mt5-optimizer-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions) {
    gap: 12px !important;
    padding: 14px !important;
    border: 1px solid var(--border) !important;
    border-radius: 18px !important;
    background: var(--surface) !important;
  }

  .qv3-clone-root .control-status,
  .qv8-clone-root .control-status,
  .ats-v2-clone-root .control-status,
  .mt5-optimizer-clone-root .control-status {
    align-items: start !important;
  }

  .qv3-clone-root .field,
  .qv8-clone-root .field,
  .ats-v2-clone-root .field,
  .mt5-optimizer-clone-root .field {
    display: grid !important;
    gap: 7px !important;
  }

  .qv3-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .qv8-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .ats-v2-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .mt5-optimizer-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) {
    min-height: 54px !important;
    padding: 13px 14px !important;
  }

  .qv8-clone-root .range-row,
  .ats-v2-clone-root .range-row,
  .mt5-optimizer-clone-root .range-row,
  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row),
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) {
    gap: 10px !important;
    margin-bottom: 12px !important;
    padding: 14px !important;
  }

  .qv3-clone-root .results-shell,
  .qv8-clone-root .results-shell,
  .ats-v2-clone-root .results-shell,
  .mt5-optimizer-clone-root .results-shell {
    margin-top: 8px !important;
  }
}

/* Flatten action areas on small screens. */
@media (max-width: 760px) {
  .qv3-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .qv8-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .ats-v2-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .mt5-optimizer-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions) {
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .qv3-clone-root :is(.control-status, .runbar-center),
  .qv8-clone-root :is(.control-status, .runbar-center),
  .ats-v2-clone-root :is(.control-status, .runbar-center),
  .mt5-optimizer-clone-root :is(.control-status, .runbar-center) {
    padding: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    background: var(--surface-muted) !important;
  }
}

/* Premium Studio skin for copied strategy modules. This file is appended after
   legacy CSS, so keep the visual decisions token based and product-wide. */
.qv3-clone-root,
.qv8-clone-root,
.ats-v2-clone-root,
.mt5-optimizer-clone-root,
.mt5-terminal-clone-root,
.studio-tv-chart,
.studio-trading-chart-mount,
.qv3-chart-shell {
  --bg-0: transparent !important;
  --bg-1: transparent !important;
  --bg-2: var(--surface) !important;
  --bg-3: var(--surface-muted) !important;
  --surface-1: var(--surface) !important;
  --surface-2: var(--surface-muted) !important;
  --surface-3: var(--surface-raised) !important;
  --panel: var(--surface) !important;
  --panel-2: var(--surface-muted) !important;
  --panel-3: var(--surface-raised) !important;
  --cta: var(--primary) !important;
  --cta-dark: var(--primary-hover) !important;
  --cta-gold: var(--primary) !important;
  --cta-gold-dark: var(--primary-hover) !important;
  --accent: var(--primary) !important;
  --accent-blue: var(--info) !important;
  background: transparent !important;
  color: var(--text) !important;
}

.qv3-clone-root .panel,
.qv3-clone-root .setup-card,
.qv3-clone-root .key-section,
.qv3-clone-root .params-summary-kpi,
.qv3-clone-root .ai-top-card,
.qv3-clone-root .kpi,
.qv3-clone-root .table-wrap,
.qv8-clone-root .panel,
.qv8-clone-root .setup-card,
.qv8-clone-root .side-bounds-card,
.qv8-clone-root .results-shell,
.qv8-clone-root .kpi,
.qv8-clone-root .table-wrap,
.ats-v2-clone-root .panel,
.ats-v2-clone-root .setup-card,
.ats-v2-clone-root .key-section,
.ats-v2-clone-root .params-summary-kpi,
.ats-v2-clone-root .ai-top-card,
.ats-v2-clone-root .kpi,
.ats-v2-clone-root .table-wrap,
.mt5-optimizer-clone-root .panel,
.mt5-optimizer-clone-root .setup-card,
.mt5-optimizer-clone-root .kpi,
.mt5-optimizer-clone-root .table-wrap,
.mt5-terminal-clone-root [class*="panel"],
.mt5-terminal-clone-root [class*="card"],
.mt5-terminal-clone-root [class*="toolbar"],
.studio-tv-toolbar,
.studio-tv-applybar,
.studio-tv-all-applies,
.studio-tv-mini,
.studio-tv-native-mini,
.studio-tv-trades,
.qv3-mini,
.qv3-symbol-card,
.qv3-chart-symbol-card,
.qv3-equity-panel {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--surface) !important;
  background-color: var(--surface) !important;
  background-image: none !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-sm) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

.qv3-clone-root h1,
.qv3-clone-root h2,
.qv3-clone-root h3,
.qv8-clone-root h1,
.qv8-clone-root h2,
.qv8-clone-root h3,
.ats-v2-clone-root h1,
.ats-v2-clone-root h2,
.ats-v2-clone-root h3,
.mt5-optimizer-clone-root h1,
.mt5-optimizer-clone-root h2,
.mt5-optimizer-clone-root h3,
.mt5-terminal-clone-root h1,
.mt5-terminal-clone-root h2,
.mt5-terminal-clone-root h3 {
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
  font-weight: 760 !important;
  letter-spacing: 0 !important;
}

.qv3-clone-root button,
.qv8-clone-root button,
.ats-v2-clone-root button,
.mt5-optimizer-clone-root button,
.mt5-terminal-clone-root button,
.studio-tv-toolbar button,
.studio-tv-mini-run,
.qv3-chart-button,
.qv3-run-button,
.qv3-timeframe-btn,
.qv3-tab,
.qv3-list-filter,
.studio-tv-all-applies,
.qv3-clone-root input,
.qv3-clone-root select,
.qv3-clone-root textarea,
.qv8-clone-root input,
.qv8-clone-root select,
.qv8-clone-root textarea,
.ats-v2-clone-root input,
.ats-v2-clone-root select,
.ats-v2-clone-root textarea,
.mt5-optimizer-clone-root input,
.mt5-optimizer-clone-root select,
.mt5-optimizer-clone-root textarea,
.mt5-terminal-clone-root input,
.mt5-terminal-clone-root select,
.mt5-terminal-clone-root textarea {
  min-height: 40px !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  background: var(--surface-raised) !important;
  background-color: var(--surface-raised) !important;
  background-image: none !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

.studio-tv-all-applies input {
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  accent-color: var(--primary) !important;
}

.qv3-clone-root input[type="checkbox"],
.qv3-clone-root input[type="radio"],
.qv8-clone-root input[type="checkbox"],
.qv8-clone-root input[type="radio"],
.ats-v2-clone-root input[type="checkbox"],
.ats-v2-clone-root input[type="radio"],
.mt5-optimizer-clone-root input[type="checkbox"],
.mt5-optimizer-clone-root input[type="radio"],
.mt5-terminal-clone-root input[type="checkbox"],
.mt5-terminal-clone-root input[type="radio"],
.studio-tv-all-applies input,
.studio-tv-toolbar input[type="checkbox"],
.studio-tv-toolbar input[type="radio"],
.studio-tv-chart input[type="checkbox"],
.studio-tv-chart input[type="radio"],
.studio-trading-chart-mount input[type="checkbox"],
.studio-trading-chart-mount input[type="radio"],
.qv3-chart-shell input[type="checkbox"],
.qv3-chart-shell input[type="radio"] {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  accent-color: var(--primary) !important;
}

.studio-tv-chart a[href],
.studio-trading-chart-mount a[href],
.qv3-chart-shell a[href],
.mt5-terminal-clone-root a[href] {
  min-height: 24px !important;
  display: inline-flex !important;
  align-items: center !important;
}

.studio-tv-all-applies span {
  color: var(--text) !important;
}

.qv3-clone-root button.primary,
.qv3-clone-root .primary,
.qv3-clone-root .btn-run,
.qv3-clone-root .apply-btn,
.qv8-clone-root button.primary,
.qv8-clone-root .primary,
.qv8-clone-root .btn-run,
.qv8-clone-root .apply-btn,
.ats-v2-clone-root button.primary,
.ats-v2-clone-root .primary,
.ats-v2-clone-root .btn-run,
.ats-v2-clone-root .apply-btn,
.mt5-optimizer-clone-root button.primary,
.mt5-optimizer-clone-root .primary,
.mt5-optimizer-clone-root .btn-run,
.mt5-optimizer-clone-root .apply-btn,
.mt5-terminal-clone-root button.primary,
.studio-tv-mini-run,
.qv3-run-button,
.qv3-chart-button.primary,
.qv3-timeframe-btn.is-active,
.qv3-tab.is-active,
.qv3-list-filter.is-active {
  border-color: transparent !important;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
  background-color: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 14px 36px color-mix(in srgb, var(--primary) 22%, transparent) !important;
}

.qv3-clone-root button:hover:not(:disabled),
.qv8-clone-root button:hover:not(:disabled),
.ats-v2-clone-root button:hover:not(:disabled),
.mt5-optimizer-clone-root button:hover:not(:disabled),
.mt5-terminal-clone-root button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--primary) 48%, var(--border)) !important;
  background: var(--primary-soft) !important;
  color: var(--text) !important;
}

.qv3-clone-root .chip-on,
.qv3-clone-root .segment-on,
.qv3-clone-root .params-filter-btn.is-active,
.qv3-clone-root .active,
.qv3-clone-root .selected,
.qv3-clone-root .is-active,
.qv8-clone-root .chip-on,
.qv8-clone-root .segment-on,
.qv8-clone-root .params-filter-btn.is-active,
.qv8-clone-root .active,
.qv8-clone-root .selected,
.qv8-clone-root .is-active,
.ats-v2-clone-root .chip-on,
.ats-v2-clone-root .segment-on,
.ats-v2-clone-root .params-filter-btn.is-active,
.ats-v2-clone-root .active,
.ats-v2-clone-root .selected,
.ats-v2-clone-root .is-active,
.mt5-optimizer-clone-root .chip-on,
.mt5-optimizer-clone-root .segment-on,
.mt5-optimizer-clone-root .params-filter-btn.is-active,
.mt5-optimizer-clone-root .active,
.mt5-optimizer-clone-root .selected,
.mt5-optimizer-clone-root .is-active {
  border-color: color-mix(in srgb, var(--primary) 54%, var(--border)) !important;
  background: color-mix(in srgb, var(--primary) 52%, var(--surface)) !important;
  color: #ffffff !important;
}

:root[data-theme="light"] .qv3-clone-root .chip-on,
:root[data-theme="light"] .qv3-clone-root .segment-on,
:root[data-theme="light"] .qv3-clone-root .params-filter-btn.is-active,
:root[data-theme="light"] .qv3-clone-root .active,
:root[data-theme="light"] .qv3-clone-root .selected,
:root[data-theme="light"] .qv3-clone-root .is-active,
:root[data-theme="light"] .qv8-clone-root .chip-on,
:root[data-theme="light"] .qv8-clone-root .segment-on,
:root[data-theme="light"] .qv8-clone-root .params-filter-btn.is-active,
:root[data-theme="light"] .qv8-clone-root .active,
:root[data-theme="light"] .qv8-clone-root .selected,
:root[data-theme="light"] .qv8-clone-root .is-active,
:root[data-theme="light"] .ats-v2-clone-root .chip-on,
:root[data-theme="light"] .ats-v2-clone-root .segment-on,
:root[data-theme="light"] .ats-v2-clone-root .params-filter-btn.is-active,
:root[data-theme="light"] .ats-v2-clone-root .active,
:root[data-theme="light"] .ats-v2-clone-root .selected,
:root[data-theme="light"] .ats-v2-clone-root .is-active,
:root[data-theme="light"] .mt5-optimizer-clone-root .chip-on,
:root[data-theme="light"] .mt5-optimizer-clone-root .segment-on,
:root[data-theme="light"] .mt5-optimizer-clone-root .params-filter-btn.is-active,
:root[data-theme="light"] .mt5-optimizer-clone-root .active,
:root[data-theme="light"] .mt5-optimizer-clone-root .selected,
:root[data-theme="light"] .mt5-optimizer-clone-root .is-active,
:root[data-theme="light"] .studio-tv-quick-tfs button.active,
:root[data-theme="light"] .qv3-timeframe-btn.is-active,
:root[data-theme="light"] .qv3-chart-button.primary {
  border-color: #065f46 !important;
  background: #087d61 !important;
  color: #ffffff !important;
}

.qv3-clone-root th,
.qv8-clone-root th,
.ats-v2-clone-root th,
.mt5-optimizer-clone-root th,
.studio-tv-trades th,
.qv3-trades-table th {
  background: var(--surface-muted) !important;
  color: var(--text-muted) !important;
}

.qv3-clone-root td,
.qv8-clone-root td,
.ats-v2-clone-root td,
.mt5-optimizer-clone-root td,
.studio-tv-trades td,
.qv3-trades-table td {
  background: transparent !important;
  color: var(--text) !important;
}

:root[data-theme="dark"] .qv3-clone-root button.chip:not(.chip-on):not(.is-active),
:root[data-theme="dark"] .qv8-clone-root button.chip:not(.chip-on):not(.is-active),
:root[data-theme="dark"] .ats-v2-clone-root button.chip:not(.chip-on):not(.is-active),
:root[data-theme="dark"] .mt5-optimizer-clone-root button.chip:not(.chip-on):not(.is-active) {
  color: var(--text) !important;
}

:root[data-theme="dark"] .qv3-clone-root .chips,
:root[data-theme="dark"] .qv8-clone-root .chips,
:root[data-theme="dark"] .ats-v2-clone-root .chips,
:root[data-theme="dark"] .mt5-optimizer-clone-root .chips {
  color: var(--text) !important;
}

/* Match Studio's final typography scale inside cloned modules. */
.qv3-clone-root,
.qv8-clone-root,
.ats-v2-clone-root,
.mt5-optimizer-clone-root,
.mt5-terminal-clone-root,
.studio-tv-chart,
.qv3-chart-shell {
  font-size: 15px !important;
}

.qv3-clone-root h1,
.qv8-clone-root h1,
.ats-v2-clone-root h1,
.mt5-optimizer-clone-root h1,
.mt5-terminal-clone-root h1 {
  font-size: 30px !important;
  line-height: 1.02 !important;
  font-weight: 800 !important;
}

.qv3-clone-root h2,
.qv3-clone-root h3,
.qv3-clone-root .setup-card-title,
.qv8-clone-root h2,
.qv8-clone-root h3,
.qv8-clone-root .setup-card-title,
.ats-v2-clone-root h2,
.ats-v2-clone-root h3,
.ats-v2-clone-root .setup-card-title,
.mt5-optimizer-clone-root h2,
.mt5-optimizer-clone-root h3,
.mt5-optimizer-clone-root .setup-card-title,
.mt5-terminal-clone-root h2,
.mt5-terminal-clone-root h3,
.studio-tv-mini-title,
.studio-tv-trades-title strong {
  font-size: 18px !important;
  line-height: 1.12 !important;
  font-weight: 780 !important;
}

.qv3-clone-root button,
.qv8-clone-root button,
.ats-v2-clone-root button,
.mt5-optimizer-clone-root button,
.mt5-terminal-clone-root button,
.studio-tv-toolbar button,
.studio-tv-toolbar select,
.studio-tv-applybar select,
.studio-tv-all-applies,
.qv3-chart-button,
.qv3-run-button,
.qv3-timeframe-btn,
.qv3-tab,
.qv3-list-filter {
  font-size: 14px !important;
  font-weight: 760 !important;
}

.qv3-clone-root input,
.qv3-clone-root select,
.qv3-clone-root textarea,
.qv8-clone-root input,
.qv8-clone-root select,
.qv8-clone-root textarea,
.ats-v2-clone-root input,
.ats-v2-clone-root select,
.ats-v2-clone-root textarea,
.mt5-optimizer-clone-root input,
.mt5-optimizer-clone-root select,
.mt5-optimizer-clone-root textarea,
.mt5-terminal-clone-root input,
.mt5-terminal-clone-root select,
.mt5-terminal-clone-root textarea {
  font-size: 14px !important;
}

.qv3-clone-root label,
.qv3-clone-root .muted,
.qv3-clone-root .tiny,
.qv3-clone-root .field-hint,
.qv3-clone-root .panel-subtitle,
.qv8-clone-root label,
.qv8-clone-root .muted,
.qv8-clone-root .tiny,
.qv8-clone-root .field-hint,
.qv8-clone-root .panel-subtitle,
.ats-v2-clone-root label,
.ats-v2-clone-root .muted,
.ats-v2-clone-root .tiny,
.ats-v2-clone-root .field-hint,
.ats-v2-clone-root .panel-subtitle,
.mt5-optimizer-clone-root label,
.mt5-optimizer-clone-root .muted,
.mt5-optimizer-clone-root .tiny,
.mt5-optimizer-clone-root .field-hint,
.mt5-optimizer-clone-root .panel-subtitle,
.mt5-terminal-clone-root small,
.mt5-terminal-clone-root [class*="muted"] {
  font-size: 13px !important;
}

.qv3-clone-root th,
.qv3-clone-root td,
.qv8-clone-root th,
.qv8-clone-root td,
.ats-v2-clone-root th,
.ats-v2-clone-root td,
.mt5-optimizer-clone-root th,
.mt5-optimizer-clone-root td,
.studio-tv-trades th,
.studio-tv-trades td,
.qv3-trades-table th,
.qv3-trades-table td {
  font-size: 13px !important;
}

@media (max-width: 820px) {
  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root,
  .mt5-terminal-clone-root,
  .studio-tv-chart,
  .qv3-chart-shell {
    font-size: 14px !important;
  }

  .qv3-clone-root h1,
  .qv8-clone-root h1,
  .ats-v2-clone-root h1,
  .mt5-optimizer-clone-root h1,
  .mt5-terminal-clone-root h1 {
    font-size: 27px !important;
  }

  .qv3-clone-root h2,
  .qv3-clone-root h3,
  .qv3-clone-root .setup-card-title,
  .qv8-clone-root h2,
  .qv8-clone-root h3,
  .qv8-clone-root .setup-card-title,
  .ats-v2-clone-root h2,
  .ats-v2-clone-root h3,
  .ats-v2-clone-root .setup-card-title,
  .mt5-optimizer-clone-root h2,
  .mt5-optimizer-clone-root h3,
  .mt5-optimizer-clone-root .setup-card-title {
    font-size: 17px !important;
  }
}

/* Mobile optimizer usability pass. Keeps legacy engines intact, but stops the
   copied optimizers from rendering as compressed desktop dashboards. */
@media (max-width: 760px) {
  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root {
    --studio-mobile-gap: 10px;
    overflow-x: clip !important;
  }

  .qv3-clone-root .app,
  .qv3-clone-root .app-shell,
  .qv8-clone-root .app,
  .qv8-clone-root .app-shell,
  .ats-v2-clone-root .app,
  .ats-v2-clone-root .app-shell,
  .mt5-optimizer-clone-root .app,
  .mt5-optimizer-clone-root .app-shell,
  .mt5-optimizer-clone-root #mt5OptimizerReactRoot,
  .mt5-optimizer-clone-root main,
  .mt5-optimizer-clone-root [class*="content"],
  .mt5-optimizer-clone-root [class*="layout"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-inline: 0 !important;
    overflow-x: clip !important;
  }

  .qv3-clone-root h1,
  .qv8-clone-root h1,
  .ats-v2-clone-root h1,
  .mt5-optimizer-clone-root h1 {
    font-size: 22px !important;
    line-height: 1.08 !important;
  }

  .qv3-clone-root h2,
  .qv3-clone-root h3,
  .qv3-clone-root .setup-card-title,
  .qv8-clone-root h2,
  .qv8-clone-root h3,
  .qv8-clone-root .setup-card-title,
  .ats-v2-clone-root h2,
  .ats-v2-clone-root h3,
  .ats-v2-clone-root .setup-card-title,
  .mt5-optimizer-clone-root h2,
  .mt5-optimizer-clone-root h3,
  .mt5-optimizer-clone-root .setup-card-title {
    font-size: 17px !important;
    line-height: 1.18 !important;
  }

  .qv3-clone-root .panel,
  .qv3-clone-root .setup-card,
  .qv3-clone-root .key-section,
  .qv3-clone-root .params-summary-kpi,
  .qv3-clone-root .ai-top-card,
  .qv3-clone-root .kpi,
  .qv8-clone-root .panel,
  .qv8-clone-root .setup-card,
  .qv8-clone-root .side-bounds-card,
  .qv8-clone-root .results-shell,
  .qv8-clone-root .kpi,
  .ats-v2-clone-root .panel,
  .ats-v2-clone-root .setup-card,
  .ats-v2-clone-root .key-section,
  .ats-v2-clone-root .params-summary-kpi,
  .ats-v2-clone-root .ai-top-card,
  .ats-v2-clone-root .kpi,
  .mt5-optimizer-clone-root .panel,
  .mt5-optimizer-clone-root .setup-card,
  .mt5-optimizer-clone-root .side-bounds-card,
  .mt5-optimizer-clone-root .results-shell,
  .mt5-optimizer-clone-root .kpi {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline: 0 !important;
    padding: 14px !important;
    border-radius: 16px !important;
  }

  .qv3-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .ai-top-grid, .results-kpis, .ai-kpis, .best-result-hero, .best-result-main, .best-result-metrics, .best-result-actions, .results-head, .results-actions, .result-grid, .apply-toolbar, .filter-row, .params-summary-strip, .robust-basket-inline),
  .qv8-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .results-kpis, .results-head, .results-actions, .filter-row, .ranges-grid, .compact-ranges),
  .ats-v2-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .ai-top-grid, .results-kpis, .ai-kpis, .best-result-hero, .best-result-main, .best-result-metrics, .best-result-actions, .results-head, .results-actions, .filter-row, .params-summary-strip, .robust-basket-inline),
  .mt5-optimizer-clone-root :is(.setup-grid, .params-panel-grid, .setup-fields, .setup-fields-3, .setup-fields-4, .setup-fields-5, .results-kpis, .results-head, .results-actions, .filter-row, .ranges-grid, .compact-ranges, .stack-card) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: var(--studio-mobile-gap) !important;
  }

  .qv3-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .qv8-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .ats-v2-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
  .mt5-optimizer-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
  }

  .qv3-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .qv8-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .ats-v2-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .mt5-optimizer-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs) {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    padding: 4px 2px 10px !important;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .qv3-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .qv8-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .ats-v2-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .mt5-optimizer-clone-root :is(.studio-module-steps, .params-toolbar, .chips, .tabs, .segmented, .result-tabs) > * {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    max-width: none !important;
    scroll-snap-align: start;
  }

  .qv3-clone-root button,
  .qv8-clone-root button,
  .ats-v2-clone-root button,
  .mt5-optimizer-clone-root button {
    min-height: 44px !important;
    padding-inline: 13px !important;
    border-radius: 12px !important;
    font-size: 14px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
  }

  .qv3-clone-root :is(.control-actions, .runbar-left, .runbar-right, .results-actions, .best-result-actions, .params-actions) button,
  .qv8-clone-root :is(.control-actions, .runbar-left, .runbar-right, .results-actions, .best-result-actions, .params-actions) button,
  .ats-v2-clone-root :is(.control-actions, .runbar-left, .runbar-right, .results-actions, .best-result-actions, .params-actions) button,
  .mt5-optimizer-clone-root :is(.control-actions, .runbar-left, .runbar-right, .results-actions, .best-result-actions, .params-actions) button {
    width: 100% !important;
    justify-content: center !important;
  }

  .qv3-clone-root input:not([type="checkbox"]):not([type="radio"]),
  .qv3-clone-root select,
  .qv3-clone-root textarea,
  .qv8-clone-root input:not([type="checkbox"]):not([type="radio"]),
  .qv8-clone-root select,
  .qv8-clone-root textarea,
  .ats-v2-clone-root input:not([type="checkbox"]):not([type="radio"]),
  .ats-v2-clone-root select,
  .ats-v2-clone-root textarea,
  .mt5-optimizer-clone-root input:not([type="checkbox"]):not([type="radio"]),
  .mt5-optimizer-clone-root select,
  .mt5-optimizer-clone-root textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 44px !important;
    padding-inline: 12px !important;
    font-size: 15px !important;
    border-radius: 12px !important;
  }

  .qv3-clone-root input[type="checkbox"],
  .qv3-clone-root input[type="radio"],
  .qv8-clone-root input[type="checkbox"],
  .qv8-clone-root input[type="radio"],
  .ats-v2-clone-root input[type="checkbox"],
  .ats-v2-clone-root input[type="radio"],
  .mt5-optimizer-clone-root input[type="checkbox"],
  .mt5-optimizer-clone-root input[type="radio"] {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
  }

  .qv3-clone-root :is(.field, label),
  .qv8-clone-root :is(.field, label),
  .ats-v2-clone-root :is(.field, label),
  .mt5-optimizer-clone-root :is(.field, label) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .qv3-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .qv8-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .ats-v2-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
  .mt5-optimizer-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
    min-height: 48px !important;
    padding: 10px 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    background: var(--surface-muted) !important;
  }

  .qv3-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) input,
  .qv8-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) input,
  .ats-v2-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) input,
  .mt5-optimizer-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) input {
    justify-self: end !important;
  }

  .qv3-clone-root .table-wrap,
  .qv3-clone-root .results-table-wrap,
  .qv8-clone-root .table-wrap,
  .qv8-clone-root .results-table-wrap,
  .ats-v2-clone-root .table-wrap,
  .ats-v2-clone-root .results-table-wrap,
  .mt5-optimizer-clone-root .table-wrap,
  .mt5-optimizer-clone-root .results-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    padding: 0 !important;
    border-radius: 16px !important;
    box-shadow: inset -20px 0 22px -24px var(--text-muted) !important;
    -webkit-overflow-scrolling: touch;
  }

  .qv8-clone-root table,
  .ats-v2-clone-root table,
  .mt5-optimizer-clone-root table,
  .qv3-clone-root .results-table-wrap table,
  .qv3-clone-root .apply-wrap table {
    min-width: 760px !important;
  }

  .qv3-clone-root .table-wrap.table-keys,
  .ats-v2-clone-root .table-wrap.table-keys {
    overflow-x: visible !important;
    box-shadow: none !important;
  }

  .qv3-clone-root .keys-section-table,
  .ats-v2-clone-root .keys-section-table {
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 10px !important;
  }

  .qv3-clone-root .keys-section-table thead,
  .ats-v2-clone-root .keys-section-table thead {
    display: none !important;
  }

  .qv3-clone-root .keys-section-table tbody,
  .qv3-clone-root .keys-section-table tr,
  .qv3-clone-root .keys-section-table td,
  .ats-v2-clone-root .keys-section-table tbody,
  .ats-v2-clone-root .keys-section-table tr,
  .ats-v2-clone-root .keys-section-table td {
    width: 100% !important;
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row),
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    background: var(--surface-muted) !important;
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td {
    display: grid !important;
    grid-template-columns: minmax(86px, 0.42fr) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td::before {
    color: var(--text-subtle) !important;
    font-size: 12px !important;
    font-weight: 760 !important;
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(1)::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(1)::before {
    content: "Parameter";
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(2)::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(2)::before {
    content: "Value";
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(3)::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(3)::before {
    content: "Min";
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(4)::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(4)::before {
    content: "Max";
  }

  .qv3-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(5)::before,
  .ats-v2-clone-root .keys-section-table tr:not(.section-row):not(.subsection-label-row) td:nth-child(5)::before {
    content: "Step";
  }

  .qv8-clone-root .range-head-row,
  .ats-v2-clone-root .range-head-row,
  .mt5-optimizer-clone-root .range-head-row {
    display: none !important;
  }

  .qv8-clone-root .range-row,
  .ats-v2-clone-root .range-row,
  .mt5-optimizer-clone-root .range-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 8px !important;
    padding: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    background: var(--surface-muted) !important;
  }

  .qv8-clone-root .range-row > *,
  .ats-v2-clone-root .range-row > *,
  .mt5-optimizer-clone-root .range-row > *,
  .qv8-clone-root .range-row .param-label,
  .ats-v2-clone-root .range-row .param-label,
  .mt5-optimizer-clone-root .range-row .param-label,
  .qv8-clone-root .range-row .kind-control,
  .ats-v2-clone-root .range-row .kind-control,
  .mt5-optimizer-clone-root .range-row .kind-control,
  .qv8-clone-root .range-row .min-control,
  .qv8-clone-root .range-row .max-control,
  .qv8-clone-root .range-row .step-control,
  .ats-v2-clone-root .range-row .min-control,
  .ats-v2-clone-root .range-row .max-control,
  .ats-v2-clone-root .range-row .step-control,
  .mt5-optimizer-clone-root .range-row .min-control,
  .mt5-optimizer-clone-root .range-row .max-control,
  .mt5-optimizer-clone-root .range-row .step-control {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
}

/* Mobile usability pass for cloned engines and live charts. */
@media (max-width: 680px) {
  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root,
  .mt5-terminal-clone-root,
  .studio-tv-chart,
  .studio-trading-chart-mount {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  .studio-module-shell {
    gap: 18px !important;
  }

  .studio-module-header,
  .studio-module-title,
  .studio-module-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .studio-module-title h1 {
    font-size: 23px !important;
    line-height: 1.1 !important;
  }

  .studio-module-scope {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px !important;
    min-height: 66px !important;
    padding: 14px 16px !important;
  }

  .studio-module-steps,
  .qv3-clone-root .studio-module-steps,
  .qv8-clone-root .studio-module-steps,
  .ats-v2-clone-root .studio-module-steps,
  .mt5-optimizer-clone-root .studio-module-steps {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 0 12px !important;
    overflow: visible !important;
    border-bottom: 1px solid var(--border) !important;
  }

  .studio-module-steps a,
  .studio-module-steps span,
  .qv3-clone-root .studio-module-steps > *,
  .qv8-clone-root .studio-module-steps > *,
  .ats-v2-clone-root .studio-module-steps > *,
  .mt5-optimizer-clone-root .studio-module-steps > * {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    justify-content: center !important;
    padding-inline: 10px !important;
    white-space: normal !important;
    text-align: center !important;
    line-height: 1.15 !important;
  }

  .qv3-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .qv8-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .ats-v2-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs),
  .mt5-optimizer-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs) {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  .qv3-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .qv8-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .ats-v2-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs) > *,
  .mt5-optimizer-clone-root :is(.params-toolbar, .chips, .tabs, .segmented, .result-tabs) > * {
    flex: 1 1 calc(50% - 8px) !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .qv3-clone-root :is(.panel, .setup-card, .key-section, .params-summary-kpi, .ai-top-card, .kpi, .table-wrap),
  .qv8-clone-root :is(.panel, .setup-card, .side-bounds-card, .results-shell, .kpi, .table-wrap),
  .ats-v2-clone-root :is(.panel, .setup-card, .key-section, .params-summary-kpi, .ai-top-card, .kpi, .table-wrap),
  .mt5-optimizer-clone-root :is(.panel, .setup-card, .side-bounds-card, .results-shell, .kpi, .table-wrap) {
    margin-bottom: 14px !important;
    padding: 15px !important;
    border-radius: 18px !important;
  }

  .qv3-clone-root details:is(.panel, .setup-card),
  .qv8-clone-root details:is(.panel, .setup-card),
  .ats-v2-clone-root details:is(.panel, .setup-card),
  .mt5-optimizer-clone-root details:is(.panel, .setup-card) {
    padding: 0 !important;
  }

  .qv3-clone-root details > summary,
  .qv8-clone-root details > summary,
  .ats-v2-clone-root details > summary,
  .mt5-optimizer-clone-root details > summary {
    min-height: 60px !important;
    padding: 16px !important;
    align-items: center !important;
    gap: 10px !important;
    line-height: 1.25 !important;
  }

  .qv3-clone-root button,
  .qv8-clone-root button,
  .ats-v2-clone-root button,
  .mt5-optimizer-clone-root button,
  .mt5-terminal-clone-root button {
    min-height: 44px !important;
    border-radius: 13px !important;
    font-size: 14px !important;
    line-height: 1.15 !important;
    white-space: normal !important;
  }

  .qv3-clone-root :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .qv8-clone-root :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .ats-v2-clone-root :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .mt5-optimizer-clone-root :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .mt5-terminal-clone-root :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: 46px !important;
    border-radius: 13px !important;
    font-size: 15px !important;
  }

  .studio-tv-chart {
    display: grid !important;
    gap: 12px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .studio-tv-toolbar,
  .studio-tv-applybar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px !important;
    padding: 12px !important;
    overflow: visible !important;
  }

  .studio-tv-toolbar select[aria-label="Symbol"],
  .studio-tv-toolbar .studio-tv-quick-tfs,
  .studio-tv-toolbar .studio-tv-layout-label,
  .studio-tv-applybar select[aria-label="Apply"],
  .studio-tv-applybar .studio-tv-apply-status,
  .studio-tv-applybar .studio-tv-apply-warning {
    grid-column: 1 / -1 !important;
  }

  .studio-tv-quick-tfs {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 7px !important;
    overflow: visible !important;
  }

  .studio-tv-toolbar button,
  .studio-tv-toolbar select,
  .studio-tv-applybar select,
  .studio-tv-all-applies {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    border-radius: 13px !important;
  }

  .studio-tv-chart-host {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .studio-tv-native-mini,
  .studio-tv-native-mini > *,
  .studio-tv-chart-host > * {
    max-width: 100% !important;
  }

  .mt5-terminal-clone-root :is(header, nav, [class*="toolbar" i], [class*="header" i], [class*="controls" i]) {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .mt5-terminal-clone-root :is([class*="toolbar" i], [class*="controls" i]) {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .mt5-terminal-clone-root :is([class*="toolbar" i], [class*="controls" i]) > * {
    min-width: 0 !important;
  }

  .mt5-terminal-clone-root .studio-mt5-status-muted,
  .mt5-terminal-clone-root [data-studio-hidden-badge="1"] {
    display: none !important;
  }

  .mt5-terminal-clone-root table.mobile-card-table,
  .studio-tv-chart table.mobile-card-table {
    border-spacing: 0 10px !important;
  }

  .qv3-clone-root :is(.panel, .setup-card, .key-section, .params-summary-kpi, .ai-top-card, .kpi, .table-wrap),
  .qv8-clone-root :is(.panel, .setup-card, .side-bounds-card, .results-shell, .kpi, .table-wrap),
  .ats-v2-clone-root :is(.panel, .setup-card, .key-section, .params-summary-kpi, .ai-top-card, .kpi, .table-wrap),
  .mt5-optimizer-clone-root :is(.panel, .setup-card, .side-bounds-card, .results-shell, .kpi, .table-wrap) {
    background: color-mix(in srgb, var(--surface) 92%, var(--bg) 8%) !important;
    border-color: color-mix(in srgb, var(--border) 86%, transparent) !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16) !important;
  }

  .qv3-clone-root details > summary,
  .qv8-clone-root details > summary,
  .ats-v2-clone-root details > summary,
  .mt5-optimizer-clone-root details > summary {
    background: color-mix(in srgb, var(--surface-muted) 82%, transparent) !important;
    border-radius: 16px !important;
  }

  .qv3-clone-root details[open] > summary,
  .qv8-clone-root details[open] > summary,
  .ats-v2-clone-root details[open] > summary,
  .mt5-optimizer-clone-root details[open] > summary {
    margin-bottom: 12px !important;
  }

  .qv3-clone-root :is(.grid, .form-grid, .bounds-grid, .params-grid, .range-grid),
  .qv8-clone-root :is(.grid, .form-grid, .bounds-grid, .params-grid, .range-grid),
  .ats-v2-clone-root :is(.grid, .form-grid, .bounds-grid, .params-grid, .range-grid),
  .mt5-optimizer-clone-root :is(.grid, .form-grid, .bounds-grid, .params-grid, .range-grid) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .qv3-clone-root label,
  .qv8-clone-root label,
  .ats-v2-clone-root label,
  .mt5-optimizer-clone-root label,
  .mt5-terminal-clone-root label {
    line-height: 1.35 !important;
  }

  .qv3-clone-root :is(input[type="checkbox"], input[type="radio"]),
  .qv8-clone-root :is(input[type="checkbox"], input[type="radio"]),
  .ats-v2-clone-root :is(input[type="checkbox"], input[type="radio"]),
  .mt5-optimizer-clone-root :is(input[type="checkbox"], input[type="radio"]),
  .mt5-terminal-clone-root :is(input[type="checkbox"], input[type="radio"]) {
    min-width: 24px !important;
    width: 24px !important;
    min-height: 24px !important;
    height: 24px !important;
  }

  .studio-tv-chart table.mobile-card-table,
  .studio-tv-chart table.data-table,
  .mt5-terminal-clone-root table.mobile-card-table,
  .mt5-terminal-clone-root table.data-table {
    border-spacing: 0 12px !important;
  }
}

/* Absolute last pass: keep optimizer modules flat after every mobile override. */
.studio-module-shell:has(.qv3-clone-root),
.studio-module-shell:has(.qv8-clone-root),
.studio-module-shell:has(.ats-v2-clone-root),
.studio-module-shell:has(.mt5-optimizer-clone-root) {
  gap: 16px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
}

.studio-module-shell:has(.qv3-clone-root) .studio-module-content,
.studio-module-shell:has(.qv8-clone-root) .studio-module-content,
.studio-module-shell:has(.ats-v2-clone-root) .studio-module-content,
.studio-module-shell:has(.mt5-optimizer-clone-root) .studio-module-content {
  overflow-x: clip !important;
}

.qv3-clone-root,
.qv8-clone-root,
.ats-v2-clone-root,
.mt5-optimizer-clone-root {
  --optimizer-section-bg: color-mix(in srgb, var(--surface) 96%, var(--bg) 4%);
  --optimizer-inner-bg: color-mix(in srgb, var(--surface-muted) 45%, transparent);
  --optimizer-inner-border: color-mix(in srgb, var(--border) 72%, transparent);
}

.qv3-clone-root :is(.panel, details.panel, details.panel-accordion),
.qv8-clone-root :is(.panel, details.panel, details.panel-accordion),
.ats-v2-clone-root :is(.panel, details.panel, details.panel-accordion),
.mt5-optimizer-clone-root :is(.panel, details.panel, details.panel-accordion) {
  border: 1px solid var(--border) !important;
  border-radius: 16px !important;
  background: var(--optimizer-section-bg) !important;
  background-color: var(--optimizer-section-bg) !important;
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.qv3-clone-root details:is(.panel, .setup-card, .panel-accordion),
.qv8-clone-root details:is(.panel, .setup-card, .panel-accordion),
.ats-v2-clone-root details:is(.panel, .setup-card, .panel-accordion),
.mt5-optimizer-clone-root details:is(.panel, .setup-card, .panel-accordion) {
  overflow: hidden !important;
  padding: 0 !important;
}

.qv3-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
.qv8-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
.ats-v2-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
.mt5-optimizer-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary {
  margin: 0 !important;
  min-height: 52px !important;
  padding: 14px 16px !important;
  border-radius: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.qv3-clone-root details:is(.panel, .setup-card, .panel-accordion)[open] > summary,
.qv8-clone-root details:is(.panel, .setup-card, .panel-accordion)[open] > summary,
.ats-v2-clone-root details:is(.panel, .setup-card, .panel-accordion)[open] > summary,
.mt5-optimizer-clone-root details:is(.panel, .setup-card, .panel-accordion)[open] > summary {
  margin-bottom: 0 !important;
  border-bottom: 1px solid var(--optimizer-inner-border) !important;
}

.qv3-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
.qv8-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
.ats-v2-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
.mt5-optimizer-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi, .stack-card) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  margin: 0 !important;
  padding: 10px 0 !important;
}

.qv3-clone-root :is(.field-hint, .field-note, .helper, .help, .note, .tiny.muted),
.qv8-clone-root :is(.field-hint, .field-note, .helper, .help, .note, .tiny.muted),
.ats-v2-clone-root :is(.field-hint, .field-note, .helper, .help, .note, .tiny.muted),
.mt5-optimizer-clone-root :is(.field-hint, .field-note, .helper, .help, .note, .tiny.muted) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 2px 0 !important;
}

.qv3-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
.qv8-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
.ats-v2-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline),
.mt5-optimizer-clone-root :is(.field-check, .params-toggle-inline, .ai-toggle-inline) {
  border: 0 !important;
  border-bottom: 1px solid var(--optimizer-inner-border) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 10px 0 !important;
}

.qv3-clone-root :is(.ai-hero, .workflow-current, .flow-step, .ai-status-card),
.qv8-clone-root :is(.ai-hero, .workflow-current, .flow-step, .ai-status-card),
.ats-v2-clone-root :is(.ai-hero, .workflow-current, .flow-step, .ai-status-card),
.mt5-optimizer-clone-root :is(.ai-hero, .workflow-current, .flow-step, .ai-status-card) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 8px 0 !important;
}

.qv3-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
.qv8-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
.ats-v2-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions),
.mt5-optimizer-clone-root :is(.runbar, .runbar-left, .runbar-center, .runbar-right, .control-actions, .control-status, .params-actions) {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.qv3-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.qv8-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.ats-v2-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.mt5-optimizer-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap) {
  border: 1px solid var(--optimizer-inner-border) !important;
  border-radius: 12px !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: auto !important;
}

.qv3-clone-root :is(.results-kpis, .ai-kpis, .best-result-metrics) > :is(.kpi, .ai-kpi, .params-summary-kpi),
.qv8-clone-root :is(.results-kpis, .ai-kpis, .best-result-metrics) > :is(.kpi, .ai-kpi, .params-summary-kpi),
.ats-v2-clone-root :is(.results-kpis, .ai-kpis, .best-result-metrics) > :is(.kpi, .ai-kpi, .params-summary-kpi),
.mt5-optimizer-clone-root :is(.results-kpis, .ai-kpis, .best-result-metrics) > :is(.kpi, .ai-kpi, .params-summary-kpi) {
  border: 1px solid var(--optimizer-inner-border) !important;
  border-radius: 12px !important;
  background: var(--optimizer-inner-bg) !important;
  box-shadow: none !important;
  padding: 10px 12px !important;
}

@media (max-width: 760px) {
  .qv3-clone-root :is(.panel, details.panel, details.panel-accordion),
  .qv8-clone-root :is(.panel, details.panel, details.panel-accordion),
  .ats-v2-clone-root :is(.panel, details.panel, details.panel-accordion),
  .mt5-optimizer-clone-root :is(.panel, details.panel, details.panel-accordion) {
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  .qv3-clone-root .panel:not(details),
  .qv8-clone-root .panel:not(details),
  .ats-v2-clone-root .panel:not(details),
  .mt5-optimizer-clone-root .panel:not(details) {
    padding: 14px !important;
  }

  .qv3-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .qv8-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .ats-v2-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .mt5-optimizer-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary {
    min-height: 54px !important;
    padding: 14px !important;
  }

  .qv3-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
  .qv8-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
  .ats-v2-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi),
  .mt5-optimizer-clone-root :is(.panel, .panel-accordion-body) :is(.setup-card, .key-section, .params-summary-kpi, .ai-top-card, .side-bounds-card, .results-shell, .best-result-hero, .result-card, .ai-kpi, .kpi, .stack-card) {
    padding: 9px 0 !important;
    margin-bottom: 0 !important;
  }
}

/* Absolute last typography pass for optimizer clones. */
.qv3-clone-root,
.qv8-clone-root,
.ats-v2-clone-root,
.mt5-optimizer-clone-root {
  --optimizer-type-page: 28px;
  --optimizer-type-section: 18px;
  --optimizer-type-card: 16px;
  --optimizer-type-body: 14px;
  --optimizer-type-control: 14px;
  --optimizer-type-table: 13px;
  --optimizer-type-meta: 12px;
  font-family: var(--font-sans) !important;
  font-size: var(--optimizer-type-body) !important;
  line-height: 1.42 !important;
}

.qv3-clone-root *,
.qv8-clone-root *,
.ats-v2-clone-root *,
.mt5-optimizer-clone-root * {
  font-family: var(--font-sans) !important;
  letter-spacing: 0 !important;
}

.qv3-clone-root :is(h1, .page-title, .hero-title),
.qv8-clone-root :is(h1, .page-title, .hero-title),
.ats-v2-clone-root :is(h1, .page-title, .hero-title),
.mt5-optimizer-clone-root :is(h1, .page-title, .hero-title) {
  font-size: var(--optimizer-type-page) !important;
  line-height: 1.08 !important;
  font-weight: 800 !important;
}

.qv3-clone-root :is(h2, .panel-title),
.qv8-clone-root :is(h2, .panel-title),
.ats-v2-clone-root :is(h2, .panel-title),
.mt5-optimizer-clone-root :is(h2, .panel-title) {
  font-size: var(--optimizer-type-section) !important;
  line-height: 1.18 !important;
  font-weight: 780 !important;
}

.qv3-clone-root :is(h3, h4, .setup-card-title, .section-title, .results-title, .ai-headline),
.qv8-clone-root :is(h3, h4, .setup-card-title, .section-title, .results-title, .ai-headline),
.ats-v2-clone-root :is(h3, h4, .setup-card-title, .section-title, .results-title, .ai-headline),
.mt5-optimizer-clone-root :is(h3, h4, .setup-card-title, .section-title, .results-title, .ai-headline) {
  font-size: var(--optimizer-type-card) !important;
  line-height: 1.22 !important;
  font-weight: 760 !important;
}

.qv3-clone-root :is(p, div, span, label, li),
.qv8-clone-root :is(p, div, span, label, li),
.ats-v2-clone-root :is(p, div, span, label, li),
.mt5-optimizer-clone-root :is(p, div, span, label, li) {
  font-size: inherit !important;
}

.qv3-clone-root :is(.field label, label.field, .field-label, .param-label, .range-label, .form-label),
.qv8-clone-root :is(.field label, label.field, .field-label, .param-label, .range-label, .form-label),
.ats-v2-clone-root :is(.field label, label.field, .field-label, .param-label, .range-label, .form-label),
.mt5-optimizer-clone-root :is(.field label, label.field, .field-label, .param-label, .range-label, .form-label) {
  font-size: var(--optimizer-type-table) !important;
  line-height: 1.3 !important;
  font-weight: 700 !important;
}

.qv3-clone-root :is(button, input, select, textarea, .btn, .ghost, .primary, .chip, .pill, .tab, .params-filter-btn, .segment-on),
.qv8-clone-root :is(button, input, select, textarea, .btn, .ghost, .primary, .chip, .pill, .tab, .params-filter-btn, .segment-on),
.ats-v2-clone-root :is(button, input, select, textarea, .btn, .ghost, .primary, .chip, .pill, .tab, .params-filter-btn, .segment-on),
.mt5-optimizer-clone-root :is(button, input, select, textarea, .btn, .ghost, .primary, .chip, .pill, .tab, .params-filter-btn, .segment-on) {
  font-size: var(--optimizer-type-control) !important;
  line-height: 1.2 !important;
}

.qv3-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle, .help, .helper, .note, .ai-badge, .ai-phase-node, .state-pill, .metric-label, .kpi span, .range-head, th, .table-head),
.qv8-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle, .help, .helper, .note, .ai-badge, .ai-phase-node, .state-pill, .metric-label, .kpi span, .range-head, th, .table-head),
.ats-v2-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle, .help, .helper, .note, .ai-badge, .ai-phase-node, .state-pill, .metric-label, .kpi span, .range-head, th, .table-head),
.mt5-optimizer-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle, .help, .helper, .note, .ai-badge, .ai-phase-node, .state-pill, .metric-label, .kpi span, .range-head, th, .table-head) {
  font-size: var(--optimizer-type-meta) !important;
  line-height: 1.35 !important;
}

.qv3-clone-root :is(table, thead, tbody, tr, th, td, .mobile-card-table, .results-table, .keys-section-table),
.qv8-clone-root :is(table, thead, tbody, tr, th, td, .mobile-card-table, .results-table, .keys-section-table),
.ats-v2-clone-root :is(table, thead, tbody, tr, th, td, .mobile-card-table, .results-table, .keys-section-table),
.mt5-optimizer-clone-root :is(table, thead, tbody, tr, th, td, .mobile-card-table, .results-table, .keys-section-table) {
  font-size: var(--optimizer-type-table) !important;
  line-height: 1.32 !important;
}

.qv3-clone-root :is(.kpi strong, .kpi-value, .metric-value, .value, .result-value),
.qv8-clone-root :is(.kpi strong, .kpi-value, .metric-value, .value, .result-value),
.ats-v2-clone-root :is(.kpi strong, .kpi-value, .metric-value, .value, .result-value),
.mt5-optimizer-clone-root :is(.kpi strong, .kpi-value, .metric-value, .value, .result-value) {
  font-size: var(--optimizer-type-card) !important;
  line-height: 1.18 !important;
  font-weight: 780 !important;
}

.qv3-clone-root :is(.param-help, .range-head, .ai-phase-node, .ai-badge),
.qv8-clone-root :is(.param-help, .range-head, .ai-phase-node, .ai-badge),
.ats-v2-clone-root :is(.param-help, .range-head, .ai-phase-node, .ai-badge),
.mt5-optimizer-clone-root :is(.param-help, .range-head, .ai-phase-node, .ai-badge) {
  min-width: 18px !important;
  min-height: 18px !important;
  font-size: var(--optimizer-type-meta) !important;
}

@media (max-width: 760px) {
  .qv3-clone-root,
  .qv8-clone-root,
  .ats-v2-clone-root,
  .mt5-optimizer-clone-root {
    --optimizer-type-page: 22px;
    --optimizer-type-section: 17px;
    --optimizer-type-card: 15px;
    --optimizer-type-body: 14px;
    --optimizer-type-control: 14px;
    --optimizer-type-table: 13px;
    --optimizer-type-meta: 12px;
  }
}

/* Final readability and contrast pass across Studio. */
.page-head h1,
.studio-module-title h1,
.qv3-clone-root h1,
.qv8-clone-root h1,
.ats-v2-clone-root h1,
.mt5-optimizer-clone-root h1,
.mt5-terminal-clone-root h1 {
  line-height: 1.16 !important;
  padding-bottom: 1px !important;
}

.brand small,
.public-brand small,
.brand-row small,
.sidebar .brand small,
.topbar .brand small,
.table-sub,
.side-nav section > span,
.studio-module-scope span,
.qv3-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle),
.qv8-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle),
.ats-v2-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle),
.mt5-optimizer-clone-root :is(.muted, .tiny, small, .field-hint, .field-note, .panel-subtitle),
.studio-tv-apply-status,
.studio-tv-native-mini-empty,
.mt5-terminal-clone-root :is(small, [class*="muted"], .studio-mt5-status-muted) {
  color: color-mix(in srgb, var(--text-muted) 86%, var(--text) 14%) !important;
  font-size: 12px !important;
  line-height: 1.36 !important;
}

.side-nav section > span {
  font-weight: 850 !important;
  letter-spacing: 0.04em !important;
}

.status-badge,
.state-pill {
  min-height: 30px !important;
  padding-inline: 12px !important;
  border-width: 1px !important;
  font-size: 13px !important;
  font-weight: 800 !important;
}

.status-badge.status-info,
.state-pill.status-info {
  color: #3b167b !important;
  background: #efe7ff !important;
  border-color: #b996ff !important;
}

.status-badge.status-good,
.state-pill.status-good,
.mt5-terminal-clone-root .studio-mt5-status-ok {
  color: #047857 !important;
  background: #dff8ef !important;
  border-color: #7bd9ba !important;
}

.status-badge.status-bad,
.state-pill.status-bad {
  color: #be123c !important;
  background: #ffe4eb !important;
  border-color: #fb9bb2 !important;
}

.status-badge.status-neutral,
.state-pill.status-neutral {
  color: var(--text) !important;
  background: var(--surface-muted) !important;
  border-color: var(--border-strong) !important;
}

.mt5-terminal-clone-root .studio-mt5-status-warn,
.mt5-terminal-clone-root :is([class*="warn" i], [class*="delay" i]) {
  color: #8a4b00 !important;
  background: #fff4d6 !important;
  border-color: #f2bd57 !important;
}

.studio-tv-chart :is(.studio-tv-apply-status, .studio-tv-native-mini-empty),
.studio-trading-chart-mount :is(.studio-tv-apply-status, .studio-tv-native-mini-empty),
.qv3-chart-shell :is(.studio-tv-apply-status, .studio-tv-native-mini-empty) {
  color: color-mix(in srgb, var(--text-muted) 80%, var(--text) 20%) !important;
}

.studio-tv-chart :is(.studio-tv-toolbar, .studio-tv-applybar),
.studio-trading-chart-mount :is(.studio-tv-toolbar, .studio-tv-applybar),
.mt5-terminal-clone-root :is([class*="toolbar" i], [class*="controls" i]) {
  background: color-mix(in srgb, var(--surface) 92%, var(--bg) 8%) !important;
  border-color: var(--border) !important;
}

.studio-tv-chart select,
.studio-trading-chart-mount select,
.mt5-terminal-clone-root select,
.qv3-clone-root select,
.qv8-clone-root select,
.ats-v2-clone-root select,
.mt5-optimizer-clone-root select {
  text-overflow: ellipsis !important;
}

.qv3-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.qv8-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.ats-v2-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap),
.mt5-optimizer-clone-root :is(.table-wrap, .results-table-wrap, .apply-wrap) {
  scrollbar-color: color-mix(in srgb, var(--primary) 42%, var(--border)) transparent;
}

@media (max-width: 820px) {
  .mobile-nav-button {
    min-height: 44px !important;
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
    border-color: transparent !important;
    box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 24%, transparent) !important;
  }

  .mobile-nav-backdrop {
    z-index: 99970 !important;
  }

  body.mobile-nav-open .sidebar {
    z-index: 99990 !important;
  }

  .side-nav {
    z-index: 100000 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    grid-template-columns: none !important;
    grid-auto-flow: row !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body.mobile-nav-open .side-nav {
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .side-nav section > span {
    color: color-mix(in srgb, var(--text-muted) 82%, var(--text) 18%) !important;
    font-size: 12px !important;
  }

  .side-nav section {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-flow: row !important;
  }

  .side-nav a,
  .side-nav .nav-disabled {
    color: var(--text) !important;
    font-size: 14px !important;
    font-weight: 760 !important;
  }

  .side-nav a.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
    border-color: transparent !important;
  }

  .status-badge,
  .state-pill {
    min-height: 42px !important;
    font-size: 13px !important;
  }

  .brand small,
  .public-brand small {
    font-size: 12px !important;
  }

  table.mobile-card-table td::before,
  table.data-table td::before {
    color: color-mix(in srgb, var(--text-muted) 88%, var(--text) 12%) !important;
    font-size: 12px !important;
  }

  .mt5-terminal-clone-root :is([class*="toolbar" i], [class*="controls" i]) {
    background: color-mix(in srgb, var(--surface) 92%, var(--bg) 8%) !important;
  }

  body.mobile-nav-open :is(.studio-tv-toolbar, .studio-tv-applybar, .studio-tv-all-applies, .mt5-terminal-clone-root [class*="toolbar" i], .mt5-terminal-clone-root [class*="controls" i]) {
    z-index: auto !important;
  }

  .studio-trading-chart-mount :is(span, small, label, button, select, .studio-tv-apply-status),
  .studio-tv-chart :is(span, small, label, button, select, .studio-tv-apply-status),
  .qv3-chart-shell :is(span, small, label, button, select, .studio-tv-apply-status) {
    font-size: 12px !important;
    line-height: 1.32 !important;
  }

  .studio-tv-chart-host > div > div:first-child span {
    font-size: 12px !important;
    line-height: 1.32 !important;
  }
}

:root[data-theme="dark"] .status-badge.status-info,
:root[data-theme="dark"] .state-pill.status-info {
  color: #f6efff !important;
  background: #5b21b6 !important;
  border-color: #8b5cf6 !important;
}

:root[data-theme="dark"] .status-badge.status-good,
:root[data-theme="dark"] .state-pill.status-good,
:root[data-theme="dark"] .mt5-terminal-clone-root .studio-mt5-status-ok {
  color: #d1fae5 !important;
  background: #065f46 !important;
  border-color: #10b981 !important;
}

:root[data-theme="dark"] .status-badge.status-bad,
:root[data-theme="dark"] .state-pill.status-bad {
  color: #ffe4eb !important;
  background: #9f1239 !important;
  border-color: #fb7185 !important;
}

:root[data-theme="dark"] .mt5-terminal-clone-root .studio-mt5-status-warn,
:root[data-theme="dark"] .mt5-terminal-clone-root :is([class*="warn" i], [class*="delay" i]) {
  color: #ffedd5 !important;
  background: #92400e !important;
  border-color: #f59e0b !important;
}

/* Final compact mobile pass. */
@media (max-width: 680px) {
  body {
    font-size: 14px !important;
  }

  .sidebar {
    gap: 6px !important;
    padding: 6px 12px !important;
  }

  .sidebar .brand-row {
    grid-template-columns: 26px minmax(0, 1fr) auto !important;
    gap: 8px !important;
    min-height: 28px !important;
  }

  .sidebar .brand-mark {
    width: 26px !important;
    height: 26px !important;
    border-radius: 9px !important;
  }

  .sidebar .brand-row strong {
    font-size: 13px !important;
  }

  .sidebar .brand-row small {
    display: none !important;
  }

  .mobile-nav-button {
    min-height: 34px !important;
    padding: 0 10px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
  }

  .topbar,
  .chart-route-active .topbar {
    gap: 6px !important;
    padding: 7px 12px !important;
  }

  .topbar select,
  #projectSelect,
  .topbar :is(.primary, .ghost, .icon-button),
  .topbar .profile-menu button {
    min-height: 34px !important;
    height: 34px !important;
    border-radius: 11px !important;
    font-size: 12px !important;
  }

  .topbar .state-pill,
  .status-badge,
  .state-pill {
    min-height: 30px !important;
    padding: 0 9px !important;
    font-size: 12px !important;
  }

  .chart-route-active .topbar {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .chart-route-active .topbar :is(#topSaveButton, #topRunButton) {
    display: none !important;
  }

  .route-outlet,
  .chart-route-active .route-outlet {
    gap: 12px !important;
    padding: 12px !important;
  }

  .page-head,
  .studio-module-header {
    gap: 5px !important;
    margin: 0 !important;
  }

  .chart-route-active .page-head {
    display: none !important;
  }

  .page-head h1,
  .studio-module-title h1 {
    font-size: 22px !important;
    line-height: 1.1 !important;
  }

  .page-head p,
  .studio-module-title p {
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  .panel,
  .project-summary-panel,
  .strategy-product-card,
  .technical-details,
  .empty-state {
    border-radius: 14px !important;
  }

  .overview-grid,
  .report-grid {
    gap: 12px !important;
  }

  .panel-title {
    min-height: 48px !important;
    padding: 10px 12px !important;
  }

  .panel-title strong {
    font-size: 17px !important;
    line-height: 1.16 !important;
  }

  .project-summary {
    gap: 8px !important;
    padding: 12px !important;
  }

  .project-summary p {
    font-size: 14px !important;
    line-height: 1.35 !important;
  }

  .project-summary strong {
    font-size: 13px !important;
  }

  .fact-grid,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    padding: 10px !important;
  }

  .fact-grid div,
  .metric-strip article {
    min-height: 54px !important;
    gap: 3px !important;
    padding: 9px 10px !important;
    border-radius: 10px !important;
  }

  .fact-grid span,
  .metric-strip span {
    font-size: 10px !important;
    line-height: 1.1 !important;
  }

  .fact-grid strong,
  .metric-strip strong {
    font-size: 14px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }

  .action-row,
  .row-actions {
    gap: 8px !important;
  }

  .action-row > *,
  .row-actions > * {
    min-height: 38px !important;
    font-size: 12px !important;
  }

  .studio-tv-chart {
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .studio-tv-toolbar,
  .studio-tv-applybar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline: 0 !important;
    padding: 8px !important;
    border-radius: 14px !important;
    box-sizing: border-box !important;
  }

  .studio-tv-toolbar select,
  .studio-tv-toolbar button,
  .studio-tv-applybar select,
  .studio-tv-all-applies {
    min-height: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
  }

  .studio-tv-toolbar select[aria-label="Symbol"],
  .studio-tv-applybar select[aria-label="Apply"] {
    flex: 1 0 100% !important;
    width: 100% !important;
  }

  .studio-tv-quick-tfs {
    display: flex !important;
    flex: 1 0 100% !important;
    grid-template-columns: none !important;
    gap: 5px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 2px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .studio-tv-quick-tfs::-webkit-scrollbar {
    display: none;
  }

  .studio-tv-quick-tfs button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 44px !important;
    padding-inline: 10px !important;
  }

  .studio-tv-toolbar > select:not([aria-label="Symbol"]) {
    flex: 1 1 calc(33.333% - 6px) !important;
    width: auto !important;
    min-width: 0 !important;
  }

  .studio-tv-all-applies {
    flex: 0 1 auto !important;
    width: auto !important;
    min-width: 116px !important;
  }

  .studio-tv-apply-status {
    display: none !important;
  }

  .studio-tv-chart-host > div > div:first-child {
    padding: 7px 9px !important;
  }

  .studio-tv-chart-host,
  .studio-tv-native-mini {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline: 0 !important;
    box-sizing: border-box !important;
  }

  .studio-tv-chart-host > div > div:first-child span {
    font-size: 11px !important;
    line-height: 1.22 !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) {
    --optimizer-type-page: 20px;
    --optimizer-type-section: 15px;
    --optimizer-type-card: 13px;
    --optimizer-type-body: 12px;
    --optimizer-type-control: 12px;
    --optimizer-type-table: 11px;
    --optimizer-type-meta: 10px;
  }

  .studio-module-shell {
    gap: 10px !important;
  }

  .studio-module-scope {
    min-height: 0 !important;
    padding: 9px 10px !important;
    border-radius: 12px !important;
  }

  .studio-module-steps,
  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps {
    display: flex !important;
    flex-wrap: nowrap !important;
    grid-template-columns: none !important;
    gap: 6px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 0 6px !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .studio-module-steps::-webkit-scrollbar {
    display: none;
  }

  .studio-module-steps > *,
  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps > * {
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 32px !important;
    padding: 0 10px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }

  .studio-module-shell .studio-module-steps > a,
  .studio-module-shell .studio-module-steps > span,
  .studio-module-shell .studio-module-steps > button,
  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps > a,
  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps > span,
  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps > button {
    flex: 0 0 auto !important;
    width: max-content !important;
    min-width: max-content !important;
    max-width: none !important;
  }

  .studio-module-shell .studio-module-steps > a,
  .studio-module-shell .studio-module-steps > span,
  .studio-module-shell .studio-module-steps > button {
    min-height: 32px !important;
    height: 32px !important;
    padding: 0 9px !important;
    border-radius: 9px !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) :is(.panel, details.panel, details.panel-accordion) {
    margin-bottom: 10px !important;
    border-radius: 12px !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .panel:not(details) {
    padding: 10px !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) details:is(.panel, .setup-card, .panel-accordion) > summary {
    min-height: 42px !important;
    padding: 10px 12px !important;
  }

  .qv3-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .qv8-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .ats-v2-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary,
  .mt5-optimizer-clone-root details:is(.panel, .setup-card, .panel-accordion) > summary {
    min-height: 40px !important;
    padding: 8px 10px !important;
    font-size: 12px !important;
    line-height: 1.18 !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) :is(.panel-accordion-body, .setup-grid, .setup-fields, .form-grid, .params-grid, .bounds-grid, .range-grid) {
    gap: 8px !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) :is(.field, label) {
    gap: 3px !important;
    min-height: 0 !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root, .mt5-terminal-clone-root) :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: 34px !important;
    height: 34px !important;
    border-radius: 9px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
  }

  .qv3-clone-root :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .qv8-clone-root :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .ats-v2-clone-root :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .mt5-optimizer-clone-root :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .mt5-terminal-clone-root :is(button, input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: 32px !important;
    height: 32px !important;
    border-radius: 9px !important;
    padding: 0 8px !important;
    font-size: 11px !important;
    line-height: 1.18 !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root, .mt5-terminal-clone-root) textarea {
    height: auto !important;
    min-height: 72px !important;
    padding-top: 8px !important;
  }

  :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root, .mt5-terminal-clone-root) :is(input[type="checkbox"], input[type="radio"]) {
    min-width: 18px !important;
    width: 18px !important;
    min-height: 18px !important;
    height: 18px !important;
  }
}

/* Mobile type system reset: keep text scale symmetric across native Studio and cloned modules. */
@media (max-width: 680px) {
  body.app-route {
    --studio-mobile-type-title: 18px;
    --studio-mobile-type-section: 14px;
    --studio-mobile-type-body: 13px;
    --studio-mobile-type-control: 12px;
    --studio-mobile-type-meta: 10px;
    font-size: var(--studio-mobile-type-body) !important;
    line-height: 1.34 !important;
  }

  body.app-route :is(.topbar, .sidebar, .route-outlet, .page-head, .panel, .studio-module-shell, .studio-module-content, .studio-tv-chart, .studio-tv-chart-host, .qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root, .mt5-terminal-clone-root) {
    font-size: var(--studio-mobile-type-body) !important;
    line-height: 1.34 !important;
  }

  body.app-route :is(.page-head h1, .studio-module-title h1, .qv3-clone-root h1, .qv8-clone-root h1, .ats-v2-clone-root h1, .mt5-optimizer-clone-root h1, .mt5-terminal-clone-root h1) {
    font-size: var(--studio-mobile-type-title) !important;
    line-height: 1.14 !important;
    font-weight: 800 !important;
  }

  body.app-route :is(.panel-title strong, .studio-module-scope strong, .panel-summary-title, .setup-card-title, .section-title, .results-title, .qv3-clone-root h2, .qv3-clone-root h3, .qv3-clone-root h4, .qv8-clone-root h2, .qv8-clone-root h3, .qv8-clone-root h4, .ats-v2-clone-root h2, .ats-v2-clone-root h3, .ats-v2-clone-root h4, .mt5-optimizer-clone-root h2, .mt5-optimizer-clone-root h3, .mt5-optimizer-clone-root h4) {
    font-size: var(--studio-mobile-type-section) !important;
    line-height: 1.18 !important;
    font-weight: 760 !important;
  }

  body.app-route :is(p, li, dd, .project-summary p, .project-summary strong, .fact-grid strong, .metric-strip strong, .status-line, .empty-state, .studio-tv-chart-host span) {
    font-size: var(--studio-mobile-type-body) !important;
    line-height: 1.34 !important;
  }

  body.app-route :is(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) :is(.kpi strong, .metric-value, .value, .result-value, .result-card strong, .setup-card strong) {
    font-size: var(--studio-mobile-type-body) !important;
    line-height: 1.34 !important;
  }

  body.app-route :is(button, .primary, .ghost, .icon-button, input:not([type="checkbox"]):not([type="radio"]), select, textarea, .mobile-nav-button, .profile-menu button, .studio-tv-toolbar button, .studio-tv-toolbar select, .studio-tv-applybar select, .studio-tv-all-applies, .studio-module-steps > *) {
    font-size: var(--studio-mobile-type-control) !important;
    line-height: 1.18 !important;
    font-weight: 740 !important;
  }

  body.app-route :is(.pill, .chip, .tab, .state-pill, .status-badge, .ai-badge, .metric-label) {
    font-size: var(--studio-mobile-type-control) !important;
    line-height: 1.18 !important;
    font-weight: 740 !important;
  }

  body.app-route :is(.brand-row strong, .top-strategy strong) {
    font-size: var(--studio-mobile-type-body) !important;
    line-height: 1.1 !important;
  }

  body.app-route :is(small, label, .field label, .field-label, .param-label, .range-label, .form-label, .fact-grid span, .metric-strip span, .table-sub, .muted, .tiny, .field-hint, .field-note, .panel-subtitle, .studio-module-scope span, .status-badge, .state-pill, th, .table-head) {
    font-size: var(--studio-mobile-type-meta) !important;
    line-height: 1.22 !important;
  }

  body.app-route :is(select, input:not([type="checkbox"]):not([type="radio"])) {
    min-height: 32px !important;
    height: 32px !important;
    max-height: 32px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }
}

/* Final mobile shell repair: keep utility controls reachable and prevent clipped steps. */
@media (max-width: 680px) {
  body.app-route.mobile-nav-open {
    overflow: hidden !important;
  }

  body.app-route.mobile-nav-open .mobile-nav-backdrop {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: rgba(15, 23, 42, 0.62) !important;
    backdrop-filter: blur(4px) !important;
  }

  body.app-route.mobile-nav-open .side-nav {
    z-index: 100020 !important;
  }

  body.app-route .notifications-panel,
  body.app-route .profile-popover {
    z-index: 100030 !important;
  }

  body.app-route :is(.route-outlet, .page-head, .panel, .studio-module-shell, .studio-module-content, .studio-tv-chart, .studio-tv-chart-host) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.app-route .topbar,
  body.app-route.chart-route-active .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 38px 38px minmax(68px, 0.72fr) !important;
    grid-auto-rows: minmax(32px, auto) !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 12px 10px !important;
  }

  body.app-route .topbar #projectSelect,
  body.app-route.chart-route-active .topbar #projectSelect {
    display: block !important;
    grid-column: 1 / -1 !important;
    order: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 34px !important;
    max-height: 34px !important;
  }

  body.app-route .topbar .top-strategy,
  body.app-route.chart-route-active .topbar .top-strategy {
    display: none !important;
  }

  body.app-route .topbar .state-pill,
  body.app-route.chart-route-active .topbar .state-pill {
    display: inline-flex !important;
    grid-column: 1 !important;
    order: 3 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 32px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar .theme-toggle,
  body.app-route.chart-route-active .topbar .theme-toggle {
    display: inline-flex !important;
    grid-column: 2 !important;
    order: 3 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 32px !important;
    justify-content: center !important;
    padding: 0 !important;
  }

  body.app-route .topbar .theme-toggle .button-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar .notifications-menu,
  body.app-route.chart-route-active .topbar .notifications-menu {
    display: block !important;
    grid-column: 3 !important;
    order: 3 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body.app-route .topbar .notifications-menu .icon-button,
  body.app-route.chart-route-active .topbar .notifications-menu .icon-button {
    display: inline-flex !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 32px !important;
    padding: 0 !important;
    justify-content: center !important;
  }

  body.app-route .topbar .profile-menu,
  body.app-route.chart-route-active .topbar .profile-menu {
    display: block !important;
    grid-column: 4 !important;
    order: 3 !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  body.app-route .topbar .profile-menu button,
  body.app-route.chart-route-active .topbar .profile-menu button {
    width: 100% !important;
    min-width: 0 !important;
    height: 32px !important;
    padding: 0 8px !important;
    justify-content: center !important;
  }

  body.app-route .topbar .profile-menu .button-label,
  body.app-route.chart-route-active .topbar .profile-menu .button-label {
    min-width: 0 !important;
    max-width: 52px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar #topRunButton {
    display: inline-flex !important;
    grid-column: 1 / -1 !important;
    order: 4 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 34px !important;
    justify-content: center !important;
  }

  body.app-route.chart-route-active .topbar #topRunButton,
  body.app-route.chart-route-active .topbar #topSaveButton {
    display: none !important;
  }

  body.app-route .page-head,
  body.app-route.chart-route-active .page-head {
    display: grid !important;
    gap: 4px !important;
    padding: 0 !important;
    margin: 0 0 10px !important;
  }

  body.app-route.chart-route-active .page-head h1 {
    display: block !important;
    max-width: 100% !important;
  }

  body.app-route.chart-route-active .page-head p {
    display: block !important;
    max-width: 100% !important;
  }

  body.app-route .studio-module-steps,
  body.app-route :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 0 6px !important;
    margin: 0 !important;
    scroll-padding-inline: 12px !important;
    overscroll-behavior-x: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.app-route .studio-module-steps > *,
  body.app-route :where(.qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root) .studio-module-steps > * {
    flex: 0 0 auto !important;
    min-width: max-content !important;
    white-space: nowrap !important;
  }

  body.app-route.chart-route-active #studioTradingChartMount,
  body.app-route.chart-route-active .studio-tv-chart,
  body.app-route.chart-route-active .studio-tv-chart-host {
    min-height: 260px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host :is(canvas, svg) {
    max-width: 100% !important;
  }
}

@media (max-width: 380px) {
  body.app-route .topbar,
  body.app-route.chart-route-active .topbar {
    grid-template-columns: minmax(0, 1fr) 34px 34px 64px !important;
    gap: 5px !important;
    padding-inline: 10px !important;
  }

  body.app-route .topbar .theme-toggle,
  body.app-route.chart-route-active .topbar .theme-toggle,
  body.app-route .topbar .notifications-menu .icon-button,
  body.app-route.chart-route-active .topbar .notifications-menu .icon-button,
  body.app-route .topbar .profile-menu button,
  body.app-route.chart-route-active .topbar .profile-menu button,
  body.app-route .topbar .state-pill,
  body.app-route.chart-route-active .topbar .state-pill {
    height: 30px !important;
  }

  body.app-route .topbar .profile-menu .button-label,
  body.app-route.chart-route-active .topbar .profile-menu .button-label {
    max-width: 44px !important;
  }
}

/* Final typography discipline: one compact scale across Studio, clones and embedded chart. */
body.app-route {
  --studio-font-main: Inter, Geist, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --studio-type-xs: 12px;
  --studio-type-sm: 13px;
  --studio-type-md: 14px;
  --studio-type-lg: 16px;
  --studio-type-xl: 18px;
  --studio-type-title: 24px;
  --studio-line-tight: 1.16;
  --studio-line-base: 1.36;
  --studio-weight-normal: 500;
  --studio-weight-medium: 600;
  --studio-weight-strong: 700;
  font-family: var(--studio-font-main) !important;
  font-size: var(--studio-type-md) !important;
  font-weight: var(--studio-weight-normal) !important;
  line-height: var(--studio-line-base) !important;
  letter-spacing: 0 !important;
}

body.app-route :is(.topbar, .sidebar, .side-nav, .route-outlet, .page-head, .panel, .empty-state, .status-line, .data-table, .studio-module-shell, .studio-module-content, .studio-tv-chart, .qv3-clone-root, .qv8-clone-root, .ats-v2-clone-root, .mt5-optimizer-clone-root, .mt5-terminal-clone-root) {
  font-family: var(--studio-font-main) !important;
  font-size: var(--studio-type-md) !important;
  font-style: normal !important;
  font-weight: var(--studio-weight-normal) !important;
  line-height: var(--studio-line-base) !important;
  letter-spacing: 0 !important;
}

body.app-route :is(h1, h2, h3, h4, h5, h6, p, span, strong, b, em, small, label, button, a, input, select, textarea, th, td, dt, dd, li),
body.app-route :is(.studio-tv-chart-host, .studio-tv-native-mini, .studio-tv-mini) :is(div, span, strong, b, label, button, select, input, p) {
  font-style: normal !important;
  letter-spacing: 0 !important;
}

body.app-route :is(.page-head h1, .studio-module-title h1, .qv3-clone-root h1, .qv8-clone-root h1, .ats-v2-clone-root h1, .mt5-optimizer-clone-root h1, .mt5-terminal-clone-root h1) {
  font-size: var(--studio-type-title) !important;
  font-weight: var(--studio-weight-strong) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route :is(.page-head p, .studio-module-scope, .project-summary p, .empty-state, .status-line, .studio-tv-apply-status, .studio-tv-apply-warning) {
  font-size: var(--studio-type-md) !important;
  font-weight: var(--studio-weight-normal) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route :is(.panel-title strong, .studio-module-scope strong, .studio-tv-mini-title, .qv3-clone-root h2, .qv3-clone-root h3, .qv8-clone-root h2, .qv8-clone-root h3, .ats-v2-clone-root h2, .ats-v2-clone-root h3, .mt5-optimizer-clone-root h2, .mt5-optimizer-clone-root h3, .mt5-terminal-clone-root h2, .mt5-terminal-clone-root h3) {
  font-size: var(--studio-type-lg) !important;
  font-weight: var(--studio-weight-strong) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route :is(button, .primary, .ghost, .icon-button, .mobile-nav-button, input:not([type="checkbox"]):not([type="radio"]), select, textarea, .studio-tv-toolbar button, .studio-tv-toolbar select, .studio-tv-applybar select, .studio-tv-all-applies, .studio-module-steps > *) {
  font-size: var(--studio-type-sm) !important;
  font-weight: var(--studio-weight-medium) !important;
  line-height: var(--studio-line-tight) !important;
}

body.app-route :is(small, label, .field label, .field-label, .param-label, .range-label, .form-label, .fact-grid span, .metric-strip span, .table-sub, .muted, .tiny, .field-hint, .field-note, .panel-subtitle, .studio-module-scope span, .status-badge, .state-pill, th, .table-head, .studio-tv-mini-scope) {
  font-size: var(--studio-type-xs) !important;
  font-weight: var(--studio-weight-medium) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route :is(strong, b, .brand-row strong, .top-strategy strong, .fact-grid strong, .metric-strip strong, .data-table td strong, .studio-tv-chart-host strong, .studio-tv-chart-host b) {
  font-weight: var(--studio-weight-strong) !important;
}

body.app-route :is(em, i, cite, .italic) {
  font-style: normal !important;
}

body.app-route .studio-tv-chart-host :is(div, span, strong, b, label, button, select) {
  font-size: var(--studio-type-sm) !important;
  line-height: var(--studio-line-base) !important;
}

body.app-route .studio-tv-chart-host :is(button, select, input) {
  font-weight: var(--studio-weight-medium) !important;
}

body.app-route .studio-tv-chart-host :is(strong, b, span[style*="font-weight: 700"], span[style*="fontWeight: 700"]) {
  font-weight: var(--studio-weight-strong) !important;
}

body.app-route .analyzer-frame-panel {
  padding: 0 !important;
  overflow: hidden !important;
  border-radius: 8px !important;
}

body.app-route .studio-analyzer-frame {
  display: block !important;
  width: 100% !important;
  height: min(1120px, calc(100vh - 170px)) !important;
  min-height: 720px !important;
  border: 0 !important;
  background: #080d18 !important;
}

@media (max-width: 680px) {
  body.app-route {
    --studio-type-xs: 12px;
    --studio-type-sm: 13px;
    --studio-type-md: 13px;
    --studio-type-lg: 15px;
    --studio-type-xl: 17px;
    --studio-type-title: 20px;
  }

  body.app-route .mobile-brand :is(strong, span),
  body.app-route .brand-row strong {
    font-size: var(--studio-type-xl) !important;
    font-weight: var(--studio-weight-strong) !important;
    line-height: var(--studio-line-tight) !important;
  }

  body.app-route .mobile-nav-button {
    font-size: var(--studio-type-sm) !important;
    font-weight: var(--studio-weight-medium) !important;
  }

  body.app-route .topbar,
  body.app-route.chart-route-active .topbar {
    grid-template-columns: minmax(0, 1fr) 36px 36px 68px !important;
    grid-auto-rows: minmax(32px, auto) !important;
    gap: 6px !important;
    padding: 8px 12px !important;
  }

  body.app-route .topbar > #projectSelect,
  body.app-route.chart-route-active .topbar > #projectSelect {
    grid-column: 1 / -1 !important;
    order: 1 !important;
    font-size: var(--studio-type-md) !important;
    font-weight: var(--studio-weight-medium) !important;
  }

  body.app-route .topbar > .state-pill,
  body.app-route.chart-route-active .topbar > .state-pill {
    display: inline-flex !important;
    visibility: visible !important;
    grid-column: 1 !important;
    order: 2 !important;
    height: 32px !important;
    justify-content: center !important;
  }

  body.app-route .topbar > .theme-toggle,
  body.app-route.chart-route-active .topbar > .theme-toggle {
    display: inline-flex !important;
    visibility: visible !important;
    grid-column: 2 !important;
    order: 2 !important;
    height: 32px !important;
  }

  body.app-route .topbar > .notifications-menu,
  body.app-route.chart-route-active .topbar > .notifications-menu {
    display: block !important;
    visibility: visible !important;
    grid-column: 3 !important;
    order: 2 !important;
    height: 32px !important;
    min-width: 0 !important;
  }

  body.app-route .topbar > .profile-menu,
  body.app-route.chart-route-active .topbar > .profile-menu {
    display: block !important;
    visibility: visible !important;
    grid-column: 4 !important;
    order: 2 !important;
    height: 32px !important;
    min-width: 0 !important;
  }

  body.app-route .topbar > .notifications-menu .icon-button,
  body.app-route.chart-route-active .topbar > .notifications-menu .icon-button,
  body.app-route .topbar > .profile-menu > button,
  body.app-route.chart-route-active .topbar > .profile-menu > button,
  body.app-route .topbar > .theme-toggle,
  body.app-route.chart-route-active .topbar > .theme-toggle {
    width: 100% !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 8px !important;
    padding: 0 !important;
  }

  body.app-route .topbar > .profile-menu > button {
    padding: 0 6px !important;
  }

  body.app-route .topbar > .profile-menu .button-label {
    max-width: 48px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar > #topRunButton {
    grid-column: 1 / -1 !important;
    order: 3 !important;
    height: 34px !important;
    min-height: 34px !important;
  }

  body.app-route.chart-route-active .topbar > #topRunButton,
  body.app-route.chart-route-active .topbar > #topSaveButton {
    display: none !important;
  }

  body.app-route .page-head,
  body.app-route.chart-route-active .page-head {
    margin-bottom: 8px !important;
  }

  body.app-route .page-head h1,
  body.app-route.chart-route-active .page-head h1 {
    font-size: var(--studio-type-title) !important;
  }

  body.app-route .page-head p,
  body.app-route.chart-route-active .page-head p {
    font-size: var(--studio-type-md) !important;
  }

  body.app-route .studio-tv-toolbar,
  body.app-route .studio-tv-applybar {
    border-radius: 8px !important;
    gap: 6px !important;
    padding: 8px !important;
  }

  body.app-route .studio-tv-toolbar select,
  body.app-route .studio-tv-toolbar button,
  body.app-route .studio-tv-applybar select,
  body.app-route .studio-tv-all-applies {
    min-height: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    font-size: var(--studio-type-md) !important;
    font-weight: var(--studio-weight-medium) !important;
  }

  body.app-route .studio-tv-quick-tfs {
    gap: 6px !important;
    padding-bottom: 4px !important;
  }

  body.app-route .studio-tv-quick-tfs button {
    min-width: 48px !important;
    font-size: var(--studio-type-md) !important;
  }

  body.app-route .studio-tv-chart-host :is(div, span, strong, b, label, button, select) {
    font-size: var(--studio-type-md) !important;
    font-weight: var(--studio-weight-medium) !important;
  }

  body.app-route .studio-tv-chart-host :is(strong, b) {
    font-weight: var(--studio-weight-strong) !important;
  }

  body.app-route .studio-tv-chart-host > div > div:first-child :is(span, strong, b, button) {
    font-size: var(--studio-type-xs) !important;
    line-height: 1.25 !important;
  }

  body.app-route .analyzer-frame-panel {
    margin-left: -8px !important;
    margin-right: -8px !important;
  }

  body.app-route .studio-analyzer-frame {
    height: calc(100vh - 128px) !important;
    min-height: 640px !important;
  }
}

/* True final mobile shell reset. Kept at EOF so it wins over every legacy block. */
@media (max-width: 680px) {
  html,
  body {
    width: 100% !important;
    overflow-x: hidden !important;
  }

  body.app-route {
    --studio-mobile-header: 56px;
  }

  body.app-route .app-shell,
  body.app-route .main-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
  }

  body.app-route .sidebar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    width: 100% !important;
    height: var(--studio-mobile-header) !important;
    min-height: var(--studio-mobile-header) !important;
    max-height: var(--studio-mobile-header) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: 1fr !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 12px !important;
    overflow: visible !important;
    border: 0 !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: rgba(8, 7, 20, 0.98) !important;
    box-shadow: none !important;
  }

  :root[data-theme="light"] body.app-route .sidebar {
    background: rgba(255, 255, 255, 0.98) !important;
  }

  body.app-route .sidebar::after {
    content: none !important;
  }

  body.app-route .sidebar .brand-row {
    min-width: 0 !important;
    display: grid !important;
    grid-template-columns: 30px minmax(0, 1fr) !important;
    gap: 8px !important;
    align-items: center !important;
  }

  body.app-route .sidebar .brand-mark {
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
  }

  body.app-route .sidebar .brand-row strong {
    overflow: hidden !important;
    color: #ffffff !important;
    font-size: 16px !important;
    line-height: 1.1 !important;
    font-weight: 650 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  :root[data-theme="light"] body.app-route .sidebar .brand-row strong {
    color: var(--studio-text) !important;
  }

  body.app-route .sidebar .brand-row small {
    display: none !important;
  }

  body.app-route .mobile-nav-button {
    width: 76px !important;
    min-width: 76px !important;
    height: 36px !important;
    min-height: 36px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    background: #7c3aed !important;
    font-size: 13px !important;
    font-weight: 650 !important;
    line-height: 1 !important;
  }

  body.app-route .mobile-nav-backdrop {
    position: fixed !important;
    inset: var(--studio-mobile-header) 0 0 !important;
    z-index: 980 !important;
    display: block !important;
    background: rgba(2, 6, 23, 0.48) !important;
    backdrop-filter: blur(3px) !important;
  }

  body.app-route .mobile-nav-backdrop[hidden] {
    display: none !important;
  }

  body.app-route .side-nav {
    position: fixed !important;
    inset: 64px 10px auto !important;
    z-index: 1010 !important;
    width: auto !important;
    height: auto !important;
    max-height: calc(100dvh - 76px) !important;
    display: grid !important;
    align-content: start !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow: auto !important;
    border: 1px solid var(--studio-border) !important;
    border-radius: 12px !important;
    color: var(--studio-text) !important;
    background: var(--studio-surface) !important;
    box-shadow: 0 18px 60px rgba(2, 6, 23, 0.42) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
    transition: opacity 140ms ease, transform 140ms ease !important;
  }

  body.app-route.mobile-nav-open .side-nav {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
  }

  body.app-route .side-nav section {
    display: grid !important;
    gap: 6px !important;
    margin: 0 !important;
  }

  body.app-route .side-nav section > span {
    padding: 4px 4px 0 !important;
    color: var(--studio-text-subtle) !important;
    font-size: 12px !important;
    font-weight: 650 !important;
  }

  body.app-route .side-nav a,
  body.app-route .side-nav .nav-disabled {
    width: 100% !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    padding: 0 10px !important;
    border: 1px solid var(--studio-border) !important;
    border-radius: 8px !important;
    color: var(--studio-text-muted) !important;
    background: var(--studio-surface-muted) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }

  body.app-route .side-nav a.active,
  body.app-route .side-nav a:hover {
    color: var(--studio-text) !important;
    background: var(--studio-primary-soft) !important;
    border-color: var(--studio-primary) !important;
  }

  body.app-route .topbar {
    position: relative !important;
    top: auto !important;
    z-index: 20 !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 84px !important;
    grid-auto-rows: 36px !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--studio-border) !important;
    background: var(--studio-surface) !important;
  }

  body.app-route.chart-route-active .topbar {
    display: none !important;
  }

  body.app-route .topbar .top-strategy,
  body.app-route .topbar #topSaveButton,
  body.app-route .topbar #topRunButton,
  body.app-route .topbar .theme-toggle,
  body.app-route .topbar .notifications-menu {
    display: none !important;
  }

  body.app-route .topbar > #projectSelect {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    max-height: 36px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
  }

  body.app-route .topbar > .state-pill {
    grid-column: 1 !important;
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    justify-content: flex-start !important;
    padding: 0 10px !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .topbar > .profile-menu {
    grid-column: 2 !important;
    width: 100% !important;
    height: 34px !important;
    min-width: 0 !important;
  }

  body.app-route .topbar > .profile-menu > button {
    width: 100% !important;
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 8px !important;
    border-radius: 8px !important;
  }

  body.app-route .topbar > .profile-menu .button-label {
    max-width: 48px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route .route-outlet {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    padding: 12px !important;
    gap: 12px !important;
    overflow-x: hidden !important;
  }

  body.app-route.chart-route-active .route-outlet {
    padding: 8px 8px 20px !important;
    gap: 8px !important;
  }

  body.app-route.chart-route-active .page-head {
    display: none !important;
  }

  body.app-route .page-head {
    margin: 0 0 10px !important;
  }

  body.app-route .page-head h1 {
    font-size: 20px !important;
    line-height: 1.15 !important;
  }

  body.app-route .page-head p {
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  body.app-route.chart-route-active #studioTradingChartMount,
  body.app-route.chart-route-active .studio-trading-chart-mount {
    min-height: calc(100dvh - var(--studio-mobile-header) - 28px) !important;
  }

  body.app-route.chart-route-active .studio-tv-chart {
    width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  body.app-route.chart-route-active .studio-tv-toolbar {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    min-height: 0 !important;
    padding: 8px !important;
    border-radius: 8px !important;
  }

  body.app-route.chart-route-active .studio-tv-toolbar select[aria-label="Symbol"] {
    grid-column: 1 / -1 !important;
  }

  body.app-route.chart-route-active .studio-tv-quick-tfs {
    grid-column: 1 / -1 !important;
    display: flex !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding-bottom: 2px !important;
  }

  body.app-route.chart-route-active .studio-tv-quick-tfs button {
    min-width: 44px !important;
    flex: 0 0 auto !important;
  }

  body.app-route.chart-route-active .studio-tv-layout-label,
  body.app-route.chart-route-active .studio-tv-toolbar button:disabled {
    display: none !important;
  }

  body.app-route.chart-route-active .studio-tv-applybar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 6px !important;
    margin-top: 6px !important;
    padding: 8px !important;
    border-radius: 8px !important;
  }

  body.app-route.chart-route-active .studio-tv-applybar > :first-child {
    grid-column: 1 / -1 !important;
  }

  body.app-route.chart-route-active .studio-tv-apply-status,
  body.app-route.chart-route-active .studio-tv-apply-warning {
    grid-column: 1 / -1 !important;
    min-height: 24px !important;
    justify-content: flex-start !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 440px !important;
    height: 440px !important;
    overflow: hidden !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host > * {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 440px !important;
    height: 440px !important;
  }

  body.app-route.chart-route-active .studio-tv-chart-host canvas,
  body.app-route.chart-route-active .studio-tv-chart-host svg {
    max-width: 100% !important;
  }
}
