@media (max-width: 768px) {

    /* --- FILTERS CONTAINER (2 Rows) --- */
    .filters-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        background: transparent !important;
        /* Let body bg show, or match screenshot if it had a container bg. Screenshot looks transparent/dark. */
        padding: 0 0 16px 0 !important;
        /* Remove padding if container shouldn't be a card */
        margin-bottom: 0px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Wrapper if we want the card look from screenshot, usually inputs are on the dark bg directly. 
       Let's stick to the element styling. */

    /* --- ROW 1: SEARCH + CLEAR --- */
    .search-row {
        display: flex;
        gap: 8px;
        width: 100%;
    }

    /* INPUTS & SELECTS COMMON STYLE */
    #search-input,
    .filter-row select,
    .filter-row #ticker-filter-dropdown button,
    #clear-filters {
        background-color: #111827 !important;
        /* Dark background matching screenshot (very dark blue/gray) */
        color: #ffffff !important;
        border: 1px solid #374151 !important;
        /* Subtle border */
        border-radius: 8px !important;
        /* Rounded corners */
        font-size: 14px !important;
        box-shadow: none !important;
        outline: none !important;
    }

    #search-input::placeholder {
        color: #9ca3af !important;
        /* Lighter gray for placeholder */
    }

    /* SPECIFIC INPUT SIZING */
    #search-input {
        flex: 1;
        min-width: 0;
        width: 100%;
        margin-bottom: 0 !important;
        height: 42px !important;
        padding: 0 12px !important;
    }

    /* CLEAR BUTTON */
    #clear-filters {
        flex: 0 0 42px;
        /* Square */
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 42px !important;
    }

    /* --- ROW 2: FILTERS --- */
    .filter-row {
        display: flex;
        gap: 8px;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .filter-row>* {
        flex: 1 1 0px;
        min-width: 0;
    }

    /* DROPDOWN SIZING */
    .filter-row select,
    .filter-row #ticker-filter-dropdown {
        width: 100% !important;
        margin: 0 !important;
    }

    .filter-row select,
    .filter-row #ticker-filter-dropdown button,
    .filter-row #ticker-filter-dropdown #filter-toggle {
        height: 42px !important;
        padding: 0 30px 0 12px !important;
        /* Right padding for arrow */
        appearance: none !important;
        /* Remove default arrow */
        -webkit-appearance: none !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 8px center !important;
        background-size: 16px !important;
        background-color: #111827 !important;
        /* Force Dark Background */
        color: white !important;
        border: 1px solid #374151 !important;
        border-radius: 8px !important;
    }

    /* Adjust ticker dropdown button specifically */
    .filter-row #ticker-filter-dropdown button,
    .filter-row #ticker-filter-dropdown #filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        white-space: nowrap;
        overflow: hidden;
        width: 100% !important;
        min-width: auto !important;
        font-size: 11px !important;
        padding: 8px 4px !important;
    }

    /* Ensure only 1 span shows text, hide default arrow text if any */
    .filter-row #ticker-filter-dropdown button span:last-child {
        display: none !important;
        /* Hide original arrow text if custom SVG is used */
    }

    /* --- TABLE MOBILE OPTIMIZATION --- */
    /* --- MOBILE DETAIL ROW (Refined) --- */
    /* --- MOBILE DETAIL ROW (Refined) --- */

    .mobile-detail-content {
        background-color: #1f2937;
        /* Dark Gray background */
        padding: 16px;
        border-bottom: 1px solid #374151;
        box-shadow: inset 0 4px 6px -1px rgba(0, 0, 0, 0.5);
        /* Inner shadow for depth */
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* FIX: Force display for detail row cell (overriding nth-child(1) hide) */
    #purchases-table tr.mobile-detail-row td {
        display: table-cell !important;
    }

    .detail-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .detail-item {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .detail-item.full-width {
        grid-column: 1 / -1;
    }

    .detail-item .label {
        font-size: 11px;
        color: #9ca3af;
        /* Muted text */
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .detail-item .value {
        font-size: 14px;
        color: #fff;
        font-weight: 500;
        white-space: normal;
        /* Allow wrapping */
    }

    .detail-actions {
        display: flex;
        gap: 12px;
        padding-top: 8px;
        border-top: 1px solid #374151;
    }

    .mobile-action-btn {
        flex: 1;
        height: 36px;
        border-radius: 8px;
        border: none;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: transform 0.1s;
    }

    .mobile-action-btn:active {
        transform: scale(0.98);
    }

    .mobile-action-btn.edit {
        background-color: #3b82f6;
        color: white;
    }

    .mobile-action-btn.delete {
        background-color: rgba(239, 68, 68, 0.15);
        color: #ef4444;
    }

    /* 
       Columns Mapping:
       1: Checkbox, 2: Asset, 3: Broker, 4: Date,  
       5: TICKER (Keep), 
       6: Name, 7: CCY, 8: Current, 
       9: QTY (Keep), 
       10: P&L, 11: %, 
       12: PRICE (Keep), 
       13: INVESTED (Keep), 
       14: Value, 15: Action 
    */

    #purchases-table th:nth-child(1),
    #purchases-table td:nth-child(1),
    /* Checkbox */
    #purchases-table th:nth-child(2),
    #purchases-table td:nth-child(2),
    /* Asset */
    /* Broker (3) is now visible */
    /* Date (4) is now visible */
    #purchases-table th:nth-child(6),
    #purchases-table td:nth-child(6),
    /* Name */
    #purchases-table th:nth-child(7),
    #purchases-table td:nth-child(7),
    /* CCY */
    #purchases-table th:nth-child(8),
    #purchases-table td:nth-child(8),
    /* Current */
    #purchases-table th:nth-child(10),
    #purchases-table td:nth-child(10),
    /* P&L */
    #purchases-table th:nth-child(11),
    #purchases-table td:nth-child(11),
    /* % */
    #purchases-table th:nth-child(14),
    #purchases-table td:nth-child(14),
    /* Value */
    #purchases-table th:nth-child(15),
    #purchases-table td:nth-child(15)

    /* Action */
        {
        display: none !important;
    }

    /* Adjust remaining columns padding/font for space */
    #purchases-table th,
    #purchases-table td {
        padding: 10px 4px !important;
        font-size: 11px !important;
        white-space: nowrap;
    }

    /* Right align numerical columns */
    #purchases-table th:nth-child(9),
    #purchases-table td:nth-child(9),
    /* Qty */
    #purchases-table th:nth-child(12),
    #purchases-table td:nth-child(12),
    /* Price */
    #purchases-table th:nth-child(13),
    #purchases-table td:nth-child(13)

    /* Invested */
        {
        text-align: right !important;
    }

    /* Ticker left align & narrower */
    #purchases-table th:nth-child(5),
    #purchases-table td:nth-child(5) {
        text-align: left !important;
        font-weight: bold;
        max-width: 50px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}