/* ==========================================================================
   GLS Equity V4 - Trade Journal Module
   Page-specific layout only. Cards, forms, buttons, messages, tooltips and text
   utilities come from styles.css (Session 4 clean-up removed the copies here).
   Journal-only table styling is scoped to .cal-scroll-wrapper.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BASE LAYOUT & SIDEBAR
   -------------------------------------------------------------------------- */
.scanner-layout { 
    display: flex; 
    gap: 20px;
    min-height: calc(100vh - 80px); 
    width: 100%; 
    margin: 0 auto; 
    padding: 16px 20px 0;
    box-sizing: border-box;
}
.scanner-main { 
    flex-grow: 1; 
    padding: 0 0 20px 0; 
    min-width: 0; 
    background: #f8fafc; 
}
.scanner-sidebar {
    background: #ffffff; 
    border-right: 1px solid #e2e8f0; 
    width: 340px; 
    flex-shrink: 0; 
    height: calc(100vh - 80px); 
    position: sticky; 
    top: 80px;
    overflow-y: auto; 
    overflow-x: hidden; 
    padding: 0 20px 20px 0; 
    box-sizing: border-box;
    transition: width 0.2s ease;
}
/* Slim rail (desktop): the sidebar's state while every panel for the current tab is minimised.
   .is-hidden = the tab has no sidebar panels (Test tab). Mobile ignores both (see section 10). */
