/**
 * Trading Simulator CSS v3.5
 * Design: Trading Journal + Mega Menu Style
 * Sprint 5: inline-style merged into stylesheet, no Google Fonts.
 * @package BuyHold
 */

/* ========================================
   PAGE-LEVEL OVERRIDES (was inline <style> in page-trading-simulator.php)
   ======================================== */

/* No horizontal page scroll while the simulator template is in use.
   This stylesheet is enqueued only by page-trading-simulator.php, so the html rule is page-scoped in practice. */
html,
body.page-template-page-trading-simulator {
    overflow-x: hidden !important;
    max-width: 100vw;
}

/* WordPress wrappers around the simulator should not add top spacing */
body.page-template-page-trading-simulator .site-content,
body.page-template-page-trading-simulator .content-area,
body.page-template-page-trading-simulator .site-main,
body.page-template-page-trading-simulator main#main,
body.page-template-page-trading-simulator main,
body.page-template-page-trading-simulator #content,
body.page-template-page-trading-simulator #primary,
body.page-template-page-trading-simulator .entry-content,
body.page-template-page-trading-simulator article.page,
body.page-template-page-trading-simulator article {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Full-bleed wrapper. Точная высота под header темы (60px) + WP admin-bar если есть. */
.tsim-fullwidth-wrapper {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-top: 0 !important;
    padding-top: 0 !important;
    background: #131722;
    height: calc(100vh - 60px);
    height: calc(100dvh - 60px);
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
}
body.admin-bar .tsim-fullwidth-wrapper { height: calc(100vh - 60px - 32px); }
body.admin-bar .tsim-fullwidth-wrapper { height: calc(100dvh - 60px - 32px); }
@media screen and (max-width: 782px) {
    body.admin-bar .tsim-fullwidth-wrapper { height: calc(100vh - 60px - 46px); }
    body.admin-bar .tsim-fullwidth-wrapper { height: calc(100dvh - 60px - 46px); }
}

/* Strip WP wrappers inside */
.tsim-fullwidth-wrapper .site-content,
.tsim-fullwidth-wrapper .content-area,
.tsim-fullwidth-wrapper .site-main,
.tsim-fullwidth-wrapper main,
.tsim-fullwidth-wrapper #content,
.tsim-fullwidth-wrapper #main,
.tsim-fullwidth-wrapper .entry-content,
.tsim-fullwidth-wrapper article,
.tsim-fullwidth-wrapper .container,
.tsim-fullwidth-wrapper .wrap,
.tsim-fullwidth-wrapper .wrapper {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

/* Unified font (Roboto from theme, no Google Fonts import) */
.tsim, .tsim * {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
}

/* Article section below simulator restores theme look */
.tsim-article-section {
    background: #fff;
    padding: 40px 0;
}
.tsim-article-section .entry-content {
    max-width: 800px !important;
    margin: 0 auto !important;
    padding: 0 20px !important;
    width: auto !important;
}

/* Hide sidebars on the simulator template */
body.page-template-page-trading-simulator .sidebar,
body.page-template-page-trading-simulator #secondary,
body.page-template-page-trading-simulator aside {
    display: none !important;
}

/* ========================================
   CSS VARIABLES - Trading Journal Palette
   ======================================== */
:root {
    /* Backgrounds */
    --tsim-bg-primary: #131722;
    --tsim-bg-secondary: #1e222d;
    --tsim-bg-tertiary: #262b36;
    --tsim-bg-hover: #2d3341;
    --tsim-bg-input: #131722;
    
    /* Borders */
    --tsim-border: #2a2e39;
    --tsim-border-light: #363c4a;
    
    /* Accent - Green (Trading Journal style) */
    --tsim-accent: #7cb342;
    --tsim-accent-hover: #95ce5a;
    --tsim-accent-dim: rgba(124, 179, 66, 0.15);
    --tsim-accent-glow: rgba(124, 179, 66, 0.3);
    
    /* Text */
    --tsim-text: #d1d4dc;
    --tsim-text-muted: #9ca3af;
    --tsim-text-bright: #f0f3fa;
    
    /* Status Colors */
    --tsim-positive: #10b981;
    --tsim-positive-dim: rgba(16, 185, 129, 0.15);
    --tsim-negative: #f43f5e;
    --tsim-negative-dim: rgba(244, 63, 94, 0.15);
    --tsim-neutral: #94a3b8;
    --tsim-neutral-dim: rgba(148, 163, 184, 0.14);
    --tsim-warning: #ffb74d;
    --tsim-warning-dim: rgba(255, 183, 77, 0.15);
    
    /* Typography - UNIFIED FONTS */
    --tsim-font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --tsim-mono: 'Roboto Mono', 'SF Mono', 'Consolas', 'Monaco', monospace;
    
    /* Layout */
    --tsim-radius: 6px;
    --tsim-radius-lg: 12px;
    --tsim-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --tsim-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.5);
    
    /* Animation */
    --tsim-transition: all 0.3s ease;
}

/* ========================================
   BASE RESET
   ======================================== */

/* Стили .tsim-fullwidth-wrapper задаются в PHP шаблоне */

.tsim {
    font-family: var(--tsim-font);
    font-size: 13px;
    line-height: 1.4;
    color: var(--tsim-text);
    background: var(--tsim-bg-primary);
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
}

.tsim,
.tsim-main,
.tsim-chart-section,
.tsim-simulator-view,
.tsim-panel,
.tsim-tab-content {
    min-width: 0;
    max-width: 100%;
}

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

/* Отменяем ТОЛЬКО декоративные стили темы для table (градиентная полоса) */
.tsim table::before,
.tsim td::before,
.tsim tr::before,
.tsim-chart-container table::before,
.tsim-chart-container td::before,
.tsim-chart-container tr::before {
    content: none !important;
    display: none !important;
}

/* Reset только для UI элементов, не для графика */
.tsim-topbar *,
.tsim-panel *,
.tsim-bottom-panel *,
.tsim-section *,
.tsim-form-row *,
.tsim-positions-tabs *,
.tsim-positions-body * {
    margin: 0;
    padding: 0;
}

/* Отменяем стили темы для таблиц внутри графика */
.tsim-chart-container table,
.tsim-chart-container table *,
.tsim-chart-container td,
.tsim-chart-container tr,
.tsim-chart-container canvas {
    margin: unset !important;
    padding: unset !important;
    border: none !important;
    background: none !important;
}

.tsim-chart-container table::before,
.tsim-chart-container table::after,
.tsim-chart-container td::before,
.tsim-chart-container td::after {
    display: none !important;
    content: none !important;
}

.tsim button {
    font-family: var(--tsim-font);
    font-size: inherit;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: none;
    color: inherit;
}

/* ========================================
   CSS GRID ТАБЛИЦЫ (вместо table)
   Полностью избегаем глобальных стилей table темы
   ======================================== */
.tsim-grid {
    display: grid;
    grid-template-columns: auto auto auto auto 1fr 1fr auto auto auto auto;
    width: 100%;
    font-size: 10px;
}

.tsim-grid-head {
    display: contents;
}

.tsim-grid-body {
    display: contents;
}

.tsim-grid-row {
    display: contents;
}

.tsim-grid-th {
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tsim-text-muted);
    background: var(--tsim-bg-secondary);
    border-bottom: 1px solid var(--tsim-border);
    white-space: nowrap;
}

.tsim-grid-td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    font-family: var(--tsim-font);
    white-space: nowrap;
    background: transparent;
    display: flex;
    align-items: center;
}

.tsim-grid-row:not(.tsim-empty-row):hover .tsim-grid-td {
    background: rgba(124, 179, 66, 0.08);
}

.tsim-empty-row .tsim-grid-td {
    padding: 16px;
    justify-content: center;
    border: none;
}

/* ========================================
   ЗАЩИТА ОТ СТИЛЕЙ ТЕМЫ - КНОПКИ
   Блокируем стили темы, добавляем свои hover
   ======================================== */
#tradingSimulator button,
#tradingSimulator .tsim-main-tab,
#tradingSimulator .tsim-pos-tab,
#tradingSimulator .tsim-tf-btn,
#tradingSimulator .tsim-play-btn,
#tradingSimulator .tsim-chart-btn,
#tradingSimulator .tsim-order-type,
#tradingSimulator .tsim-vol-btn,
#tradingSimulator .tsim-qv-btn,
#tradingSimulator .tsim-risk-btn,
#tradingSimulator .tsim-btn-secondary,
#tradingSimulator .tsim-toolbar-btn,
#tradingSimulator .tsim-cell-btn,
#tradingSimulator .tsim-icon-btn,
#tradingSimulator .tsim-page-btn {
    transition: all 0.15s ease !important;
    -webkit-transition: all 0.15s ease !important;
    outline: none !important;
    text-shadow: none !important;
    filter: none !important;
    -webkit-filter: none !important;
}

.tsim input {
    font-family: var(--tsim-font);
    font-size: 12px;
    background: var(--tsim-bg-input);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-bright);
    padding: 6px 10px;
    outline: none;
    transition: var(--tsim-transition);
}

.tsim input:focus {
    border-color: var(--tsim-accent);
    box-shadow: 0 0 0 2px var(--tsim-accent-dim);
}

.tsim input::placeholder {
    color: var(--tsim-text-muted);
}

.tsim input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--tsim-accent);
    cursor: pointer;
}

.tsim input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: var(--tsim-bg-tertiary);
    height: 6px;
    border-radius: 3px;
    border: none;
    padding: 0;
    cursor: pointer;
}

.tsim input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--tsim-accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 179, 66, 0.4);
    transition: var(--tsim-transition);
}

.tsim input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    background: var(--tsim-accent-hover);
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */
.tsim.tsim-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    z-index: 999999 !important;
}

.tsim:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
}

/* Hotkeys hint - ALWAYS VISIBLE, ABOVE BOTTOM PANEL */
.tsim-hotkeys {
    display: flex;
    position: absolute;
    bottom: 8px;
    left: 10px;
    gap: 8px;
    font-size: 9px;
    color: var(--tsim-text-muted);
    z-index: 50;
    background: rgba(19, 23, 34, 0.9);
    padding: 4px 8px;
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
}

.tsim-hotkeys kbd {
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    padding: 1px 4px;
    border-radius: 3px;
    font-family: var(--tsim-font);
    font-size: 8px;
    margin-right: 2px;
    color: var(--tsim-text);
}

