/* ── Backtesting page styles ──────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    color: #ffffff;
    background-color: #181b24;
    overflow: hidden;
}

/* ── App shell ─────────────────────────────────────────────────────────────── */
#bt-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ════════════════════════════════════════════════════════════════════════════
   DASHBOARD VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#bt-dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    padding: 0 0 40px;
}

.bt-dash-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 32px;
    background: rgba(32, 38, 54, 0.85);
    border-bottom: 1.5px solid #232634;
    border-radius: 0 0 18px 18px;
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
}

.bt-dash-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.bt-dash-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin: 0;
}

.bt-dash-time-box {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    background: rgba(32, 227, 178, 0.08);
    border: 1px solid rgba(32, 227, 178, 0.18);
    border-radius: 12px;
    padding: 8px 16px;
}

.bt-dash-time-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--tb-muted);
}

.bt-dash-time-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--tb-accent);
    font-family: 'Courier New', monospace;
}

/* Top row: new session + combined overview as cards */
.bt-dash-top-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 24px 32px 0;
    flex-wrap: wrap;
}

/* Shared card style for dashboard cards */
.bt-dash-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    padding: 20px 24px;
}

/* New session controls */
.bt-dash-new-session {
    flex: 0 0 auto;
}

.bt-dash-section-title {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--tb-muted);
    margin-bottom: 14px;
}

.bt-dash-new-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.bt-btn-lg {
    padding: 10px 22px;
    font-size: 0.95rem;
}

/* Session cards */
.bt-dash-sessions {
    padding: 16px 32px 0;
}

.bt-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.bt-card-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--tb-muted);
    font-style: italic;
    padding: 40px 20px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px dashed rgba(148, 163, 184, 0.2);
    border-radius: 16px;
}

