.page--trading {
    background: #071017;
}

.trading-page {
    min-height: calc(100vh - 160px);
    padding: 104px 16px 48px;
}

.trading-shell {
    width: min(100%, 1280px);
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: #0b121b;
    color: #e6edf3;
}

.trading-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1fr);
    gap: 16px;
    align-items: end;
    padding: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.trading-pair {
    display: grid;
    gap: 6px;
}

.trading-pair strong {
    font-size: 1.55rem;
    letter-spacing: 0;
}

.trading-pair span,
.trading-controls span,
.trading-stats span {
    color: rgba(230, 237, 243, 0.58);
    font-size: 0.82rem;
}

.trading-pair__label {
    text-transform: uppercase;
}

.trading-controls {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) 110px 110px auto auto auto auto;
    gap: 12px;
    align-items: end;
}

.trading-controls label {
    display: grid;
    gap: 7px;
}

.trading-controls input,
.trading-controls select,
.trading-button {
    min-height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #111a25;
    color: #e6edf3;
    padding: 0 12px;
    border-radius: 6px;
}

.trading-controls input {
    text-transform: uppercase;
}

.trading-button {
    cursor: pointer;
    background: #0ecb81;
    border-color: #0ecb81;
    color: #06130d;
    font-weight: 700;
    white-space: nowrap;
}

.trading-button--secondary {
    background: #111a25;
    border-color: rgba(255, 255, 255, 0.16);
    color: #e6edf3;
}

.trading-button:disabled {
    cursor: not-allowed;
    opacity: 0.52;
    background: #111a25;
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(230, 237, 243, 0.76);
}

.trading-button--secondary.is-active {
    border-color: #0ecb81;
    color: #0ecb81;
}

.trading-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.trading-stats div {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 14px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.trading-stats div:last-child {
    border-right: 0;
}

.trading-stats strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1rem;
}

.trading-stats strong[data-tone="up"] {
    color: #0ecb81;
}

.trading-stats strong[data-tone="down"] {
    color: #f6465d;
}

.trading-chart-wrap {
    position: relative;
    min-height: 620px;
}

.pro-indicator {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    width: min(360px, calc(100% - 28px));
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(9, 15, 24, 0.88);
    color: #e6edf3;
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
}

.pro-indicator[data-tone="buy"] {
    border-color: rgba(14, 203, 129, 0.42);
}

.pro-indicator[data-tone="sell"] {
    border-color: rgba(246, 70, 93, 0.42);
}

.pro-indicator[data-tone="warning"] {
    border-color: rgba(240, 185, 11, 0.5);
}

.pro-indicator__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pro-indicator__head span,
.pro-indicator__grid span {
    color: rgba(230, 237, 243, 0.58);
    font-size: 0.76rem;
}

.pro-indicator__head strong {
    color: #8b949e;
    font-size: 0.84rem;
}

.pro-indicator[data-tone="buy"] .pro-indicator__head strong {
    color: #0ecb81;
}

.pro-indicator[data-tone="sell"] .pro-indicator__head strong {
    color: #f6465d;
}

.pro-indicator[data-tone="warning"] .pro-indicator__head strong {
    color: #f0b90b;
}

.pro-indicator__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: rgba(255, 255, 255, 0.06);
}

.pro-indicator__grid div {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px;
    background: rgba(9, 15, 24, 0.94);
}

.pro-indicator__grid strong {
    overflow: hidden;
    color: #f0f6fc;
    font-size: 0.86rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pro-indicator__levels {
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(230, 237, 243, 0.76);
    font-size: 0.78rem;
    line-height: 1.45;
}

.pro-indicator__checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 12px;
}

.pro-indicator__checklist span {
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 4px 7px;
    color: rgba(230, 237, 243, 0.7);
    font-size: 0.72rem;
}

.pro-indicator__checklist span[data-pass="true"] {
    border-color: rgba(14, 203, 129, 0.36);
    color: #0ecb81;
}

.pro-indicator__checklist span[data-pass="false"] {
    border-color: rgba(246, 70, 93, 0.34);
    color: #f6465d;
}

.trading-chart {
    width: 100%;
    height: 620px;
}