/* ========================================
   TOP BAR - Mega Menu Style
   ======================================== */
.tsim-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 16px;
    background: linear-gradient(180deg, #1a1d28 0%, #151820 100%);
    border-bottom: 1px solid var(--tsim-border);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    min-height: 44px;
}

.tsim-topbar-left,
.tsim-topbar-center,
.tsim-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tsim-topbar-left {
    flex: 0 1 auto;
}

.tsim-topbar-right {
    flex: 0 0 auto;
}

.tsim-topbar-center {
    flex: 1 1 auto;
    justify-content: flex-end;
    padding-right: 20px;
}

/* Logo */
.tsim-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    text-decoration: none;
}

.tsim-logo-icon {
    width: 20px;
    height: 20px;
}

.tsim-logo-text {
    font-size: 14px;
    letter-spacing: -0.3px;
}

/* ========================================
   INSTRUMENT SELECTOR - COMPACT
   ======================================== */
.tsim-instrument-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tsim-bg-secondary);
    padding: 4px 10px 4px 6px;
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
    cursor: pointer;
    position: relative;
    min-width: 130px;
}

.tsim-instrument-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: #fff;
    flex-shrink: 0;
}

.tsim-instrument-icon.btc { background: linear-gradient(135deg, #f7931a, #ffb84d); }
.tsim-instrument-icon.eth { background: linear-gradient(135deg, #627eea, #8c9eff); }
.tsim-instrument-icon.eur { background: linear-gradient(135deg, #003399, #1a53ff); }
.tsim-instrument-icon.gbp { background: linear-gradient(135deg, #c8102e, #ff3355); }
.tsim-instrument-icon.xau { background: linear-gradient(135deg, #ffd700, #ffec80); color: #333; }
.tsim-instrument-icon.spx { background: linear-gradient(135deg, #1a5f2a, #2ea043); }

.tsim-instrument-info {
    flex: 1;
    min-width: 0;
}

.tsim-instrument-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--tsim-text-bright);
}

.tsim-instrument-fullname {
    font-size: 9px;
    color: var(--tsim-text-muted);
}

.tsim-chevron {
    width: 12px;
    height: 12px;
    color: var(--tsim-text-muted);
}

/* Dropdown - Card Style */
.tsim-instrument-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 240px;
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius-lg);
    box-shadow: var(--tsim-shadow);
    display: none;
    z-index: 9999; /* P1-4: выше indicators-bar (z:auto), legend (z:6), modals остаются выше (z:100000) */
    overflow: hidden;
    animation: tsim-dropdown-in 0.2s ease;
}
.tsim-instrument-selector { position: relative; } /* нужно для absolute dropdown */
.tsim-topbar { position: relative; z-index: 50; } /* поднимаем topbar над chart-area */

@keyframes tsim-dropdown-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tsim-instrument-dropdown.active {
    display: block;
}

.tsim-dropdown-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--tsim-text-muted);
    padding: 12px 14px 8px;
    background: var(--tsim-bg-tertiary);
    border-bottom: 1px solid var(--tsim-border);
}

.tsim-instrument-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
}

.tsim-instrument-option.selected {
    background: var(--tsim-accent-dim);
    border-left: 3px solid var(--tsim-accent);
}

.tsim-instrument-option .tsim-instrument-icon {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.tsim-opt-info {
    display: flex;
    flex-direction: column;
}

.tsim-opt-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--tsim-text-bright);
}

.tsim-opt-desc {
    font-size: 11px;
    color: var(--tsim-text-muted);
}

/* ========================================
   TIMEFRAMES - COMPACT
   ======================================== */
.tsim-timeframes {
    display: flex;
    gap: 2px;
    background: var(--tsim-bg-secondary);
    padding: 2px;
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
}

.tsim-tf-btn {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tsim-text-muted);
    border-radius: var(--tsim-radius);
}

.tsim-tf-btn.active {
    background: var(--tsim-accent);
    color: #000;
}

/* ========================================
   MAIN TABS - COMPACT
   ======================================== */
.tsim-main-tabs {
    display: flex;
    gap: 2px;
    background: var(--tsim-bg-secondary);
    padding: 3px;
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.tsim-main-tabs::-webkit-scrollbar {
    display: none;
}

.tsim-main-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    border-radius: var(--tsim-radius);
    white-space: nowrap;
    background: transparent;
}

.tsim-main-tab svg {
    width: 12px;
    height: 12px;
}

.tsim-main-tab.active {
    background: var(--tsim-accent);
    color: #000;
}

.tsim-main-tab.active svg {
    stroke: #000;
}

/* ========================================
   ACCOUNT INFO - UNIFIED FONT
   ======================================== */
.tsim-account {
    display: flex;
    gap: 24px;
    flex-wrap: nowrap;
}

.tsim-account-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.tsim-account-label {
    font-family: var(--tsim-font);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tsim-text-muted);
    font-weight: 500;
}

.tsim-account-value {
    font-family: var(--tsim-font);
    font-size: 15px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    letter-spacing: -0.3px;
}

.tsim-pnl-value.positive { color: var(--tsim-positive); }
.tsim-pnl-value.negative { color: var(--tsim-negative); }

/* Icon Button */
.tsim-icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
}

.tsim-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   MAIN CONTENT AREA - FIXED WIDTH
   ======================================== */
.tsim-main {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* ========================================
   CHART SECTION - FILL AVAILABLE SPACE
   ======================================== */
.tsim-chart-section {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--tsim-bg-secondary);
    position: relative;
    overflow: hidden;
}

/* Simulator View (default) */
.tsim-simulator-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

/* Live Chart View */
.tsim-livechart-view {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.tsim-livechart-view iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--tsim-bg-primary);
}

.tsim-price-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    border-bottom: 1px solid var(--tsim-border);
    background: linear-gradient(180deg, #1e222d 0%, #1a1e28 100%);
    flex-shrink: 0;
}

.tsim-price-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.tsim-current-price {
    font-family: var(--tsim-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    letter-spacing: -0.5px;
}

.tsim-price-change {
    font-family: var(--tsim-font);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--tsim-radius);
}

.tsim-price-change.positive {
    color: var(--tsim-positive);
    background: var(--tsim-positive-dim);
}

.tsim-price-change.negative {
    color: var(--tsim-negative);
    background: var(--tsim-negative-dim);
}

.tsim-data-source {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: min(320px, 34vw);
    height: 24px;
    padding: 0 9px;
    border: 1px solid rgba(124, 179, 66, 0.28);
    border-radius: 999px;
    background: rgba(124, 179, 66, 0.08);
    color: var(--tsim-text-muted);
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.tsim-data-source.ok::before,
.tsim-data-source.error::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    margin-right: 6px;
    border-radius: 50%;
}

.tsim-data-source.ok::before {
    background: var(--tsim-positive);
    box-shadow: 0 0 8px var(--tsim-positive-dim);
}

.tsim-data-source.error {
    border-color: rgba(239, 83, 80, 0.35);
    background: rgba(239, 83, 80, 0.10);
    color: #fca5a5;
}

.tsim-data-source.error::before {
    background: var(--tsim-negative);
    box-shadow: 0 0 8px var(--tsim-negative-dim);
}

.tsim-ohlcv {
    display: flex;
    gap: 16px;
    font-family: var(--tsim-font);
    font-size: 11px;
    color: var(--tsim-text-muted);
}

.tsim-ohlcv b {
    color: var(--tsim-text);
    font-weight: 600;
    margin-right: 4px;
}

/* Chart Container - FILL AVAILABLE SPACE */
.tsim-chart-container {
    flex: 1 1 0%;
    min-height: 200px;
    background: var(--tsim-bg-primary);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

/* Lightweight Charts - не переопределяем размеры */
.tsim-chart-container > div {
    overflow: hidden !important;
}

/* Chart Controls Overlay */
.tsim-chart-controls {
    position: absolute;
    top: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.tsim-chart-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
    font-size: 18px;
    font-weight: 600;
}

/* ========================================
   RIGHT PANEL - Card Style (TJ) - SCROLLABLE
   ======================================== */
.tsim-panel {
    width: 320px;
    min-width: 320px;
    flex-shrink: 0;
    background: var(--tsim-bg-primary);
    border-left: 1px solid var(--tsim-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tsim-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Неприметный скроллбар для правой панели */
.tsim-tab-content::-webkit-scrollbar {
    width: 4px;
}

.tsim-tab-content::-webkit-scrollbar-track {
    background: transparent;
}

.tsim-tab-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.tsim-tab-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tsim-tab-content.active {
    display: flex;
}

/* Sections - Card Style - ULTRA COMPACT */
.tsim-section {
    padding: 8px;
    border-bottom: 1px solid var(--tsim-border);
    background: var(--tsim-bg-secondary);
    margin: 4px;
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
    flex-shrink: 0;
}

.tsim-section:first-child {
    margin-top: 4px;
}

.tsim-section-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 100px;
}

.tsim-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tsim-text-muted);
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--tsim-border);
}

.tsim-section-icon {
    color: var(--tsim-accent);
    font-size: 10px;
}

/* ========================================
   PLAYBACK CONTROLS - ULTRA COMPACT
   ======================================== */
.tsim-playback {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.tsim-play-btn {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text);
    transition: var(--tsim-transition);
}

.tsim-play-btn svg {
    width: 14px;
    height: 14px;
}

.tsim-play-btn-main {
    flex: 2;
}

.tsim-play-btn-main.playing {
    background: var(--tsim-accent);
    border-color: var(--tsim-accent);
    color: #000;
}

.tsim-play-btn-main.playing .play-icon { display: none; }
.tsim-play-btn-main.playing .pause-icon { display: block; }

/* Speed Control - COMPACT */
.tsim-speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.tsim-speed-label {
    font-size: 10px;
    color: var(--tsim-text-muted);
    font-weight: 500;
    min-width: 50px;
}

.tsim-slider {
    flex: 1;
}

.tsim-speed-value {
    font-family: var(--tsim-font);
    font-size: 11px;
    font-weight: 600;
    color: var(--tsim-accent);
    min-width: 24px;
    text-align: right;
}

/* Progress */
.tsim-progress {
    font-size: 12px;
    color: var(--tsim-text-muted);
}

