/* CSS for Responsive Expandable Tables in Mobile View */

@media (max-width: 768px) {
    /* Transform tables into blocks */
    table.holdings-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }

    table.holdings-table thead {
        display: none !important; /* Hide header columns */
    }

    /* Keep monthly realized tracking tables fully visible on mobile */
    #trading-monthly-stock-matrix-table,
    #trading-monthly-option-matrix-table {
        display: table !important;
        width: 100% !important;
        background: transparent !important;
        border-collapse: collapse !important;
    }

    #trading-monthly-stock-matrix-table thead,
    #trading-monthly-option-matrix-table thead {
        display: table-header-group !important;
    }

    #trading-monthly-stock-matrix-table tbody,
    #trading-monthly-option-matrix-table tbody {
        display: table-row-group !important;
    }

    #trading-monthly-stock-matrix-table tr,
    #trading-monthly-option-matrix-table tr {
        display: table-row !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        cursor: default !important;
        box-shadow: none !important;
        position: static !important;
    }

    #trading-monthly-stock-matrix-table tr::after,
    #trading-monthly-option-matrix-table tr::after {
        content: none !important;
    }

    #trading-monthly-stock-matrix-table td,
    #trading-monthly-option-matrix-table td {
        display: table-cell !important;
        padding: 10px 8px !important;
        border: none !important;
        width: auto !important;
        background: transparent !important;
        text-align: left !important;
    }

    table.holdings-table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
        padding: 4px 0 !important;
    }

    table.holdings-table tr.ticker-group-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: var(--bg-card) !important;
        border: 1px solid var(--border-card) !important;
        border-radius: 12px !important;
        padding: 10px 12px !important;
        position: relative !important;
        cursor: pointer !important;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.15) !important;
        padding-right: 28px !important;
    }

    /* Expand indicator */
    table.holdings-table tr.ticker-group-row::after {
        content: "▼" !important;
        position: absolute !important;
        top: 22px !important; /* Anchor to the first line's vertical center */
        right: 12px !important;
        transform: translateY(-50%) !important;
        font-size: 0.7rem !important;
        color: var(--text-secondary, #94a3b8) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        pointer-events: none !important;
    }

    table.holdings-table tr.ticker-group-row.expanded::after {
        transform: translateY(-50%) rotate(180deg) !important;
    }

    table.holdings-table tr.ticker-group-row:hover {
        background: rgba(var(--primary-rgb), 0.08) !important;
        border-color: var(--primary) !important;
    }

    /* Hide default expandable chevron inside td cell on mobile since card has its own */
    table.holdings-table tr.ticker-group-row td:nth-child(1) .ticker-expand-chevron {
        display: none !important;
    }

    /* Visual merging of expanded parent card and child rows */
    table.holdings-table tr.ticker-group-row.expanded {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }

    /* Nested child card rows */
    table.holdings-table tr.ticker-child-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: rgba(var(--primary-rgb), 0.03) !important;
        background-color: var(--bg-card) !important;
        border-left: 1px solid var(--border-card) !important;
        border-right: 1px solid var(--border-card) !important;
        border-top: none !important;
        border-bottom: none !important;
        border-radius: 0 !important;
        margin-top: -10px !important; /* cancel flex gap */
        box-shadow: none !important;
        padding: 8px 12px 8px 24px !important; /* Indent left side slightly for tree view */
        position: relative !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-top: 1px solid rgba(var(--primary-rgb), 0.08) !important;
        padding-right: 28px !important; /* Make room for the expand chevron */
    }

    /* Expand indicator for child rows */
    table.holdings-table tr.ticker-child-row::after {
        content: "▼" !important;
        position: absolute !important;
        top: 20px !important; /* Anchor to the first line's vertical center */
        right: 12px !important;
        transform: translateY(-50%) !important;
        font-size: 0.62rem !important;
        color: var(--text-secondary, #94a3b8) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        pointer-events: none !important;
    }

    table.holdings-table tr.ticker-child-row.expanded::after {
        transform: translateY(-50%) rotate(180deg) !important;
    }

    table.holdings-table tr.ticker-child-row.last-child-row {
        border-bottom: 1px solid var(--border-card) !important;
        border-bottom-left-radius: 12px !important;
        border-bottom-right-radius: 12px !important;
        box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.15) !important;
        margin-bottom: 10px !important; /* spacing to next card */
    }

    /* Hide logo on child rows on mobile to reduce clutter */
    table.holdings-table tr.ticker-child-row td:nth-child(1) .holding-logo {
        display: none !important;
    }

    /* Style cells */
    table.holdings-table td {
        display: none !important; /* Hide details by default */
        padding: 6px 0 !important;
        border: none !important;
        width: 100% !important;
        background: transparent !important;
        box-sizing: border-box !important;
        font-size: 0.88rem !important;
        color: var(--text-primary) !important;
    }

    /* Make sure child row cells display side by side */
    table.holdings-table tr.ticker-child-row td:nth-child(1),
    table.holdings-table tr.ticker-child-row td:nth-child(5) {
        display: flex !important;
        background: transparent !important;
        border: none !important;
        padding: 4px 0 !important;
        width: auto !important;
    }
    table.holdings-table tr.ticker-child-row td:nth-child(7) {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: auto !important;
        padding: 4px 0 !important;
    }

    /* Style the sub-labels (Stock Holding, Crypto Asset) as premium badges */
    .holding-name {
        font-size: 0.72rem !important;
        font-weight: 600 !important;
        background: rgba(var(--primary-rgb), 0.08) !important;
        color: var(--text-secondary) !important;
        padding: 2px 8px !important;
        border-radius: 6px !important;
        border: 1px solid rgba(var(--primary-rgb), 0.1) !important;
        margin-top: 6px !important;
        display: inline-block !important;
        width: fit-content !important;
    }

    /* Keep first column layout vertical so name stays directly under ticker */
    #holdings-table-body tr td:nth-child(1),
    #options-table-body tr td:nth-child(1),
    #watchlist-table-body tr td:nth-child(1) {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding-right: 12px !important;
        order: 1 !important;
        padding-bottom: 0 !important;
        width: auto !important;
    }

    /* Display main value/price cells on card */
    #holdings-table-body tr td:nth-child(5) {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        order: 2 !important;
        font-weight: 700 !important;
        font-size: 1.05rem !important;
        color: var(--text-primary) !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.1) !important;
        padding-bottom: 6px !important;
        margin-bottom: 2px !important;
    }

    #holdings-table-body tr td:nth-child(5)::before {
        content: "Current Value" !important;
        font-size: 0.76rem !important;
        font-weight: 600 !important;
        color: var(--text-secondary, #94a3b8) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    #options-table-body tr td:nth-child(7) {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        order: 2 !important;
        font-weight: 700 !important;
        font-size: 1.05rem !important;
        color: var(--text-primary) !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.1) !important;
        padding-bottom: 6px !important;
        margin-bottom: 2px !important;
    }

    #options-table-body tr td:nth-child(7)::before {
        content: "Current Value" !important;
        font-size: 0.76rem !important;
        font-weight: 600 !important;
        color: var(--text-secondary, #94a3b8) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    #watchlist-table-body tr td:nth-child(3) {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        order: 2 !important;
        font-weight: 700 !important;
        font-size: 1.05rem !important;
        color: var(--text-primary) !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.1) !important;
        padding-bottom: 6px !important;
        margin-bottom: 2px !important;
    }

    #watchlist-table-body tr td:nth-child(3)::before {
        content: "Last Price" !important;
        font-size: 0.76rem !important;
        font-weight: 600 !important;
        color: var(--text-secondary, #94a3b8) !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    /* Removed old summary table headers */

    /* Removed old stock ledger amount rules */

    /* Removed old option ledger expiration date rules */

    /* Removed old cash flows rules */

    /* Keep monthly tracking tables full-width and uncollapsed */
    #trading-monthly-stock-matrix-table td,
    #trading-monthly-option-matrix-table td {
        display: table-cell !important;
        text-align: left !important;
    }

    #trading-monthly-stock-matrix-table tr td[colspan],
    #trading-monthly-option-matrix-table tr td[colspan] {
        display: table-cell !important;
        text-align: center !important;
        padding: 24px 16px !important;
    }

    /* Placeholder or single-cell empty columns */
    table.holdings-table tr td[colspan] {
        display: block !important;
        text-align: center !important;
        padding: 32px 16px !important;
    }

    /* Show other details when row is expanded */
    table.holdings-table tr.expanded td:not(:nth-child(1)):not(:nth-child(5)):not(:nth-child(7)):not(:nth-child(3)) {
        display: flex !important;
        order: 3 !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.08) !important;
        animation: fadeInMobileRow 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
        width: 100% !important;
        padding: 8px 0 !important;
    }

    table.holdings-table tr.expanded td:last-child {
        border-bottom: none !important;
    }

    /* Hide the column label when row is collapsed (not expanded) or for child rows */
    table.holdings-table tr:not(.expanded) td::before,
    table.holdings-table tr.ticker-child-row td::before {
        display: none !important;
    }

    /* Display main value/price cells side by side when not expanded */
    #holdings-table-body tr.ticker-group-row:not(.expanded) td:nth-child(5),
    #options-table-body tr.ticker-group-row:not(.expanded) td:nth-child(7),
    #watchlist-table-body tr.ticker-group-row:not(.expanded) td:nth-child(3) {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        order: 2 !important;
        font-weight: 700 !important;
        font-size: 1.05rem !important;
        color: var(--text-primary) !important;
        border-bottom: none !important;
        padding: 0 !important;
        margin: 0 !important;
        width: auto !important;
    }

    /* Display Edit/Delete buttons side by side next to the value */
    #holdings-table-body tr td:nth-child(7),
    #options-table-body tr td:nth-child(9),
    #watchlist-table-body tr td:nth-child(8) {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        order: 2 !important;
        width: auto !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    /* Add Row Attribute Titles on Mobile */
    /* Holdings Table Details */
    #holdings-table-body tr.expanded td:nth-child(2)::before { content: "Portfolio" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #holdings-table-body tr.expanded td:nth-child(3)::before { content: "Shares" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #holdings-table-body tr.expanded td:nth-child(4)::before { content: "Avg Price" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #holdings-table-body tr.expanded td:nth-child(6)::before { content: "Gain / Loss" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #holdings-table-body tr.expanded td:nth-child(7)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }

    /* Options Table Details */
    #options-table-body tr.expanded td:nth-child(2)::before { content: "Underlying" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(3)::before { content: "Portfolio" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(4)::before { content: "Contracts" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(5)::before { content: "Strike Price" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(6)::before { content: "Premium" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(8)::before { content: "Gain / Loss" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #options-table-body tr.expanded td:nth-child(9)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }

    /* Watchlist Table Details */
    #watchlist-table-body tr.expanded td:nth-child(2)::before { content: "Last Price" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #watchlist-table-body tr.expanded td:nth-child(4)::before { content: "Day Change" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #watchlist-table-body tr.expanded td:nth-child(5)::before { content: "Cost Basis" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #watchlist-table-body tr.expanded td:nth-child(6)::before { content: "Total Value" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #watchlist-table-body tr.expanded td:nth-child(7)::before { content: "Total Gain" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }
    #watchlist-table-body tr.expanded td:nth-child(8)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary, #94a3b8) !important; }

    /* Removed old summary expanded labels */
    /* Removed old stock ledger labels */
    /* Removed old options ledger labels */
    /* Removed old cash flows labels */

    /* Remove standard cell alignments */
    table.holdings-table td {
        text-align: right !important;
    }

    /* Hide the actions cell (which has "click to expand" text) on group rows on mobile */
    table.holdings-table tr.ticker-group-row td:nth-child(7) {
        display: none !important;
    }

    /* Expandable Card Layout for Trading Subview Tables on Mobile */
    #trading-cash-tbody tr:not(.skeleton-row),
    #trading-options-tbody tr:not(.skeleton-row),
    #trading-stocks-tbody tr:not(.skeleton-row),
    #trading-summary-open-stocks-tbody tr:not(.skeleton-row),
    #trading-summary-options-tbody tr:not(.skeleton-row),
    #trading-monthly-income-loss-summary-body tr:not(.skeleton-row) {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: var(--bg-card) !important;
        border: 1px solid var(--border-card) !important;
        border-radius: 12px !important;
        padding: 10px 12px !important;
        position: relative !important;
        cursor: pointer !important;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
        box-sizing: border-box !important;
        width: 100% !important;
        box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.15) !important;
        padding-right: 28px !important;
        margin-bottom: 10px !important;
    }

    #trading-cash-tbody tr:not(.skeleton-row)::after,
    #trading-options-tbody tr:not(.skeleton-row)::after,
    #trading-stocks-tbody tr:not(.skeleton-row)::after,
    #trading-summary-open-stocks-tbody tr:not(.skeleton-row)::after,
    #trading-summary-options-tbody tr:not(.skeleton-row)::after,
    #trading-monthly-income-loss-summary-body tr:not(.skeleton-row)::after {
        content: "▼" !important;
        position: absolute !important;
        top: 22px !important; /* Anchor to the first line's vertical center */
        right: 12px !important;
        transform: translateY(-50%) !important;
        font-size: 0.7rem !important;
        color: var(--text-secondary, #94a3b8) !important;
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    }

    #trading-cash-tbody tr.expanded::after,
    #trading-options-tbody tr.expanded::after,
    #trading-stocks-tbody tr.expanded::after,
    #trading-summary-open-stocks-tbody tr.expanded::after,
    #trading-summary-options-tbody tr.expanded::after,
    #trading-monthly-income-loss-summary-body tr.expanded::after {
        transform: translateY(-50%) rotate(180deg) !important;
    }

    #trading-cash-tbody tr td,
    #trading-options-tbody tr td,
    #trading-stocks-tbody tr td,
    #trading-summary-open-stocks-tbody tr td,
    #trading-summary-options-tbody tr td,
    #trading-monthly-income-loss-summary-body tr td {
        display: none !important; /* Hide other columns by default */
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* Key Header Cells displayed in collapsed state (left side) */
    #trading-cash-tbody tr td:nth-child(3),
    #trading-options-tbody tr td:nth-child(3),
    #trading-stocks-tbody tr td:nth-child(3),
    #trading-summary-open-stocks-tbody tr td:nth-child(2),
    #trading-summary-options-tbody tr td:nth-child(2),
    #trading-monthly-income-loss-summary-body tr td:nth-child(1) {
        display: flex !important;
        order: 1 !important;
        align-items: center !important;
        width: auto !important;
        font-weight: 600 !important;
        color: var(--text-primary) !important;
    }

    /* Key Header Cells displayed in collapsed state (right side) */
    #trading-cash-tbody tr td:nth-child(4),
    #trading-options-tbody tr td:nth-child(9),
    #trading-stocks-tbody tr td:nth-child(8),
    #trading-summary-open-stocks-tbody tr td:nth-child(9),
    #trading-summary-options-tbody tr td:nth-child(7),
    #trading-monthly-income-loss-summary-body tr td:nth-child(4) {
        display: flex !important;
        order: 2 !important;
        align-items: center !important;
        justify-content: flex-end !important;
        width: auto !important;
        font-weight: 700 !important;
        font-size: 1.05rem !important;
    }

    /* Expanded display rules */
    #trading-cash-tbody tr.expanded td:nth-child(1),
    #trading-cash-tbody tr.expanded td:nth-child(2),
    #trading-cash-tbody tr.expanded td:nth-child(5),
    #trading-cash-tbody tr.expanded td:nth-child(6),
    
    #trading-options-tbody tr.expanded td:nth-child(1),
    #trading-options-tbody tr.expanded td:nth-child(2),
    #trading-options-tbody tr.expanded td:nth-child(4),
    #trading-options-tbody tr.expanded td:nth-child(5),
    #trading-options-tbody tr.expanded td:nth-child(6),
    #trading-options-tbody tr.expanded td:nth-child(7),
    #trading-options-tbody tr.expanded td:nth-child(8),
    #trading-options-tbody tr.expanded td:nth-child(10),
    #trading-options-tbody tr.expanded td:nth-child(11),
    #trading-options-tbody tr.expanded td:nth-child(12),
    #trading-options-tbody tr.expanded td:nth-child(13),
    #trading-options-tbody tr.expanded td:nth-child(14),
    #trading-options-tbody tr.expanded td:nth-child(15),
    #trading-options-tbody tr.expanded td:nth-child(16),
    
    #trading-stocks-tbody tr.expanded td:nth-child(1),
    #trading-stocks-tbody tr.expanded td:nth-child(2),
    #trading-stocks-tbody tr.expanded td:nth-child(4),
    #trading-stocks-tbody tr.expanded td:nth-child(5),
    #trading-stocks-tbody tr.expanded td:nth-child(6),
    #trading-stocks-tbody tr.expanded td:nth-child(7),
    #trading-stocks-tbody tr.expanded td:nth-child(9),
    #trading-stocks-tbody tr.expanded td:nth-child(10),
    
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(1),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(3),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(4),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(5),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(6),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(7),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(8),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(10),
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(11),
    
    #trading-summary-options-tbody tr.expanded td:nth-child(1),
    #trading-summary-options-tbody tr.expanded td:nth-child(3),
    #trading-summary-options-tbody tr.expanded td:nth-child(4),
    #trading-summary-options-tbody tr.expanded td:nth-child(5),
    #trading-summary-options-tbody tr.expanded td:nth-child(6),
    
    #trading-monthly-income-loss-summary-body tr.expanded td:nth-child(2),
    #trading-monthly-income-loss-summary-body tr.expanded td:nth-child(3) {
        display: flex !important;
        order: 3 !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.08) !important;
        width: 100% !important;
        padding: 8px 0 !important;
        background: transparent !important;
    }

    #trading-cash-tbody tr.expanded td::before,
    #trading-options-tbody tr.expanded td::before,
    #trading-stocks-tbody tr.expanded td::before,
    #trading-summary-open-stocks-tbody tr.expanded td::before,
    #trading-summary-options-tbody tr.expanded td::before,
    #trading-monthly-income-loss-summary-body tr.expanded td::before {
        display: flex !important;
    }

    /* Row Attribute Titles on Mobile for Trading Subview */
    /* Cash Flows */
    #trading-cash-tbody tr.expanded td:nth-child(1)::before { content: "No." !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-cash-tbody tr.expanded td:nth-child(2)::before { content: "Date" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-cash-tbody tr.expanded td:nth-child(5)::before { content: "Brokerage" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-cash-tbody tr.expanded td:nth-child(6)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Stock Trades Ledger */
    #trading-stocks-tbody tr.expanded td:nth-child(1)::before { content: "No." !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(2)::before { content: "Date" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(4)::before { content: "Current Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(5)::before { content: "Type" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(6)::before { content: "Shares" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(7)::before { content: "Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(9)::before { content: "Realized P/L" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-stocks-tbody tr.expanded td:nth-child(10)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Option Trades Ledger */
    #trading-options-tbody tr.expanded td:nth-child(1)::before { content: "No." !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(2)::before { content: "Date" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(4)::before { content: "Stock Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(5)::before { content: "Action" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(6)::before { content: "Option Type" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(7)::before { content: "Contracts" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(8)::before { content: "Strike Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(10)::before { content: "Premium/Share" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(11)::before { content: "Total Premium" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(12)::before { content: "Close Date" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(13)::before { content: "Close Premium" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(14)::before { content: "Net Profit/Loss" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(15)::before { content: "Status" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-options-tbody tr.expanded td:nth-child(16)::before { content: "Actions" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Open Stock Positions */
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(1)::before { content: "No." !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(3)::before { content: "Total Shares" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(4)::before { content: "Average Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(5)::before { content: "Current Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(6)::before { content: "Total Cost" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(7)::before { content: "Current Value" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(8)::before { content: "Total Profit" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(10)::before { content: "Return %" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-open-stocks-tbody tr.expanded td:nth-child(11)::before { content: "Avg Price After Prem" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Open Options Positions */
    #trading-summary-options-tbody tr.expanded td:nth-child(1)::before { content: "No." !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-options-tbody tr.expanded td:nth-child(3)::before { content: "Action" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-options-tbody tr.expanded td:nth-child(4)::before { content: "Type" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-options-tbody tr.expanded td:nth-child(5)::before { content: "Strike Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-summary-options-tbody tr.expanded td:nth-child(6)::before { content: "Current Price" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Monthly Income / Loss Summary */
    #trading-monthly-income-loss-summary-body tr.expanded td:nth-child(2)::before { content: "Options Income/Loss" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }
    #trading-monthly-income-loss-summary-body tr.expanded td:nth-child(3)::before { content: "Stocks Income/Loss" !important; font-weight: 600 !important; color: var(--text-secondary) !important; }

    /* Realized Stocks & Options Layout: Single Row with Ticker and Profit/Loss Side by Side */
    #trading-realized-stock-ticker-body tr,
    #trading-realized-option-ticker-body tr {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.08) !important;
        border-radius: 0 !important;
        padding: 8px 4px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        box-shadow: none !important;
        margin-bottom: 0 !important;
    }

    #trading-realized-stock-ticker-body tr:last-child,
    #trading-realized-option-ticker-body tr:last-child {
        border-bottom: none !important;
    }

    #trading-realized-stock-ticker-body tr td,
    #trading-realized-option-ticker-body tr td {
        display: none !important;
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    #trading-realized-stock-ticker-body tr td[colspan],
    #trading-realized-option-ticker-body tr td[colspan] {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 24px !important;
    }

    #trading-realized-stock-ticker-body tr td:nth-child(1),
    #trading-realized-option-ticker-body tr td:nth-child(1) {
        display: flex !important;
        order: 1 !important;
        align-items: center !important;
        width: auto !important;
        font-weight: 600 !important;
        color: var(--text-primary) !important;
    }

    #trading-realized-stock-ticker-body tr td:nth-child(2),
    #trading-realized-option-ticker-body tr td:nth-child(2) {
        display: flex !important;
        order: 2 !important;
        align-items: center !important;
        justify-content: flex-end !important;
        width: auto !important;
        font-size: 0.95rem !important;
    }

    #trading-realized-stock-ticker-body tr td::before,
    #trading-realized-option-ticker-body tr td::before {
        display: none !important;
    }

    /* Style the table headers for compact single-row trading tables */
    table.trading-open-stocks-table thead,
    table.trading-open-options-table thead,
    table.trading-stock-tx-table thead,
    table.trading-option-tx-table thead,
    table.trading-cash-table thead,
    table.trading-monthly-summary-table thead,
    table.trading-realized-stocks-table thead,
    table.trading-realized-options-table thead {
        display: flex !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 4px !important;
        border-bottom: 1px solid rgba(var(--primary-rgb), 0.15) !important; /* Continuous row border matching desktop exactly */
        padding-bottom: 0 !important;
    }

    table.trading-open-stocks-table thead tr,
    table.trading-open-options-table thead tr,
    table.trading-stock-tx-table thead tr,
    table.trading-option-tx-table thead tr,
    table.trading-cash-table thead tr,
    table.trading-monthly-summary-table thead tr,
    table.trading-realized-stocks-table thead tr,
    table.trading-realized-options-table thead tr {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0 4px !important;
    }

    table.trading-open-stocks-table thead th,
    table.trading-open-options-table thead th,
    table.trading-stock-tx-table thead th,
    table.trading-option-tx-table thead th,
    table.trading-cash-table thead th,
    table.trading-monthly-summary-table thead th,
    table.trading-realized-stocks-table thead th,
    table.trading-realized-options-table thead th {
        display: none !important;
        border-bottom: none !important; /* Remove individual cell underlines */
        padding: 8px 0 !important;
    }

    /* Target specific header text elements to show on mobile */
    table.trading-open-stocks-table thead th:nth-child(2),
    table.trading-open-options-table thead th:nth-child(2),
    table.trading-stock-tx-table thead th:nth-child(3),
    table.trading-option-tx-table thead th:nth-child(3) {
        display: flex !important;
        order: 1 !important;
        text-align: left !important;
        font-size: 0.8rem !important; /* Matches desktop font size */
        text-transform: uppercase !important;
        color: var(--primary) !important; /* Matches desktop brand color */
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-monthly-summary-table thead th:nth-child(1),
    table.trading-realized-stocks-table thead th:nth-child(1),
    table.trading-realized-options-table thead th:nth-child(1) {
        display: flex !important;
        order: 1 !important;
        text-align: left !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-cash-table thead th:nth-child(3) {
        display: flex !important;
        order: 1 !important;
        text-align: left !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-open-stocks-table thead th:nth-child(9) {
        display: flex !important;
        order: 2 !important;
        text-align: right !important;
        justify-content: flex-end !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-open-options-table thead th:nth-child(7),
    table.trading-option-tx-table thead th:nth-child(9) {
        display: flex !important;
        order: 2 !important;
        text-align: right !important;
        justify-content: flex-end !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-stock-tx-table thead th:nth-child(9) {
        display: flex !important;
        order: 2 !important;
        text-align: right !important;
        justify-content: flex-end !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-cash-table thead th:nth-child(4) {
        display: flex !important;
        order: 2 !important;
        text-align: right !important;
        justify-content: flex-end !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }

    table.trading-monthly-summary-table thead th:nth-child(4),
    table.trading-realized-stocks-table thead th:nth-child(2),
    table.trading-realized-options-table thead th:nth-child(2) {
        display: flex !important;
        order: 2 !important;
        text-align: right !important;
        justify-content: flex-end !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        color: var(--primary) !important;
        font-weight: 700 !important;
        letter-spacing: 0.5px !important;
        border-bottom: none !important;
    }
}

@keyframes fadeInMobileRow {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
