:root,
:root[data-theme='dark'] {
    --btc-rotation: #65d4a7;
    --btc-cash: #4aa3ff;
    --btc-bitx: #f28a5b;
    --btc-btc: #d4b85c;
    --btc-dom: #aeb8c2;
    --btc-ma: #c7d1ca;
    --btc-upper: #65d4a7;
    --btc-lower: #ff7188;
    --btc-execution-buy: #4aa3ff;
    --btc-execution-sell: #f5b942;
    --btc-candle-up: #48c78e;
    --btc-candle-down: #ff647c;
    --btc-chart-grid: rgba(128, 170, 151, 0.11);
    --btc-chart-bg: #0c1713;
}

:root[data-theme='light'],
:root[data-theme='clear'] {
    --btc-rotation: #0f7a48;
    --btc-cash: #1c6bc7;
    --btc-bitx: #c85b31;
    --btc-btc: #8b6f16;
    --btc-dom: #69747e;
    --btc-ma: #52655a;
    --btc-upper: #0f7a48;
    --btc-lower: #c9344a;
    --btc-execution-buy: #1c6bc7;
    --btc-execution-sell: #9a6711;
    --btc-candle-up: #0f7a48;
    --btc-candle-down: #c9344a;
    --btc-chart-grid: rgba(24, 47, 35, 0.08);
    --btc-chart-bg: #ffffff;
}

html[data-page='btc-strategy'] body {
    background: var(--bg-body);
}

.btc-shell {
    width: min(1840px, calc(100vw - 32px));
}

html[data-page='btc-strategy'] .strategy-header .brand-group {
    flex: 0 0 auto;
}

html[data-page='btc-strategy'] .strategy-header .strategy-view-nav {
    flex: 1 1 auto;
    max-width: none;
    margin-left: 0;
}

.btc-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btc-command {
    border-top: 2px solid color-mix(in srgb, var(--btc-rotation) 82%, transparent);
}

.btc-position-command {
    min-width: 0;
}

.btc-position-command .allocation-command-head > div {
    min-width: 0;
}

.btc-position-command .allocation-command-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btc-position-track {
    height: 14px;
}

.btc-position-long,
.btc-position-defensive {
    display: block;
    height: 100%;
    transition: width 240ms var(--ease-out);
}

.btc-position-long {
    width: 0;
    background: var(--btc-rotation);
}

.btc-position-defensive {
    width: 100%;
    background: var(--btc-dom);
}

.dot-btc-long {
    background: var(--btc-rotation);
}

.dot-btc-dom {
    background: var(--btc-dom);
}

.btc-command-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 18px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 10px;
}

.btc-equity-panel,
.btc-signal-panel {
    min-width: 0;
}

.btc-equity-chart {
    width: 100%;
    height: clamp(340px, 42vh, 500px);
}

.btc-drawdown-chart {
    width: 100%;
    height: clamp(180px, 22vh, 250px);
}

.btc-price-chart {
    width: 100%;
    height: clamp(460px, 55vh, 680px);
    overflow: hidden;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--btc-chart-bg);
}

.btc-price-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 28px;
    margin-bottom: 8px;
}

.btc-price-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 27px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 10px;
}

.btc-price-chip strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 11px;
}

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

.btc-snapshot-panel,
.btc-model-panel {
    min-width: 0;
    padding: 16px 18px;
}

.btc-snapshot-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.btc-snapshot-row {
    min-width: 0;
    padding: 10px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-card) 48%, transparent);
}

.btc-snapshot-row dt {
    margin: 0;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 650;
}

