.day-investor-section {
    overflow: hidden;
}

.day-investor-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

.day-investor-section .investor-flow-chart-section,
.day-investor-section .investor-chart-container {
    min-width: 0;
}

#spotInvestorChartContainer {
    padding: 0;
}

.day-investor-section .investor-chart-container canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
}

.day-investor-table-section {
    padding-bottom: 0;
    order: 1;
    grid-column: 1 / -1;
}

#spotInvestorFlowChartSection {
    order: 2;
    grid-column: 1;
}

#investorFlowChartSection {
    order: 3;
    grid-column: 2;
}

.investor-chart-legend--shared {
    order: 4;
    grid-column: 1 / -1;
}

.day-investor-table-section .card-header,
.day-investor-section .investor-flow-chart-section .card-header {
    min-height: 58px;
}

.investor-table-wrap {
    padding: 0.35rem 1.25rem 1.25rem;
}

.investor-table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.investor-table th,
.investor-table td {
    padding: 0.86rem 0.2rem;
    border-bottom: 1px solid var(--border-color);
}

.investor-table tr:last-child th,
.investor-table tr:last-child td {
    border-bottom: none;
}

.investor-table th {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.investor-table thead th {
    padding: 0.55rem 0.2rem 0.65rem;
    color: var(--text-muted);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.investor-table thead th:last-child {
    text-align: right;
}

.investor-table thead th:nth-child(2) {
    text-align: right;
}

.investor-table td {
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 800;
    text-align: right;
}

.investor-row-dot {
    display: inline-block;
    width: 0.56rem;
    height: 0.56rem;
    margin-right: 0.55rem;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
    flex-shrink: 0;
    vertical-align: -0.05rem;
}

.investor-row--individual th,
.legend-individual {
    color: #34d399;
}

.investor-row--foreign th,
.legend-foreign {
    color: #38bdf8;
}

.investor-row--investment th,
.legend-investment {
    color: #fbbf24;
}

.investor-row--trust th,
.legend-trust {
    color: #a78bfa;
}

.investor-row--bank th,
.legend-bank {
    color: #22c55e;
}

.investor-row--insurance th,
.legend-insurance {
    color: #fb7185;
}

.investor-row--pension th,
.legend-pension {
    color: #60a5fa;
}

.investor-row--pef th,
.legend-pef {
    color: #2dd4bf;
}

.investor-row--otherCorp th,
.legend-otherCorp {
    color: #f97316;
}

.investor-row--otherFinance th,
.legend-otherFinance {
    color: #e879f9;
}

.legend-trust,
.legend-bank,
.legend-insurance,
.legend-pension,
.legend-pef,
.legend-otherFinance,
.legend-otherCorp {
    background: currentColor;
}

.day-investor-section .investor-flow-chart-section {
    border-left: 0;
}

#investorFlowChartSection {
    border-left: 1px solid var(--border-color);
}

.day-investor-section .investor-chart-container {
    height: 320px;
}

.day-investor-section .investor-chart-legend {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.75rem;
    padding: 0 1.25rem 1rem;
    row-gap: 0.45rem;
}

.day-investor-section .investor-legend-toggle {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.18s ease, color 0.18s ease;
}

.day-investor-section .investor-legend-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.day-investor-section .investor-legend-toggle.is-hidden {
    opacity: 0.45;
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.day-investor-section .investor-legend-toggle.is-hidden .legend-dot {
    opacity: 0.35;
}

@media (max-width: 768px) {
    .day-investor-layout {
        grid-template-columns: 1fr;
    }

    #spotInvestorFlowChartSection,
    #investorFlowChartSection,
    .investor-chart-legend--shared {
        grid-column: 1;
    }

    #investorFlowChartSection {
        border-left: 0;
    }

    .investor-table-wrap {
        padding: 0.15rem 0.75rem 0.95rem;
    }

    .investor-table {
        display: block;
        table-layout: auto;
    }

    .investor-table thead,
    .investor-table tbody {
        display: block;
        width: 100%;
    }

    .investor-table tr {
        display: grid;
        grid-template-columns: minmax(4rem, 1fr) minmax(5.2rem, 0.8fr) minmax(6.2rem, 0.9fr);
        align-items: center;
        width: 100%;
        border-bottom: 1px solid var(--border-color);
    }

    .investor-table th,
    .investor-table td {
        display: block;
        min-width: 0;
        padding: 0.6rem 0.1rem;
        border-bottom: 0;
    }

    .investor-table tr:last-child {
        border-bottom: none;
    }

    .investor-table th {
        font-size: 0.72rem;
    }

    .investor-table thead th {
        font-size: 0.62rem;
        letter-spacing: 0.02em;
    }

    .investor-table thead th:last-child {
        white-space: normal;
        line-height: 1.25;
    }

    .investor-table td {
        font-size: 0.9rem;
        text-align: right;
        white-space: nowrap;
        overflow: visible;
    }

    .investor-row-dot {
        width: 0.45rem;
        height: 0.45rem;
        margin-right: 0.38rem;
        box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 18%, transparent);
    }

    .day-investor-section .investor-chart-container {
        height: 270px;
    }

    .day-investor-section .investor-chart-legend {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 0.35rem 0.5rem;
        padding-right: 0.75rem;
        padding-left: 0.75rem;
        line-height: 1.4;
    }

    .day-investor-section .investor-chart-legend span {
        min-width: 0;
        font-size: 0.66rem;
        white-space: normal;
    }

    .day-investor-section .investor-chart-legend > span {
        flex: 0 1 auto;
        max-width: 100%;
    }
}

