.stats-section {
    border: var(--stats-section-border, 1px solid var(--dim-color));
    border-radius: var(--stats-section-radius, 0);
    padding: var(--stats-section-padding, 15px);
    background: var(--stats-section-bg, rgba(0, 0, 0, 0.2));
    margin-bottom: var(--stats-section-margin-bottom, 0);
}

.stats-section:last-child {
    margin-bottom: var(--stats-section-last-margin-bottom, 0);
}

.breakdown-table {
    width: var(--breakdown-table-width, 100%);
    border-collapse: var(--breakdown-table-border-collapse, collapse);
    border-spacing: var(--breakdown-table-border-spacing, 0);
    font-size: var(--breakdown-table-font-size, 0.9em);
}

.breakdown-table th {
    text-align: left;
    padding: var(--breakdown-th-padding, 8px 12px);
    border-bottom: var(--breakdown-th-border-bottom, 2px solid var(--dim-color));
    color: var(--breakdown-th-color, var(--dim-color));
    font-weight: var(--breakdown-th-font-weight, 600);
    font-size: var(--breakdown-th-font-size, 0.85em);
    letter-spacing: var(--breakdown-th-letter-spacing, normal);
    text-transform: var(--breakdown-th-text-transform, uppercase);
    background: var(--breakdown-th-bg, transparent);
}

.breakdown-table th:first-child {
    border-radius: var(--breakdown-th-first-radius, 0);
}

.breakdown-table th:last-child {
    border-radius: var(--breakdown-th-last-radius, 0);
}

.breakdown-table td {
    padding: var(--breakdown-td-padding, 8px 12px);
    border-bottom: var(--breakdown-td-border-bottom, 1px solid rgba(255, 255, 255, 0.05));
    transition: var(--breakdown-td-transition, none);
}

.breakdown-table tr:hover {
    background-color: var(--breakdown-row-hover-bg, rgba(255, 255, 255, 0.03));
}

.breakdown-table tr:hover td {
    background-color: var(--breakdown-cell-hover-bg, transparent);
}

.breakdown-table .stat-name {
    color: var(--accent-color);
    font-weight: 500;
}

.breakdown-table .positive {
    color: var(--success-color);
}

.breakdown-table .negative {
    color: var(--error-color);
}

.breakdown-table .total {
    font-weight: 600;
    color: var(--breakdown-total-color, var(--warning-color));
}

.breakdown-table .subtotal {
    color: var(--dim-color);
    font-style: italic;
}

.breakdown-table .subtotal-header {
    color: var(--dim-color);
    text-align: center;
    width: 2em;
    padding: 8px 4px;
}

.formula-explanation {
    color: var(--dim-color);
    font-size: 0.85em;
    margin-bottom: 0.75rem;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.breakdown-table tbody tr:last-child td {
    border-bottom: none;
}

/* Desktop: hide mobile-only elements */
.mobile-total,
.mobile-total-header {
    display: none;
}

/* Desktop: hide cell labels, show only values */
.breakdown-table .cell-label {
    display: none;
}

/* Responsive Stats Layout - Mobile */
@media (max-width: 900px) {
    /* Hide formula explanation on mobile */
    .formula-explanation {
        display: none;
    }

    /* Hide desktop total, show mobile total */
    .desktop-total,
    .desktop-total-header {
        display: none;
    }

    .mobile-total,
    .mobile-total-header {
        display: table-cell;
    }

    /* Card-based breakdown table for mobile */
    .breakdown-table {
        display: block;
    }

    .breakdown-table thead {
        display: none;
    }

    .breakdown-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .breakdown-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 4px 12px;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 12px;
    }

    .breakdown-table td {
        padding: 2px 0;
        border: none;
    }

    .breakdown-table td.stat-name {
        grid-column: 1;
        grid-row: 1;
        font-size: 1.1em;
        font-weight: 600;
        color: var(--accent-color);
    }

    .breakdown-table td.mobile-total {
        grid-column: 2;
        grid-row: 1;
        font-size: 1.2em;
        font-weight: 600;
        text-align: right;
    }

    .breakdown-table td.breakdown-cell {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        grid-column: 1 / -1;
        padding: 4px 8px;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 2px;
    }

    .breakdown-table .cell-label {
        display: inline;
        color: var(--dim-color);
        font-size: 0.9em;
        font-weight: normal;
    }

    .breakdown-table .cell-value {
        text-align: right;
    }

    .breakdown-table td.desktop-total {
        display: none;
    }
}
