/* Winston V3 — Performance screen (tracker #228).
 *
 * Sub-tab strip mirrors Money's golden-rule pill nav. Everything from
 * the period chips down is a verbatim port of dashboard/v3/mockups/
 * performance.html — the design Chris approved. All Winston's-read
 * classes are scoped to #screen-performance to avoid collisions with
 * other screens that use the same short class names. */

/* ── Sub-tab strip — mirrors .money-subtabs exactly ────────────────── */
#screen-performance .perf-subtab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-3) 0 var(--space-5);
  flex-wrap: wrap;
}
#screen-performance .perf-subtab-row .perf-subtabs {
  margin: 0;
  flex: 1 1 auto;
}
#screen-performance .perf-subtabs {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-5);
  flex-wrap: wrap;
}
#screen-performance .perf-subtab {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-3);
  font-family: inherit;
  font-size: var(--type-sm);
  font-weight: var(--weight-semi);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
#screen-performance .perf-subtab:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--border-strong);
}
#screen-performance .perf-subtab.is-active {
  background: var(--ai);
  color: white;
  border-color: var(--ai);
  font-weight: var(--weight-bold);
}
#screen-performance .perf-subtab[data-sub="winston"]:not(.is-active)::before {
  content: "✦";
  color: var(--ai);
  font-size: 12px;
  font-weight: var(--weight-bold);
}
#screen-performance .perf-subtab .perf-winston-mark { display: none; }

/* ════════════════════════════════════════════════════════════════════
   Below: verbatim port of dashboard/v3/mockups/performance.html
   ════════════════════════════════════════════════════════════════════ */

/* Period chips above the headline */
#screen-performance .period-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}
#screen-performance .period-row .label {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-right: 8px;
}
#screen-performance .period-chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
}
#screen-performance .period-chip.active {
  background: var(--ai-soft);
  border-color: var(--ai);
  color: var(--ai);
}

/* Headline card — biggest number, the answer to "how am I doing?" */
#screen-performance .headline-card {
  background: linear-gradient(180deg, rgba(31,63,143,0.08), rgba(31,63,143,0.03));
  border: 1px solid var(--ai-line);
  border-radius: 16px;
  padding: 32px 36px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
#screen-performance .headline-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--ai);
}
#screen-performance .headline-card .h-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
#screen-performance .headline-card .winston-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--ai);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
#screen-performance .headline-card .speaker {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai);
  letter-spacing: 0.02em;
}
#screen-performance .headline-card .h-period {
  font-size: 13px;
  color: var(--ink-muted);
  margin-left: auto;
}
#screen-performance .headline-card .h-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 36px;
  align-items: center;
}
#screen-performance .headline-card .h-amount {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 700;
  color: var(--money-up);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 8px;
}
#screen-performance .headline-card .h-amount.is-down { color: var(--money-down); }
#screen-performance .headline-card .h-pct {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--money-up);
  margin-bottom: 18px;
}
#screen-performance .headline-card .h-pct.is-down { color: var(--money-down); }
#screen-performance .headline-card .h-context {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.6;
}
#screen-performance .headline-card .h-context strong {
  color: var(--ink);
  font-weight: 700;
}
#screen-performance .headline-card .spark {
  width: 100%;
  height: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
#screen-performance .headline-card .spark svg {
  display: block;
  width: 100%;
  height: 100%;
}
#screen-performance .headline-card .spark .spark-cap {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
}
#screen-performance .spark-area-up { fill: rgba(34, 139, 90, 0.16); }
#screen-performance .spark-line-up { stroke: var(--money-up); stroke-width: 2; fill: none; }

/* What worked / didn't — two-col cards */
#screen-performance .winston-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
#screen-performance .w-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
}
#screen-performance .w-card .w-eyebrow {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#screen-performance .w-card .w-eyebrow .pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
#screen-performance .w-card.up   .w-eyebrow .pill { background: var(--money-up-soft);   color: var(--money-up); }
#screen-performance .w-card.down .w-eyebrow .pill { background: var(--money-down-soft); color: var(--money-down); }
#screen-performance .w-card .w-amount {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
#screen-performance .w-card.up   .w-amount { color: var(--money-up); }
#screen-performance .w-card.down .w-amount { color: var(--money-down); }
#screen-performance .w-card .w-body {
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.6;
  margin-bottom: 14px;
}
#screen-performance .w-card .w-body strong { color: var(--ink); font-weight: 600; }
#screen-performance .w-card .w-links {
  display: flex;
  gap: 16px;
  font-size: 13px;
  font-weight: 600;
  flex-wrap: wrap;
}
#screen-performance .w-card .w-links a {
  color: var(--ai);
  text-decoration: none;
}
#screen-performance .w-card .w-links a:hover { text-decoration: underline; }

