body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    padding: 76px 20px 32px;
    color: var(--tb-text);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.back-home-btn {
    position: fixed;
    top: 18px;
    left: 20px;
    z-index: 1000;
}

.tb-shell {
    width: 100%;
    max-width: 1200px;
    display: grid;
    gap: 20px;
    padding-bottom: 40px;
}

.analytics-shell.analytics-loading .section-links,
.analytics-shell.analytics-loading .section-toggle {
    display: none;
}

#analysis-shell:not(.analytics-loading) #analysis-loading-panel {
    display: none;
}

.analytics-loading-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    text-align: center;
}

.analytics-loading-copy {
    display: grid;
    gap: 10px;
}

.analytics-loading-copy h2 {
    margin: 0;
    font-size: 1.25rem;
}

.analytics-loading-copy p {
    margin: 0;
    color: var(--tb-muted);
}

.hero {
    padding: 28px;
}

.hero-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 20px;
}

.toolbar input {
    flex: 1 1 260px;
    min-width: 220px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.72);
    color: var(--tb-text);
}

.toolbar button,
.toolbar a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.toolbar button {
    background: linear-gradient(135deg, rgba(32, 227, 178, 0.24), rgba(87, 199, 255, 0.22));
    color: #fff;
}

.toolbar a {
    background: rgba(71, 85, 105, 0.9);
    color: #fff;
}

.section-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-start;
}

.section-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.88rem;
    color: #fff;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.section-link:hover {
    background: rgba(30, 41, 59, 0.92);
    border-color: rgba(87, 199, 255, 0.34);
    transform: translateY(-1px);
}

.summary-grid,
.insight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}

.cards-grid-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-subgroup {
    margin-top: 18px;
    display: grid;
    gap: 12px;
}

.subsection-title {
    margin: 0;
    font-size: 1rem;
    color: #dbeafe;
}

.metric-card,
.insight-card {
    padding: 18px;
    border-radius: 16px;
    background: rgba(7, 17, 31, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* .metric-label, .metric-value, .positive, .negative defined in shared-theme.css */

.metric-card.positive .metric-value { color: #5eead4; }
.metric-card.negative .metric-value { color: #fca5a5; }

.neutral,
.muted { color: var(--tb-muted); }

.section-card {
    padding: 22px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.section-head h2,
.section-toggle > summary h2 {
    margin: 0;
    font-size: 1.25rem;
}

.section-head p,
.section-toggle > summary p {
    margin: 6px 0 0;
    color: var(--tb-muted);
}

.insight-card h3 {
    margin: 0 0 6px;
    font-size: 1.02rem;
}

.insight-card p {
    margin: 0 0 12px;
    color: var(--tb-muted);
    font-size: 0.9rem;
}

.insight-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.insight-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.crowded-worst-ea {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding: 5px 8px;
    border-left: 3px solid rgba(239, 68, 68, 0.55);
    border-radius: 0 6px 6px 0;
    background: rgba(239, 68, 68, 0.06);
    font-size: 0.88rem;
    color: var(--tb-muted);
}

.insight-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.insight-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--tb-muted);
    font-size: 0.88rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 800;
    border: 1px solid transparent;
}

.status-badge.working {
    color: #9ff5db;
    background: rgba(32, 227, 178, 0.16);
    border-color: rgba(32, 227, 178, 0.3);
}

.status-badge.watch {
    color: #fcd34d;
    background: rgba(250, 204, 21, 0.12);
    border-color: rgba(250, 204, 21, 0.24);
}

.status-badge.weak {
    color: #fecaca;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.24);
}

.status-badge.sample-warn {
    color: #fb923c;
    background: rgba(251, 146, 60, 0.12);
    border-color: rgba(251, 146, 60, 0.28);
}

.table-wrap {
    overflow: auto;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1020px;
    background: rgba(3, 10, 20, 0.42);
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    text-align: left;
    vertical-align: top;
    font-size: 0.92rem;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(10, 18, 33, 0.96);
    color: #dbeafe;
}

.range-card {
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 14px;
}

.range-card summary,
.section-toggle > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(7, 17, 31, 0.4);
}

.range-card summary::-webkit-details-marker,
.section-toggle > summary::-webkit-details-marker {
    display: none;
}

.range-card summary > div span,
.section-toggle > summary > div span {
    display: block;
    color: var(--tb-muted);
    margin-top: 4px;
    font-size: 0.9rem;
}

.range-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-weight: 700;
}

.toggle-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-top: 0;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(15, 23, 42, 0.72);
    flex-shrink: 0;
}