.bt-session-card {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.bt-session-card:hover {
    border-color: rgba(87, 199, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.bt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.bt-card-symbol {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
}

.bt-card-date {
    font-size: 0.78rem;
    color: var(--tb-muted);
}

.bt-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.bt-card-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(7, 17, 31, 0.5);
    border-radius: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(148, 163, 184, 0.08);
}

.bt-card-stat-label {
    font-size: 0.68rem;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bt-card-stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.bt-card-stat-value.positive { color: #5eead4; }
.bt-card-stat-value.negative { color: #fca5a5; }

.bt-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.08);
}

.bt-card-bt-time {
    font-size: 0.76rem;
    color: var(--tb-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.bt-card-bt-time svg {
    opacity: 0.6;
}

.bt-card-actions {
    display: flex;
    gap: 6px;
}

.bt-card-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.bt-card-btn:active { transform: scale(0.97); }

.bt-card-btn-go {
    background: rgba(32, 227, 178, 0.18);
    border-color: rgba(32, 227, 178, 0.36);
    color: var(--tb-accent);
}
.bt-card-btn-go:hover {
    background: rgba(32, 227, 178, 0.28);
    border-color: var(--tb-accent);
    transform: translateY(-1px);
}

.bt-card-btn-delete {
    background: rgba(242, 54, 69, 0.12);
    border-color: rgba(242, 54, 69, 0.24);
    color: #f87171;
}
.bt-card-btn-delete:hover {
    background: rgba(242, 54, 69, 0.22);
    border-color: #f23645;
}

/* ── Mini equity curve in session cards ── */
.bt-card-equity-curve {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    background: rgba(7, 17, 31, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.06);
}

/* ── Duration label in card footer ── */
.bt-card-duration {
    font-size: 0.74rem;
    color: var(--tb-muted);
    opacity: 0.8;
}

/* Notes snippet shown at bottom of session card */
.bt-card-notes {
    margin: 0 16px 12px;
    padding: 7px 10px;
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 7px;
    font-size: 0.78rem;
    color: var(--tb-muted);
    line-height: 1.45;
    word-break: break-word;
}

/* ════════════════════════════════════════════════════════════════════════════
   COMBINED OVERVIEW
   ════════════════════════════════════════════════════════════════════════════ */
.bt-combined-overview {
    flex: 1;
    min-width: 0;
}

.bt-combined-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.bt-combined-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 10px;
    padding: 12px 14px;
}

.bt-combined-stat-label {
    font-size: 0.7rem;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bt-combined-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.bt-combined-stat-value.positive { color: #5eead4; }
.bt-combined-stat-value.negative { color: #fca5a5; }

/* ════════════════════════════════════════════════════════════════════════════
   PERFORMANCE BY MONTH / BY TIME
   ════════════════════════════════════════════════════════════════════════════ */
.bt-dash-perf-section {
    display: flex;
    gap: 20px;
    padding: 0 32px 20px;
    flex-wrap: wrap;
}

.bt-perf-card {
    flex: 1;
    min-width: 320px;
}

.bt-perf-table-wrap {
    overflow-x: auto;
}

.bt-title-ph-icon {
    margin-right: 8px;
    vertical-align: middle;
}

.bt-perf-chart-wrap {
    margin-top: 14px;
    min-height: 180px;
}

/* Keep ApexCharts toolbar from overflowing */
.bt-perf-chart-wrap .apexcharts-toolbar {
    display: none;
}

.bt-perf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.bt-perf-table th {
    padding: 7px 10px;
    text-align: left;
    color: var(--tb-muted);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    white-space: nowrap;
}

.bt-perf-table td {
    padding: 6px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.07);
    white-space: nowrap;
    color: #e2e8f0;
}

.bt-perf-table tbody tr:hover td {
    background: rgba(148, 163, 184, 0.06);
}

.bt-perf-table .positive { color: #5eead4; }
.bt-perf-table .negative { color: #fca5a5; }

.bt-crowded-card {
    width: 100%;
}

.bt-crowded-table td.warn {
    color: #facc15;
    font-weight: 700;
}

.bt-crowded-table td.negative {
    font-weight: 700;
}

.bt-crowded-arrow {
    color: var(--tb-muted);
    margin: 0 6px;
}

.bt-crowded-ratio {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: #fbbf24;
}

.bt-crowded-empty {
    color: var(--tb-muted);
    font-size: 0.82rem;
    padding: 8px 0;
}

.bt-reduction-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.bt-reduction-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
}

.bt-reduction-label {
    font-size: 0.7rem;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bt-reduction-stat strong {
    font-size: 1rem;
}

.bt-reduction-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.bt-reduction-item {
    display: flex;
    gap: 10px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    padding: 10px 12px;
}

.bt-reduction-rank {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: rgba(242, 54, 69, 0.15);
    border: 1px solid rgba(242, 54, 69, 0.35);
    color: #fca5a5;
    display: grid;
    place-items: center;
    font-size: 0.76rem;
    font-weight: 700;
    flex: 0 0 28px;
}

.bt-reduction-body {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.bt-reduction-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.bt-reduction-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--tb-muted);
}

.bt-reduction-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.7rem;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.bt-reduction-keep {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.78rem;
    color: #dbe8fa;
}

.bt-reduction-keep-prefix {
    color: var(--tb-muted);
}

/* ════════════════════════════════════════════════════════════════════════════
   CHART VIEW
   ════════════════════════════════════════════════════════════════════════════ */
#bt-chart-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */
#bt-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    background: rgba(32, 38, 54, 0.85);
    box-shadow: 0 4px 24px 0 rgba(0,0,0,0.12);
    border-bottom: 1.5px solid #232634;
    border-radius: 0 0 18px 18px;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 30;
}

.bt-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    white-space: nowrap;
}

.bt-title-icon { font-size: 1.2rem; }

.bt-tf-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(32, 227, 178, 0.18);
    border: 1px solid rgba(32, 227, 178, 0.28);
    color: var(--tb-accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

#bt-setup-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#bt-setup-controls select,
#bt-setup-controls input[type="datetime-local"] {
    appearance: none;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #f1f5f9;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

#bt-setup-controls select:focus,
#bt-setup-controls input[type="datetime-local"]:focus {
    border-color: var(--tb-accent-2);
}

.bt-time-display {
    margin-left: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: var(--tb-accent);
    background: rgba(32, 227, 178, 0.08);
    border: 1px solid rgba(32, 227, 178, 0.16);
    border-radius: 8px;
    padding: 4px 10px;
    white-space: nowrap;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.bt-btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.bt-btn:active { transform: scale(0.97); }
.bt-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.bt-btn-primary {
    background: rgba(32, 227, 178, 0.18);
    border-color: rgba(32, 227, 178, 0.36);
    color: var(--tb-accent);
}
.bt-btn-primary:hover:not(:disabled) {
    background: rgba(32, 227, 178, 0.28);
    border-color: var(--tb-accent);
    transform: translateY(-1px);
}

/* ── Trading-time info banner ─────────────────────────────────────────────── */
.bt-trading-banner {
    display: none;
    width: 100%;
    text-align: center;
    background: linear-gradient(135deg, rgba(242,54,69,0.12), rgba(20,24,36,0.95));
    border-bottom: 1px solid rgba(242,54,69,0.25);
    color: #f5a0a0;
    padding: 9px 12px;
    z-index: 29;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}
.bt-trading-message {
    font-size: 14px;
    line-height: 1.3;
    font-weight: 500;
}
.bt-status-bar {
    padding: 0 14px;
    font-size: 0.84rem;
    color: var(--tb-muted);
    background: rgba(10, 18, 33, 0.6);
    height: 26px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    flex-shrink: 0;
    transition: color 0.3s;
}
.bt-status-bar.is-error { color: #fca5a5; }
.bt-status-bar.is-success { color: var(--tb-accent); }

/* ── Main layout ─────────────────────────────────────────────────────────────── */
#bt-main {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
    overflow: hidden;
}

/* ── Left sidebar (drawing tools) ─────────────────────────────────────────── */
#bt-sidebar {
    display: flex;
    flex-direction: column;
    width: 80px;
    flex-shrink: 0;
    background: #13161f;
    border-right: 1px solid #1e2233;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 7px;
    gap: 4px;
    z-index: 50;
}

.bt-sidebar-tools {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bt-sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 8px 2px;
}

.bt-sidebar-tool-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 4px;
    border-radius: 8px;
    background: rgba(44, 51, 73, 0.7);
    border: 1.5px solid #2a2e3d;
    color: #a0a8bc;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.bt-sidebar-tool-btn:hover {
    background: rgba(60, 70, 100, 1);
    color: #eaeef5;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}
.bt-sidebar-tool-btn:active { transform: translateY(0); }

.bt-sidebar-tool-btn.active-btn {
    background: rgba(41,98,255,0.2) !important;
    border-color: #2962ff !important;
    color: #7ea8ff !important;
    box-shadow: 0 0 0 2px rgba(41,98,255,0.18);
}

.bt-sidebar-tool-btn.bt-sidebar-tool-sm {
    padding: 8px 4px;
}

.bt-sidebar-tool-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: inherit;
    line-height: 1;
}
.bt-sidebar-tool-btn.active-btn .bt-sidebar-tool-label { color: #7ea8ff; }

#btn-undo:disabled,
#btn-redo:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

/* ── Chart column ─────────────────────────────────────────────────────────────── */
#bt-chart-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

#bt-chart-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    background: #ffffff;
    overflow: hidden;
}

#btchart {
    width: 100%;
    height: 100%;
}

/* ── Playback bar ─────────────────────────────────────────────────────────────── */
#bt-playback-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: rgba(10, 18, 33, 0.92);
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bt-ctrl-btn {
    appearance: none;
    background: rgba(71, 85, 105, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #e2e8f0;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.12s;
    white-space: nowrap;
}
.bt-ctrl-btn:hover:not(:disabled) {
    background: rgba(100, 116, 139, 0.75);
    border-color: rgba(148, 163, 184, 0.35);
    transform: translateY(-1px);
}
.bt-ctrl-btn:active:not(:disabled) { transform: scale(0.97); }
.bt-ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.bt-ctrl-btn.is-playing {
    background: rgba(32, 227, 178, 0.18);
    border-color: rgba(32, 227, 178, 0.36);
    color: var(--tb-accent);
}

.bt-speed-label {
    font-size: 0.82rem;
    color: var(--tb-muted);
    white-space: nowrap;
}

#bt-speed-select {
    appearance: none;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.22);
    color: #f1f5f9;
    border-radius: 7px;
    padding: 5px 8px;
    font-size: 0.82rem;
    cursor: pointer;
}

.bt-counter {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--tb-muted);
    white-space: nowrap;
}

/* ── Right panel ─────────────────────────────────────────────────────────────── */
#bt-right-panel {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    background: rgba(7, 17, 31, 0.7);
    border-left: 1px solid rgba(148, 163, 184, 0.12);
}