.trading-shell.is-chart-filled {
    position: fixed;
    inset: 12px;
    z-index: 100;
    width: auto;
    margin: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.trading-shell.is-chart-filled .trading-chart-wrap,
.trading-shell.is-chart-filled .trading-chart {
    height: 100%;
    min-height: 0;
}

.page--trading.is-chart-filled {
    overflow: hidden;
}

.page--trading.is-backtest-open {
    overflow: hidden;
}

.backtest-page {
    padding: 104px 18px 32px;
}

.backtest-workbench {
    width: min(1600px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: #0b121b;
    color: #e6edf3;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.backtest-page__head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    padding: 22px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.backtest-page__copy {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.backtest-page__eyebrow {
    color: rgba(230, 237, 243, 0.58);
    font-size: 0.82rem;
}

.backtest-page__title {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.1;
}

.backtest-page__lead {
    margin: 0;
    max-width: 760px;
    color: rgba(230, 237, 243, 0.72);
    font-size: 0.95rem;
}

.backtest-page__head-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.trading-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 7, 12, 0.74);
}

.trading-modal[hidden] {
    display: none;
}

.trading-modal__dialog {
    width: min(calc(100vw - 36px), 1480px);
    height: min(calc(100vh - 36px), 920px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: #0b121b;
    color: #e6edf3;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
    transform: translate(var(--modal-offset-x, 0px), var(--modal-offset-y, 0px));
}

.trading-modal__dialog.is-maximized {
    width: calc(100vw - 36px);
    height: calc(100vh - 36px);
    transform: none;
}

.trading-modal__dialog.is-dragging {
    transition: none;
}

.trading-modal__head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: move;
    user-select: none;
    touch-action: none;
}

.trading-modal__head span,
.backtest-controls span,
.backtest-summary span {
    color: rgba(230, 237, 243, 0.58);
    font-size: 0.8rem;
}

.trading-modal__head h2 {
    margin: 6px 0 0;
    font-size: 1.7rem;
    line-height: 1.1;
}

.trading-modal__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trading-modal__toggle,
.trading-modal__close {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    background: #111a25;
    color: #e6edf3;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.trading-modal__toggle {
    width: auto;
    min-width: 138px;
    padding: 0 16px;
    font-size: 0.84rem;
    font-weight: 700;
}

.trading-modal__dialog.is-maximized .trading-modal__head {
    cursor: default;
}

.backtest-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 24px;
    align-items: start;
    padding: 20px 24px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.backtest-pane {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.backtest-pane--side {
    align-content: start;
}

.backtest-section {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.backtest-section:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.backtest-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.backtest-section__head strong {
    color: #f0f4f8;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.backtest-grid {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.backtest-grid--market {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.backtest-grid--money {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.backtest-grid--filter-inputs {
    grid-template-columns: minmax(180px, 1.1fr) minmax(120px, 0.7fr) minmax(160px, 0.9fr);
}

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

.backtest-controls label {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.backtest-controls input,
.backtest-controls select {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: #111a25;
    color: #e6edf3;
    padding: 0 12px;
}

.backtest-controls input:focus,
.backtest-controls select:focus {
    outline: none;
    border-color: rgba(36, 148, 255, 0.7);
    box-shadow: 0 0 0 3px rgba(36, 148, 255, 0.14);
}

.backtest-controls input[type="datetime-local"] {
    font-size: 0.88rem;
}

.backtest-checkbox {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(17, 26, 37, 0.84);
    color: #e6edf3;
}

.backtest-checkbox input {
    width: 16px;
    height: 16px;
    min-height: auto;
    margin: 0;
    padding: 0;
    accent-color: #0ecb81;
}

.backtest-checkbox span {
    color: #e6edf3;
    font-size: 0.9rem;
    font-weight: 600;
}

.backtest-action-panel {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.backtest-actions {
    display: grid;
    gap: 10px;
}

.backtest-actions .trading-button {
    width: 100%;
    min-height: 48px;
}

.backtest-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 18px 24px 0;
}

.backtest-summary div {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(17, 26, 37, 0.58);
}

.backtest-summary strong[data-tone="up"] {
    color: #0ecb81;
}

.backtest-summary strong[data-tone="down"] {
    color: #f6465d;
}

.backtest-status {
    padding: 14px 24px 16px;
    color: rgba(230, 237, 243, 0.72);
    font-size: 0.84rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.backtest-status[data-tone="warning"] {
    color: #f0b90b;
}

.backtest-table-wrap {
    flex: 1;
    min-height: 0;
    max-height: 420px;
    overflow: auto;
}

.backtest-workbench .backtest-table-wrap {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-height: none;
}

.trading-modal__dialog .backtest-table-wrap {
    max-height: none;
}

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

.backtest-table th,
.backtest-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
    white-space: nowrap;
}

.backtest-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #111a25;
    color: rgba(230, 237, 243, 0.66);
    font-weight: 700;
}

.backtest-table td[data-action="BUY"] {
    color: #0ecb81;
}

.backtest-table td[data-action="SELL"] {
    color: #f6465d;
}

/* Backtest History Panel */
.backtest-history-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 20px;
}

.backtest-history-list {
    display: grid;
    gap: 12px;
    margin-top: 12px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Custom Scrollbar for list */
.backtest-history-list::-webkit-scrollbar {
    width: 6px;
}
.backtest-history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}
.backtest-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.backtest-history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.24);
}