.tsim-progress-text {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    font-family: var(--tsim-font);
}

.tsim-progress-bar {
    height: 6px;
    background: var(--tsim-bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.tsim-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--tsim-accent), var(--tsim-accent-hover));
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* ========================================
   ORDER FORM
   ======================================== */

/* Order Types - Tab Style */
.tsim-order-types {
    display: flex;
    gap: 4px;
    background: var(--tsim-bg-primary);
    padding: 4px;
    border-radius: var(--tsim-radius);
    margin-bottom: 16px;
    border: 1px solid var(--tsim-border);
}

.tsim-order-type {
    flex: 1;
    padding: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tsim-text-muted);
    border-radius: var(--tsim-radius);
}

.tsim-order-type.active {
    background: var(--tsim-accent);
    color: #000;
}

/* Form Rows - COMPACT */
.tsim-form-row {
    margin-bottom: 10px;
}

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

.tsim-form-row label {
    font-family: var(--tsim-font);
    font-size: 11px;
    color: var(--tsim-text-muted);
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.tsim-hint {
    font-family: var(--tsim-font);
    font-size: 11px;
    color: var(--tsim-accent);
    font-weight: 600;
}

/* Volume Control - COMPACT */
.tsim-volume-control {
    display: flex;
    gap: 4px;
}

.tsim-volume-control input {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 8px;
}

.tsim-vol-btn {
    width: 32px;
    height: 32px;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
    font-size: 16px;
    font-weight: 600;
}

/* Quick Volume */
.tsim-quick-vol {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.tsim-qv-btn {
    flex: 1;
    padding: 5px 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
}

.tsim-qv-btn.active {
    border-color: var(--tsim-accent);
    color: var(--tsim-accent);
    background: var(--tsim-accent-dim);
}

/* Risk Calculator - COMPACT */
.tsim-risk-calc {
    margin-bottom: 10px;
    padding: 8px;
    background: var(--tsim-bg-primary);
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
}

.tsim-risk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tsim-risk-row span {
    font-size: 12px;
    color: var(--tsim-text-muted);
    font-weight: 500;
}

.tsim-risk-btns {
    display: flex;
    gap: 6px;
}

.tsim-risk-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
}

/* SL/TP Row - COMPACT */
.tsim-sltp-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.tsim-sltp-item label {
    font-size: 11px;
    color: var(--tsim-text-muted);
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.tsim-sltp-item input {
    width: 100%;
}

.tsim-sltp-pips {
    display: block;
    font-size: 10px;
    color: var(--tsim-text-muted);
    margin-top: 3px;
    font-family: var(--tsim-font);
}

/* Trailing Stop - COMPACT */
.tsim-trailing {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tsim-trailing label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    white-space: nowrap;
    cursor: pointer;
}

.tsim-trailing input[type="number"] {
    flex: 1;
    padding: 8px 12px;
}

/* ========================================
   TRADE BUTTONS - ULTRA COMPACT
   ======================================== */
.tsim-trade-btns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 6px;
}

.tsim-trade-btn {
    padding: 8px 6px;
    border-radius: var(--tsim-radius);
    color: #fff;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
    border: 1px solid transparent;
    transition: var(--tsim-transition);
}

.tsim-trade-btn.buy {
    background: linear-gradient(180deg, #10b981 0%, #1e8e82 100%);
    border-color: #2bbd84;
}

.tsim-trade-btn.sell {
    background: linear-gradient(180deg, #f43f5e 0%, #d32f2f 100%);
    border-color: #f85149;
}

.tsim-trade-price {
    font-family: var(--tsim-font);
    font-size: 12px;
    font-weight: 700;
}

.tsim-trade-label {
    font-size: 9px;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.tsim-trade-key {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 9px;
    font-weight: 600;
    opacity: 0.5;
    background: rgba(255,255,255,0.15);
    padding: 1px 4px;
    border-radius: 4px;
}

/* One Click Trading - COMPACT & WHITE TEXT */
.tsim-one-click {
    margin-top: 4px;
}

.tsim-one-click label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-bottom: 0 !important;
    font-size: 9px !important;
    font-weight: 500 !important;
    color: rgba(255, 255, 255, 0.9) !important;
}

/* ========================================
   POSITIONS TABS - TJ Tab Style
   ======================================== */
.tsim-positions-tabs {
    display: flex;
    border-bottom: 1px solid var(--tsim-border);
    padding: 0 18px;
    background: var(--tsim-bg-tertiary);
    border-radius: var(--tsim-radius-lg) var(--tsim-radius-lg) 0 0;
}

.tsim-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    background: var(--tsim-bg-primary);
    border-radius: 10px;
    margin-left: 6px;
}

/* Positions Content */
.tsim-positions-content {
    flex: 1;
    overflow: hidden;
    background: var(--tsim-bg-secondary);
    border-radius: 0 0 var(--tsim-radius-lg) var(--tsim-radius-lg);
}

.tsim-pos-list {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.tsim-pos-list.active {
    display: block;
}

/* Empty State */
.tsim-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    color: var(--tsim-text-muted);
    text-align: center;
}

.tsim-empty span {
    font-size: 40px;
    margin-bottom: 14px;
    opacity: 0.4;
}

.tsim-empty p {
    font-size: 13px;
    font-weight: 500;
}

/* Position Item */
.tsim-position-item {
    padding: 14px 18px;
    border-bottom: 1px solid var(--tsim-border);
}

.tsim-pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.tsim-pos-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: var(--tsim-radius);
    letter-spacing: 0.5px;
}

.tsim-pos-badge.buy {
    background: var(--tsim-positive-dim);
    color: var(--tsim-positive);
}

.tsim-pos-badge.sell {
    background: var(--tsim-negative-dim);
    color: var(--tsim-negative);
}

.tsim-pos-pnl {
    font-family: var(--tsim-font);
    font-size: 15px;
    font-weight: 700;
}

.tsim-pos-pnl.positive { color: var(--tsim-positive); }
.tsim-pos-pnl.negative { color: var(--tsim-negative); }

.tsim-pos-details {
    display: flex;
    gap: 18px;
    font-size: 12px;
    color: var(--tsim-text-muted);
    margin-bottom: 12px;
    font-family: var(--tsim-font);
}

.tsim-pos-actions {
    display: flex;
    gap: 8px;
}

.tsim-pos-btn {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
}

/* ========================================
   QUICK ACTIONS TOOLBAR - BOTTOM BAR
   ======================================== */
.tsim-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 16px;
    background: linear-gradient(180deg, #1e222d 0%, #181c25 100%);
    border-top: 1px solid var(--tsim-border);
    flex-shrink: 0;
}

.tsim-toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tsim-toolbar-right {
    margin-left: auto;
}

.tsim-toolbar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

.tsim-toolbar-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: var(--tsim-text-muted);
    white-space: nowrap;
}

.tsim-toolbar-btn svg {
    width: 12px;
    height: 12px;
}

/* Placeholder */
.tsim-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px;
    text-align: center;
}

.tsim-placeholder-icon {
    font-size: 40px;
    margin-bottom: 16px;
}

.tsim-placeholder h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    margin-bottom: 8px;
}

.tsim-placeholder p {
    font-size: 14px;
    color: var(--tsim-text-muted);
    margin-bottom: 24px;
    max-width: 300px;
    line-height: 1.6;
}

.tsim-placeholder-badge {
    display: inline-block;
    padding: 8px 18px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: var(--tsim-accent-dim);
    border: 1px solid var(--tsim-accent);
    border-radius: 20px;
    color: var(--tsim-accent);
}

/* ========================================
   BACKTEST UI
   ======================================== */
.tsim-select {
    width: 100%;
    background: var(--tsim-bg-input);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    padding: 8px 10px;
    border-radius: var(--tsim-radius);
    font-family: var(--tsim-font);
    font-size: 13px;
    cursor: pointer;
}
.tsim-select:focus {
    outline: none;
    border-color: var(--tsim-accent);
}

.tsim-bt-config { padding: 8px 12px 0; }
.tsim-bt-desc {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--tsim-bg-tertiary);
    border-radius: var(--tsim-radius);
    font-size: 12px;
    color: var(--tsim-text-muted);
    line-height: 1.5;
}
.tsim-bt-params {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}
.tsim-bt-param { display: flex; flex-direction: column; gap: 4px; }
.tsim-bt-param label {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-bt-param input {
    background: var(--tsim-bg-input);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    padding: 6px 8px;
    border-radius: var(--tsim-radius);
    font-family: var(--tsim-mono);
    font-size: 13px;
}
.tsim-bt-param input:focus {
    outline: none;
    border-color: var(--tsim-accent);
}

.tsim-bt-actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
    padding: 12px;
}
.tsim-bt-actions .tsim-trade-btn {
    padding: 12px;
}
.tsim-bt-actions .tsim-trade-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tsim-bt-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--tsim-text-muted);
    font-size: 13px;
}
.tsim-bt-results { padding: 0 12px 12px; }
.tsim-bt-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}
.tsim-bt-metric {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 10px;
    background: var(--tsim-bg-tertiary);
    border-radius: var(--tsim-radius);
}
.tsim-bt-metric span {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-bt-metric b {
    font-family: var(--tsim-mono);
    font-size: 13px;
    color: var(--tsim-text-bright);
    font-weight: 600;
}
.tsim-bt-metric b.positive { color: var(--tsim-positive); }
.tsim-bt-metric b.negative { color: var(--tsim-negative); }

/* ===== PRO TOOLS: Optimizer + Walk-Forward + Monte Carlo ===== */
.tsim-bt-pro-output { margin-top: 12px; }
.tsim-bt-pro-block {
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    padding: 12px;
    margin-bottom: 12px;
}
.tsim-bt-pro-block.error {
    background: rgba(244, 63, 94, 0.1);
    border-color: var(--tsim-negative);
    color: var(--tsim-negative);
}
.tsim-bt-pro-head {
    font-size: 13px;
    color: var(--tsim-text-bright);
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-bt-pro-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}
.tsim-bt-pro-grid > div {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--tsim-bg-secondary);
    border-radius: var(--tsim-radius);
}
.tsim-bt-pro-grid span {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-bt-pro-grid b {
    font-family: var(--tsim-mono);
    color: var(--tsim-text-bright);
    font-size: 12px;
}
.tsim-bt-pro-grid b.positive { color: var(--tsim-positive); }
.tsim-bt-pro-grid b.negative { color: var(--tsim-negative); }
.tsim-bt-pro-summary {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--tsim-text-muted);
}
.tsim-bt-pro-summary b { color: var(--tsim-text-bright); font-family: var(--tsim-mono); }
.tsim-bt-pro-summary b.positive { color: var(--tsim-positive); }
.tsim-bt-pro-summary b.negative { color: var(--tsim-negative); }
.tsim-bt-pro-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 11px;
    margin-top: 6px;
}
.tsim-bt-pro-table th {
    text-align: left;
    padding: 5px 6px;
    background: var(--tsim-bg-secondary);
    color: var(--tsim-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--tsim-border);
    white-space: nowrap;
}
.tsim-bt-pro-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    font-family: var(--tsim-mono);
    white-space: nowrap;
}
.tsim-bt-pro-table td.positive { color: var(--tsim-positive); }
.tsim-bt-pro-table td.negative { color: var(--tsim-negative); }
.tsim-opt-best { background: rgba(124, 179, 66, 0.15); }
.tsim-opt-best td { color: var(--tsim-text-bright); font-weight: 600; }
.tsim-bt-pro-note {
    margin-top: 10px;
    padding: 8px 10px;
    background: rgba(251, 191, 36, 0.07);
    border-left: 3px solid var(--tsim-warning);
    border-radius: var(--tsim-radius);
    font-size: 11px;
    color: var(--tsim-text-muted);
    line-height: 1.5;
}

