/* Portfolio (logged-in) view — /portfolio-performance.
   Replaces the inline CSS that used to live in portfolio_performance.html. Scoped to #portfolio-ui (and,
   since Oct 25, 2026, #containers-ui: the Container Manager shares the sidebar, KPI, button and state classes);
   the logged-out marketing block keeps its own inline styles. One breakpoint, 768px, matching
   portfolio.js isMobile() and mobile-fix.css. Palette: the site's navy page/header, purple
   hairlines, gold accents; VT323 only for labels, Roboto with tabular numerals for data. */

#portfolio-ui, #containers-ui {
    --pf-surface: #121a26;
    --pf-surface-2: #182230;
    --pf-line: rgba(147, 112, 219, 0.22);
    --pf-line-strong: rgba(147, 112, 219, 0.45);
    --pf-gold: #FFD700;
    --pf-purple: #9370DB;
    --pf-text: #f1f1f1;
    --pf-muted: #8d95a3;
    --pf-radius: 12px;
    --pf-radius-sm: 8px;
    --pf-font-data: 'Roboto', sans-serif;
    --pf-font-label: 'Quantico', sans-serif;
    --pf-font-pixel: 'VT323', monospace;
    --pf-header-h: 64px;   /* the sticky site header the table head tucks under */
}

/* body is a flex column and .content has margin:auto, so it shrinks to fit; the grid needs the width */
.content { width: 100%; }

/* ---------- layout ---------- */
.pf-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; max-width: 1400px; margin: 0 auto; align-items: start; }
.pf-main { min-width: 0; }