.bt-panel-card {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.bt-panel-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--tb-muted);
    margin-bottom: 10px;
}

.bt-input {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: #f1f5f9;
    border-radius: 7px;
    padding: 6px 9px;
    font-size: 0.88rem;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}
.bt-input:focus { border-color: var(--tb-accent-2); }

.bt-entry-info {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #cbd5e1;
    min-height: 18px;
}

.bt-session-summary {
    margin-top: 12px;
    display: grid;
    gap: 7px;
}

.bt-session-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--tb-muted);
    font-size: 0.78rem;
}

.bt-session-summary-row strong {
    color: #f8fafc;
    font-size: 0.84rem;
    text-align: right;
}

/* Skip buttons group */
.bt-skip-group {
    display: flex;
    gap: 4px;
}
.bt-skip-btn {
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(41, 98, 255, 0.15);
    border-color: rgba(41, 98, 255, 0.35);
    color: #93b4ff;
}
.bt-skip-btn:hover:not(:disabled) {
    background: rgba(41, 98, 255, 0.28);
    border-color: rgba(41, 98, 255, 0.55);
}

/* Session notes */
.bt-notes-wrap {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}
.bt-notes-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.bt-notes-textarea {
    resize: vertical;
    min-height: 52px;
    line-height: 1.5;
    font-family: inherit;
    font-size: 0.82rem;
}