.sidebar-rail { display: none; }
@media (min-width: 769px) {
    .scanner-sidebar.is-hidden { display: none; }
    .scanner-sidebar.is-slim { width: 56px; padding: 0; }
    .scanner-sidebar.is-slim .journal-accordion { display: none !important; }
    .scanner-sidebar.is-slim .sidebar-rail { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
    .sidebar-rail-btn {
        display: flex; flex-direction: column; align-items: center; gap: 10px;
        width: 100%; padding: 12px 0; border: none; border-radius: 6px;
        background: #ffffff; color: #0f172a; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 13px;
    }
    .sidebar-rail-btn:hover { background: #f1f5f9; }
    .sidebar-rail-icon { font-size: 16px; color: #64748b; }
    .sidebar-rail-text { writing-mode: vertical-rl; letter-spacing: 0.04em; white-space: nowrap; }
}

/* --------------------------------------------------------------------------
   2. UNIFIED ACCORDION SYSTEM (Matched to Buttons)
   -------------------------------------------------------------------------- */
.journal-accordion {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px; 
    margin-bottom: 15px; 
    overflow: hidden;
}
.accordion-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 10px 20px; 
    min-height: 42px; 
    background: #ffffff; 
    cursor: pointer;
    box-sizing: border-box;
}
.journal-accordion:not(.collapsed) .accordion-header {
    border-bottom: 1px solid #e2e8f0;
}
.accordion-header h3 { 
    font-size: 14px; 
    font-weight: bold;
    color: #0f172a; 
    margin: 0; 
}
.accordion-toggle-icon { 
    background: none; 
    border: none; 
    font-size: 16px; 
    color: #64748b; 
    cursor: pointer; 
    padding: 0; 
    pointer-events: none; 
}
.accordion-content { 
    max-height: 5000px; /* Allows full rendering */
    padding: 16px; 
    overflow: visible;
}
.journal-accordion.collapsed .accordion-content { 
    max-height: 0; /* Hides content but retains horizontal width for charts */
    padding: 0 16px;
    margin: 0;
    overflow: hidden;
    border: none;
}

/* --------------------------------------------------------------------------
   3. TOP NAVIGATION & TABS
   -------------------------------------------------------------------------- */
.scanner-tabs {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
    border-bottom: 1px solid #cbd5e1;
    padding: 6px 0 10px;
    margin-bottom: 20px;
    position: sticky; top: var(--nav-h, 70px); z-index: 40; background: #f8fafc;   /* stays under the site header */
}
.desktop-tabs {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
/* Filters / Analytics toggles at the right of the tab row (window.updateTabTools) */
.tab-tools { display: flex; gap: 8px; align-items: center; }
.tool-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px;
    border: 1px solid #cbd5e1; background: #fff; color: #334155; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.tool-btn:hover { background: #f8fafc; border-color: #94a3b8; }
.tool-btn.is-open { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
.tool-btn.has-count { border-color: #fbbf24; }
.tool-icon { font-size: 13px; }
.tool-sep { width: 1px; height: 22px; background: #e2e8f0; margin: 0 4px; }
.tool-btn.tool-action { background: #0f172a; color: #fff; border-color: #0f172a; }
.tool-btn.tool-action:hover:not(:disabled) { background: #1e293b; }
.tool-btn.tool-go { background: #10b981; border-color: #10b981; }
.tool-btn.tool-go:hover:not(:disabled) { background: #059669; }
.tool-btn.tool-danger { background: #fff; color: #dc2626; border-color: #fecaca; }
.tool-btn.tool-danger:hover:not(:disabled) { background: #fee2e2; }
.tool-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tool-count { background: #f59e0b; color: #fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }
/* Tool panels have no bar of their own: closed = gone, open = just the content card */
.journal-accordion.tool-panel .accordion-header { display: none; }
.journal-accordion.tool-panel.collapsed { display: none; }
.tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 1rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    text-decoration: none;
}
.tab-btn:hover { color: #0f172a; }
.tab-btn.active {
    color: #2563eb;
    border-bottom: 3px solid #2563eb;
}

/* --------------------------------------------------------------------------
   4. FORMS, BUTTONS & FILTERS
   -------------------------------------------------------------------------- */
/* Filter Flex Layouts */
.filter-flex-container { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 15px; }
.test-filter-group { display: flex; gap: 15px; align-items: flex-end; }
.filter-item { margin-bottom: 0; }
.scanner-layout .filter-label { display: block; margin-bottom: 6px; }
.filter-input { min-width: 130px; }

/* Custom Multi-Select Dropdowns */
.custom-multi-select { position: relative; display: inline-block; width: 100%; min-width: 170px; text-align: left; }
.custom-multi-select .select-box { 
    background: #fff; border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 12px; 
    font-size: 14px; cursor: pointer; display: flex; justify-content: space-between; 
    align-items: center; color: #0f172a; text-align: left; 
}
.custom-multi-select .options-container { 
    display: none; position: absolute; top: 100%; left: 0; background: #fff; 
    border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); 
    width: 220px; max-height: 300px; overflow-y: auto; z-index: 9999; margin-top: 5px; padding: 5px 0; 
}
.custom-multi-select .options-container label { 
    display: flex; align-items: center; justify-content: flex-start; /* 💥 FIX: Forces left alignment */
    padding: 8px 12px; cursor: pointer; font-size: 13px; font-weight: 500; 
    color: #334155; transition: background 0.1s; margin: 0; text-align: left; 
}
.custom-multi-select .options-container label:hover { background: #f8fafc; }
.custom-multi-select .options-container input { 
    margin-right: 10px; cursor: pointer; width: 15px; height: 15px; 
    accent-color: #0ea5e9; flex-shrink: 0; /* 💥 FIX: Stops checkboxes from squishing */
}

/* Action Wrapper (the big Log Trade / Save buttons) */
.action-btn-wrapper { margin: 0 0 15px 0; display: flex; flex-direction: column; gap: 15px; align-items: center; width: 100%; }
.action-btn-wrapper .btn { width: 100%; max-width: 400px; }

/* --------------------------------------------------------------------------
   5. SUMMARY CARDS & TOOLTIPS
   -------------------------------------------------------------------------- */
.journal-summary-card {
    background: #ffffff; border: 1px solid #cbd5e1; border-radius: 10px; padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); display: flex; flex-direction: column; justify-content: flex-start; 
}
.journal-summary-card.test-active { border: 1px dashed #0ea5e9; background: #f0f9ff; transition: all 0.2s; }
.journal-summary-card.test-inactive { border: 1px dashed #94a3b8; background: #f8fafc; transition: all 0.2s; }

.summary-header {
    display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 1.1rem; color: #0f172a;
    border-bottom: 1px solid #e2e8f0; padding-bottom: 12px; margin-bottom: 16px; min-height: 24px; 
}

.journal-summary-card .summary-row {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; padding: 10px 14px; 
    font-size: 0.95rem; background-color: #f8fafc; border: 1px solid #f1f5f9; border-radius: 8px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.journal-summary-card .summary-row:hover { background-color: #f1f5f9; border-color: #e2e8f0; }

.summary-label { color: #64748b; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.summary-val { font-weight: 700; color: #0f172a; }

.info-icon-btn {
    position: relative; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 6px; padding: 0; border: none; background: transparent; cursor: pointer; color: transparent; vertical-align: middle; transform: translateY(-1px); 
}
.info-icon-btn::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center; background-size: contain; transition: background-image 0.2s ease; 
}
.info-icon-btn:hover::before { 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233b82f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E"); 
}

/* --------------------------------------------------------------------------
   6. MAIN DATA TABLES
   -------------------------------------------------------------------------- */
.cal-scroll-wrapper {
    width: 100%; max-height: 65vh; overflow-x: auto; overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; box-shadow: inset 0 0 0 1px #e2e8f0;
}
/* Journal tables: wide, sticky header, thick pale gap between rows (scoped so other pages keep the global look) */
.cal-scroll-wrapper .data-table { min-width: 1200px; }
.cal-scroll-wrapper .data-table th { padding: 10px 25px 10px 12px; background: #f8fafc; font-weight: 700; position: sticky; top: 0; z-index: 20; }
.cal-scroll-wrapper .data-table th:hover { background: #f1f5f9; }
.cal-scroll-wrapper .data-table td { padding: 10px 12px; border-bottom: 4px solid #f8fafc; vertical-align: middle; }

.data-table tr.journal-row-win td { background-color: #f0fdf4; transition: background 0.15s; }
.data-table tr.journal-row-win:hover td { background-color: #d1fae5; }
.data-table tr.journal-row-loss td { background-color: #fef2f2; transition: background 0.15s; }
.data-table tr.journal-row-loss:hover td { background-color: #fee2e2; }
.data-table tr.journal-row-test td { background-color: #ffffff; transition: background 0.15s; border-bottom: 4px solid #f8fafc; border-left: 2px solid #0ea5e9; }
.data-table tr.journal-row-test:hover td { background-color: #f1f5f9; }

/* --------------------------------------------------------------------------
   7. LEG & TRADE DETAILS UI
   -------------------------------------------------------------------------- */
.leg-render-item { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 13px; line-height: 1.1; }
.leg-render-item:last-child { margin-bottom: 0; }
.leg-render-type { padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; cursor: pointer; transition: opacity 0.2s; }
.leg-render-type:hover { opacity: 0.8; }
.leg-render-type.csp { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.leg-render-type.cc { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.leg-render-type.short { background: #fce7f3; color: #be185d; border: 1px solid #fbcfe8; }
.leg-render-type.long { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.leg-render-status { font-size: 11px; font-weight: 800; }

.leg-action-icon { cursor: pointer; font-size: 0.85rem; font-weight: 900; margin-left: 5px; opacity: 0.5; transition: opacity 0.2s, transform 0.2s; }
.leg-action-icon:hover { opacity: 1; transform: scale(1.2); }
.leg-action-icon.close { color: #ef4444; }
.leg-action-icon.edit { color: #64748b; }

.manage-icon { font-size: 1.1rem; cursor: pointer; opacity: 0.6; margin-right: 12px; transition: transform 0.2s, opacity 0.2s; }
.manage-icon:hover { opacity: 1; transform: scale(1.2); }
.manage-icon.delete { margin-right: 0; }

.leg-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.leg-card.leg-sell { border-left: 4px solid #ef4444; border-top: none; }
.leg-card.leg-buy { border-left: 4px solid #10b981; border-top: none; }
.leg-header { margin: 0 0 10px 0; font-size: 0.9rem; color: #0f172a; }
.leg-flex-row { display: flex; gap: 10px; margin-bottom: 10px; }
.leg-input-label { display: block; font-size: 0.75rem; color: #64748b; margin-bottom: 4px; }
.leg-input { width: 100%; padding: 6px; font-size: 0.85rem; border: 1px solid #cbd5e1; border-radius: 4px; }

.metrics-box { background: #0f172a; color: #f8fafc; padding: 15px; border-radius: 8px; margin-top: 15px; margin-bottom: 15px; }
.metrics-box .metrics-header { font-weight: 800; font-size: 1rem; border-bottom: 1px solid #334155; padding-bottom: 8px; margin-bottom: 8px; }

/* --------------------------------------------------------------------------
   8. JOURNAL TEXT UTILITIES (colour classes .text-success/.text-danger/... are global)
   -------------------------------------------------------------------------- */
.d-flex { display: flex; }
.align-center { align-items: center; }

.td-bold-dark { font-weight: 700; color: #0f172a; }
.td-semi-dark { font-weight: 600; color: #0f172a; }
.td-semi-muted { color: #64748b; font-weight: 600; }
.td-muted { color: #94a3b8; font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   9. APEXCHARTS OVERRIDES
   -------------------------------------------------------------------------- */
.apexcharts-tooltip, .apexcharts-tooltip.apexcharts-theme-light {
    background: #ffffff !important; border: 1px solid #cbd5e1 !important; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1) !important;
    max-width: 85vw !important; white-space: normal !important; overflow-wrap: break-word !important; z-index: 9999 !important;
    pointer-events: none !important; transition: none !important; 
}
.apexcharts-tooltip.apexcharts-active { opacity: 1 !important; visibility: visible !important; }
/* (the series dot, .apexcharts-tooltip-marker, is coloured by an inline "color:" in current ApexCharts - keep it out of this rule) */
.apexcharts-tooltip span:not(.apexcharts-tooltip-marker), .apexcharts-tooltip div, .apexcharts-tooltip-text-y-value, .apexcharts-tooltip-text-y-label { color: #0f172a !important; white-space: normal !important; }
.apexcharts-tooltip-title { background: #f8fafc !important; border-bottom: 1px solid #e2e8f0 !important; font-family: inherit !important; font-weight: 700 !important; padding: 8px 10px !important; }
.apexcharts-tooltip-series-group { padding: 8px 10px !important; background: #ffffff !important; }
.apexcharts-tooltip-series-group.apexcharts-active { display: flex !important; }
.apexcharts-tooltip-text { font-size: 13px !important; font-family: inherit !important; padding-left: 6px !important; line-height: 1.4 !important; }
.apexcharts-legend-text { color: #475569 !important; font-family: inherit !important; }

/* Custom HTML Tooltips for Pie Charts */
.apex-custom-tooltip { padding: 10px 14px; background: #fff; border: 1px solid #cbd5e1; border-radius: 4px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); font-family: inherit; min-width: 140px; z-index: 9999 !important; pointer-events: none; transition: none; }
.apex-tooltip-title { font-weight: 700; color: #0f172a; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; margin-bottom: 8px; text-align: center; font-size: 14px; }
.apex-tooltip-row { display: flex; justify-content: space-between; gap: 15px; font-size: 13px; margin-bottom: 4px; }
.apex-tooltip-label { color: #64748b; font-weight: 600; }
.apex-tooltip-val { font-weight: 700; color: #334155; }

.apex-pie-tooltip { padding: 10px 14px; background: #fff; border: 1px solid #cbd5e1; border-radius: 4px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); font-family: inherit; z-index: 9999 !important; pointer-events: none; transition: none; }
.apex-pie-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.apex-pie-dot { width: 12px; height: 12px; border-radius: 50%; }
.apex-pie-label { font-weight: 700; color: #334155; font-size: 14px; line-height: 1; }
.apex-pie-val { font-weight: 700; color: #0ea5e9; font-size: 14px; margin-left: 20px; }
.apex-pie-pct { font-weight: 500; color: #64748b; font-size: 12px; margin-left: 4px; }

/* --------------------------------------------------------------------------
   9b. PERFORMANCE TAB (daily equity log) - Session 4j/4k
   Sidebar panels (Log today, Margin, Currency & data) reuse the accordion system above.
   Main area: DOM order = phone order; desktop uses grid areas so the equity chart sits beside the
   statistics (same height) and the Annual table + tabbed monthly chart sit beside Monthly (same height).
   -------------------------------------------------------------------------- */
.perf-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.perf-tool-btns { display: flex; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.perf-tool-btns label { margin: 0; }
.perf-explain p { font-size: 13px; line-height: 1.45; margin: 0 0 8px; color: #334155; }
.perf-explain p:last-child { margin-bottom: 0; }

.perf-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); grid-template-areas: "equity stats" "monthly right" "daily daily"; gap: 20px; align-items: stretch; }
.perf-card { margin: 0; }
/* Row 1: the chart card sets the height (640 px); the statistics table scrolls inside the same height */
.perf-area-equity { grid-area: equity; display: flex; flex-direction: column; height: 700px; }
.perf-area-stats { grid-area: stats; display: flex; flex-direction: column; height: 700px; }
.perf-stats-box { flex: 1; min-height: 0; max-height: none; }
.perf-stats td { padding: 4px 10px; line-height: 1.3; }
.perf-area-monthly { grid-area: monthly; }
.perf-area-right { grid-area: right; display: flex; flex-direction: column; gap: 20px; }
.perf-area-daily { grid-area: daily; }
.perf-chart-tabs-card { flex: 1; display: flex; flex-direction: column; min-height: 340px; }
.perf-chart-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e2e8f0; margin-bottom: 8px; }
.perf-chart-tabs .tab-btn { padding: 6px 12px; font-size: 0.85rem; }
.perf-chart-fill { flex: 1; min-height: 300px; overflow: hidden; }
.perf-help { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; }
.perf-help p { font-size: 13px; line-height: 1.45; margin: 0 0 8px; color: #334155; }
.perf-help-btn { vertical-align: middle; margin-left: 4px; }

/* These tables are read-only summaries: no sort arrows, no sort cursor (the arrows were overlapping short headers) */
.perf-table th { cursor: default; padding: 7px 10px !important; }
.perf-table th::after { display: none !important; }
.perf-table td { padding: 7px 10px; font-size: 0.85rem; white-space: nowrap; }
.perf-table th { font-size: 0.7rem; white-space: nowrap; }
.perf-stat-label, .perf-period { font-weight: 600; color: #334155; }
.perf-stat-label .text-sm-muted { display: block; font-weight: 500; font-size: 0.7rem; line-height: 1.1; }
.perf-monthly-box { max-height: 560px; }
.perf-body.fx-off .perf-fx-col, #perf-body.fx-off .perf-fx-col { display: none; }
.perf-daily-box { max-height: 60vh; }
.perf-daily td { padding: 8px 10px; }
.perf-note-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: #64748b; }
.perf-manage { white-space: nowrap; }
.perf-icon { background: none; border: none; cursor: pointer; font-size: 0.95rem; opacity: 0.65; padding: 0 3px; }
.perf-icon:hover { opacity: 1; }
.perf-confirm { font-size: 0.8rem; color: #b91c1c; font-weight: 600; }
.data-table tr.show-more-row td { text-align: center; padding: 14px 16px; background: #f8fafc; white-space: normal; }
.show-more-text { display: inline-block; margin-right: 12px; color: #64748b; font-size: 0.85rem; font-weight: 600; }

/* --------------------------------------------------------------------------
   10. MOBILE RESPONSIVE OVERRIDES (<= 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Flatten DOM to allow flex ordering between sidebar and main elements */
    .scanner-layout { display: flex; flex-direction: column; gap: 0; padding: 10px; box-sizing: border-box; }
    .scanner-sidebar, .scanner-main, [id$="-wheel-table-container"] { display: contents; }
    
    /* Exact Reordering: Menu -> Log Trade -> Filters -> Analytics -> Button */
    .scanner-tabs { order: 1; margin: 0 0 12px 0; border: none; padding: 8px 0; flex-direction: column; align-items: stretch; gap: 8px; }
    .scanner-tabs .mobile-tab-dropdown { order: -1; margin: 0; }
    .tab-tools { justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
    .tool-btn { flex: 1; justify-content: center; padding: 6px 8px; }
    .tool-sep { display: none; }
    .journal-accordion { margin-bottom: 10px; }
    #panel-new-trade { order: 2; margin: 0 0 15px 0; }
    [id^="panel-filters"] { order: 3; margin: 0 0 15px 0; }
    [id^="panel-analytics"] { order: 4; margin: 0 0 15px 0; }
    
    /* Button Bleed Fix: Removes left/right margins, relies on parent padding */
    .action-btn-wrapper { order: 5; margin: 0 0 15px 0; width: 100%; box-sizing: border-box; }
    .action-btn-wrapper .btn { width: 100%; max-width: none; box-sizing: border-box; }
    
    [id$="-summary-cards"] { order: 6; margin: 0 0 15px 0; flex-direction: column; }
    [id$="-table-wrapper"] { order: 7; margin: 0; }

    /* Mobile Dropdown Visibility (the dropdown itself is styled globally) */
    .desktop-tabs { display: none; }

    /* Filters */
    .filter-flex-container, .test-filter-group { flex-direction: column; align-items: stretch; gap: 0; }
    .form-group.filter-item { display: flex; align-items: center; justify-content: flex-start; margin-bottom: 12px; gap: 10px; }
    .form-group.filter-item label { margin-bottom: 0; flex: 0 0 90px; text-align: left; }
    /* 💥 FIX: Restricts stretching to text boxes only, leaving checkboxes perfectly aligned */
    .form-group.filter-item select, .form-group.filter-item input[type="text"], .form-group.filter-item .custom-multi-select { flex: 1; box-sizing: border-box; }

    /* Performance tab: sidebar panels sit where Log New Trade does; cards stack in DOM order */
    [id^="panel-perf"] { order: 2; margin: 0 0 10px 0; }
    #performance-container { order: 8; }
    .perf-main { display: block; }
    .perf-card, .perf-area-right { margin-bottom: 16px; }
    .perf-area-right { display: block; }
    .perf-area-right .perf-card:first-child { margin-bottom: 16px; }
    .perf-area-equity, .perf-area-stats { height: auto; display: block; }
    .perf-stats-box { max-height: 70vh; }
    .perf-chart-fill { height: 240px; min-height: 0; flex: none; }
    #perf-chart-equity.perf-chart-fill { height: 260px; }
    .perf-chart-tabs-card { min-height: 0; }
    .perf-monthly-box { max-height: 420px; }
}
