/*
 * Vested screen parts (window.VX + .vx-* classes). docs/systems/UI_PARTS.md
 *
 * ONE set of parts for every adviser screen, agreed with Stuart in the layout mockups
 * (13 Nov 2026). Rules that keep it safe to load on every page:
 *   - every selector is a .vx-* class (no element, id or global selectors), so loading
 *     this file changes nothing until a page opts in;
 *   - every colour comes from the firm's brand variables (--brand-accent, --brand-ink,
 *     their -rgb triplets, set on :root by vested-demo.html and overwritten per firm),
 *     or from the fixed semantic tokens below. Never write a brand hex here.
 * test/uiParts.test.js enforces both.
 */
:root {
  --vx-page: #f4f5f5;
  --vx-surface: #ffffff;
  --vx-fill: #f1f2f2;
  --vx-head-fill: #f7f8f8;
  --vx-line: #e4e5e3;
  --vx-line-strong: #cfd0cc;
  --vx-text-2: #56636e;
  --vx-text-3: #848484;
  --vx-warm: #8c8478;
  --vx-warm-2: #a59d90;
  /* Semantic tones: fixed across firms (BUILD_STANDARDS §2 sentiment pills). */
  --vx-good-bg: #e8f6ee; --vx-good: #1d7a45;
  --vx-warn-bg: #fdf1e7; --vx-warn: #9a5b1f;
  --vx-bad-bg: #fbeaea; --vx-bad: #a13434; --vx-badge: #e5534b;
  --vx-r-ctl: 8px;
  --vx-r-card: 12px;
}