/* Stats */
.bt-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.bt-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 7px 10px;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.bt-stat-wide { grid-column: 1 / -1; }

.bt-stat-label {
    font-size: 0.72rem;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bt-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

/* ── Trades table (foldable) ──────────────────────────────────────────────── */
#bt-trades-section {
    flex-shrink: 0;
    border-bottom: none;
    border-top: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(7, 17, 31, 0.55);
}

.bt-trades-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0 14px;
    user-select: none;
}
.bt-trades-header:hover { background: rgba(148, 163, 184, 0.04); }

.bt-fold-btn {
    appearance: none;
    background: transparent;
    border: none;
    color: var(--tb-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.2s;
}
.bt-fold-btn:hover { background: rgba(148, 163, 184, 0.1); color: #fff; }

/* Collapsed state */
.bt-trades-foldable.is-collapsed .bt-trades-body {
    display: none;
}
.bt-trades-foldable.is-collapsed .bt-fold-btn svg {
    transform: rotate(-90deg);
}

.bt-trades-body {
    overflow-x: auto;
    max-height: 220px;
    overflow-y: auto;
}

#bt-trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

#bt-trades-table th {
    padding: 6px 10px;
    text-align: left;
    color: var(--tb-muted);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: rgba(10, 18, 33, 0.95);
    z-index: 1;
}

#bt-trades-table td {
    padding: 5px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.07);
    white-space: nowrap;
    color: #e2e8f0;
}

#bt-trades-table tbody tr:hover td {
    background: rgba(148, 163, 184, 0.06);
}

.bt-no-trades td {
    text-align: center;
    color: var(--tb-muted);
    padding: 18px;
    font-style: italic;
}