/* Winston's interpretation — full-width plain card */
#screen-performance .read-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 24px;
}
#screen-performance .read-card .r-eyebrow {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#screen-performance .read-card .winston-avatar-sm {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ai);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
}
#screen-performance .read-card .r-body {
  font-size: 15px;
  color: var(--ink);
  line-height: 1.7;
}
#screen-performance .read-card .r-body strong { font-weight: 700; }
#screen-performance .read-card .r-body .mono {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ai);
}

/* Winston suggests — the action card */
#screen-performance .suggest-card {
  background: linear-gradient(180deg, rgba(31,63,143,0.10), rgba(31,63,143,0.04));
  border: 1px solid var(--ai-line);
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
#screen-performance .suggest-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--ai);
}
#screen-performance .suggest-card .s-eyebrow {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ai);
  font-weight: 700;
  margin-bottom: 10px;
}
#screen-performance .suggest-card .s-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  line-height: 1.4;
}
#screen-performance .suggest-card .s-title .mono {
  font-family: var(--font-mono);
  color: var(--ai);
}
#screen-performance .suggest-card .s-body {
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.6;
  margin-bottom: 18px;
}
#screen-performance .suggest-card .s-body strong { color: var(--ink); font-weight: 600; }

/* Diff strip — visualize what would change */
#screen-performance .diff-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
#screen-performance .diff-strip .d-head {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 12px;
}
#screen-performance .diff-strip .d-row {
  display: grid;
  grid-template-columns: 100px 1fr 24px 1fr;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  padding: 6px 0;
}
#screen-performance .diff-strip .d-engine { color: var(--ink-3); font-weight: 600; }
#screen-performance .diff-strip .d-before {
  font-family: var(--font-mono);
  color: var(--ink-muted);
  text-decoration: line-through;
}
#screen-performance .diff-strip .d-arrow {
  color: var(--ink-muted);
  text-align: center;
}
#screen-performance .diff-strip .d-after {
  font-family: var(--font-mono);
  color: var(--ink);
  font-weight: 700;
}

/* Confirm row — typing to confirm */
/* [hidden] needs explicit display:none — display:flex on these blocks
   overrides the UA default. Required for hydrateSuggest's hide of
   the diff strip + confirm row when the recommendation is 'hold'. */
#screen-performance .confirm-row[hidden],
#screen-performance .diff-strip[hidden] {
  display: none !important;
}
#screen-performance .confirm-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
#screen-performance .confirm-row .c-label {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 500;
}
#screen-performance .confirm-row .c-label .mono {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
#screen-performance .confirm-row input.c-input {
  flex: 0 0 200px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface);
  color: var(--ink);
}
#screen-performance .confirm-row input.c-input:focus {
  outline: none;
  border-color: var(--ai);
}
#screen-performance .confirm-row .c-cta {
  margin-left: auto;
  display: flex;
  gap: 10px;
}
#screen-performance .btn-confirm {
  background: var(--ai);
  color: white;
  border: 1px solid var(--ai);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
#screen-performance .btn-confirm:disabled {
  background: var(--surface-3);
  color: var(--ink-muted);
  border-color: var(--border);
  cursor: not-allowed;
}
#screen-performance .btn-secondary {
  background: var(--surface);
  color: var(--ink-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* Bookshelf — links to the manual sub-tabs */
#screen-performance .bookshelf {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
}
#screen-performance .bookshelf .b-head {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 14px;
}
#screen-performance .bookshelf .b-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
#screen-performance .bookshelf .b-grid.b-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
#screen-performance .b-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color var(--motion-fast) var(--ease-out);
}
#screen-performance .b-tile:hover { border-color: var(--ai); }
#screen-performance .b-tile .b-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
#screen-performance .b-tile .b-sub {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Container query — V3's chrome (sidebar + chat dock) eats horizontal
   space; key the headline grid stack on actual content-area width so
   the +$ number doesn't crowd the sparkline. */
#screen-performance {
  container-type: inline-size;
  container-name: perf-content;
}
@container perf-content (max-width: 920px) {
  #screen-performance .headline-card .h-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  #screen-performance .headline-card .spark { height: 100px; }
}
@container perf-content (max-width: 680px) {
  #screen-performance .winston-cards,
  #screen-performance .bookshelf .b-grid.b-grid-2 {
    grid-template-columns: 1fr;
  }
  #screen-performance .headline-card .h-amount { font-size: 44px; }
  #screen-performance .headline-card { padding: 22px 24px; }
  #screen-performance .confirm-row .c-cta { margin-left: 0; width: 100%; }
}

/* Viewport fallback for browsers without container query support. */
@media (max-width: 1280px) {
  #screen-performance .headline-card .h-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  #screen-performance .headline-card .spark { height: 100px; }
}
@media (max-width: 768px) {
  #screen-performance .winston-cards,
  #screen-performance .bookshelf .b-grid.b-grid-2 {
    grid-template-columns: 1fr;
  }
  #screen-performance .headline-card .h-amount { font-size: 44px; }
  #screen-performance .headline-card { padding: 22px 24px; }
  #screen-performance .confirm-row .c-cta { margin-left: 0; width: 100%; }
}