.backtest-history-placeholder {
    padding: 24px 12px;
    text-align: center;
    color: rgba(230, 237, 243, 0.4);
    font-size: 0.84rem;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(17, 26, 37, 0.2);
}

.backtest-history-placeholder.warning {
    color: #f0b90b;
    border-color: rgba(240, 185, 11, 0.25);
    background: rgba(240, 185, 11, 0.04);
}

/* History Card Item */
.backtest-history-item {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(17, 26, 37, 0.4);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.backtest-history-item:hover {
    background: rgba(17, 26, 37, 0.85);
    border-color: rgba(255, 255, 255, 0.16);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.backtest-history-item.is-active {
    border-color: #0ecb81;
    background: rgba(14, 203, 129, 0.05);
    box-shadow: 0 0 12px rgba(14, 203, 129, 0.08);
}

.backtest-history-item__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.backtest-history-item__symbol {
    font-weight: 700;
    font-size: 0.88rem;
    color: #f0f6fc;
}

.backtest-history-item__strategy {
    font-size: 0.74rem;
    color: rgba(230, 237, 243, 0.5);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.backtest-history-item.is-active .backtest-history-item__strategy {
    color: #0ecb81;
    background: rgba(14, 203, 129, 0.1);
    border-color: rgba(14, 203, 129, 0.15);
}

.backtest-history-item__meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: rgba(230, 237, 243, 0.45);
}

.backtest-history-item__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
    margin-top: 4px;
}

.backtest-history-item__pnl {
    font-weight: 700;
    font-size: 0.95rem;
}

.backtest-history-item__pnl[data-tone="up"] {
    color: #0ecb81;
}

.backtest-history-item__pnl[data-tone="down"] {
    color: #f6465d;
}

.backtest-history-item__delete {
    background: transparent;
    border: none;
    padding: 6px;
    margin: -6px;
    border-radius: 4px;
    color: rgba(230, 237, 243, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.backtest-history-item__delete:hover {
    color: #f6465d;
    background: rgba(246, 70, 93, 0.1);
}

@media (max-width: 1280px) {
    .backtest-controls {
        grid-template-columns: 1fr;
    }

    .backtest-grid--market,
    .backtest-grid--money,
    .backtest-grid--filter-inputs,
    .backtest-toggle-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 900px) {
    .trading-page {
        padding-top: 88px;
    }

    .trading-toolbar,
    .trading-controls {
        grid-template-columns: 1fr;
    }

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

    .trading-stats div {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .trading-chart-wrap,
    .trading-chart {
        min-height: 520px;
        height: 520px;
    }

    .pro-indicator {
        position: static;
        width: auto;
        border-width: 0 0 1px;
        box-shadow: none;
    }

    .backtest-controls,
    .backtest-summary,
    .backtest-grid--market,
    .backtest-grid--range,
    .backtest-grid--money,
    .backtest-grid--filter-inputs,
    .backtest-toggle-grid {
        grid-template-columns: 1fr;
    }

    .trading-modal__dialog,
    .trading-modal__dialog.is-maximized {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
    }

    .trading-modal__actions {
        width: 100%;
        justify-content: flex-end;
    }

    .trading-modal__toggle {
        min-width: 96px;
    }

    .backtest-page {
        padding: 96px 12px 24px;
    }

    .backtest-page__head {
        padding: 18px;
        grid-template-columns: 1fr;
        display: grid;
    }

    .backtest-controls {
        padding: 18px;
    }

    .backtest-summary {
        padding: 18px 18px 0;
    }

    .backtest-status {
        padding: 14px 18px 16px;
    }
}

@media (max-width: 560px) {
    .trading-stats {
        grid-template-columns: 1fr;
    }

    .pro-indicator__grid {
        grid-template-columns: 1fr;
    }

    .backtest-page__title {
        font-size: 1.4rem;
    }

    .trading-modal__head {
        padding: 18px;
    }

    .trading-modal__head h2 {
        font-size: 1.4rem;
    }
}