/* Optimizer config table в модалке */
.tsim-opt-config {
    font-size: 12px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tsim-opt-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}
.tsim-opt-table th, .tsim-opt-table td {
    padding: 4px 6px;
    text-align: left;
    border-bottom: 1px solid var(--tsim-border);
    font-size: 11px;
}
.tsim-opt-table th { color: var(--tsim-text-muted); }
.tsim-opt-table input, .tsim-opt-table select {
    width: 100%;
    background: var(--tsim-bg-input);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    padding: 3px 6px;
    border-radius: 3px;
    font-family: var(--tsim-mono);
    font-size: 11px;
}
.tsim-opt-table input:disabled, .tsim-opt-table select:disabled { opacity: 0.4; }
.tsim-opt-bottom-row {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.tsim-opt-bottom-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--tsim-text);
}
.tsim-opt-bottom-row select, .tsim-opt-bottom-row input {
    background: var(--tsim-bg-input);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    padding: 4px 8px;
    border-radius: var(--tsim-radius);
    font-size: 12px;
}

/* Custom strategy editor */
.tsim-bt-custom {
    margin-top: 12px;
    padding: 10px;
    background: var(--tsim-bg-tertiary);
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
}
.tsim-bt-custom-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-bt-tpl { width: auto; padding: 3px 8px; font-size: 11px; }
.tsim-bt-code {
    width: 100%;
    height: 240px;
    background: #0f1218;
    color: #d1d4dc;
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    padding: 10px;
    font-family: var(--tsim-mono);
    font-size: 12px;
    line-height: 1.55;
    resize: vertical;
    outline: none;
    tab-size: 4;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.tsim-bt-code:focus { border-color: var(--tsim-accent); }
.tsim-bt-custom-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}
.tsim-bt-custom-foot button {
    background: var(--tsim-bg-secondary);
    color: var(--tsim-text-bright);
    border: 1px solid var(--tsim-border);
    padding: 5px 12px;
    border-radius: var(--tsim-radius);
    cursor: pointer;
    font-size: 12px;
}
.tsim-bt-custom-foot button:hover { border-color: var(--tsim-accent); color: var(--tsim-accent); }
.tsim-bt-status { font-size: 11px; flex: 1; }
.tsim-bt-status.ok { color: var(--tsim-positive); }
.tsim-bt-status.error { color: var(--tsim-negative); }

.tsim-bt-help {
    margin-top: 8px;
    background: var(--tsim-bg-secondary);
    border-radius: var(--tsim-radius);
    border: 1px solid var(--tsim-border);
}
.tsim-bt-help summary {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--tsim-text-bright);
    user-select: none;
}
.tsim-bt-help summary:hover { color: var(--tsim-accent); }
.tsim-bt-help-body {
    padding: 4px 12px 12px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--tsim-text);
}
.tsim-bt-help-body code {
    background: rgba(255,255,255,0.06);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: var(--tsim-mono);
    font-size: 11.5px;
    color: var(--tsim-accent);
}
.tsim-bt-help-body strong { color: var(--tsim-text-bright); }

/* Equity + Drawdown mini-charts в результатах бэктеста */
.tsim-bt-charts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}
.tsim-bt-chart-block { display: flex; flex-direction: column; }
.tsim-bt-chart-label {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.tsim-bt-chart {
    width: 100%;
    height: 140px;
    background: var(--tsim-bg-secondary);
    border-radius: var(--tsim-radius);
}

.tsim-bt-export-row {
    display: flex;
    justify-content: flex-end;
    margin: 8px 0 12px;
}
.tsim-bt-export-row button {
    background: var(--tsim-bg-tertiary);
    color: var(--tsim-text-bright);
    border: 1px solid var(--tsim-border);
    padding: 6px 14px;
    border-radius: var(--tsim-radius);
    cursor: pointer;
    font-size: 12px;
    transition: var(--tsim-transition);
}
.tsim-bt-export-row button:hover {
    border-color: var(--tsim-accent);
    color: var(--tsim-accent);
}

.tsim-bt-trades-header {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tsim-bt-trades {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 240px;
    overflow-y: auto;
}
.tsim-bt-trade {
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto auto;
    gap: 6px;
    align-items: center;
    padding: 5px 8px;
    background: var(--tsim-bg-tertiary);
    border-radius: 4px;
    font-family: var(--tsim-mono);
    font-size: 11px;
}
.tsim-bt-trade.win { border-left: 2px solid var(--tsim-positive); }
.tsim-bt-trade.loss { border-left: 2px solid var(--tsim-negative); }
.tsim-bt-trade.breakeven { border-left: 2px solid var(--tsim-neutral); }
.tsim-bt-trade-dir {
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 700;
    font-size: 10px;
}
.tsim-bt-trade-dir.buy { background: var(--tsim-positive-dim); color: var(--tsim-positive); }
.tsim-bt-trade-dir.sell { background: var(--tsim-negative-dim); color: var(--tsim-negative); }
.tsim-bt-trade-reason {
    font-size: 10px;
    color: var(--tsim-text-muted);
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--tsim-bg-secondary);
}
.tsim-bt-trade .positive { color: var(--tsim-positive); }
.tsim-bt-trade .negative { color: var(--tsim-negative); }
.tsim-bt-trade .neutral { color: var(--tsim-neutral); }

/* ========================================
   STATISTICS VIEW
   ======================================== */
.tsim-stats-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}
.tsim-stats-empty p {
    color: var(--tsim-text-muted);
    font-size: 13px;
    max-width: 280px;
    line-height: 1.6;
}
.tsim-stats-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 12px;
}

.tsim-stats-extras {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 0 12px 12px;
}
.tsim-stats-extra {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 10px;
    background: var(--tsim-bg-tertiary);
    border-radius: var(--tsim-radius);
}
.tsim-stats-extra span {
    font-size: 11px;
    color: var(--tsim-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tsim-stats-extra b {
    font-family: var(--tsim-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--tsim-text-bright);
}
.tsim-stats-extra b.positive { color: var(--tsim-positive); }
.tsim-stats-extra b.negative { color: var(--tsim-negative); }

.tsim-stats-chart {
    height: 200px;
    width: 100%;
    margin: 0 0 8px;
}

.tsim-stats-distribution {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 140px;
    padding: 8px 12px 0;
}
.tsim-stats-dist-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    min-width: 0;
}
.tsim-stats-dist-fill {
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height 0.3s ease;
}
.tsim-stats-dist-fill.pos { background: var(--tsim-positive); }
.tsim-stats-dist-fill.neg { background: var(--tsim-negative); }
.tsim-stats-dist-label {
    text-align: center;
    font-size: 9px;
    color: var(--tsim-text-muted);
    margin-top: 4px;
    font-family: var(--tsim-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   BOTTOM PANEL - UNIFIED STATS + POSITIONS
   Прижат к низу экрана
   ======================================== */
.tsim-bottom-panel {
    flex-shrink: 0;
    flex-grow: 0;
    display: flex;
    flex-direction: column;
    background: var(--tsim-bg-secondary);
    border-top: 1px solid var(--tsim-border);
    max-height: 32vh; /* P0-1: ограничиваем чтобы таблица позиций всегда влезала в viewport */
    overflow: hidden;
}

.tsim-stats-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 6px 16px;
    background: linear-gradient(180deg, #1e222d 0%, #1a1e28 100%);
    border-bottom: 1px solid var(--tsim-border);
}

.tsim-stat-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tsim-stat-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tsim-text-muted);
    font-weight: 500;
}

.tsim-stat-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    font-family: var(--tsim-font);
}

.tsim-stat-value.positive { color: var(--tsim-positive); }
.tsim-stat-value.negative { color: var(--tsim-negative); }

.tsim-bottom-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.tsim-btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    cursor: pointer;
}

/* Positions Row */
.tsim-positions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: var(--tsim-bg-primary);
    border-bottom: 1px solid var(--tsim-border);
}

.tsim-positions-tabs {
    display: flex;
    gap: 2px;
    background: var(--tsim-bg-tertiary);
    padding: 2px;
    border-radius: var(--tsim-radius);
}

.tsim-pos-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: transparent;
    border: none;
    border-radius: var(--tsim-radius);
    cursor: pointer;
}

