/* ea-profitability.css – EA Profitability page styles */

#profit-shell.profit-loading .section-links,
#profit-shell.profit-loading .section-toggle,
#profit-shell.profit-loading #profit-compare-section,
#profit-shell.profit-loading #profit-scatter-section,
#profit-shell.profit-loading .profit-summary-section {
    display: none;
}

#profit-shell:not(.profit-loading) #profit-loading-panel {
    display: none;
}

.profit-loading-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    text-align: center;
}

.profit-loading-copy {
    display: grid;
    gap: 10px;
}

.profit-loading-copy h2 {
    margin: 0;
    font-size: 1.25rem;
}

.profit-loading-copy p {
    margin: 0;
    color: var(--tb-muted);
}

/* Summary Overview */
.profit-summary-section {
    margin-bottom: 4px;
}

.profit-summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 4px 0;
}

/* Overfit Radar */
.overfit-radar-section {
    border-color: rgba(87, 199, 255, 0.18);
}

.overfit-radar-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.overfit-radar-head h2 {
    margin: 0 0 6px;
}

.overfit-radar-head p {
    max-width: 760px;
    margin: 0;
    color: var(--tb-muted);
    line-height: 1.55;
}

.overfit-radar-head .tb-eyebrow {
    margin-bottom: 10px;
}

.overfit-method {
    display: flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    color: var(--tb-muted);
    font-size: 0.76rem;
}

.overfit-method i {
    color: var(--tb-accent-2);
    font-size: 1rem;
}

.overfit-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.overfit-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 8px 11px;
    color: var(--tb-muted);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    background: rgba(15, 23, 42, 0.64);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 7px;
    cursor: pointer;
}

.overfit-filter strong {
    color: var(--tb-text);
    font-size: 1rem;
}

.overfit-filter:hover,
.overfit-filter.is-active {
    color: var(--tb-text);
    border-color: var(--tb-accent-2);
    background: rgba(87, 199, 255, 0.10);
}