.bt-dir-buy  { color: #34d399; font-weight: 700; }
.bt-dir-sell { color: #f87171; font-weight: 700; }

.bt-status-open   { color: #93c5fd; }
.bt-status-tp     { color: #34d399; }
.bt-status-sl     { color: #f87171; }
.bt-status-manual { color: #f59e0b; }

/* Manual-close button in trades table */
.bt-close-btn {
    appearance: none;
    background: rgba(242, 54, 69, 0.14);
    border: 1px solid rgba(242, 54, 69, 0.3);
    color: #f87171;
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.bt-close-btn:hover {
    background: rgba(242, 54, 69, 0.26);
    border-color: #f23645;
}

/* SVG drawing overlay */
#svg-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9;
    will-change: transform;
}

/* Floating selection toolbar */
#floating-toolbar {
    display: none;
    position: absolute;
    background: #1e222d;
    border: 1px solid #2a2e3d;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.40);
    padding: 5px 4px;
    backdrop-filter: blur(10px);
    z-index: 20;
    pointer-events: auto;
    transform: translate(-50%, -100%);
    margin-top: -12px;
    align-items: center;
    gap: 2px;
}

.float-btn {
    background: transparent;
    border: none;
    color: #a0a8bc;
    cursor: pointer;
    padding: 7px 9px;
    border-radius: 7px;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.float-btn:hover { background: rgba(255,255,255,0.08); color: #eaeef5; transform: translateY(-1px); }
.float-btn:active { transform: translateY(0); }
.float-btn.delete { color: #e05f6b; }
.float-btn.delete:hover { background: rgba(242,54,69,0.15); color: #f23645; }

/* Drawn shapes */
.chart-rect {
    position: absolute;
    border: 1px solid transparent;
    pointer-events: none;
    z-index: 10;
    transition: border 0.1s, background-color 0.1s;
}
.chart-rect.blue { background-color: #2962ff3d; }
.chart-rect.red  { background-color: #b2283448; }
.chart-rect.green  { background-color: rgba(8,153,129,0.18); }
.chart-rect.yellow { background-color: rgba(234,179,8,0.18); }
.chart-rect.orange { background-color: rgba(234,100,8,0.18); }
.chart-rect.purple { background-color: rgba(139,92,246,0.18); }
.chart-rect.selected-shape.blue  { background-color: #2962ff3d; border-color: #2962ff3d; }
.chart-rect.selected-shape.red   { background-color: #b2283448; border-color: #b2283448; }
.chart-rect.alarm-on  { outline: 3px solid rgba(245,162,35,0.18); }
.chart-rect.alarm-sent { box-shadow: 0 0 18px 4px rgba(242,100,23,0.18); }
.chart-rect .rect-label {
    opacity: 1 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.handle {
    position: absolute;
    width: 16px; height: 16px;
    background: rgba(255,255,255,0.9);
    border: 2px solid #2962ff;
    transform: translate(-50%, -50%);
    cursor: crosshair;
    opacity: 0;
    pointer-events: none;
    z-index: 12;
    border-radius: 50%;
    touch-action: none;
}
.handle.visible-handle { opacity: 1; pointer-events: auto; }

.chart-text {
    position: absolute;
    font-size: 11.2px;
    font-weight: bold;
    line-height: 1.2;
    white-space: pre-wrap;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 11;
    padding: 4px;
    border: 1px solid transparent;
    border-radius: 4px;
}
.chart-text-content { white-space: pre-wrap; }
.chart-text.green { color: #089981; }
.chart-text.red   { color: #f23645; }
.chart-text.gray  { color: #787b86; }
.chart-text.selected-shape { border-color: #d1d4dc; background: rgba(0,0,0,0.05); }

/* Text editor modal */
.text-editor-overlay {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10, 14, 23, 0.65); padding: 16px;
}
.text-editor-modal {
    width: min(420px, 100%);
    background: #1e222d;
    border: 1px solid #2a2e3d;
    border-radius: 12px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.35);
    padding: 14px;
}
.text-editor-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: #eaeef5; }
.text-editor-input {
    width: 100%; min-height: 110px; resize: vertical;
    padding: 10px 12px; border-radius: 8px;
    border: 1px solid #394055; background: #151924; color: #eaeef5; font: inherit;
}
.text-editor-hint { margin-top: 8px; font-size: 12px; color: #a0a8bc; }
.text-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Long/Short position tool */
.ls-tool {
    position: absolute;
    pointer-events: none;
    z-index: 8;
    opacity: 0.85;
}
.ls-tool.selected-shape { opacity: 1; }
.ls-box {
    position: absolute; width: 100%; left: 0;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; font-size: 10px; font-weight: bold;
    color: rgba(19, 23, 34, 0.34); text-align: center; line-height: 1.2;
}
.ls-tool.selected-shape .ls-box { color: rgba(19, 23, 34, 0.5); }
.ls-profit { background: rgba(8, 153, 129, 0.10); }
.ls-loss   { background: rgba(242, 54, 69, 0.10); }

/* Alarm/pending badges (for full compatibility with drawEngine) */
.rect-alarm-badge {
    display: none; position: absolute; top: 2px; right: 2px;
    background: rgba(255,255,255,0.9); color: #f5a623;
    padding: 1px 2px; border-radius: 12px; font-size: 12px; line-height: 1;
    pointer-events: none;
}
.chart-rect.alarm-on .rect-alarm-badge { display: block; }
.chart-rect.alarm-sent .rect-alarm-badge { background: rgba(242,54,69,0.95); color: #fff; }

/* ── Trade rectangles on chart (matching live trading ls-tool style) ────── */
.bt-trade-rect {
    position: absolute;
    pointer-events: none;
    z-index: 8;
    opacity: 0.85;
}
.bt-trade-rect.bt-trade-rect-closed {
    opacity: 0.45;
}

.bt-trade-box {
    position: absolute;
    width: 100%;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-size: 10px;
    font-weight: bold;
    color: rgba(19, 23, 34, 0.50);
    text-align: center;
    line-height: 1.2;
}

.bt-trade-profit { background: rgba(8, 153, 129, 0.10); }
.bt-trade-loss   { background: rgba(242, 54, 69, 0.10); }

.bt-trade-box-label {
    font-size: 9px;
    font-weight: 600;
    color: rgba(19, 23, 34, 0.45);
    pointer-events: none;
}

/* Early close button on chart trade rect */
.bt-trade-rect-close {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(242, 54, 69, 0.85);
    border: 1px solid rgba(242, 54, 69, 0.5);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.15s, transform 0.1s;
    z-index: 15;
}
.bt-trade-rect-close:hover {
    background: rgba(242, 54, 69, 1);
    transform: scale(1.15);
}

@media (max-width: 900px) {
    #bt-main { flex-direction: column; }

    #bt-sidebar { display: none; }

    #bt-right-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(148, 163, 184, 0.12);
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    #bt-right-panel .bt-panel-card {
        min-width: 200px;
        border-bottom: none;
        border-right: 1px solid rgba(148, 163, 184, 0.1);
    }

    .bt-stats-grid { grid-template-columns: repeat(3, 1fr); }
    .bt-stat-wide  { grid-column: auto; }

    .bt-cards-grid { grid-template-columns: 1fr; }
    .bt-dash-header { gap: 12px; }
    .bt-dash-top-row { padding-left: 16px; padding-right: 16px; flex-direction: column; }
    .bt-dash-sessions { padding-left: 16px; padding-right: 16px; }
    .bt-combined-overview { flex: unset; width: 100%; }
    .bt-combined-stats { grid-template-columns: repeat(2, 1fr); }
    .bt-dash-perf-section { flex-direction: column; padding-left: 16px; padding-right: 16px; }
    .bt-perf-card { min-width: 0; }
    .bt-reduction-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    #bt-topbar { gap: 8px; }
    .bt-time-display { margin-left: 0; }
    .bt-dash-header { padding: 14px 16px; }
    .bt-card-stats { grid-template-columns: repeat(2, 1fr); }
    .bt-combined-stats { grid-template-columns: repeat(2, 1fr); }
    .bt-reduction-summary { grid-template-columns: 1fr; }
}