.tsim-pos-tab svg {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.tsim-pos-tab.active {
    background: var(--tsim-accent);
    color: #000;
}

.tsim-pos-tab.active svg {
    opacity: 1;
    stroke: #000;
}

.tsim-tab-badge {
    font-size: 9px;
    padding: 1px 6px;
    background: var(--tsim-accent);
    color: #000;
    border-radius: 10px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.tsim-tab-badge.tsim-badge-muted {
    background: var(--tsim-bg-tertiary);
    color: var(--tsim-text-muted);
}

/* Pagination */
.tsim-pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    font-size: 10px;
    color: var(--tsim-text-muted);
}

.tsim-page-btn {
    padding: 3px 8px;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: #fff;
    font-size: 10px;
    cursor: pointer;
}

.tsim-page-btn.active {
    background: var(--tsim-accent);
    color: #000;
}

.tsim-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Positions Body */
.tsim-positions-body {
    background: var(--tsim-bg-primary);
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto; /* P0-1: внутренний scroll, если строк много */
}

.tsim-table-wrapper {
    display: none;
}

.tsim-table-wrapper.active {
    display: block;
}

.tsim-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--tsim-text-muted);
    font-size: 11px;
}

.tsim-empty-state svg {
    opacity: 0.4;
}

/* Table Cell Styles */
.tsim-cell-id {
    color: var(--tsim-text-muted);
    font-size: 9px;
}

.tsim-cell-symbol {
    font-weight: 600;
    color: var(--tsim-text-bright);
}

.tsim-cell-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: var(--tsim-radius);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.tsim-cell-type.buy {
    background: var(--tsim-positive-dim);
    color: var(--tsim-positive);
}

.tsim-cell-type.sell {
    background: var(--tsim-negative-dim);
    color: var(--tsim-negative);
}

.tsim-cell-pnl {
    font-weight: 700;
}

.tsim-cell-pnl.positive { color: var(--tsim-positive); }
.tsim-cell-pnl.negative { color: var(--tsim-negative); }

.tsim-cell-time {
    color: var(--tsim-text-muted);
    font-size: 9px;
}

.tsim-cell-btn {
    padding: 3px 8px;
    font-size: 9px;
    font-weight: 600;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius);
    color: #fff;
    cursor: pointer;
}

/* ========================================
   TOASTS
   ======================================== */
.tsim-toasts {
    position: absolute;
    top: 120px; /* P1-6: ниже OHLC-панели чтобы не перекрывать */
    right: 376px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; /* контейнер не блокирует клики, отдельные тосты включают pe в стилях .tsim-toast */
}
.tsim-toast { pointer-events: auto; }

.tsim-toast {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius-lg);
    box-shadow: var(--tsim-shadow);
    min-width: 280px;
    animation: tsim-toast-in 0.3s ease;
}

.tsim-toast.success { border-left: 4px solid var(--tsim-positive); }
.tsim-toast.error { border-left: 4px solid var(--tsim-negative); }
.tsim-toast.warning { border-left: 4px solid var(--tsim-warning); }

.tsim-toast-icon { font-size: 20px; }
.tsim-toast-content { flex: 1; }
.tsim-toast-title { 
    font-weight: 700; 
    font-size: 14px; 
    color: var(--tsim-text-bright); 
    margin-bottom: 2px;
}
.tsim-toast-message { font-size: 13px; color: var(--tsim-text-muted); }
.tsim-toast-close {
    color: var(--tsim-text-muted);
    font-size: 20px;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    transition: var(--tsim-transition);
    font-weight: 300;
}
.tsim-toast-close:hover { color: var(--tsim-text); }

@keyframes tsim-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   SCROLLBAR
   ======================================== */
.tsim ::-webkit-scrollbar { width: 8px; height: 8px; }
.tsim ::-webkit-scrollbar-track { background: var(--tsim-bg-primary); }
.tsim ::-webkit-scrollbar-thumb { 
    background: var(--tsim-border-light); 
    border-radius: 4px; 
}
.tsim ::-webkit-scrollbar-thumb:hover { background: var(--tsim-accent); }

/* ========================================
   RESPONSIVE
   ======================================== */
/* ========================================
   INDICATORS / DRAWING TOOLBAR
   ======================================== */
.tsim-indicators-bar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 10px;
    background: var(--tsim-bg-secondary);
    border-bottom: 1px solid var(--tsim-border);
    flex-wrap: nowrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    contain: layout paint;
    scrollbar-width: thin;
    scrollbar-color: var(--tsim-border-light) transparent;
}
.tsim-indicators-bar::-webkit-scrollbar {
    height: 4px;
}
.tsim-indicators-bar::-webkit-scrollbar-track {
    background: transparent;
}
.tsim-indicators-bar::-webkit-scrollbar-thumb {
    background: var(--tsim-border-light);
    border-radius: 999px;
}
.tsim-indicators-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: max-content;
    flex-wrap: nowrap;
}
.tsim-indicators-label {
    font-size: 11px;
    color: var(--tsim-text-bright);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 2px;
}
.tsim-indicator-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    border-radius: 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--tsim-text-bright);
    cursor: pointer;
    user-select: none;
    transition: var(--tsim-transition);
    position: relative;
    white-space: nowrap;
}
.tsim-indicator-chip::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chip-color, var(--tsim-text-muted));
    box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}