/* ── Standalone Performance — kit single-page layout (design-port).
   KPI strip + cumulative multi-series chart + by-engine bars + a folded
   Winston-read banner. Ported from the kit screens.css .kpi/.perf-filter/
   .range-tab/.sleeve-perf-row/.bartrack blocks; scoped to #screen-performance,
   tokens mapped to V3 names (1:1 with the kit). ── */
#screen-performance .page-head { margin-bottom: var(--space-5); }
#screen-performance .page-head h1 { font-size: var(--type-2xl); }
#screen-performance .page-head p { color: var(--ink-muted); font-size: var(--type-sm); margin-top: var(--space-1); }

#screen-performance .perf-winston-banner {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--ai-soft); border: 1px solid var(--ai-line);
  border-left: 3px solid var(--ai); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-5);
}
#screen-performance .perf-winston-banner .winston-avatar-sm {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ai); color: var(--ink-inverse); font-weight: var(--weight-black);
  font-size: var(--type-xs); display: inline-flex; align-items: center; justify-content: center;
}
#screen-performance .pwb-text { flex: 1; min-width: 0; font-size: var(--type-sm); color: var(--ink-2); line-height: var(--leading-snug); }
#screen-performance .pwb-cta { flex: none; color: var(--ai); text-decoration: none; font-weight: var(--weight-semi); font-size: var(--type-sm); white-space: nowrap; }
#screen-performance .pwb-cta:hover { text-decoration: underline; }

#screen-performance .kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
@media (max-width: 720px) { #screen-performance .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
/* Phone: the mono P&L value won't shrink below ~189px, so 2-up still overflows
   358px of usable width — drop to a single column at --bp-sm (mobile-parity,
   2026-06-01). 600px is the canonical single-column breakpoint. */
@media (max-width: 600px) { #screen-performance .kpi-grid { grid-template-columns: 1fr; } }
#screen-performance .kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); }
#screen-performance .kpi .k-label { font-size: var(--type-xs); color: var(--ink-muted); text-transform: uppercase; letter-spacing: var(--tracking-wide); font-weight: var(--weight-bold); }
#screen-performance .kpi .k-value { font-family: var(--font-mono); font-size: var(--type-2xl); font-weight: var(--weight-bold); margin-top: var(--space-2); letter-spacing: -0.02em; }
#screen-performance .kpi .k-value.up { color: var(--money-up); }
#screen-performance .kpi .k-value.down { color: var(--money-down); }
#screen-performance .kpi .k-sub { font-size: var(--type-xs); color: var(--ink-muted); margin-top: var(--space-1); }

#screen-performance .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
#screen-performance .range-tabs { display: flex; gap: var(--space-1); }
#screen-performance .range-tab { font-size: var(--type-xs); font-weight: var(--weight-semi); padding: 4px 10px; border-radius: var(--radius-sm); color: var(--ink-muted); cursor: pointer; }
#screen-performance .range-tab.active { background: var(--ai-soft); color: var(--ai); }

#screen-performance .perf-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
#screen-performance .perf-filter { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--ink-muted); font-size: var(--type-xs); font-weight: var(--weight-semi); cursor: pointer; font-family: inherit; transition: background var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out); }
#screen-performance .perf-filter i { width: 9px; height: 9px; border-radius: 3px; opacity: 0.35; transition: opacity var(--motion-fast); }
#screen-performance .perf-filter.on { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
#screen-performance .perf-filter.on i { opacity: 1; }
#screen-performance .chart-wrap { height: 300px; position: relative; }
#screen-performance .perf-chart-note { font-size: var(--type-xs); margin-top: var(--space-3); }

#screen-performance .sleeve-perf-row { display: grid; grid-template-columns: 140px 1fr auto; gap: var(--space-4); align-items: center; padding: var(--space-3) 0; border-bottom: 1px solid var(--hairline); }
#screen-performance .sleeve-perf-row:last-child { border-bottom: none; }
#screen-performance .sleeve-tag { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-semi); font-size: var(--type-sm); }
#screen-performance .sleeve-tag i { width: 10px; height: 10px; border-radius: 3px; }
#screen-performance .bartrack { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
#screen-performance .barfill { height: 100%; border-radius: 999px; }
#screen-performance .sleeve-perf-row .mono { font-size: var(--type-sm); }
#screen-performance .sleeve-perf-row .mono.up { color: var(--money-up); font-weight: var(--weight-bold); }
#screen-performance .sleeve-perf-row .mono.down { color: var(--money-down); font-weight: var(--weight-bold); }
#screen-performance .sleeve-perf-row .mono.muted { color: var(--ink-muted); font-weight: var(--weight-regular); }
/* #335 — Closed (realized) + Open (unrealized) shown side by side so a sleeve
   holding open positions with no closed trades no longer reads as flat $0. */
#screen-performance .spr-figs { display: flex; gap: var(--space-5); justify-content: flex-end; }
#screen-performance .spr-fig { min-width: 76px; text-align: right; }
#screen-performance .spr-fig-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); margin-bottom: 2px; }
