.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    /* Remove top-left roundness so the tab sits flush */
    border-radius: 0 12px 12px 12px;
    position: relative;
    z-index: 1;
    max-width: 100%;
    overflow: hidden;
    /* Ensures rows don't bleed past rounded corners */
}
thead tr {
    border-left: 4px solid var(--table-header);
}
table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    /* Required for the 1% width column trick */
}

/* --- 3. HEADERS & ROWS --- */
th {
    background: var(--table-header);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--table-header);
    color: var(--text-secondary);
    padding: 12px 15px;
    text-align: left;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.main-row {
    cursor: pointer;
    border-left: 4px solid transparent;
    /* Placeholder for sector colors */
    transition: background-color 0.2s ease;
}
.main-row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Sector Border Colors */
.row-tech {
    border-left-color: var(--tech-color);
}
.row-comm {
    border-left-color: var(--comm-color);
}
.row-cons {
    border-left-color: var(--cons-color);
}
.row-fin {
    border-left-color: var(--fin-color);
}
.row-inv {
    border-left-color: var(--inv-color);
}

/* --- 4. COLUMN 1: ENTITY (FLEXIBLE) --- */
.company-cell {
    padding: 5px 15px;
    width: 100%;
    max-width: 0;
    /* Forces cell to respect table width for ellipsis */
    overflow: hidden;
}

.identity-container {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.name-stack {
    display: flex;
    flex-direction: row;
    gap: 8px;
    min-width: 0;
}

.name-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
}

.rank-prefix {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.company-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    text-overflow: ellipsis;
    overflow: hidden;
    flex: 1;
}

.metadata-line {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.separator {
    opacity: 0.3;
}

/* --- 5. COLUMN 2: INFLOWS (DISAPPEARING) --- */
.inflow-cell {
    text-align: right;
    width: 1%;
    white-space: nowrap;
    padding: 5px 15px;
}
/* --- Column Specific Logic --- */
.inflow-cell {
    text-align: right;
    width: 1%;
    white-space: nowrap;
    padding: 5px 15px;
    font-family: ui-monospace, monospace;
    font-weight: 600;
    font-size: 0.8rem;
}

/* --- Responsive "Step-Down" Logic --- */

/* 1. At 900px: The table is getting tight, hide the 1D column */
@media (max-width: 900px) {
    td.col-1d,
    th.col-1d {
        display: none;
    }
    .name-stack {
        flex-direction: column;
        gap: 0;
    }
}

/* 2. At 700px: Hide the 1M column as well */
@media (max-width: 700px) {
    td.col-1m,
    th.col-1m {
        display: none;
    }

    /* Give the extra space back to the company name */
    .company-cell {
        padding: 5px 10px;
    }
}

/* 3. At 480px: Standard phone optimizations */
@media (max-width: 480px) {
    .usd-valuation {
        align-items: flex-end;
    }
}
.inflow-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: ui-monospace, 'Roboto Mono', monospace;
    font-weight: 600;
}

.primary-inflow {
    font-size: 0.8rem;
}
.secondary-inflow {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 1px;
}

.neutral-zero {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* --- 6. COLUMN 3: HOLDINGS (HUGGING) --- */
.holdings-cell {
    text-align: right;
    width: 1%;
    white-space: nowrap;
    padding: 5px 15px;
}

.holdings-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.ltc-amount {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-color);
}

.usd-valuation {
    font-size: 0.75rem;
    color: var(--accent-euro);
    display: flex;
    align-items: center;
    gap: 4px;
}

.percentage-label {
    font-size: 0.65rem;
    opacity: 0.8;
    color: var(--text-secondary);
}

/* --- 7. RANK CHANGE PILLS --- */
.rank-chg-pill {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.rank-up {
    color: #2e7d32;
    background: rgba(46, 125, 50, 0.1);
}
.rank-down {
    color: #d32f2f;
    background: rgba(211, 47, 47, 0.1);
}

/* --- 8. MOBILE RESPONSIVENESS --- */

/* Tablet & Smaller: Hide Inflows */
@media (max-width: 768px) {
    /* Targets the 2nd header (Inflows) and the inflow cells */
    .inflow-cell,
    th:nth-child(2) {
        display: none;
    }

    .company-cell,
    .holdings-cell {
        padding: 5px 10px;
    }
}

/* Phones: Extreme Space Saving */
@media (max-width: 480px) {
    .company-name {
        font-size: 0.85rem;
        /* Smaller name */
    }

    .usd-valuation {
        align-items: flex-end;
    }

    .rank-prefix {
        font-size: 0.7rem;
    }
}
/* This is the invisible layer that covers the row */
.row-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10; /* Sits above the row but below the text if needed */
    border-bottom: 0px;
}

.row-link:hover {
    border-bottom: 0px;
}
/* Ensure child elements don't block the click, or stay above it */
.identity-container, .holdings-stack, .inflow-value {
    position: relative;
    z-index: 11;
    pointer-events: none; /* Clicks pass through to the .row-link underneath */
}
/* --- Base Row Style --- */
.main-row {
    position: relative; /* Anchor for the link */
}

/* --- Unified Hover Effect --- */
.main-row:hover {
    /* 1. Background Change */
    background-color: var(--table-header); 
    
}

/* 4. Text and Font effects on hover */
.main-row:hover .company-name {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
}