/* ── Page header ───────────────────────────────────────────────────────────── */
.vx-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; }
.vx-crumb { font-size: 12.5px; color: var(--vx-text-3); }
.vx-crumb a { color: var(--vx-text-2); text-decoration: none; cursor: pointer; }
.vx-title { font-family: var(--brand-font-display); font-weight: 400; font-size: 26px; line-height: 1.15; margin: 0; color: var(--brand-ink); }
.vx-sub { font-size: 13px; color: var(--vx-text-2); margin-top: 3px; }
.vx-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.vx-btn { font: 600 13px/1 var(--brand-font-body); height: 32px; padding: 0 14px; border-radius: var(--vx-r-ctl); border: 1px solid var(--vx-line-strong); background: var(--vx-surface); color: var(--brand-ink); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.vx-btn:hover { background: var(--vx-fill); }
.vx-btn:focus-visible { outline: 3px solid rgba(var(--brand-accent-rgb), .35); outline-offset: 1px; }
.vx-btn.primary { background: var(--brand-accent); border-color: var(--brand-accent); color: #fff; }
.vx-btn.primary:hover { filter: brightness(.92); }
.vx-btn.ghost { border-color: transparent; background: transparent; color: var(--vx-text-2); }
.vx-btn.ghost:hover { background: var(--vx-fill); color: var(--brand-ink); }
.vx-btn.danger { color: var(--vx-bad); border-color: #e7b9b9; }
.vx-btn.danger:hover { background: var(--vx-bad-bg); }
.vx-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.vx-btn.lg { height: 36px; padding: 0 16px; font-size: 13.5px; }
.vx-btn[disabled] { opacity: .45; cursor: not-allowed; }
.vx-btn svg { width: 14px; height: 14px; }

/* ── Pills (a state) and tags (a code) ─────────────────────────────────────── */
.vx-pill { display: inline-flex; align-items: center; gap: 5px; font: 700 11px/1 var(--brand-font-body); padding: 4px 9px; border-radius: 999px; white-space: nowrap; background: var(--vx-fill); color: var(--vx-text-2); }
.vx-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.vx-pill.nodot::before { display: none; }
.vx-pill.good { background: var(--vx-good-bg); color: var(--vx-good); }
.vx-pill.warn { background: var(--vx-warn-bg); color: var(--vx-warn); }
.vx-pill.bad { background: var(--vx-bad-bg); color: var(--vx-bad); }
.vx-pill.info { background: rgba(var(--brand-accent-rgb), .10); color: var(--brand-accent); }
.vx-tag { display: inline-flex; align-items: center; gap: 6px; font: 700 11px/1 var(--brand-font-body); padding: 4px 7px; border-radius: 5px; border: 1px solid var(--vx-line-strong); background: var(--vx-surface); color: var(--brand-ink); white-space: nowrap; letter-spacing: .02em; }
.vx-tag.ink { background: var(--brand-ink); color: #fff; border-color: var(--brand-ink); }
.vx-tag.link { cursor: pointer; }
.vx-tag.link:hover { border-color: var(--brand-accent); color: var(--brand-accent); background: rgba(var(--brand-accent-rgb), .10); }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.vx-card { background: var(--vx-surface); border: 1px solid var(--vx-line); border-radius: var(--vx-r-card); min-width: 0; }
.vx-card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--vx-line); }
.vx-card-h h4 { margin: 0; font: 700 11px/1.3 var(--brand-font-body); letter-spacing: .09em; text-transform: uppercase; color: var(--vx-text-2); }
.vx-card-h .vx-meta { font-size: 12px; color: var(--vx-text-3); }
.vx-card-b { padding: 11px 14px; }
.vx-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.vx-kv dt { color: var(--vx-text-3); }
.vx-kv dd { margin: 0; text-align: right; font-weight: 600; }

/* ── Coloured tiles: filter tiles (buttons) and record tiles (figures) ───────── */
.vx-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.vx-tile { text-align: left; border: 0; border-radius: var(--vx-r-card); padding: 11px 15px; color: #fff; min-width: 0; font-family: var(--brand-font-body); box-shadow: 0 1px 2px rgba(var(--brand-ink-rgb), .12); }
button.vx-tile { cursor: pointer; }
.vx-tile .vx-tile-l { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vx-tile b { display: block; font-family: var(--brand-font-display); font-weight: 400; font-size: 26px; line-height: 1.12; margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vx-tile .vx-tile-t { display: block; font-size: 13px; font-weight: 700; margin-top: 2px; }
.vx-tile .vx-tile-s { display: block; font-size: 11.5px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vx-tile.navy { background: linear-gradient(135deg, var(--brand-ink), rgba(var(--brand-ink-rgb), .86)); }
.vx-tile.teal { background: linear-gradient(135deg, rgba(var(--brand-accent-rgb), .88), var(--brand-accent)); }
.vx-tile.deep { background: linear-gradient(135deg, rgba(var(--brand-ink-rgb), .92), rgba(var(--brand-accent-rgb), .62)); }
.vx-tile.warm { background: linear-gradient(135deg, var(--vx-warm), var(--vx-warm-2)); }
.vx-tile.light { background: var(--vx-surface); color: var(--brand-ink); border: 1px solid var(--vx-line); box-shadow: none; }
.vx-tile.light .vx-tile-l, .vx-tile.light .vx-tile-s { color: var(--vx-text-2); opacity: 1; }
.vx-tile.on { box-shadow: 0 0 0 2px var(--vx-page), 0 0 0 4px var(--brand-accent); }
.vx-tile:focus-visible { outline: 3px solid rgba(var(--brand-accent-rgb), .5); outline-offset: 2px; }
.vx-tile .vx-tile-badge { float: right; background: var(--vx-badge); color: #fff; font: 700 11px/1 var(--brand-font-body); padding: 3px 7px; border-radius: 999px; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.vx-tablewrap { border: 1px solid var(--vx-line); border-radius: var(--vx-r-card); background: var(--vx-surface); overflow-x: auto; }
.vx-table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--brand-ink); }
.vx-table th { text-align: left; background: var(--vx-head-fill); font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--vx-text-3); padding: 0 12px; height: 34px; border-bottom: 1px solid var(--vx-line); white-space: nowrap; }
.vx-table th.vx-sort { cursor: pointer; }
.vx-table th.vx-sorted { color: var(--brand-ink); }
.vx-table th.vx-sorted::after { content: " \2193"; color: var(--brand-accent); }
.vx-table th.vx-sorted.asc::after { content: " \2191"; }
.vx-table td { padding: 0 12px; height: 40px; border-bottom: 1px solid var(--vx-line); white-space: nowrap; }
.vx-table.dense td { height: 36px; }
.vx-table tr:last-child td { border-bottom: 0; }
.vx-table tbody tr.vx-go:hover td { background: rgba(var(--brand-accent-rgb), .045); cursor: pointer; }
.vx-table .r { text-align: right; font-variant-numeric: tabular-nums; }
.vx-table tfoot td { background: var(--vx-head-fill); font-weight: 700; border-top: 1px solid var(--vx-line); }
.vx-pos { color: var(--vx-good); }
.vx-neg { color: var(--vx-bad); }
.vx-dim { color: var(--vx-text-3); }

/* ── Toolbars, inputs, switches, chips, tabs ───────────────────────────────── */
.vx-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vx-input { font: 400 13.5px/1.2 var(--brand-font-body); height: 32px; padding: 0 11px; border: 1px solid var(--vx-line-strong); border-radius: var(--vx-r-ctl); background: var(--vx-surface); color: var(--brand-ink); min-width: 0; }
textarea.vx-input { height: auto; padding: 9px 11px; line-height: 1.5; resize: vertical; }
select.vx-input { padding-right: 28px; }
.vx-input:focus { outline: none; border-color: var(--brand-accent); box-shadow: 0 0 0 3px rgba(var(--brand-accent-rgb), .15); }
.vx-field { display: grid; gap: 5px; min-width: 0; }
.vx-field label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--vx-text-3); }
.vx-field .vx-hint { font-size: 12px; color: var(--vx-text-3); }
.vx-field.err .vx-input { border-color: var(--vx-bad); }
.vx-field.err .vx-hint { color: var(--vx-bad); }
.vx-seg { display: inline-flex; background: var(--vx-fill); border-radius: var(--vx-r-ctl); padding: 3px; gap: 2px; }
.vx-seg button { font: 600 12.5px/1 var(--brand-font-body); border: 0; background: none; color: var(--vx-text-2); padding: 6px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.vx-seg button.on { background: var(--vx-surface); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(var(--brand-ink-rgb), .12); }
.vx-chip { font: 600 12px var(--brand-font-body); border: 1px solid var(--vx-line-strong); background: var(--vx-surface); color: var(--vx-text-2); border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.vx-chip.on { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.vx-tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--vx-line); overflow-x: auto; }
.vx-tab { font: 600 14px/1 var(--brand-font-body); color: var(--vx-text-2); padding: 10px 0 11px; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.vx-tab.on { color: var(--brand-ink); border-bottom-color: var(--brand-accent); }
.vx-tab .vx-count { font-size: 11px; font-weight: 700; background: var(--vx-fill); color: var(--vx-text-2); border-radius: 999px; padding: 2px 7px; }

/* ── Activity feed ─────────────────────────────────────────────────────────── */
.vx-feed { list-style: none; margin: 0; padding: 0; }
.vx-feed li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--vx-line); font-size: 13px; }
.vx-feed li:first-child { border-top: 0; padding-top: 0; }
.vx-feed .vx-ic { width: 28px; height: 28px; border-radius: 7px; background: var(--vx-fill); display: grid; place-items: center; color: var(--vx-text-2); }
.vx-feed .vx-when { color: var(--vx-text-3); font-size: 12px; white-space: nowrap; }
.vx-feed p { margin: 1px 0 0; color: var(--vx-text-2); }

/* ── Empty, loading, callout ───────────────────────────────────────────────── */
.vx-empty { text-align: center; padding: 28px 16px; }
.vx-empty b { display: block; font-size: 14.5px; color: var(--brand-ink); }
.vx-empty p { margin: 3px auto 12px; font-size: 13px; color: var(--vx-text-2); max-width: 42ch; }
.vx-skel { height: 12px; border-radius: 5px; background: linear-gradient(90deg, var(--vx-fill) 25%, #e8eaea 50%, var(--vx-fill) 75%); background-size: 300% 100%; animation: vx-skel 1.4s infinite; }
@keyframes vx-skel { from { background-position: 100% 0; } to { background-position: 0 0; } }
.vx-callout { border-left: 3px solid var(--brand-accent); background: rgba(var(--brand-accent-rgb), .06); padding: 10px 14px; border-radius: 0 8px 8px 0; font-size: 13px; }
.vx-callout.warn { border-color: #e08c2a; background: var(--vx-warn-bg); }

/* ── Pop-up (VX.modal), toast (VX.toast), row menu (VX.menu) ───────────────── */
.vx-modal-bd { position: fixed; inset: 0; z-index: 100080; background: rgba(var(--brand-ink-rgb), .45); display: grid; place-items: center; padding: 20px; }
.vx-modal { width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--vx-surface); border-radius: var(--vx-r-card); box-shadow: 0 20px 50px rgba(var(--brand-ink-rgb), .3); overflow: hidden; color: var(--brand-ink); font-family: var(--brand-font-body); }
.vx-modal.sm { max-width: 420px; }
.vx-modal.lg { max-width: 820px; }
.vx-modal-h { padding: 18px 22px 6px; }
.vx-modal-h h3 { margin: 0; font-size: 17px; font-weight: 700; }
.vx-modal-h p { margin: 4px 0 0; font-size: 13px; color: var(--vx-text-2); }
.vx-modal-b { padding: 12px 22px 18px; display: grid; gap: 12px; overflow: auto; }
.vx-modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px; background: var(--vx-head-fill); border-top: 1px solid var(--vx-line); }
.vx-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100090; display: inline-flex; align-items: center; gap: 10px; background: var(--brand-ink); color: #fff; font: 600 13px var(--brand-font-body); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(var(--brand-ink-rgb), .25); }
.vx-toast.bad { background: var(--vx-bad); }
.vx-toast button { background: none; border: 0; color: #9fd8dc; font: 700 13px var(--brand-font-body); cursor: pointer; padding: 0; }
.vx-menu { position: fixed; z-index: 100085; width: 230px; background: var(--vx-surface); border: 1px solid var(--vx-line); border-radius: 10px; box-shadow: 0 14px 34px rgba(var(--brand-ink-rgb), .18); padding: 6px; font-family: var(--brand-font-body); }
.vx-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; font: 500 13px var(--brand-font-body); color: var(--brand-ink); padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.vx-menu button:hover, .vx-menu button:focus-visible { background: var(--vx-fill); outline: none; }
.vx-menu button.danger { color: var(--vx-bad); }
.vx-menu button.danger:hover { background: var(--vx-bad-bg); }
.vx-menu .vx-menu-g { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--vx-text-3); padding: 8px 10px 3px; border-top: 1px solid var(--vx-line); margin-top: 4px; }
.vx-menu .vx-menu-g:first-child { border-top: 0; margin-top: 0; padding-top: 4px; }

@media (prefers-reduced-motion: reduce) { .vx-skel { animation: none; } }

/* ── The right-hand panel (window.VXPanel, static/shared/vxPanel.js) ─────────
   Only drawn while the new frame is on (body.ws-frame). A 48px strip down the right
   edge; open, a 380px panel beside it. The page and the top bar make room for it;
   under 900px the open panel lies over the page instead. */
.vx-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 950; display: flex; font-family: var(--brand-font-body); color: var(--brand-ink); }
.vx-panel[hidden] { display: none; }
.vx-strip { width: 48px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--vx-head-fill); border-left: 1px solid var(--vx-line); }
.vx-strip-btn { position: relative; width: 36px; height: 36px; border-radius: 9px; border: 0; background: none; color: var(--vx-text-2); display: grid; place-items: center; cursor: pointer; }
.vx-strip-btn:hover { background: var(--vx-fill); color: var(--brand-ink); }
.vx-strip-btn.on { background: rgba(var(--brand-accent-rgb), .12); color: var(--brand-accent); }
.vx-strip-btn:focus-visible { outline: 3px solid rgba(var(--brand-accent-rgb), .35); }
.vx-strip-btn svg { width: 18px; height: 18px; }
.vx-strip-badge { position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; border-radius: 8px; padding: 0 3px; background: var(--vx-badge); color: #fff; font: 700 9.5px/15px var(--brand-font-body); }
.vx-strip-sp { flex: 1; }
.vx-panel-body { order: -1; width: 380px; display: flex; flex-direction: column; min-height: 0; background: var(--vx-surface); border-left: 1px solid var(--vx-line); }
.vx-panel-body[hidden] { display: none; }
.vx-panel-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 16px 10px; border-bottom: 1px solid var(--vx-line); }
.vx-panel-h b { display: block; font-size: 15px; }
.vx-panel-h span { font-size: 12px; color: var(--vx-text-3); }
.vx-panel-c { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.vx-has-panel .content-area { margin-right: 48px; }
.vx-has-panel .vtop { right: 48px; }
@media (min-width: 900px) {
  .vx-panel-open .content-area { margin-right: 429px; }
  .vx-panel-open .vtop { right: 429px; }
}
@media (max-width: 899px) {
  .vx-panel-body { position: fixed; top: 0; bottom: 0; right: 48px; width: min(380px, calc(100vw - 48px)); box-shadow: -14px 0 32px rgba(var(--brand-ink-rgb), .18); }
}

/* Stepper (− value +) and progress bar (Engine Room, 20 Nov). Markup:
   <div class="vx-stepper"><button class="vx-stepper-b" data-step="-1">−</button><span class="vx-stepper-v">$15k</span><button class="vx-stepper-b" data-step="1">+</button></div>
   <div class="vx-progress"><i style="width:40%"></i></div>   .good = green fill */
.vx-stepper { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px; height: 40px; padding: 0 6px; border: 1.5px solid var(--brand-accent); border-radius: var(--vx-r-ctl); background: var(--vx-surface); min-width: 0; }
.vx-stepper-v { font: 700 18px/1 var(--brand-font-body); color: var(--brand-ink); text-align: center; flex: 1; font-variant-numeric: tabular-nums; }
.vx-stepper-b { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--brand-accent); font: 700 18px/1 var(--brand-font-body); cursor: pointer; }
.vx-stepper-b:hover { background: var(--vx-fill); }
.vx-stepper-b:disabled { color: var(--vx-line-strong); cursor: default; background: transparent; }
.vx-stepper.sm { height: 32px; }
.vx-stepper.sm .vx-stepper-v { font-size: 15px; }
.vx-progress { height: 8px; border-radius: 999px; background: var(--vx-fill); overflow: hidden; }
.vx-progress > i { display: block; height: 100%; border-radius: 999px; background: var(--brand-accent); max-width: 100%; }
.vx-progress.good > i { background: var(--vx-good); }
.vx-progress.thin { height: 5px; }
