:root {
    color-scheme: dark;
    background: #121212;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: #121212 !important;
    color: #d1d4dc;
    font-family: system-ui, sans-serif;
}

.minimal-dashboard {
    min-height: 100vh;
    padding: 8px !important;
}

.workspace-tabs { color: #a9adb5; }
.workspace-tabs .tab-container { border-bottom: 1px solid #2a2e39; }
.workspace-tab {
    padding: 9px 20px !important;
    border: 0 !important;
    border-bottom: 2px solid transparent !important;
    background: #121212 !important;
    color: #777d87 !important;
}
.workspace-tab-selected {
    border-bottom-color: #2962ff !important;
    color: #ffffff !important;
}

.backtest-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    padding: 6px 8px;
    margin-bottom: 6px;
    border: 1px solid #262a33;
    background: #151515;
}
.backtest-switch { margin: 0 8px 0 0; white-space: nowrap; font-size: 12px; }
.backtest-compact-select { width: 90px; min-width: 90px; }
.backtest-strategy-select { width: 180px; min-width: 160px; }
.backtest-toolbar .Select-control,
.backtest-toolbar .Select-menu-outer {
    border-color: #343945;
    background: #191919 !important;
    color: #d1d4dc;
}
.backtest-toolbar .Select-value-label { color: #d1d4dc !important; }
.backtest-toolbar input {
    width: 88px;
    height: 32px;
    padding: 0 7px;
    border: 1px solid #343945;
    border-radius: 3px;
    background: #191919;
    color: #d1d4dc;
}
.backtest-run { border-color: #2962ff; color: #dbe5ff; }
.backtest-inline-status { margin-left: auto; color: #8b919c; font-size: 11px; white-space: nowrap; }

.operations-workspace { min-height: 82vh; padding: 18px 8px; }
.operations-header { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.operations-header h2 { margin: 0; color: #e4e7eb; font-size: 20px; }
.operations-header small { color: #707680; }
.operations-mode { margin-left: auto; }
.operations-mode label { margin-left: 14px; color: #aeb3bc; }
.operations-summary { margin: 8px 0; color: #7d8490; font-size: 12px; }

.minimal-toolbar {
    display: flex;
    align-items: center;
    min-height: 44px;
    gap: 8px;
    padding-bottom: 8px;
}

.symbol-selector {
    width: 240px;
    flex: 0 0 240px;
}

.timezone-selector {
    width: 190px;
    flex: 0 0 190px;
    margin-left: auto;
}

.broker-indicators {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 2px;
    white-space: nowrap;
}

.broker-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #aeb3bc;
    font-size: 11px;
}

.broker-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef5350;
    box-shadow: 0 0 6px rgba(239, 83, 80, 0.65);
}

.broker-indicator.connected .broker-light {
    background: #26a69a;
    box-shadow: 0 0 6px rgba(38, 166, 154, 0.75);
}

.timezone-selector .Select-control,
.timezone-selector .Select-menu-outer {
    border-color: #2a2e39;
    background: #191919 !important;
    color: #d1d4dc;
}

.timezone-selector .Select-value-label,
.timezone-selector .Select-input > input {
    color: #d1d4dc !important;
}

.market-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chart-stage {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

.drawing-toolbar {
    z-index: 5;
    flex: 0 0 46px;
    width: 46px;
    min-width: 46px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 3px;
    padding: 8px 5px;
    border: 1px solid #262626;
    border-right: 0;
    background: #111111;
}

.drawing-toolbar .market-tool-button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border-color: transparent;
    font-size: 16px;
    line-height: 32px;
}

.drawing-toolbar .market-tool-button:hover,
.drawing-toolbar .market-tool-button.tool-active {
    border-color: #3a4250;
    background: #20242c;
}

.drawing-toolbar .market-tool-button:nth-child(5) {
    margin-top: 8px;
    border-top-color: #343945;
}

.toolbar-label {
    margin: 0 4px;
    color: #717680;
    font-size: 11px;
    text-transform: uppercase;
}

.market-tool-button {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #343945;
    border-radius: 3px;
    background: #191919;
    color: #a9adb5;
    font-size: 12px;
    cursor: pointer;
}

.market-tool-button:hover,
.market-tool-button.tool-active {
    border-color: #2962ff;
    background: #202b45;
    color: #ffffff;
}

.market-tool-button[data-tool="long"].tool-active { border-color: #26a69a; }
.market-tool-button[data-tool="short"].tool-active { border-color: #ef5350; }

.chart-drawing-layer {
    position: absolute;
    z-index: 3;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    touch-action: none;
}

.chart-tool-box {
    position: absolute;
    border: 1px solid;
    background: color-mix(in srgb, currentColor 16%, transparent);
    pointer-events: auto;
    cursor: move;
}

.chart-measure-box {
    position: absolute;
    border: 1px solid #42a5f5;
    background: rgba(41, 98, 255, 0.2);
    color: #42a5f5;
    pointer-events: auto;
    cursor: move;
}

.chart-tool-label {
    position: absolute;
    padding: 3px 6px;
    border-radius: 2px;
    background: rgba(18, 18, 18, 0.9);
    color: #e0e3e7;
    font: 11px/14px system-ui, sans-serif;
    white-space: nowrap;
    pointer-events: auto;
    cursor: move;
}

.chart-level-handle {
    position: absolute;
    z-index: 2;
    min-width: 20px;
    height: 12px;
    padding: 0 3px;
    border: 1px solid currentColor;
    border-radius: 7px;
    background: #121212;
    font: 8px/10px system-ui, sans-serif;
    text-align: center;
    pointer-events: auto;
    cursor: ns-resize;
    user-select: none;
}

.chart-target-handle { color: #26a69a; }
.chart-stop-handle { color: #ef5350; }
.chart-position-time-handle {
    position: absolute;
    z-index: 3;
    width: 12px;
    height: 12px;
    border: 2px solid #f5c542;
    border-radius: 50%;
    background: #121212;
    pointer-events: auto;
    cursor: ew-resize;
    user-select: none;
}
.chart-target-label { background: rgba(15, 91, 83, 0.92); }
.chart-stop-label { background: rgba(128, 38, 38, 0.92); }

.chart-measure-handle {
    position: absolute;
    z-index: 3;
    width: 10px;
    height: 10px;
    border: 2px solid #90caf9;
    border-radius: 50%;
    background: #2962ff;
    pointer-events: auto;
    cursor: move;
}

.chart-measure-label { background: rgba(25, 67, 130, 0.92); }

.drawing-selected {
    outline: 2px solid #f5c542;
    outline-offset: 1px;
}

.chart-lasso-box {
    position: absolute;
    border: 1px dashed #64b5f6;
    background: rgba(41, 98, 255, 0.12);
}

.lightweight-chart.tool-armed { cursor: crosshair; }
.lightweight-chart.tool-armed .chart-drawing-layer { pointer-events: auto; }

.symbol-selector .Select-control,
.symbol-selector .Select-menu-outer {
    border-color: #2a2e39;
    background: #191919 !important;
    color: #d1d4dc;
}

.symbol-selector .Select-value-label,
.symbol-selector .Select-input > input {
    color: #d1d4dc !important;
}

.chart-timeframe-selector {
    width: 78px;
    min-width: 78px;
}

.chart-timeframe-selector .Select-control,
.chart-timeframe-selector .Select-menu-outer {
    border-color: #2a2e39;
    background: #191919 !important;
    color: #d1d4dc;
}

.chart-timeframe-selector .Select-value-label {
    color: #d1d4dc !important;
}

.multitimeframe-grid {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

.lightweight-chart-frame {
    display: none;
    position: relative;
    min-width: 0;
    width: 100%;
    height: 76vh;
    min-height: 520px;
    overflow: hidden;
    border: 1px solid #262626;
    background: #121212;
    transition: border-color 120ms ease;
}

.lightweight-chart-frame.chart-selected {
    display: block;
    border-color: #343945;
}

.lightweight-chart-frame.chart-dragging {
    opacity: 0.45;
}

.lightweight-chart-frame.chart-drop-target {
    border-color: #7aa2f7;
}

.lightweight-chart {
    width: 100%;
    height: 100%;
}

.chart-card-header {
    position: absolute;
    z-index: 2;
    top: 8px;
    left: 10px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
}

.lightweight-chart-title {
    color: #8b8f96;
    font-size: 11px;
    font-weight: 600;
}

.chart-promote {
    width: 26px;
    height: 24px;
    padding: 0;
    border: 1px solid #343945;
    border-radius: 3px;
    background: rgba(18, 18, 18, 0.8);
    color: #8b8f96;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
}

.chart-promote:hover {
    border-color: #7aa2f7;
    color: #d1d4dc;
}

.market-chart-status,
.chart-attribution {
    color: #62666f;
    font-size: 10px;
    line-height: 14px;
    text-align: right;
}

.chart-attribution a {
    color: #7a8290;
}

@media (max-width: 900px) {
    .lightweight-chart-frame {
        height: calc(100dvh - 210px);
        min-height: 420px;
    }

    .chart-timeframe-selector {
        width: 72px;
        min-width: 72px;
    }

    .drawing-toolbar {
        flex-basis: 42px;
        width: 42px;
        min-width: 42px;
        padding: 6px 3px;
    }

    .drawing-toolbar .market-tool-button {
        width: 34px;
        min-width: 34px;
        height: 34px;
    }

    .symbol-selector {
        width: 100%;
        flex-basis: 100%;
    }

    .minimal-toolbar { flex-wrap: wrap; }
    .timezone-selector { width: 100%; flex-basis: 100%; margin-left: 0; }
    .backtest-toolbar { flex-wrap: wrap; }
    .backtest-inline-status { width: 100%; margin-left: 0; }
    .operations-header { flex-wrap: wrap; }
    .operations-mode { width: 100%; margin-left: 0; }
}
