/* ==========================================================================
   COLOSIAN MARKETS — PORTFOLIO
   ========================================================================== */

.portfolio-page {
    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: grid;

    grid-template-rows:
        auto minmax(0, 1fr);

    gap: 0.75rem;

    overflow: hidden;
}

/* ==========================================================================
   PORTFOLIO STATS
   ========================================================================== */

.portfolio-stats-grid {
    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    flex: 0 0 auto;

    margin: 0;
}

.stat-card__value {
    margin: 0;

    font-size: 1.6rem;
    line-height: 1.1;

    letter-spacing: -0.03em;

    font-weight: 600;

    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   PORTFOLIO HOLDINGS CARD
   ========================================================================== */

.portfolio-page .market-table-card {
    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: grid;

    grid-template-rows:
        auto minmax(0, 1fr);

    overflow: hidden;
}

/* ==========================================================================
   HOLDINGS CARD HEADER
   ========================================================================== */

.portfolio-page .market-table-card__header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 1rem;

    margin: 0;

    padding-bottom: 0.65rem;

    flex: 0 0 auto;

    background: transparent;
}

.portfolio-page .market-table-card__title {
    margin: 0;

    font-size: 0.96rem;

    font-weight: 650;

    letter-spacing: -0.02em;
}

.portfolio-page .market-table-card__meta {
    margin: 0;

    color:
        var(--color-text-muted);

    font-size: 0.76rem;

    white-space: nowrap;
}

/* ==========================================================================
   PORTFOLIO TABLE SCROLL REGION

   Only portfolio rows scroll.
   ========================================================================== */

.portfolio-page .market-table-wrap {
    position: relative;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    overflow: auto;

    overscroll-behavior: contain;

    scrollbar-width: thin;

    scrollbar-gutter: stable;
}

.portfolio-page .market-table-wrap::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.portfolio-page .market-table-wrap::-webkit-scrollbar-track {
    background:
        rgba(255, 255, 255, 0.015);
}

.portfolio-page .market-table-wrap::-webkit-scrollbar-thumb {
    background:
        rgba(255, 255, 255, 0.12);

    border-radius: 999px;
}

/* ==========================================================================
   STICKY HOLDINGS COLUMN HEADERS
   ========================================================================== */

.portfolio-page .portfolio-table {
    width: 100%;

    border-collapse: separate;
    border-spacing: 0;
}

.portfolio-page .portfolio-table thead {
    position: relative;

    z-index: 5;
}

.portfolio-page .portfolio-table th {
    position: sticky;

    top: 0;

    z-index: 6;

    background:
        #1b1d1f;

    border-top:
        1px solid rgba(255, 255, 255, 0.025);

    border-bottom:
        1px solid rgba(255, 255, 255, 0.065);

    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   PORTFOLIO ASSET
   ========================================================================== */

.portfolio-asset {
    display: grid;

    gap: 0.18rem;
}

.portfolio-asset__name {
    font-weight: 600;

    letter-spacing: -0.01em;
}

.portfolio-asset__name-button {
    font-weight: 600;

    letter-spacing: -0.01em;
}

.portfolio-asset__symbol {
    color:
        var(--color-text-muted);

    font-size: 0.76rem;

    text-transform: uppercase;

    letter-spacing: 0.08em;
}

/* ==========================================================================
   PORTFOLIO ACTIONS
   ========================================================================== */

.portfolio-actions {
    display: inline-flex;

    gap: 0.4rem;
}

.portfolio-action {
    appearance: none;

    padding:
        0.42rem 0.68rem;

    border:
        1px solid rgba(255, 255, 255, 0.06);

    border-radius: 999px;

    background:
        rgba(255, 255, 255, 0.02);

    color:
        var(--color-text-soft);

    font-size: 0.72rem;
    font-weight: 600;

    letter-spacing: 0.02em;

    cursor: pointer;

    opacity: 1;

    transition:
        transform 160ms ease,
        border-color 160ms ease,
        background 160ms ease,
        color 160ms ease;
}

.portfolio-action:hover {
    transform:
        translateY(-1px);
}

.portfolio-action--buy {
    border-color:
        rgba(86, 168, 121, 0.22);

    background:
        rgba(39, 84, 56, 0.16);

    color:
        #b6f0cf;
}

.portfolio-action--buy:hover {
    border-color:
        rgba(86, 168, 121, 0.34);

    background:
        rgba(39, 84, 56, 0.24);

    color:
        #d2ffe4;
}

.portfolio-action--sell {
    border-color:
        rgba(190, 86, 86, 0.20);

    background:
        rgba(86, 39, 39, 0.14);

    color:
        #f2b9b9;
}

.portfolio-action--sell:hover {
    border-color:
        rgba(190, 86, 86, 0.34);

    background:
        rgba(86, 39, 39, 0.22);

    color:
        #ffd4d4;
}

/* ==========================================================================
   HOLDINGS TABLE ALIGNMENT
   ========================================================================== */

.portfolio-table th:nth-child(2),
.portfolio-table th:nth-child(3),
.portfolio-table th:nth-child(4),
.portfolio-table th:nth-child(5),
.portfolio-table th:nth-child(6),
.portfolio-table th:nth-child(7),
.portfolio-table th:nth-child(8),
.portfolio-table td:nth-child(2),
.portfolio-table td:nth-child(3),
.portfolio-table td:nth-child(4),
.portfolio-table td:nth-child(5),
.portfolio-table td:nth-child(6),
.portfolio-table td:nth-child(7),
.portfolio-table td:nth-child(8) {
    text-align: right;
}

.portfolio-table th:nth-child(9),
.portfolio-table td:nth-child(9) {
    text-align: center;
}

/* ==========================================================================
   RECENT TRADES TABLE ALIGNMENT
   ========================================================================== */

.portfolio-trades-table th:nth-child(4),
.portfolio-trades-table th:nth-child(5),
.portfolio-trades-table th:nth-child(6),
.portfolio-trades-table td:nth-child(4),
.portfolio-trades-table td:nth-child(5),
.portfolio-trades-table td:nth-child(6) {
    text-align: right;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1280px) {
    .portfolio-page {
        height: auto;

        overflow: visible;

        display: grid;

        grid-template-rows: auto auto;
    }

    .portfolio-stats-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .portfolio-page .market-table-card {
        height: auto;

        overflow: visible;
    }

    .portfolio-page .market-table-wrap {
        height: auto;

        max-height: none;

        overflow-x: auto;
        overflow-y: visible;
    }
}

@media (max-width: 980px) {
    .portfolio-stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .portfolio-actions {
        flex-direction: column;

        width: 100%;
    }

    .portfolio-page .market-table-card__header {
        flex-direction: column;

        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .portfolio-stats-grid {
        grid-template-columns: 1fr;
    }
}