.tsim-indicator-chip[data-color="#42a5f5"] { --chip-color: #42a5f5; }
.tsim-indicator-chip[data-color="#ffb74d"] { --chip-color: #ffb74d; }
.tsim-indicator-chip[data-color="#7cb342"] { --chip-color: #7cb342; }
.tsim-indicator-chip[data-color="#ab47bc"] { --chip-color: #ab47bc; }
.tsim-indicator-chip[data-color="#26c6da"] { --chip-color: #26c6da; }
.tsim-indicator-chip[data-color="#f48fb1"] { --chip-color: #f48fb1; }
.tsim-indicator-chip[data-color="#f43f5e"] { --chip-color: #f43f5e; }
.tsim-indicator-chip[data-color="#06b6d4"] { --chip-color: #06b6d4; }
.tsim-indicator-chip[data-color="#a78bfa"] { --chip-color: #a78bfa; }
.tsim-indicator-chip[data-color="#10b981"] { --chip-color: #10b981; }
.tsim-indicator-chip[data-color="#fbbf24"] { --chip-color: #fbbf24; }
.tsim-indicator-chip[data-color="#facc15"] { --chip-color: #facc15; }
.tsim-indicator-chip:hover {
    border-color: var(--chip-color, var(--tsim-accent));
    background: var(--tsim-bg-hover);
}
.tsim-indicator-chip input[type="checkbox"] {
    accent-color: var(--tsim-accent);
    margin: 0;
    cursor: pointer;
    width: 12px;
    height: 12px;
}
.tsim-indicator-chip:has(input:checked) {
    background: var(--tsim-accent-dim);
    border-color: var(--tsim-accent);
    color: var(--tsim-text-bright);
    box-shadow: 0 0 0 1px var(--tsim-accent-glow);
}
.tsim-subpane-select {
    width: auto;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--tsim-text-bright);
    font-weight: 500;
}
.tsim-draw-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--tsim-border);
    background: var(--tsim-bg-tertiary);
    color: var(--tsim-text-bright);
    border-radius: var(--tsim-radius);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--tsim-transition);
    font-family: var(--tsim-mono);
}
.tsim-draw-btn:hover {
    border-color: var(--tsim-accent);
    color: var(--tsim-accent);
    background: var(--tsim-bg-hover);
}
.tsim-draw-btn.active {
    background: var(--tsim-accent);
    color: #fff;
    border-color: var(--tsim-accent);
    box-shadow: 0 0 0 1px var(--tsim-accent-glow);
}
.tsim-draw-btn.tsim-draw-eraser:hover,
.tsim-draw-btn.tsim-draw-eraser.active {
    background: var(--tsim-warning);
    color: #131722;
    border-color: var(--tsim-warning);
}
.tsim-draw-btn.tsim-draw-clear {
    color: var(--tsim-negative);
    font-size: 18px;
}
.tsim-draw-btn.tsim-draw-clear:hover {
    border-color: var(--tsim-negative);
    color: #fff;
    background: var(--tsim-negative);
}
.tsim-subpane-container {
    height: 140px;
    width: 100%;
    border-top: 1px solid var(--tsim-border);
    flex-shrink: 0;
}

/* Chart legend (top-left of chart) */
.tsim-chart-legend {
    position: absolute;
    top: 8px;
    left: 12px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
}
.tsim-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(19, 23, 34, 0.75);
    border: 1px solid var(--tsim-border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--tsim-text-bright);
    font-family: var(--tsim-mono);
}
.tsim-legend-item i {
    display: inline-block;
    width: 10px;
    height: 2px;
    border-radius: 1px;
}

/* Drawing overlay sits above chart canvas */
.tsim-drawing-overlay { position: absolute; left: 0; top: 0; }

/* Inline SL/TP edit input */
.tsim-cell-input {
    width: 90%;
    max-width: 100px;
    background: var(--tsim-bg-input);
    border: 1px solid transparent;
    color: var(--tsim-text-bright);
    padding: 3px 5px;
    border-radius: 3px;
    font-family: var(--tsim-mono);
    font-size: 12px;
    text-align: right;
}
.tsim-cell-input:hover,
.tsim-cell-input:focus {
    border-color: var(--tsim-accent);
    outline: none;
}
.tsim-cell-input::-webkit-inner-spin-button,
.tsim-cell-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tsim-cell-input { -moz-appearance: textfield; }

/* ========================================
   REALISM: Margin Level, Leverage, Swaps
   ======================================== */
.tsim-account-value.warning { color: var(--tsim-warning); }
.tsim-account-value.negative { color: var(--tsim-negative); }
.tsim-account-value.positive { color: var(--tsim-positive); }
.tsim-account-value.tsim-blink {
    animation: tsim-blink 0.8s infinite;
}
@keyframes tsim-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.tsim-leverage-select {
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text-bright);
    padding: 2px 6px;
    border-radius: var(--tsim-radius);
    font-family: var(--tsim-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.tsim-leverage-select:focus {
    outline: none;
    border-color: var(--tsim-accent);
}

/* ========================================
   MODAL
   ======================================== */
.tsim-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.tsim-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.tsim-modal {
    background: var(--tsim-bg-secondary);
    border: 1px solid var(--tsim-border);
    border-radius: var(--tsim-radius-lg);
    box-shadow: var(--tsim-shadow);
    padding: 24px;
    min-width: 320px;
    max-width: 720px;
    max-height: 85vh;
    overflow-y: auto;
    width: 92%;
    transform: translateY(10px);
    transition: transform 0.2s ease;
    font-family: var(--tsim-font);
    color: var(--tsim-text);
}
.tsim-modal-overlay.active .tsim-modal {
    transform: translateY(0);
}
.tsim-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--tsim-accent-dim);
    color: var(--tsim-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 0 auto 14px;
}
.tsim-modal-title {
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: var(--tsim-text-bright);
    margin-bottom: 10px;
}
.tsim-modal-body {
    text-align: center;
    color: var(--tsim-text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 18px;
}
.tsim-modal-body b {
    color: var(--tsim-text-bright);
    font-weight: 600;
}
.tsim-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.tsim-modal-actions button {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--tsim-radius);
    cursor: pointer;
    transition: var(--tsim-transition);
    border: 1px solid var(--tsim-border);
}
.tsim-modal-actions .tsim-btn-secondary {
    background: var(--tsim-bg-tertiary);
    color: var(--tsim-text);
}
.tsim-modal-actions .tsim-btn-secondary:hover {
    background: var(--tsim-bg-hover);
}
.tsim-modal-trade {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    background: var(--tsim-bg-tertiary);
    padding: 12px;
    border-radius: var(--tsim-radius);
    margin: 4px 0 0;
}
.tsim-modal-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 13px;
}
.tsim-modal-row span {
    color: var(--tsim-text-muted);
}
.tsim-modal-row b {
    color: var(--tsim-text-bright);
    font-family: var(--tsim-mono);
}
.tsim-modal-row b.buy { color: var(--tsim-positive); }
.tsim-modal-row b.sell { color: var(--tsim-negative); }

/* ========================================
   MOBILE MENU
   ======================================== */
.tsim-mobile-menu-btn {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--tsim-bg-tertiary);
    border: 1px solid var(--tsim-border);
    color: var(--tsim-text);
    padding: 8px 12px;
    border-radius: var(--tsim-radius);
    cursor: pointer;
    font-family: var(--tsim-font);
    font-size: 13px;
    font-weight: 600;
    transition: var(--tsim-transition);
}
.tsim-mobile-menu-btn:hover {
    background: var(--tsim-bg-hover);
    border-color: var(--tsim-accent);
}
.tsim-mobile-menu-label {
    color: var(--tsim-text-bright);
}

.tsim-mobile-tabs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 90000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.tsim-mobile-tabs-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.tsim-mobile-tabs-sheet {
    background: var(--tsim-bg-secondary);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    width: 100%;
    max-width: 480px;
    padding: 14px 14px 22px;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}
.tsim-mobile-tabs-overlay.active .tsim-mobile-tabs-sheet {
    transform: translateY(0);
}
.tsim-mobile-tabs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px 12px;
    color: var(--tsim-text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--tsim-border);
    margin-bottom: 8px;
}
.tsim-mobile-tabs-close {
    background: none;
    border: none;
    color: var(--tsim-text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.tsim-mobile-tab-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--tsim-radius);
    color: var(--tsim-text);
    font-family: var(--tsim-font);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}
.tsim-mobile-tab-item.active {
    background: var(--tsim-accent-dim);
    color: var(--tsim-accent);
    font-weight: 600;
}
.tsim-mobile-tab-item:hover {
    background: var(--tsim-bg-hover);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
    .tsim-panel { width: 320px; min-width: 320px; }
    .tsim-account { gap: 18px; }
    .tsim-account-item:nth-child(4) { display: none; }
}

@media (max-width: 1360px) and (min-width: 1025px) {
    .tsim-logo-text { display: none; }
    .tsim-topbar-center { padding-right: 8px; }
    .tsim-account { gap: 14px; }
    .tsim-account-value { font-size: 13px; }
    .tsim-icon-btn { width: 38px; height: 38px; }
}

@media (max-width: 1024px) {
    .tsim-main-tabs { display: none; }
    .tsim-mobile-menu-btn { display: inline-flex; }
    .tsim-topbar-center { display: flex; }
    .tsim-logo { display: none; }
    /* Compact account: hide Margin, keep Balance/Equity/PnL */
    .tsim-account { gap: 14px; }
    .tsim-account-item:nth-child(n+4) { display: none; }
    .tsim-account-label { font-size: 9px; }
    .tsim-account-value { font-size: 12px; }
}

@media (max-width: 768px) {
    .tsim-fullwidth-wrapper {
        height: auto;
        min-height: calc(100vh - 60px);
        min-height: calc(100dvh - 60px);
        overflow-y: visible;
    }

    .tsim {
        height: auto;
        min-height: calc(100vh - 60px);
        min-height: calc(100dvh - 60px);
        overflow: visible;
    }

    .tsim-main { flex-direction: column; }

    .tsim-chart-section {
        min-height: 350px;
        max-height: 450px;
    }

    .tsim-panel {
        width: 100%;
        min-width: 100%;
        flex: 1;
    }

    .tsim-topbar { padding: 10px 14px; }

    /* Timeframes as scrollable strip instead of hidden */
    .tsim-timeframes {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
        flex-wrap: nowrap;
        max-width: 100%;
        gap: 4px;
    }
    .tsim-timeframes::-webkit-scrollbar { display: none; }
    .tsim-tf-btn { flex-shrink: 0; }

    /* Hide account on phones — too cramped */
    .tsim-account { display: none; }

    .tsim-ohlcv { display: none; }

    .tsim-stats-row {
        flex-wrap: wrap;
        gap: 14px 24px;
    }

    .tsim-toasts {
        right: 16px;
        left: 16px;
    }

    .tsim-toast { min-width: auto; }

    .tsim-section { margin: 4px; }

    .tsim-modal { padding: 18px; }

    .tsim-bt-params { grid-template-columns: 1fr; }
    .tsim-bt-metrics { grid-template-columns: 1fr; }
    .tsim-stats-extras { grid-template-columns: 1fr; }
    .tsim-bottom-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .tsim-instrument-selector {
        min-width: auto;
    }

    .tsim-instrument-info {
        display: none;
    }

    .tsim-current-price {
        font-size: 24px;
    }

    .tsim-sltp-row {
        grid-template-columns: 1fr;
    }

    .tsim-trade-btns {
        grid-template-columns: 1fr;
    }
}

/* Hide hotkey hints on touch-only devices (no hover, coarse pointer) */
@media (hover: none) and (pointer: coarse) {
    .tsim-hotkeys { display: none !important; }
    .tsim-trade-key { display: none !important; }
}

@media (max-width: 480px) {
    .tsim-instrument-selector {
        min-width: auto;
    }
    
    .tsim-instrument-info {
        display: none;
    }
    
    .tsim-current-price {
        font-size: 24px;
    }
    
    .tsim-sltp-row {
        grid-template-columns: 1fr;
    }

    .tsim-trade-btns {
        grid-template-columns: 1fr;
    }
}

/* ==================== Pro Tools: Stat sig / OOS / Heatmap / Presets / Portfolio / CSV ==================== */
.tsim-stat-badge-row { margin: 8px 0; }
.tsim-stat-badge {
    display: inline-block; padding: 6px 12px; border-radius: 6px;
    font-size: 12px; font-weight: 600;
}
.tsim-stat-badge.ok { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.4); }
.tsim-stat-badge.warn { background: rgba(251, 191, 36, 0.15); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }

.tsim-opt-oos-col { border-left: 2px dashed #2a2e39 !important; }
.tsim-opt-result-table th.tsim-opt-oos-col,
.tsim-opt-result-table td.tsim-opt-oos-col { background: rgba(99, 102, 241, 0.06); }
.tsim-opt-oos { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; }
.tsim-opt-table-wrap {
    overflow-x: auto;
    margin: 8px 0;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.tsim-opt-table-wrap .table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tsim-opt-table-wrap .tsim-bt-pro-table {
    min-width: 760px;
}
.tsim-bt-pro-table::before,
.tsim-opt-table::before,
.tsim-hm-table::before {
    content: none !important;
    display: none !important;
}
.tsim-opt-table-wrap .responsive-cards .tsim-bt-pro-table,
.tsim-opt-config .responsive-cards .tsim-opt-table {
    display: table !important;
}
.tsim-opt-table-wrap .responsive-cards thead,
.tsim-opt-config .responsive-cards thead {
    display: table-header-group !important;
    position: static !important;
}
.tsim-opt-table-wrap .responsive-cards tbody,
.tsim-opt-config .responsive-cards tbody {
    display: table-row-group !important;
}
.tsim-opt-table-wrap .responsive-cards tr,
.tsim-opt-config .responsive-cards tr {
    display: table-row !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible !important;
}
.tsim-opt-table-wrap .responsive-cards th,
.tsim-opt-table-wrap .responsive-cards td,
.tsim-opt-config .responsive-cards th,
.tsim-opt-config .responsive-cards td {
    display: table-cell !important;
    position: static !important;
    padding: 4px 6px !important;
    border-bottom: 1px solid var(--tsim-border) !important;
    background: transparent !important;
    box-shadow: none !important;
}
.tsim-opt-table-wrap .responsive-cards th,
.tsim-opt-config .responsive-cards th {
    padding: 5px 6px !important;
    background: var(--tsim-bg-secondary) !important;
}
.tsim-opt-table-wrap .responsive-cards tr::before,
.tsim-opt-table-wrap .responsive-cards td::before,
.tsim-opt-config .responsive-cards tr::before,
.tsim-opt-config .responsive-cards td::before {
    content: none !important;
    display: none !important;
}
.tsim-opt-heatmap-btn { margin-left: auto; }
.tsim-opt-heatmap { margin-top: 12px; padding: 12px; background: #131722; border-radius: 6px; border: 1px solid #2a2e39; }
.tsim-hm-head { font-weight: 600; color: #e6e9ee; margin-bottom: 10px; }
.tsim-hm-table-wrap { overflow-x: auto; }
.tsim-hm-table { border-collapse: collapse; font-size: 11px; }
.tsim-hm-table th, .tsim-hm-table td { padding: 6px 8px; text-align: center; min-width: 50px; border: 1px solid #1e222d; }
.tsim-hm-axis { background: #1e222d; color: #9ca3af; font-weight: 500; font-size: 11px; }
.tsim-hm-axis-label { background: #1e222d; color: #9ca3af; font-weight: 600; }
.tsim-hm-cell { color: #fff; font-weight: 600; font-size: 11px; }
.tsim-hm-empty { background: #2a2e39; color: #6b7280; }
.tsim-hm-legend { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 11px; color: #9ca3af; }
.tsim-hm-grad { display: inline-block; width: 120px; height: 12px; border-radius: 3px;
    background: linear-gradient(90deg, #f43f5e, #fbbf24, #10b981); }

.tsim-bt-presets-row {
    display: flex; gap: 6px; align-items: center; margin: 8px 0;
    padding: 8px; background: rgba(99, 102, 241, 0.06); border-radius: 6px;
}
.tsim-bt-preset-sel {
    flex: 1; min-width: 160px; padding: 6px 10px;
    background: #131722; color: #e6e9ee; border: 1px solid #2a2e39; border-radius: 4px;
    font-size: 12px;
}

.tsim-pf-body { font-size: 13px; }
.tsim-pf-note { padding: 8px 10px; background: rgba(99, 102, 241, 0.08); border-radius: 6px; margin-bottom: 12px; color: #c5cad5; font-size: 12px; }
.tsim-pf-symbols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tsim-pf-sym {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    background: #131722; border: 1px solid #2a2e39; border-radius: 4px;
    cursor: pointer; user-select: none; transition: background 0.15s;
}
.tsim-pf-sym:hover { background: #1a1e29; }
.tsim-pf-sym input[type=checkbox] { margin: 0; }
.tsim-pf-sym .tsim-pf-icon { font-weight: 600; }
.tsim-pf-sym small { color: #6b7280; margin-left: auto; }
.tsim-pf-subhead { font-weight: 600; color: #e6e9ee; margin: 14px 0 6px; font-size: 13px; }
.tsim-pf-corr td, .tsim-pf-corr th { text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

.tsim-csv-body { font-size: 13px; }
.tsim-csv-note { padding: 10px; background: rgba(99, 102, 241, 0.08); border-radius: 6px; margin-bottom: 10px; color: #c5cad5; font-size: 12px; line-height: 1.5; }
.tsim-csv-note code { background: #131722; padding: 1px 6px; border-radius: 3px; color: #f59e0b; font-size: 11px; }
.tsim-csv-body input[type=file] { display: block; margin-bottom: 10px; color: #c5cad5; }
.tsim-csv-body textarea {
    width: 100%; min-height: 140px;
    background: #131722; color: #c5cad5; border: 1px solid #2a2e39; border-radius: 4px;
    padding: 8px; font-family: 'JetBrains Mono', monospace; font-size: 11px;
    resize: vertical;
}
.tsim-csv-status { margin-top: 6px; font-size: 12px; }

/* Random search hint */
.tsim-opt-mode-hint { color: #9ca3af; font-size: 11px; flex: 1; }

/* Compare presets chart */
.tsim-cmp-chart {
    width: 100%; height: 280px; margin: 12px 0;
    border-radius: 6px; overflow: hidden;
    border: 1px solid #2a2e39;
}
.tsim-cmp-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 6px; vertical-align: middle;
}

/* FAQ */
.tsim-bt-faq {
    margin: 12px 0;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
}
.tsim-bt-faq summary {
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    color: #c5cad5;
    user-select: none;
    font-size: 13px;
}
.tsim-bt-faq summary:hover { color: #fff; }
.tsim-bt-faq[open] summary { border-bottom: 1px solid rgba(99, 102, 241, 0.2); }
.tsim-bt-faq-body {
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.55;
    color: #c5cad5;
    max-height: 400px;
    overflow-y: auto;
}
.tsim-bt-faq-body h4 {
    margin: 14px 0 6px;
    font-size: 13px;
    color: #fbbf24;
    font-weight: 600;
}
.tsim-bt-faq-body h4:first-child { margin-top: 0; }
.tsim-bt-faq-body ul { margin: 4px 0 10px 18px; padding: 0; }
.tsim-bt-faq-body li { margin-bottom: 4px; }
.tsim-bt-faq-body p { margin: 0 0 8px; }
.tsim-bt-faq-body code {
    background: #131722; padding: 1px 5px; border-radius: 3px;
    color: #f59e0b; font-size: 11px; font-family: 'JetBrains Mono', monospace;
}
.tsim-bt-faq-body b { color: #e6e9ee; }

@media (max-width: 600px) {
    .tsim-bt-presets-row { flex-wrap: wrap; }
    .tsim-pf-symbols { grid-template-columns: 1fr; }
    .tsim-bt-faq-body { padding: 10px 12px; max-height: 280px; }
    .tsim-opt-config .tsim-opt-table { min-width: 640px; }
}

/* ==================== MOBILE LAYOUT REFRESH (≤768px) ==================== */
/* По умолчанию mobile-only элементы скрыты на desktop */
.tsim-mobile-toolbar,
.tsim-mobile-account-bar,
.tsim-mobile-fab { display: none; }

@media (max-width: 768px) {
    /* === Topbar: компактный, sticky === */
    .tsim-fullwidth-wrapper {
        height: auto;
        min-height: calc(100vh - 60px);
        min-height: calc(100dvh - 60px);
        overflow-y: visible;
    }
    .tsim {
        height: auto;
        min-height: calc(100vh - 60px);
        min-height: calc(100dvh - 60px);
        overflow: visible;
    }
    .tsim-topbar {
        position: sticky; top: 0; z-index: 50;
        background: #1e222d;
        padding: 6px 10px !important;
        gap: 6px;
        min-height: 52px;
        flex-wrap: nowrap;
    }
    .tsim-topbar-left { gap: 4px; flex: 0 1 auto; min-width: 0; overflow: hidden; }
    .tsim-topbar-center { flex: 0 0 auto; min-width: 0; justify-content: flex-end; }
    .tsim-topbar-right { flex: 0 0 auto; }
    .tsim-logo { display: none; }
    .tsim-logo-text { display: none; }
    .tsim-instrument-name { font-size: 13px; }
    .tsim-instrument-fullname { display: none; }
    .tsim-instrument-selector { padding: 4px 8px !important; }
    .tsim-timeframes {
        gap: 2px;
        flex: 0 1 auto;
        max-width: 180px;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .tsim-timeframes::-webkit-scrollbar { display: none; }
    .tsim-tf-btn { padding: 4px 8px; font-size: 11px; min-width: 30px; min-height: 32px; }
    /* На мобильном скрываем текст активного таба у hamburger — оставляем только ☰ */
    .tsim-mobile-menu-btn {
        width: 40px; min-width: 40px !important; padding: 0 !important;
        justify-content: center;
    }
    .tsim-mobile-menu-label { display: none !important; }
    .tsim-chevron { display: none !important; }
    /* Скрываем чужую кнопку fullscreen в topbar-right на мобильном — экономим место */
    .tsim-topbar-right .tsim-fullscreen-btn { display: none !important; }

    /* === Account bar (mobile sticky strip) === */
    .tsim-mobile-account-bar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        padding: 8px 10px;
        background: #131722;
        border-bottom: 1px solid #2a2e39;
        position: sticky; top: 52px; z-index: 49;
    }
    .tsim-mobile-account-item {
        display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        text-align: center;
        min-width: 0;
    }
    .tsim-mobile-account-label {
        font-size: 9px; color: #6b7280;
        text-transform: uppercase; letter-spacing: 0.5px;
        line-height: 1;
    }
    .tsim-mobile-account-value {
        font-size: 13px; font-weight: 600; color: #e6e9ee;
        margin-top: 2px; line-height: 1.1;
        white-space: nowrap;
    }
    .tsim-mobile-account-value.positive { color: #10b981; }
    .tsim-mobile-account-value.negative { color: #f43f5e; }

    /* === Скрыть оригинальный desktop account widget на мобильном === */
    .tsim-account { display: none !important; }

    /* === Mobile quick toolbar (3 кнопки) === */
    .tsim-mobile-toolbar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px 10px;
        background: #1e222d;
        border-bottom: 1px solid #2a2e39;
    }
    .tsim-mobile-tool-btn {
        display: flex; align-items: center; justify-content: center;
        gap: 6px;
        min-height: 40px;
        padding: 0 8px;
        background: #2a2e39;
        border: 1px solid #2a2e39;
        border-radius: 8px;
        color: #c5cad5;
        font-size: 12px; font-weight: 500;
        cursor: pointer;
        transition: background 0.15s;
    }
    .tsim-mobile-tool-btn:active { background: #353a48; }
    .tsim-mobile-tool-btn.is-active { background: rgba(99, 102, 241, 0.18); border-color: rgba(99, 102, 241, 0.5); color: #fff; }
    .tsim-mobile-tool-icon { font-size: 16px; line-height: 1; }
    .tsim-mobile-tool-label { line-height: 1; }

    /* === Chart Section: максимум места для свечей на вкладке Симуляция === */
    .tsim-main {
        flex: 0 0 auto;
        flex-direction: column;
        min-height: auto;
        overflow: visible;
    }
    .tsim-chart-section {
        min-height: 60vh !important;
        max-height: none !important;
        height: 60vh;
    }
    .tsim-simulator-view {
        display: flex; flex-direction: column;
        height: 100%;
    }
    .tsim-chart-container {
        flex: 1 1 auto;
        min-height: 50vh;
        height: auto !important;
    }
    .tsim-subpane-container { flex: 0 0 auto; max-height: 25vh; }

    /* === Tab-content панель (бэктест/статистика/живой график) на мобильном === */
    .tsim-panel {
        width: 100%;
        min-height: auto;
        overflow: visible;
    }
    /* На backtest/statistics — скрываем chart-section целиком (там только симулятор-view) */
    .tsim-fullwidth-wrapper[data-active-tab="backtest"] .tsim-chart-section,
    .tsim-fullwidth-wrapper[data-active-tab="statistics"] .tsim-chart-section {
        display: none !important;
    }
    /* На livechart — chart-section остаётся (iframe внутри), но занимает весь экран */
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-chart-section {
        min-height: calc(100vh - 52px - 64px) !important;
        height: calc(100vh - 52px - 64px) !important;
    }
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-livechart-view {
        height: 100% !important;
    }
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-livechart-view iframe {
        width: 100% !important;
        height: 100% !important;
        min-height: 70vh;
    }
    /* На небольших экранах при backtest/stats/livechart не нужны mobile-toolbar и FAB */
    .tsim-fullwidth-wrapper[data-active-tab="backtest"] .tsim-mobile-toolbar,
    .tsim-fullwidth-wrapper[data-active-tab="statistics"] .tsim-mobile-toolbar,
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-mobile-toolbar,
    .tsim-fullwidth-wrapper[data-active-tab="backtest"] .tsim-mobile-fab,
    .tsim-fullwidth-wrapper[data-active-tab="statistics"] .tsim-mobile-fab,
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-mobile-fab {
        display: none !important;
    }
    /* В backtest/stats tab content становится прокручиваемым на весь оставшийся экран */
    .tsim-fullwidth-wrapper[data-active-tab="backtest"] .tsim-tab-content[data-content="backtest"],
    .tsim-fullwidth-wrapper[data-active-tab="statistics"] .tsim-tab-content[data-content="statistics"] {
        display: block !important;
        min-height: calc(100vh - 52px - 64px);
        height: auto !important;
        overflow: visible !important;
        padding: 12px 10px !important;
    }
    /* На backtest/stats скрываем дублирующиеся positions/orders/history табы — они для simulation */
    .tsim-fullwidth-wrapper[data-active-tab="backtest"] .tsim-bottom-panel,
    .tsim-fullwidth-wrapper[data-active-tab="statistics"] .tsim-bottom-panel,
    .tsim-fullwidth-wrapper[data-active-tab="livechart"] .tsim-bottom-panel {
        display: none !important;
    }

    /* === Price header: компактный === */
    .tsim-price-header { padding: 6px 10px; gap: 6px; }
    .tsim-current-price { font-size: 18px !important; line-height: 1.2; }
    .tsim-price-change { font-size: 11px; padding: 2px 6px; }
    .tsim-data-source {
        max-width: 46vw;
        height: 20px;
        padding: 0 7px;
        font-size: 10px;
    }

    /* === Скрываем inline indicators-bar — управляется через mobile-toolbar drawer === */
    .tsim-indicators-bar {
        display: none;
    }
    /* В режиме открытого drawer: показываем как bottom-sheet */
    .tsim-indicators-bar.is-mobile-open {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 100;
        background: #1e222d;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        padding: 16px 14px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
        gap: 14px;
        animation: tsimSlideUp 0.25s ease-out;
    }
    /* В drawer-mode: какую группу показать? Управляется атрибутом data-mobile-section */
    .tsim-indicators-bar[data-mobile-section="indicators"] .tsim-indicators-group:nth-child(1),
    .tsim-indicators-bar[data-mobile-section="indicators"] .tsim-indicators-group:nth-child(2) { display: flex; }
    .tsim-indicators-bar[data-mobile-section="indicators"] .tsim-indicators-group:nth-child(3) { display: none; }
    .tsim-indicators-bar[data-mobile-section="drawing"] .tsim-indicators-group:nth-child(1),
    .tsim-indicators-bar[data-mobile-section="drawing"] .tsim-indicators-group:nth-child(2) { display: none; }
    .tsim-indicators-bar[data-mobile-section="drawing"] .tsim-indicators-group:nth-child(3) { display: flex; }

    /* В развёрнутом виде индикаторы-чипы — крупнее, в сетке */
    .tsim-indicators-bar.is-mobile-open .tsim-indicators-group {
        flex-wrap: wrap;
        gap: 6px;
    }
    .tsim-indicators-bar.is-mobile-open .tsim-indicator-chip {
        flex: 0 0 calc(50% - 3px);
        padding: 10px 12px;
        font-size: 12px;
        min-height: 40px;
    }
    .tsim-indicators-bar.is-mobile-open .tsim-indicators-label {
        flex: 0 0 100%;
        font-weight: 600; color: #fff;
        font-size: 13px;
        text-transform: uppercase;
    }
    .tsim-indicators-bar.is-mobile-open .tsim-draw-btn {
        width: 48px; height: 48px;
        font-size: 18px;
    }
    .tsim-indicators-bar.is-mobile-open .tsim-subpane-select {
        flex: 1 1 100%;
        min-height: 40px;
        font-size: 13px;
    }

    /* === Backdrop для bottom-sheets === */
    .tsim-mobile-drawer-backdrop {
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        animation: tsimFadeIn 0.2s;
    }

    /* === Скрываем hotkey-подсказки и chart-controls на mobile === */
    .tsim-hotkeys, .tsim-chart-controls { display: none !important; }

    /* === Chart controls overlay для управления (Plyer): bottom-sheet === */
    /* tsim-controls-section — это плеер УПРАВЛЕНИЕ. Он сейчас в bottom-panel. Сделаем отдельный drawer. */
    .tsim-controls-drawer {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 100;
        background: #1e222d;
        border-radius: 16px 16px 0 0;
        padding: 16px 14px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
        transform: translateY(100%);
        transition: transform 0.25s ease;
    }
    .tsim-controls-drawer.is-open { transform: translateY(0); }

    /* === Trading FAB === */
    .tsim-mobile-fab {
        display: flex; align-items: center; gap: 6px;
        position: fixed;
        right: 16px;
        bottom: calc(20px + env(safe-area-inset-bottom));
        z-index: 95;
        height: 56px;
        padding: 0 20px;
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        color: #fff;
        border: none;
        border-radius: 28px;
        box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
        font-weight: 700;
        font-size: 14px;
        cursor: pointer;
        transition: transform 0.15s;
    }
    .tsim-mobile-fab:active { transform: scale(0.96); }
    .tsim-mobile-fab-icon { font-size: 18px; line-height: 1; }
    .tsim-mobile-fab-label { line-height: 1; }

    /* === Trading-form (Simulation tab) → bottom-sheet === */
    /* На мобильном вся форма Симуляции = drawer, открывается через FAB */
    .tsim-tab-content[data-content="simulation"] {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 100;
        background: #1e222d;
        max-height: 80vh;
        overflow-y: auto;
        border-radius: 16px 16px 0 0;
        padding: 18px 14px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
        transform: translateY(100%);
        transition: transform 0.25s ease;
        display: block !important;
    }
    .tsim-tab-content[data-content="simulation"].is-mobile-open {
        transform: translateY(0);
    }
    .tsim-tab-content[data-content="simulation"]::before {
        content: '';
        display: block;
        width: 40px; height: 4px;
        background: #4a5568;
        border-radius: 2px;
        margin: 0 auto 14px;
    }

    /* === Backtest/Statistics: оставляем нормальный поток, но компактно === */
    .tsim-tab-content[data-content="backtest"],
    .tsim-tab-content[data-content="statistics"],
    .tsim-tab-content[data-content="livechart"] {
        padding: 10px 8px;
    }
    .tsim-bt-results {
        padding: 0 6px 12px;
    }
    .tsim-bt-metric {
        align-items: center;
        gap: 10px;
    }
    .tsim-bt-metric span {
        letter-spacing: 0.2px;
    }
    .tsim-bt-metric b {
        text-align: right;
        overflow-wrap: anywhere;
    }
    .tsim-bt-export-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        justify-content: stretch;
    }
    .tsim-bt-export-row button {
        width: 100%;
        min-height: 38px;
        padding: 6px 8px;
        font-size: 11px;
    }
    .tsim-bt-pro-block {
        padding: 10px;
        overflow: hidden;
    }
    .tsim-bt-pro-head {
        font-size: 12px;
        line-height: 1.35;
        letter-spacing: 0.2px;
    }
    .tsim-bt-pro-grid {
        grid-template-columns: 1fr;
    }
    .tsim-bt-pro-grid > div,
    .tsim-bt-pro-summary span {
        min-width: 0;
    }
    .tsim-bt-pro-summary {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .tsim-bt-pro-summary span {
        display: flex;
        justify-content: space-between;
        gap: 10px;
        padding: 6px 10px;
        background: var(--tsim-bg-secondary);
        border-radius: var(--tsim-radius);
    }
    .tsim-bt-pro-summary b {
        text-align: right;
    }
    .tsim-bt-pro-note {
        font-size: 10.5px;
        line-height: 1.45;
    }
    .tsim-bt-pro-table {
        font-size: 10.5px;
    }
    .tsim-bt-trade {
        grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 4px 6px;
        padding: 6px 8px;
    }
    .tsim-bt-trade span {
        min-width: 0;
    }
    .tsim-bt-trade-reason {
        grid-column: 1 / 3;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .tsim-bt-trade span:last-child {
        grid-column: 3 / 5;
        justify-self: end;
    }
    .tsim-opt-table-wrap .tsim-bt-pro-table {
        min-width: 820px;
    }
    .tsim-hm-table {
        min-width: 560px;
    }

    /* === Bottom panel (где tabs+positions table) на mobile === */
    .tsim-bottom-panel { padding: 8px 6px; padding-bottom: 100px; /* отступ под FAB */ }
    /* Скрываем дублирующиеся stats (Баланс/Эквити/P&L) — они уже в mobile-account-bar */
    .tsim-stats-row .tsim-stat-item:nth-child(1),
    .tsim-stats-row .tsim-stat-item:nth-child(2),
    .tsim-stats-row .tsim-stat-item:nth-child(3) { display: none !important; }
    /* Bottom-actions: компактные + отступ снизу под FAB */
    .tsim-bottom-actions {
        flex-wrap: wrap;
        gap: 6px !important;
        margin-bottom: 8px;
    }
    .tsim-bottom-actions button {
        flex: 1 1 calc(50% - 3px);
        min-height: 38px;
        font-size: 11px;
        padding: 0 8px !important;
        white-space: nowrap;
    }

    /* === Кнопки рисования — крупнее === */
    .tsim-draw-btn {
        min-width: 36px; min-height: 36px;
        font-size: 16px;
    }

    /* === Modal на мобильном на весь экран === */
    .tsim-modal {
        max-width: 96vw !important;
        max-height: 92vh !important;
        margin: 4vh auto;
        padding: 16px !important;
    }
    .tsim-modal-actions { flex-wrap: wrap; gap: 6px; }
    .tsim-modal-actions button { min-height: 44px; padding: 0 14px; }
}

/* Микро-экраны (iPhone SE / 360px) */
@media (max-width: 380px) {
    .tsim-mobile-account-bar { grid-template-columns: repeat(2, 1fr); }
    .tsim-mobile-tool-label { display: none; }
    .tsim-mobile-tool-btn { min-height: 44px; }
    .tsim-mobile-tool-icon { font-size: 20px; }
}

@keyframes tsimSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes tsimFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