.section-toggle[open] .toggle-indicator::before {
    transform: rotate(90deg);
}

.toggle-indicator::before {
    content: '▸';
    color: var(--tb-muted);
    font-size: 1.05rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.toggle-content {
    padding-top: 16px;
}

.correlation-wrap .data-table {
    min-width: 720px;
}

.correlation-table td,
.correlation-table th {
    text-align: center;
}

.corr-cell {
    font-weight: 700;
    color: #07111f;
}

.corr-empty {
    color: var(--tb-muted);
    background: rgba(148, 163, 184, 0.08);
}

.pair-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.pair-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(7, 17, 31, 0.35);
    display: grid;
    gap: 6px;
}

.pair-card.positive { border-color: rgba(32, 227, 178, 0.28); }
.pair-card.negative { border-color: rgba(255, 107, 107, 0.28); }

.heat-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    color: var(--tb-muted);
    font-size: 0.85rem;
}

.legend-swatch {
    width: 56px;
    height: 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.legend-swatch.negative {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.9), rgba(248, 113, 113, 0.25));
}

.legend-swatch.neutral {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.35), rgba(203, 213, 225, 0.16));
}

.legend-swatch.positive {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.9));
}

.equity-panel {
    display: grid;
    gap: 16px;
}

.equity-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.stat-chip {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(7, 17, 31, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.12);
    display: grid;
    gap: 4px;
}

.stat-chip span {
    color: var(--tb-muted);
    font-size: 0.84rem;
}

.stat-chip strong {
    font-size: 1.02rem;
}

.equity-chart-frame {
    padding: 12px;
    border-radius: 16px;
    background: rgba(7, 17, 31, 0.35);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.equity-chart {
    width: 100%;
    height: auto;
    display: block;
}

.equity-axis {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--tb-muted);
    font-size: 0.84rem;
    margin-top: 6px;
}

/* ── Daily Overview (above equity chart) ───────────────── */
.daily-overview-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.daily-overview-chips .stat-chip {
    flex: 1 1 130px;
    min-width: 120px;
}

.daily-overview-empty {
    margin: 0;
    color: var(--tb-muted);
    font-size: 0.88rem;
}

.daily-overview-details {
    border-radius: 12px;
    overflow: hidden;
}

.daily-overview-details-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--tb-muted);
    padding: 6px 2px;
    list-style: none;
    user-select: none;
}

.daily-overview-details-label::-webkit-details-marker { display: none; }

.daily-overview-details[open] .daily-overview-details-label {
    color: var(--tb-text);
    margin-bottom: 8px;
}

.daily-overview-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.18);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--tb-text);
}

