.hero--backtest {
    padding-bottom: 20px;
}
.hero--backtest .hero-lead,
.hero--backtest .hero-sub,
.hero--backtest .bt-scope-note {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}
.hero--backtest .hero-sub {
    margin-top: 10px;
    max-width: 40rem;
    font-size: 1.02rem;
    line-height: 1.65;
    color: #cbd5e1;
}
.hero--backtest .bt-scope-note {
    margin-top: 16px;
    max-width: 40rem;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.35);
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #94a3b8;
}
.bt-intro {
    margin: 0 0 28px;
    padding: 22px 22px 20px;
    max-width: none;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.bt-intro-title {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #f8fafc;
}
.bt-intro-lead {
    margin: 0 0 14px;
    font-size: 0.98rem;
    line-height: 1.65;
    color: #cbd5e1;
}
.bt-intro-list {
    margin: 0 0 14px;
    padding-left: 1.25rem;
    list-style: disc;
    list-style-position: outside;
    color: #cbd5e1;
    font-size: 0.92rem;
    line-height: 1.6;
}
.bt-intro-list li {
    margin-bottom: 0.65rem;
    padding-left: 0.2rem;
}
.bt-intro-list li::marker {
    color: #60a5fa;
}
.bt-intro-list li:last-child {
    margin-bottom: 0;
}
.bt-intro-list strong {
    color: #f1f5f9;
    font-weight: 700;
}
.bt-intro-note {
    margin: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
    font-size: 0.88rem;
    line-height: 1.55;
    color: #94a3b8;
}
.bt-disclaimer {
    margin: 36px 0 12px;
    padding: 18px 20px;
    max-width: none;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 12px;
}
.bt-disclaimer-title {
    margin: 0 0 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
}
.bt-disclaimer p {
    margin: 0 0 0.75rem;
    font-size: 0.82rem;
    line-height: 1.6;
    color: #94a3b8;
}
.bt-disclaimer p:last-child {
    margin-bottom: 0;
}
.bt-disclaimer code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    color: #cbd5e1;
}
.backtest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 8px;
}
.backtest-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.backtest-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
}
.backtest-card-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-shrink: 0;
}
.backtest-card-heading {
    min-width: 0;
}
.backtest-card-title {
    font-size: 1.05rem;
    font-weight: 750;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.01em;
}
.bt-preset-badge {
    display: inline-block;
    margin-top: 5px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 8pt;
    font-weight: 700;
    line-height: 1.2;
    padding: 3px 7px;
    border-radius: 0;
    border: 1px solid transparent;
}
.bt-preset-badge--recommended {
    color: #1e3a5f;
    background: #E5F0FC;
    border-color: #c5d5e8;
}
.bt-preset-badge--optimized {
    color: #14532d;
    background: #ecfdf3;
    border-color: #bbf7d0;
}
.backtest-card-sub,
.bt-settings-line {
    font-family: Tahoma, Arial, sans-serif;
    font-size: 8pt;
    color: #334155;
    line-height: 1.35;
    margin: 3px 0 0;
}
.bt-settings-line {
    font-weight: 700;
}
.bt-meta-tags,
.bt-modal-settings {
    width: 100%;
}
.bt-tag {
    display: inline-block;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 8pt;
    font-weight: 700;
    color: #111;
    background: #E5F0FC;
    border: none;
    border-radius: 0;
    padding: 4px 8px;
    line-height: 1.2;
}
.backtest-card-chart {
    width: 100%;
    max-height: 88px;
    height: 88px;
    object-fit: cover;
    object-position: left center;
    border-radius: 0;
    border: 1px solid #c5d5e8;
    background: #fff;
}
/* MT5 Strategy Tester–style Results / Settings tables */
.bt-results-table,
.bt-settings-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 1px;
    font-family: Tahoma, Arial, sans-serif;
    font-size: 8pt;
    color: #111;
    background: #fff;
}
.bt-results-table th {
    font-family: Tahoma, Arial, sans-serif;
    font-size: 9pt;
    font-weight: 700;
    text-align: center;
    padding: 4px;
    background: #E5F0FC;
    color: #111;
}
.bt-results-table td,
.bt-settings-table td {
    font-family: Tahoma, Arial, sans-serif;
    font-size: 8pt;
    padding: 3px 6px;
    vertical-align: middle;
}
.bt-row-a { background: #FFFFFF; }
.bt-row-b { background: #F7F7F7; }
.bt-results-label,
.bt-settings-label {
    text-align: right;
    white-space: nowrap;
    color: #111;
    font-weight: 400;
}
.bt-results-table .bt-results-label {
    width: auto;
}
.bt-results-value,
.bt-settings-value {
    text-align: left;
    font-weight: 700;
    color: #111;
    white-space: nowrap;
}
.bt-results-value.is-pos { color: #008000; }
.bt-results-value.is-neg { color: #c00000; }
.backtest-card-footer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}
.backtest-card-footer .buy-btn,
.backtest-card-footer .details-link-btn {
    flex: 1 1 auto;
    min-width: 120px;
}
.bt-modal-settings {
    margin-top: 8px;
    width: 100%;
}
.backtest-empty {
    text-align: center;
    color: #94a3b8;
    padding: 48px 16px;
}

/* Report viewer: almost fullscreen — main job is reading the report */
.bt-report-overlay.tool-detail-overlay {
    padding: 10px;
    align-items: stretch;
    justify-content: center;
    z-index: 10050;
}
.tool-detail-dialog.bt-report-dialog {
    max-width: min(1400px, 98vw);
    width: 98vw;
    height: 96vh;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0;
}
.bt-report-dialog .tool-detail-hero {
    flex-shrink: 0;
    padding: 14px 20px 12px;
}
.bt-report-dialog .tool-detail-title {
    font-size: 1.2rem;
}
.bt-report-dialog .tool-detail-logo {
    width: 44px;
    height: 44px;
}
.bt-report-dialog .tool-detail-header {
    align-items: flex-start;
    gap: 12px;
}
.bt-report-dialog .tool-detail-header > div {
    min-width: 0;
    flex: 1;
}
.bt-report-content.tool-detail-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 12px 16px 16px;
}
.bt-report-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
}
.bt-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.bt-report-actions .buy-btn,
.bt-report-actions .bt-report-tool-btn {
    width: auto;
    min-width: 132px;
    min-height: 0;
    height: auto;
    padding: 8px 14px;
    font-size: 0.88rem;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}
.bt-report-actions .buy-btn:hover,
.bt-report-actions .bt-report-tool-btn:hover {
    transform: none;
    box-shadow: none;
}
.bt-report-actions .buy-btn--secondary {
    background: #fff;
    color: #1e40af;
    border: 1px solid #93c5fd;
    box-shadow: none;
}
.bt-report-actions .buy-btn--secondary:hover {
    background: #eff6ff;
    transform: none;
    box-shadow: none;
}
.bt-report-frame {
    display: block;
    width: 100%;
    min-height: 240px;
    height: 240px;
    border: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    /* Let the outer .bt-report-scroll handle touch scrolling on iOS */
    pointer-events: none;
}
.tool-badge--backtest {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.tool-badge--backtest-optimized {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.tool-detail-backtest {
    margin: 14px 0 18px;
    padding: 14px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #f8fbff;
}
.tool-detail-backtest-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1d4ed8;
    margin-bottom: 8px;
}
.tool-detail-backtest-note {
    margin: 0 0 12px;
    font-size: 0.84rem;
    line-height: 1.55;
    color: #475569;
}
.tool-detail-backtest-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tool-detail-backtest-item {
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: #fff;
}
.tool-detail-backtest-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.tool-detail-bt-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 0 0 8px;
}
.tool-detail-bt-label {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    min-width: 0;
    max-width: 100%;
}
.tool-detail-bt-label.is-wide {
    grid-column: unset;
}
.tool-detail-bt-label-k {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    line-height: 1.2;
    white-space: nowrap;
}
.tool-detail-bt-label-v {
    font-size: 0.72rem;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    word-break: break-word;
}
.tool-detail-bt-label.is-pos .tool-detail-bt-label-v { color: #15803d; }
.tool-detail-bt-label.is-neg .tool-detail-bt-label-v { color: #b91c1c; }
.bt-modal-settings {
    margin-top: 8px;
    width: 100%;
}
.bt-modal-settings .tool-detail-bt-labels {
    margin-bottom: 0;
}
.bt-modal-settings .tool-detail-bt-label {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.35);
}
.bt-modal-settings .tool-detail-bt-label-k {
    color: #94a3b8;
    font-size: 0.58rem;
}
.bt-modal-settings .tool-detail-bt-label-v {
    color: #f8fafc;
    font-size: 0.7rem;
}
.bt-variant-pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 3px 10px;
}
.bt-variant-pill--recommended {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
.bt-variant-pill--optimized {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}
.tool-detail-backtest-item-meta {
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 600;
}
.tool-detail-backtest-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}
.tool-detail-backtest-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0;
}
.tool-detail-backtest-actions .buy-btn,
.tool-detail-backtest-actions .details-link-btn {
    width: auto;
}
.tool-detail-backtest-frame {
    width: 100%;
    min-height: 360px;
    height: min(55vh, 520px);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
@media (max-width: 959px) {
    .bt-report-overlay.tool-detail-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
        overscroll-behavior: contain;
        /* Fill the fixed overlay; avoid 100dvh overflow when body is position:fixed */
        height: 100%;
        max-height: 100%;
    }
    .tool-detail-dialog.bt-report-dialog {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        min-height: 0;
    }
    .bt-report-dialog .tool-detail-close {
        position: absolute;
        top: max(8px, env(safe-area-inset-top, 0px));
        right: max(8px, env(safe-area-inset-right, 0px));
        z-index: 2;
    }
    .bt-report-dialog .tool-detail-hero {
        flex: 0 1 auto;
        max-height: 38%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(56px, calc(14px + env(safe-area-inset-right, 0px)));
        padding-bottom: 8px;
    }
    .bt-report-dialog .tool-detail-title {
        font-size: 1.05rem;
        line-height: 1.3;
        padding-right: 8px;
    }
    .bt-report-dialog .tool-detail-logo {
        width: 36px;
        height: 36px;
    }
    .bt-report-content.tool-detail-content {
        flex: 1 1 auto;
        min-height: 0;
        padding: 8px 12px max(10px, env(safe-area-inset-bottom, 0px));
        overflow: hidden;
    }
    .bt-report-scroll {
        flex: 1 1 auto;
        min-height: 0;
        border-radius: 8px;
    }
    .bt-report-actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 8px;
    }
    .bt-report-actions .bt-report-tool-btn,
    .bt-report-actions .buy-btn,
    .bt-report-actions .tool-detail-bt-all-link {
        flex: 1 1 calc(50% - 4px);
        width: auto;
        min-width: 0;
        margin-left: 0 !important;
        justify-content: center;
        text-align: center;
        padding: 8px 10px;
        font-size: 0.82rem;
    }
    .bt-report-frame {
        min-height: 180px;
        height: 180px;
        border-radius: 0;
        pointer-events: none;
    }
    .bt-modal-settings {
        margin-top: 6px;
    }
    .bt-modal-settings .tool-detail-bt-labels {
        gap: 4px;
    }
    .bt-modal-settings .tool-detail-bt-label {
        padding: 2px 7px;
    }
    .bt-modal-settings .tool-detail-bt-label-k {
        font-size: 0.55rem;
    }
    .bt-modal-settings .tool-detail-bt-label-v {
        font-size: 0.66rem;
    }
    .tool-detail-bt-labels {
        gap: 4px;
    }
    .tool-detail-backtest-frame {
        height: 45vh;
        min-height: 260px;
    }
}