.overfit-filter--high strong { color: #fca5a5; }
.overfit-filter--watch strong { color: #fbbf24; }
.overfit-filter--stable strong { color: #5eead4; }

.overfit-table-wrap {
    overflow-x: auto;
}

.overfit-table {
    width: 100%;
    min-width: 1050px;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.overfit-table th {
    padding: 8px 9px;
    color: var(--tb-muted);
    font-size: 0.68rem;
    text-align: left;
    text-transform: uppercase;
    background: rgba(15, 23, 42, 0.88);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.overfit-table td {
    padding: 10px 9px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.overfit-table tbody tr:hover td {
    background: rgba(87, 199, 255, 0.05);
}

.overfit-strategy strong,
.overfit-strategy span,
.overfit-reasons span {
    display: block;
}

.overfit-strategy strong {
    margin-bottom: 3px;
    color: var(--tb-text);
    font-size: 0.84rem;
}

.overfit-ea-name {
    display: block;
    margin-bottom: 2px;
    color: var(--tb-muted);
    font-size: 0.7rem;
    font-weight: 600;
}

.overfit-strategy span {
    color: var(--tb-muted);
    font-size: 0.7rem;
    white-space: nowrap;
}

.overfit-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 6px;
    color: var(--tb-muted);
    font-weight: 800;
    white-space: nowrap;
}

.overfit-status--high { color: #fca5a5; border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }
.overfit-status--watch { color: #fbbf24; border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.overfit-status--stable { color: #5eead4; border-color: rgba(94, 234, 212, 0.32); background: rgba(94, 234, 212, 0.07); }

.overfit-score {
    display: grid;
    grid-template-columns: 74px 24px;
    align-items: center;
    gap: 7px;
}

.overfit-score > span {
    position: relative;
    width: 74px;
    height: 5px;
    overflow: hidden;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.18);
}

.overfit-score > span::after {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--score);
    content: '';
    background: linear-gradient(90deg, #5eead4 0%, #fbbf24 50%, #f87171 100%);
}

.overfit-pair {
    white-space: nowrap;
}

.overfit-pair i {
    margin: 0 4px;
    color: var(--tb-muted);
}

.overfit-metric-bt {
    color: var(--tb-muted);
}

.overfit-reasons {
    min-width: 220px;
    color: var(--tb-muted);
    line-height: 1.45;
}

.overfit-reasons span::before {
    margin-right: 5px;
    color: var(--tb-accent-2);
    content: '·';
}

@media (max-width: 780px) {
    .overfit-radar-head {
        align-items: start;
        flex-direction: column;
        gap: 10px;
    }

    .overfit-summary {
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .overfit-filter {
        flex: 0 0 145px;
    }
}

/* ── Year × Month Heatmap Grid ─────────────────────────────────────────────── */
.heatmap-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.heatmap-card {
    border-radius: 14px;
    background: rgba(7, 17, 31, 0.44);
    border: 1px solid rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.heatmap-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.48);
    flex-wrap: wrap;
}

.heatmap-magic {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--tb-text);
}

.heatmap-ea-name {
    display: block;
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--tb-muted);
    margin-top: 1px;
}

.monthly-summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.heatmap-grids {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
}

.heatmap-section-title {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px 6px;
}

.heatmap-scroll {
    overflow-x: auto;
}

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    min-width: 400px;
}

.heatmap-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.heatmap-table th {
    padding: 5px 4px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(15, 23, 42, 0.78);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.heatmap-table th.hm-year-col {
    text-align: left;
    padding-left: 8px;
    min-width: 48px;
}

.heatmap-table th.hm-total-col {
    color: #fbbf24;
}

.heatmap-table td {
    padding: 4px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.76rem;
}

.heatmap-table td.hm-year-col {
    text-align: left;
    padding-left: 8px;
    color: var(--tb-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.heatmap-table td.hm-cell {
    min-width: 52px;
}

.heatmap-table td.hm-total-col {
    font-weight: 800;
    font-size: 0.8rem;
}

.heatmap-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.06);
}

/* Live month underperforming backtest average */
.hm-under-bt-avg {
    background: rgba(248, 113, 113, 0.18) !important;
    box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.35);
    border-radius: 3px;
}

.hm-under-bt-avg:hover {
    background: rgba(248, 113, 113, 0.30) !important;
}

/* Summary rows */
.hm-total-row {
    background: rgba(251, 191, 36, 0.07);
    border-top: 2px solid rgba(251, 191, 36, 0.30);
}

.hm-total-row td {
    padding-top: 6px;
    padding-bottom: 6px;
}

.hm-total-row td.hm-year-col {
    color: #fbbf24;
}

.hm-total-cell {
    font-weight: 800 !important;
}

.hm-avg-row {
    background: rgba(94, 234, 212, 0.06);
    border-top: 1px solid rgba(94, 234, 212, 0.25);
}

.hm-avg-row td {
    padding-top: 6px;
    padding-bottom: 6px;
    color: var(--tb-muted);
}

.hm-avg-row td.hm-year-col {
    color: #5eead4;
}

@media (max-width: 780px) {
    .heatmap-cards {
        grid-template-columns: 1fr;
    }

    .heatmap-table {
        font-size: 0.72rem;
    }

    .heatmap-table td {
        padding: 3px 2px;
        font-size: 0.7rem;
    }

    .mc-table {
        font-size: 0.74rem;
    }

    .mc-table th,
    .mc-table td {
        padding: 5px 6px;
    }
}

/* ── Monthly Comparison Table ──────────────────────────────────────────────── */
.mc-table-wrap {
    overflow-x: auto;
}

.mc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.mc-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.mc-table th {
    padding: 8px 10px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(15, 23, 42, 0.88);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.mc-table th[rowspan] {
    vertical-align: middle;
}

.mc-table td {
    padding: 7px 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
    font-weight: 600;
}

.mc-table tbody tr:hover td {
    background: rgba(59, 130, 246, 0.06);
}

.mc-magic {
    text-align: left !important;
    font-weight: 800 !important;
    color: var(--tb-text);
    font-size: 0.85rem;
}

.mc-ea-name {
    display: block;
    font-weight: 600;
    font-size: 0.68rem;
    color: var(--tb-muted);
    margin-top: 1px;
}

.mc-cell {
    font-size: 0.82rem;
}

.mc-z {
    font-size: 0.88rem;
    font-weight: 800 !important;
}

.mc-z.positive { color: #5eead4; }
.mc-z.negative { color: #fca5a5; }
.mc-z.neutral  { color: #fbbf24; }

/* ── PF Scatter Plot ───────────────────────────────────────────────────────── */
.scatter-wrap {
    padding: 4px;
}

.scatter-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.scatter-chart-frame {
    border-radius: 12px;
    overflow: hidden;
    background: rgba(3, 10, 20, 0.24);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.scatter-svg {
    display: block;
    width: 100%;
    max-width: 700px;
    height: auto;
}

.scatter-list-section {
    margin-top: 14px;
}

.scatter-list-title {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.scatter-list--good { color: #5eead4; }
.scatter-list--warn { color: #fbbf24; }
.scatter-list--bad  { color: #fca5a5; }

.scatter-list-items {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.scatter-magic-tag {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(30, 41, 59, 0.55);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--tb-text);
}

.scatter-magic-tag small {
    font-weight: 500;
    color: var(--tb-muted);
    font-size: 0.7rem;
}