.daily-overview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.daily-overview-table th,
.daily-overview-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.daily-overview-table th {
    color: var(--tb-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.daily-overview-table tr:last-child td {
    border-bottom: none;
}

@media (max-width: 600px) {
    .daily-overview-table th:last-child,
    .daily-overview-table td:last-child {
        display: none;
    }
}


.empty-state {
    padding: 18px;
    border-radius: 14px;
    background: rgba(7, 17, 31, 0.35);
    color: var(--tb-muted);
    border: 1px dashed rgba(148, 163, 184, 0.18);
}

@media (max-width: 768px) {
    body { padding: 70px 14px 14px; }
    .hero { padding: 18px; }
    .section-card { padding: 16px; }
    .tb-title { font-size: 2rem; }
    .back-home-btn { top: 14px; left: 14px; }
}

/* ── Profitability split ─────────────────────────────── */
.profit-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.profit-col-head {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 0 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    margin-bottom: 10px;
}

.profit-col-head.positive { color: #5eead4; }
.profit-col-head.negative { color: #fca5a5; }
.profit-col-head.neutral  { color: var(--tb-muted); }

.profit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.profit-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.profit-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.profit-bar-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.profit-bar {
    height: 100%;
    border-radius: 999px;
    min-width: 2px;
}

.profit-bar.positive { background: #20e3b2; }
.profit-bar.negative { background: #ef4444; }
.profit-bar.neutral  { background: rgba(148, 163, 184, 0.5); }

.profit-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--tb-muted);
    font-size: 0.82rem;
    align-items: center;
}

/* ── Trade activity ──────────────────────────────────── */
.activity-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.activity-col-head {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 8px 0 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    margin-bottom: 10px;
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.activity-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.activity-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.activity-bar-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.activity-bar {
    height: 100%;
    border-radius: 999px;
    min-width: 2px;
    background: rgba(87, 199, 255, 0.7);
}

.activity-bar.positive { background: #20e3b2; }
.activity-bar.negative { background: #ef4444; }

.activity-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--tb-muted);
    font-size: 0.82rem;
    align-items: center;
}

/* ── Monthly P&L ─────────────────────────────────────── */
.monthly-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.monthly-table-wrap .data-table {
    min-width: 480px;
}

.monthly-table {
    width: 100%;
}

.monthly-bar-cell {
    min-width: 180px;
}

.monthly-bar-track {
    height: 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    overflow: hidden;
}

.monthly-bar {
    height: 100%;
    border-radius: 999px;
    min-width: 2px;
}

.monthly-bar.positive { background: #20e3b2; }
.monthly-bar.negative { background: #ef4444; }
.monthly-bar.neutral  { background: rgba(148, 163, 184, 0.5); }

/* Best 2 EA pairs list */
.best2-card { grid-column: 1 / -1; }

.best2-list { gap: 12px; }

.best2-pair-item {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 8px;
    align-items: start;
    padding: 12px;
}

.best2-pair-rank {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--tb-muted);
    padding-top: 2px;
    text-align: center;
}

.best2-pair-body {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
}

.best2-ea-half {
    display: grid;
    gap: 4px;
}

.best2-pair-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    text-align: center;
}

.best2-corr {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--tb-accent, #20e3b2);
    white-space: nowrap;
}

.best2-corr--positive { color: #20e3b2; }
.best2-corr--watch    { color: #f59e0b; }
.best2-corr--weak     { color: #ef4444; }

.pair-freq-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(148, 163, 184, 0.18);
    color: var(--tb-muted);
    vertical-align: middle;
}

.dominant-magic-note {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
    font-size: 0.8rem;
    color: #f59e0b;
    line-height: 1.5;
}

.cluster-ranked-item {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 6px;
    align-items: start;
}

.cluster-rank {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--tb-muted);
    padding-top: 2px;
    text-align: center;
}

@media (max-width: 600px) {
    .best2-pair-body {
        grid-template-columns: 1fr;
    }
    .best2-pair-divider {
        flex-direction: row;
        justify-content: center;
    }
}

/* -----------------------------------------------------------------------
   Reduction suggestions
   ----------------------------------------------------------------------- */

.reduction-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.reduction-summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 10px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.reduction-stat-label {
    font-size: 0.78rem;
    color: var(--tb-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.reduction-summary-stat strong {
    font-size: 1.3rem;
}

.reduction-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.reduction-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(239, 68, 68, 0.18);
}

.reduction-rank {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: rgba(239, 68, 68, 0.7);
    padding-top: 2px;
}

.reduction-body {
    display: grid;
    gap: 6px;
}

.reduction-remove-ea {
    display: grid;
    gap: 4px;
}

.reduction-keep-ea {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    padding: 5px 8px;
    border-left: 3px solid rgba(32, 227, 178, 0.45);
    border-radius: 0 6px 6px 0;
    background: rgba(32, 227, 178, 0.05);
    font-size: 0.88rem;
    color: var(--tb-muted);
}

/* -----------------------------------------------------------------------
   Hourly P&L chart
   ----------------------------------------------------------------------- */

.hourly-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.hourly-chart {
    display: flex;
    gap: 3px;
    height: 140px;
    align-items: flex-end;
    background: rgba(3, 10, 20, 0.42);
    border-radius: 12px;
    padding: 12px 10px 0;
    overflow-x: auto;
}

.hourly-bar-col {
    flex: 1;
    min-width: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    padding-bottom: 24px;
}

.hourly-bar-track {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.hourly-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    cursor: default;
    transition: opacity 0.15s;
}

.hourly-bar:hover {
    opacity: 0.75;
}

.hourly-bar.positive { background: rgba(32, 227, 178, 0.65); }
.hourly-bar.negative { background: rgba(239, 68, 68, 0.65); }
.hourly-bar.neutral  { background: rgba(148, 163, 184, 0.35); }

.hourly-hour-label {
    font-size: 0.68rem;
    color: var(--tb-muted);
    text-align: center;
    white-space: nowrap;
    user-select: none;
}

.hourly-axis-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--tb-muted);
    text-align: center;
}