.btc-snapshot-row dd {
    margin: 4px 0 0;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 720;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btc-fact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.btc-fact {
    min-width: 0;
    padding: 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.btc-fact span {
    display: block;
    color: var(--text-muted);
    font-size: 10px;
}

.btc-fact strong {
    display: block;
    margin-top: 5px;
    overflow: hidden;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btc-performance-panel,
.btc-signals-panel,
.btc-trades-panel {
    min-width: 0;
}

.btc-performance-table td:first-child {
    font-weight: 750;
}

.btc-performance-table tbody tr:first-child td {
    background: color-mix(in srgb, var(--btc-rotation) 8%, transparent);
}

html[data-page='btc-strategy'] .data-table td.positive,
html[data-page='btc-strategy'] .data-table td.value-positive {
    color: var(--accent-positive);
}

html[data-page='btc-strategy'] .data-table td.negative,
html[data-page='btc-strategy'] .data-table td.value-negative {
    color: var(--accent-negative);
}

html[data-page='btc-strategy'] .data-table td.neutral {
    color: var(--text-muted);
    text-align: center;
}

.btc-detail-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.btc-detail-grid .yearly-panel,
.btc-detail-grid .heatmap-panel {
    min-width: 0;
}

.btc-detail-grid .yearly-table-scroll,
.btc-detail-grid .heatmap-scroll {
    max-height: 560px;
}

.btc-detail-grid .heatmap-table th,
.btc-detail-grid .heatmap-table td {
    min-width: 50px;
    padding: 8px 7px;
    text-align: center;
}

.btc-detail-grid .heatmap-table th:first-child,
.btc-detail-grid .heatmap-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 58px;
    background: var(--bg-panel);
    text-align: left;
}

.btc-ledger-scroll {
    max-height: 560px;
}

.btc-action-badge,
.btc-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 750;
}

.btc-action-badge.buy {
    border-color: color-mix(in srgb, var(--btc-upper) 45%, var(--border));
    background: color-mix(in srgb, var(--btc-upper) 11%, transparent);
    color: var(--btc-upper);
}

.btc-action-badge.sell {
    border-color: color-mix(in srgb, var(--btc-lower) 45%, var(--border));
    background: color-mix(in srgb, var(--btc-lower) 11%, transparent);
    color: var(--btc-lower);
}

.btc-status-badge.open {
    border-color: color-mix(in srgb, var(--btc-rotation) 45%, var(--border));
    background: color-mix(in srgb, var(--btc-rotation) 11%, transparent);
    color: var(--btc-rotation);
}

.btc-status-badge.closed {
    color: var(--text-muted);
}

.btc-method-panel {
    padding: 0;
    overflow: hidden;
}

.btc-method-panel > summary {
    min-height: 52px;
    padding: 16px 18px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.btc-method-panel > p {
    margin: 0;
    padding: 0 18px 18px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.7;
}

.btc-method-panel > .btc-refresh-note {
    padding-top: 0;
    color: var(--accent-negative);
    font-size: 11px;
}

html[data-page='btc-strategy'] .hidden {
    display: none !important;
}

@media (max-width: 1240px) {
    .btc-detail-grid,
    .btc-status-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 900px) {
    .btc-equity-chart {
        height: 380px;
    }

    .btc-drawdown-chart {
        height: 210px;
    }

    .btc-price-chart {
        height: 480px;
    }
}

@media (max-width: 720px) {
    .btc-shell {
        width: min(100%, calc(100vw - 16px));
        padding-top: 8px;
    }

    .btc-main {
        gap: 8px;
    }

    html[data-page='btc-strategy'] .strategy-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px 10px;
        align-items: center;
    }

    html[data-page='btc-strategy'] .strategy-header .brand-group {
        min-width: 0;
    }

    html[data-page='btc-strategy'] .strategy-header .brand-subtitle {
        display: none;
    }

    html[data-page='btc-strategy'] .strategy-header .strategy-view-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        max-width: 100%;
    }

    html[data-page='btc-strategy'] .strategy-header .header-actions {
        grid-column: 2;
        grid-row: 1;
    }

    html[data-page='btc-strategy'] .strategy-header .status-chip {
        max-width: 128px;
    }

    .btc-command,
    .btc-equity-panel,
    .btc-signal-panel,
    .btc-snapshot-panel,
    .btc-model-panel,
    .btc-performance-panel,
    .btc-detail-grid .yearly-panel,
    .btc-detail-grid .heatmap-panel,
    .btc-signals-panel,
    .btc-trades-panel {
        padding: 14px 12px;
    }

    .btc-snapshot-list,
    .btc-fact-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .btc-equity-chart {
        height: 300px;
    }

    .btc-drawdown-chart {
        height: 180px;
    }

    .btc-price-chart {
        height: 390px;
    }

    .btc-command-meta {
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    html[data-page='btc-strategy'] * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