@media (max-width: 430px) {
    .day-investor-section .investor-chart-legend {
        gap: 0.32rem 0.4rem;
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }
}

@media (max-width: 360px) {
    .investor-table tr {
        grid-template-columns: minmax(3.8rem, 1fr) minmax(4.6rem, 0.7fr) minmax(5.5rem, 0.8fr);
    }

    .investor-table th {
        font-size: 0.68rem;
    }

    .investor-table td {
        font-size: 0.84rem;
    }
}


.program-trade-section .card-header {
    min-height: 58px;
}

.program-trade-status {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.program-trade-metric {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    padding: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
}

.program-trade-metric > span {
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 600;
}

.program-trade-metric strong {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.program-trade-metric strong.up { color: #2fba84; }
.program-trade-metric strong.down { color: #ef5967; }

.program-trade-chart {
    flex: 1;
    min-height: 270px;
    position: relative;
    background: var(--chart-bg);
}

.program-trade-chart canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.program-trade-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.68rem;
    border-top: 1px solid var(--border-color);
}

.program-trade-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.program-trade-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
}

.program-trade-dot--net { background: #38bdf8; }
.program-trade-dot--arb { background: #fbbf24; }
.program-trade-dot--non-arb { background: #e879f9; }

@media (max-width: 560px) {
    .program-trade-status { gap: 0.3rem; padding: 0.6rem; }
    .program-trade-metric { padding: 0.55rem 0.4rem; }
    .program-trade-metric strong { font-size: 0.85rem; }
}

@media (max-width: 768px) {
    main > .bottom-grid { display: contents; }
    main > .bottom-grid > .program-trade-section { order: 1; }
    main > .bottom-grid > .combined-section { order: 2; }
}

@media (min-width: 769px) {
    .bottom-grid { align-items: start; }
    .program-trade-section { min-height: 0; }
    .program-trade-chart { flex: 1 1 0; min-height: 0; overflow: hidden; }
    .program-trade-chart canvas { position: absolute; inset: 0; }
}

.trade-info-section.has-spot-metrics .trade-info-grid {
    grid-template-columns: 1.5fr 0.8fr 0.9fr 1.15fr 1.3fr 1.3fr;
}

.spot-index-values {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.spot-change {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: var(--font-mono);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .trade-info-section.has-spot-metrics .trade-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