/* ---------- sidebar ---------- */
.pf-sidebar { background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: var(--pf-radius); padding: 14px; position: sticky; top: calc(var(--pf-header-h) + 16px); }
.pf-sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pf-sidebar-title { display: flex; align-items: center; gap: 8px; font-family: var(--pf-font-pixel); font-size: 1.4rem; letter-spacing: .5px; text-transform: uppercase; color: var(--pf-gold); line-height: 1; }
.pf-sidebar-title img { height: 28px; width: auto; }
.pf-sidebar-manage { font-family: var(--pf-font-label); font-size: .76rem; font-weight: 600; color: var(--pf-purple); text-decoration: none; border: 1px solid var(--pf-line-strong); border-radius: 999px; padding: 4px 10px; white-space: nowrap; transition: color .15s, border-color .15s; }
.pf-sidebar-manage:hover { color: var(--pf-gold); border-color: var(--pf-gold); }
.pf-sidebar-empty { font-family: var(--pf-font-label); font-size: .85rem; color: var(--pf-muted); padding: 6px 2px; }
.pf-sidebar-empty a { color: var(--pf-purple); }
.pf-container-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.pf-container { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: var(--pf-radius-sm); border: 1px solid transparent; background: rgba(255, 255, 255, 0.025); cursor: pointer; transition: background .15s, border-color .15s; }
.pf-container:hover { background: rgba(147, 112, 219, 0.08); border-color: var(--pf-line); }
.pf-container.selected { background: rgba(147, 112, 219, 0.14); border-color: var(--pf-line-strong); box-shadow: inset 3px 0 0 var(--pf-purple); }
.pf-container-name { font-family: var(--pf-font-label); font-weight: 600; font-size: .9rem; color: var(--pf-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-container-meta { font-family: var(--pf-font-data); font-size: .74rem; color: var(--pf-muted); margin-top: 2px; }
.pf-container-value { font-family: var(--pf-font-data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: .85rem; color: var(--pf-gold); white-space: nowrap; }

/* ---------- KPI strip ---------- */
.pf-kpis { display: grid; grid-template-columns: minmax(0, 1.7fr) repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.pf-kpi { background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: var(--pf-radius); padding: 14px 16px; min-width: 0; }
.pf-kpi-label { font-family: var(--pf-font-pixel); font-size: 1.1rem; letter-spacing: .4px; text-transform: uppercase; color: var(--pf-muted); line-height: 1; margin-bottom: 8px; }
.pf-kpi-value { font-family: var(--pf-font-data); font-weight: 700; font-size: 1.75rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; color: var(--pf-gold); line-height: 1.1; }
.pf-kpi-value.plain { color: var(--pf-text); }
.pf-kpi-value.small { font-size: 1.3rem; padding-top: 4px; }
.pf-kpi-sub { font-family: var(--pf-font-data); font-size: .78rem; color: var(--pf-muted); margin-top: 6px; }
.pf-kpi-sub.pf-kpi-warn { color: #e0a94a; }   /* Steam failed: the stored inventory is shown (Oct 21, 2026) */
.pf-deltas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pf-delta { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); font-family: var(--pf-font-data); font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-delta .l { font-family: var(--pf-font-label); font-size: .7rem; color: var(--pf-muted); }
.pf-delta .v { font-weight: 600; }

/* ---------- toolbar ---------- */
.pf-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pf-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-seg { display: inline-flex; background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: 999px; padding: 3px; }
.pf-seg button { border: 0; background: transparent; color: var(--pf-muted); font-family: var(--pf-font-label); font-size: .82rem; font-weight: 600; padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.pf-seg button:hover { color: var(--pf-text); }
.pf-seg button.active { background: rgba(147, 112, 219, 0.24); color: var(--pf-gold); }
.pf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--pf-surface); border: 1px solid var(--pf-line); color: var(--pf-text); font-family: var(--pf-font-label); font-size: .82rem; font-weight: 600; padding: 8px 12px; border-radius: var(--pf-radius-sm); cursor: pointer; line-height: 1; white-space: nowrap; transition: border-color .15s, color .15s; }
.pf-btn:hover:not(:disabled) { border-color: var(--pf-gold); color: var(--pf-gold); }
.pf-btn:disabled { opacity: .5; cursor: not-allowed; }
.pf-btn.icon { padding: 7px 9px; font-size: 1rem; }
.pf-dropdown { position: relative; display: inline-flex; }
.pf-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 170px; z-index: 60; background: var(--pf-surface-2); border: 1px solid var(--pf-line-strong); border-radius: var(--pf-radius-sm); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); padding: 4px; }
.pf-menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 6px; font-family: var(--pf-font-data); font-size: .86rem; color: var(--pf-text); cursor: pointer; white-space: nowrap; }
.pf-menu-item:hover, .pf-menu-item.active { background: rgba(147, 112, 219, 0.16); color: var(--pf-gold); }
/* checkbox-style rows (the Timeframes menu): muted when off, the last one on can't be removed */
.pf-menu-item.off { color: var(--pf-muted); }
.pf-menu-item.disabled { opacity: .45; cursor: not-allowed; }
.pf-check { color: var(--pf-gold); min-width: 1em; text-align: right; }
.pf-mobile-only { display: none; }

/* ---------- states ---------- */
.pf-state { padding: 26px; text-align: center; color: var(--pf-muted); font-family: var(--pf-font-label); background: var(--pf-surface); border: 1px dashed var(--pf-line); border-radius: var(--pf-radius); }
.pf-state.error { color: #ff8a8a; border-color: rgba(255, 92, 92, 0.45); border-style: solid; }
.pf-state .big { font-size: 1.8rem; margin-bottom: 6px; }

/* ---------- table ---------- */
.pf-table-wrap { background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: var(--pf-radius); overflow: clip; }   /* clip, not hidden: keeps the sticky thead working */
/* Fixed layout, sized from the number of timeframe columns the user chose (--pf-tf-count, set by
   the template): money and timeframe columns have pixel widths, the Item column absorbs the rest
   (long names truncate; the row's title has the full name). 1440px: all eight timeframes fit
   (.dense); 1280px: seven fit, eight scroll sideways inside the card (.scrolls, measured by
   fitTable()). Timeframe cells carry .pf-th-tf — never address them by nth-child, the Alpine
   template element in the row counts as a child. */
.pf-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-family: var(--pf-font-data);
            --pf-tf-count: 5; --pf-tf-w: 92px; --pf-money-w: 104px; --pf-item-min: 210px;   /* 7 dense = 950px: fits a 1280 laptop's 958px column */
            min-width: calc(var(--pf-item-min) + 2 * var(--pf-money-w) + var(--pf-tf-count) * var(--pf-tf-w)); }
.pf-table th:nth-child(2), .pf-table th:nth-child(3) { width: var(--pf-money-w); }
.pf-table th.pf-th-tf { width: var(--pf-tf-w); }
.pf-table.dense { --pf-tf-w: 76px; }                      /* six or more timeframes */
.pf-table.dense th, .pf-table.dense td { padding-left: 8px; padding-right: 8px; font-size: .88rem; }
.pf-table-wrap.scrolls { overflow-x: auto; }               /* wider than its card: scroll, header can't stick */
.pf-table-wrap.scrolls .pf-table th { top: 0; }
.pf-table th { position: sticky; top: var(--pf-header-h); z-index: 2; background: var(--pf-surface-2); font-family: var(--pf-font-pixel); font-weight: 400; font-size: 1.2rem; letter-spacing: .3px; text-transform: uppercase; color: var(--pf-muted); padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--pf-line); cursor: pointer; user-select: none; white-space: nowrap; }
.pf-table th:first-child { text-align: left; }
.pf-table th:hover, .pf-table th.sorted { color: var(--pf-gold); }
.pf-table th:focus-visible { outline: 2px solid var(--pf-gold); outline-offset: -2px; }
.pf-table td { padding: 8px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); text-align: right; font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--pf-text); white-space: nowrap; }
.pf-table td:first-child { text-align: left; }
.pf-table tbody tr:last-child td { border-bottom: 0; }
.pf-table tbody tr:hover td { background: rgba(147, 112, 219, 0.07); }
.pf-table td.total { font-weight: 600; }
.pf-table td.delta { font-weight: 600; }
.pf-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pf-icon { flex: 0 0 auto; width: 36px; height: 28px; border-radius: 6px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.06); object-fit: contain; padding: 2px; box-sizing: border-box; }
.pf-item a { flex: 0 1 auto; min-width: 0; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-item a:hover { color: var(--pf-gold); }
.pf-qty { flex: 0 0 auto; font-size: .72rem; font-weight: 700; color: var(--pf-gold); background: rgba(255, 215, 0, 0.12); border: 1px solid rgba(255, 215, 0, 0.3); border-radius: 999px; padding: 1px 7px; }
.pf-float { flex: 0 0 auto; font-family: var(--pf-font-data); font-size: .74rem; color: var(--pf-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }   /* the asset's wear float(s) */
.pf-pattern { color: #8ab4f8; }   /* a Case Hardened pattern: "#442 · 78 % blue · T2" */
.pf-watermark { padding: 8px 14px !important; text-align: center !important; border-top: 1px solid var(--pf-line); opacity: .55; }
.pf-watermark img { width: 22px; height: 22px; vertical-align: middle; margin-right: 6px; }
.pf-watermark span { font-family: var(--pf-font-pixel); font-size: 1.1rem; color: #ccc; vertical-align: middle; }

/* ---------- cards (phones) ---------- */
.pf-cards { display: none; }
.pf-card { background: var(--pf-surface); border: 1px solid var(--pf-line); border-radius: var(--pf-radius); padding: 12px; }
.pf-card-head { display: flex; align-items: center; gap: 10px; }
.pf-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }   /* name over its float tag */
.pf-card-name { flex: 1; min-width: 0; color: inherit; text-decoration: none; font-family: var(--pf-font-data); font-size: .92rem; font-weight: 500; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pf-card-price { font-family: var(--pf-font-data); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--pf-gold); white-space: nowrap; }
.pf-card-metrics { display: grid; grid-template-columns: repeat(var(--pf-card-cols, 5), minmax(0, 1fr)); gap: 4px; margin-top: 10px; }   /* up to five chips a row (--pf-card-cols from the template); more wrap */
.pf-card-metric { background: rgba(255, 255, 255, 0.03); border-radius: 6px; padding: 5px 2px; text-align: center; }
.pf-card-metric .l { display: block; font-family: var(--pf-font-label); font-size: .62rem; letter-spacing: .3px; color: var(--pf-muted); }
.pf-card-metric .v { display: block; font-family: var(--pf-font-data); font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.pf-card-qty { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 8px; font-family: var(--pf-font-data); font-size: .8rem; color: var(--pf-muted); }
.pf-card-qty b { color: var(--pf-text); }

/* ---------- pagination ---------- */
.pf-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pf-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pf-page { min-width: 34px; height: 34px; padding: 0 8px; border-radius: var(--pf-radius-sm); border: 1px solid var(--pf-line); background: var(--pf-surface); color: var(--pf-text); font-family: var(--pf-font-data); font-size: .85rem; cursor: pointer; }
.pf-page:hover:not(:disabled) { border-color: var(--pf-gold); color: var(--pf-gold); }
.pf-page.active { background: rgba(255, 215, 0, 0.14); border-color: var(--pf-gold); color: var(--pf-gold); font-weight: 700; }
.pf-page:disabled { opacity: .35; cursor: default; }
.pf-pager-info { display: flex; align-items: center; gap: 10px; font-family: var(--pf-font-data); font-size: .8rem; color: var(--pf-muted); }
.pf-select { background: var(--pf-surface); border: 1px solid var(--pf-line); color: var(--pf-text); border-radius: var(--pf-radius-sm); padding: 5px 8px; font-family: var(--pf-font-data); font-size: .82rem; }

/* ---------- compact (tablets and phones, <= 1100px): one column, the sidebar collapses behind
   the Containers button. With a sidebar an iPad-portrait main column is ~570px and the table clips. ---------- */
.pf-compact-only { display: none; }
@media (max-width: 1100px) {
    .pf-layout { display: block; }
    .pf-compact-only { display: inline-flex; }
    .pf-sidebar { position: static; margin-bottom: 12px; }
    .pf-kpis { grid-template-columns: 1fr 1fr; }
    .pf-kpi.wide { grid-column: 1 / -1; }
    /* the per-unit Price goes (Total stays), and the rest tighten up. Collapsed to zero width rather
       than display:none: a display:none cell leaves its column "auto" in the fixed layout, and that
       phantom column then shared the leftover width with the Item column (Item 100px, 100px of
       nothing, on a phone with eight timeframes). */
    .pf-table th:nth-child(2), .pf-table td:nth-child(2) { width: 0; max-width: 0; padding: 0; border: 0; overflow: hidden; visibility: hidden; }
    .pf-table { --pf-tf-w: 84px; --pf-money-w: 96px; --pf-item-min: 210px;
                min-width: calc(var(--pf-item-min) + var(--pf-money-w) + var(--pf-tf-count) * var(--pf-tf-w)); }
    .pf-table.dense { --pf-tf-w: 72px; }
    .pf-table th, .pf-table td { padding: 8px 10px; font-size: .88rem; }
}

/* ---------- phones ---------- */
@media (max-width: 768px) {
    .pf-mobile-only { display: inline-flex; }
    .pf-kpis { gap: 8px; }
    .pf-kpi { padding: 12px 14px; }
    .pf-kpi-value { font-size: 1.5rem; }
    .pf-kpi-value.small { font-size: 1.1rem; }
    .pf-toolbar { display: block; }
    .pf-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; box-sizing: border-box; margin-bottom: 8px; }
    .pf-seg button { padding: 8px 4px; }
    /* rows of three; a lone last button spans its row, and x-show-hidden buttons leave no hole */
    .pf-tools { display: flex; flex-wrap: wrap; gap: 8px; }
    .pf-tools > * { flex: 1 1 calc(33.333% - 6px); min-width: 0; }
    .pf-btn { padding: 10px 6px; font-size: .8rem; }
    .pf-btn.icon { font-size: 1rem; }
    .pf-dropdown { display: flex; }
    .pf-dropdown .pf-btn { flex: 1; }
    .pf-menu { left: 0; right: auto; min-width: 100%; }
    .pf-cards { display: flex; flex-direction: column; gap: 10px; }
    /* table view on a phone scrolls sideways inside its card; that makes the card a scroll container,
       so the header can't be sticky to the viewport here anyway */
    .pf-table-wrap { overflow-x: auto; }
    .pf-table { --pf-item-min: 200px; --pf-money-w: 90px; --pf-tf-w: 72px; }   /* 650px for five timeframes, 866px for eight */
    .pf-table th { top: 0; }
    .pf-table th, .pf-table td { font-size: .85rem; }
    .pf-pager { justify-content: center; }
}
