/* Signed-in workspace: navigation, dashboard, investments, detail, settings.
   Tokens come from tokens.css (chart colours included), keyframes from motion.css. */

body.is-workspace .app-header { display: none; }
body.is-workspace .shell { max-width: none; margin: 0; padding: 0; }
body.is-workspace { padding: 0; }

.ws { min-height: 100vh; min-height: 100dvh; display: block; }
.ws-side { display: none; }
.ws-main { max-width: 44rem; margin: 0 auto; padding: calc(var(--space-4) + env(safe-area-inset-top)) var(--space-4) calc(6rem + env(safe-area-inset-bottom)); }
.ws-outlet { min-height: 60vh; }
.ws-outlet > * + * { margin-top: var(--space-8); }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-6); }
.topbar .lockup-mark { width: 1.9rem; height: 1.9rem; }
.topbar .wordmark { --wm-h: 1.45rem; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-1); }
.chip-status { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 30px; margin-right: var(--space-2); padding: 0 var(--space-3) 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); font-size: var(--fs-caption); font-weight: 500; line-height: 1; color: var(--text-muted); white-space: nowrap; }
.chip-status::before { content: ""; flex: none; width: 7px; height: 7px; margin-left: var(--space-1); border-radius: 50%; background: var(--positive); box-shadow: 0 0 0 3px color-mix(in srgb, var(--positive) 22%, transparent); }
/* On narrow phones the chip shrinks to its dot (the full text stays for screen readers). */
@media (max-width: 420px) { .chip-status { font-size: 0; gap: 0; padding: 0 var(--space-2); margin-right: var(--space-1); } .chip-status::before { margin-left: 0; } }
.icon-btn { width: var(--tap-min); height: var(--tap-min); display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-input); border: 0; background: transparent; color: var(--text-muted); cursor: pointer; touch-action: manipulation; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); }
@media (hover: hover) { .icon-btn:hover { background: var(--surface-2); color: var(--text); } }
.icon-btn:active { transform: scale(0.92); transition-duration: var(--dur-instant); }

/* ---- bottom tabs (phones and tablets): frosted, with a sliding marker ---- */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); border-top: 1px solid var(--border); }
.tabbar::before { content: ""; position: absolute; top: -1px; left: 0; width: var(--ind-w, 0); height: 2px; border-radius: 2px; background: var(--accent); opacity: var(--ind-o, 0); transform: translateX(var(--ind-x, 0)); transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-fast) var(--ease-out); }
.tab { flex: 1; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-muted); text-decoration: none; font-size: min(var(--fs-caption), 0.875rem); font-weight: 500; /* capped so four labels always fit, even at the largest text size */ transition: color var(--dur-fast) var(--ease-out); -webkit-tap-highlight-color: transparent; }
.tab .icon { transition: transform var(--dur-base) var(--ease-spring); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .icon { transform: translateY(-1px) scale(1.1); }

/* ---- desktop sidebar ---- */
@media (min-width: 1024px) {
  .ws { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .ws-side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; padding: var(--space-6) var(--space-4); border-right: 1px solid var(--border); gap: var(--space-8); background: color-mix(in srgb, var(--surface) 55%, var(--bg)); }
  .ws-side .lockup { padding: 0 var(--space-2); }
  .ws-side .wordmark { --wm-h: 1.5rem; }
  .side-nav { position: relative; display: flex; flex-direction: column; gap: 4px; }
  .side-nav::before { content: ""; position: absolute; left: 0; top: 0; width: 100%; height: var(--ind-h, 0); border-radius: var(--radius-input); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); opacity: var(--ind-o, 0); transform: translateY(var(--ind-y, 0)); transition: transform var(--dur-base) var(--ease-out), height var(--dur-base) var(--ease-out), opacity var(--dur-fast) var(--ease-out); }
  .side-nav a { position: relative; z-index: 1; display: flex; align-items: center; gap: var(--space-3); min-height: 46px; padding: 0 var(--space-3); border-radius: var(--radius-input); color: var(--text-muted); text-decoration: none; font-weight: 500; transition: color var(--dur-fast) var(--ease-out); }
  .side-nav a .icon { transition: color var(--dur-fast) var(--ease-out); }
  @media (hover: hover) { .side-nav a:hover { color: var(--text); } }
  .side-nav a[aria-current="page"] { color: var(--text); }
  .side-nav a[aria-current="page"] .icon { color: var(--accent); }
  .side-user { margin-top: auto; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--card-highlight), var(--shadow-1); }
  .side-user-text { flex: 1; min-width: 0; }
  .side-user-name { margin: 0; font-weight: 600; font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user-sub { margin: 0; font-size: var(--fs-caption); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar { display: none; }
  .ws-main { max-width: var(--content-max); padding: var(--space-6) var(--space-12) var(--space-16); margin: 0 auto; width: 100%; }
  .topbar .lockup { display: none; }
  .topbar { justify-content: flex-end; }
}
.avatar { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 600 var(--fs-small) var(--font-sans); letter-spacing: 0.02em; }
.avatar--lg { width: 52px; height: 52px; font-size: var(--fs-body); }
.side-user { display: none; }
@media (min-width: 1024px) { .side-user { display: flex; } }

/* ---- headings and shared text ---- */
.page-title { font: 500 var(--fs-h1)/1.15 var(--font-serif); letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.page-head > .btn, .page-head > a.btn { flex: none; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.section-head h2 { font-size: var(--fs-h3); }
.sub { color: var(--text-muted); font-size: var(--fs-small); margin: var(--space-1) 0 0; }
.money { font-variant-numeric: tabular-nums; }
.flat { color: var(--text-muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--space-6); box-shadow: var(--card-highlight), var(--shadow-1); min-width: 0; }
.panel--flush { padding: var(--space-2) var(--space-4); }
.rise { animation: rise var(--dur-slow) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* ---- amounts that can be hidden: they blur, they do not vanish ---- */
.amt { display: inline-block; font-variant-numeric: tabular-nums; transition: filter var(--dur-base) var(--ease-out); }
html[data-amounts-hidden] .amt { filter: blur(9px); -webkit-user-select: none; user-select: none; }
html.amt-anim[data-amounts-hidden] .amt { animation: amt-blur var(--dur-slow) var(--ease-out) both; }
html.amt-anim:not([data-amounts-hidden]) .amt { animation: amt-focus var(--dur-slow) var(--ease-out) both; }
@keyframes amt-blur { from { filter: blur(0); } to { filter: blur(9px); } }
@keyframes amt-focus { from { filter: blur(9px); } to { filter: blur(0); } }

/* ---- dashboard grid ---- */
.dash { display: grid; gap: var(--space-6); }
.dash-main, .dash-side { display: grid; gap: var(--space-6); align-content: start; min-width: 0; }
.dash-wide { min-width: 0; }
@media (min-width: 1100px) {
  .dash { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: stretch; }
  .dash-main { align-content: stretch; }
  .dash-wide { grid-column: 1 / -1; }
}

/* ---- the statement ---- */
.statement-label { margin: 0; color: var(--text-muted); font-size: var(--fs-small); font-weight: 500; }
.hero-btn { display: block; text-align: left; background: none; border: 0; padding: 0; margin: var(--space-2) 0 var(--space-3); color: var(--text); cursor: pointer; font: 500 var(--fs-hero)/var(--lh-hero) var(--font-serif); letter-spacing: -0.025em; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.hero-btn:focus-visible { outline-offset: 6px; border-radius: 6px; }
.hero-num .cur { font-size: 0.6em; margin-right: 0.1em; vertical-align: 0.34em; color: var(--text-muted); font-weight: 400; }
.hero-num .dec { font-size: 0.55em; color: var(--text-muted); font-weight: 400; }
.statement .gold-rule { margin: var(--space-3) 0 var(--space-4); }
.statement-sub { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: var(--space-1); font: 600 var(--fs-small)/1 var(--font-sans); padding: 7px 12px; border-radius: var(--radius-pill); border: 1px solid color-mix(in srgb, currentColor 35%, transparent); background: color-mix(in srgb, currentColor 9%, transparent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill .icon { width: 14px; height: 14px; }
.pill--small { font-size: var(--fs-caption); padding: 4px 8px; }
.pill.gain { color: var(--positive); } .pill.loss { color: var(--negative); } .pill.flat { color: var(--text-muted); }
.pill.flat { border-style: dashed; background: transparent; font-weight: 500; }
.statement-line { display: grid; grid-template-columns: repeat(2, 1fr); margin: var(--space-6) 0 0; border-top: 1px solid var(--border); }
.statement-line > div { padding: var(--space-3) var(--space-3) var(--space-3) 0; }
.statement-line dt { color: var(--text-muted); font-size: var(--fs-small); }
.statement-line dd { margin: 2px 0 0; font: 600 var(--fs-h3)/1.3 var(--font-sans); font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .statement-line { grid-template-columns: repeat(4, 1fr); } .statement-line > div { padding-left: var(--space-4); border-left: 1px solid var(--border); } .statement-line > div:first-child { padding-left: 0; border-left: 0; } }

/* ---- growth chart (inside the statement card) ---- */
.growth { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.growth-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.growth-head .readout { flex: 1 1 14rem; margin: 0; min-height: 2.6em; display: flex; align-items: center; }
.growth-note { margin: var(--space-3) 0 0; text-align: center; max-width: 30rem; margin-inline: auto; }
.chart--ghost .grid { stroke-dasharray: 2 6; }
.chart--ghost .ghost-line { fill: none; stroke: var(--border-strong); stroke-width: 2.4; stroke-dasharray: 3 8; stroke-linecap: round; }
.chart--ghost .ghost-dot { fill: var(--surface); stroke: var(--border-strong); stroke-width: 2.4; }
.statement .statement-line { margin-top: var(--space-4); }

/* ---- chart ---- */
.chart-box { margin-top: var(--space-2); min-height: 8rem; }
.readout { min-height: 2.6em; margin: 0 0 var(--space-2); font-size: var(--fs-small); color: var(--text-muted); }
.readout strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font: 11px var(--font-sans); }
.chart .line-a { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; animation: draw 0.9s var(--ease-out) 0.1s forwards; }
.chart .line-b { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: 0; animation: fade var(--dur-slow) var(--ease-out) 0.3s forwards; }
.chart .area { opacity: 0; animation: fade var(--dur-slow) var(--ease-out) 0.55s forwards; }
.chart .stop-a { stop-color: var(--accent); }
.chart .cross { stroke: var(--text-muted); stroke-dasharray: 3 3; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart .hit { cursor: crosshair; touch-action: pan-y; }
.chart-empty { margin: var(--space-6) 0; text-align: center; }
.legend-inline { display: flex; gap: var(--space-4); flex-wrap: wrap; margin: var(--space-2) 0 0; font-size: var(--fs-caption); color: var(--text-muted); }
.legend-inline span::before { content: ""; display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legend-inline .dashed::before { border-top: 2px dashed var(--text-muted); }

/* ---- segmented control (the sliding thumb itself lives in components.css) ---- */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); padding: 2px; background: var(--surface-2); max-width: 100%; }
.seg button { white-space: nowrap; min-height: 34px; padding: 0 var(--space-3); border: 0; background: transparent; color: var(--text-muted); font: 500 var(--fs-small) var(--font-sans); border-radius: var(--radius-pill); cursor: pointer; transition: color var(--dur-fast) var(--ease-out); touch-action: manipulation; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---- allocation ---- */
.alloc { display: grid; gap: var(--space-4); justify-items: center; }
.alloc .rows { width: 100%; }
.donut { width: 13rem; max-width: 100%; height: auto; margin: 0 auto; overflow: visible; }
.donut-track { stroke: var(--surface-2); }
.donut-seg { transition: opacity var(--dur-base) var(--ease-out), stroke-width var(--dur-base) var(--ease-out); animation: donut-sweep var(--dur-hero) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 80ms + 80ms); }
@keyframes donut-sweep { from { stroke-dasharray: 0 var(--C); } to { stroke-dasharray: var(--len) var(--rest); } }
.donut.has-hl .donut-seg { opacity: 0.3; }
.donut.has-hl .donut-seg.is-hl { opacity: 1; stroke-width: 24; }
.donut-total { fill: var(--text); font: 500 24px var(--font-serif); font-variant-numeric: tabular-nums; }
.donut-cap { fill: var(--text-muted); font: 500 11px var(--font-sans); }
.seg-1 { stroke: var(--chart-1); } .seg-2 { stroke: var(--chart-2); } .seg-3 { stroke: var(--chart-3); }
.seg-4 { stroke: var(--chart-4); } .seg-5 { stroke: var(--chart-5); } .seg-6 { stroke: var(--chart-6); }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.swatch.seg-1 { background: var(--chart-1); } .swatch.seg-2 { background: var(--chart-2); } .swatch.seg-3 { background: var(--chart-3); }
.swatch.seg-4 { background: var(--chart-4); } .swatch.seg-5 { background: var(--chart-5); } .swatch.seg-6 { background: var(--chart-6); }

/* ---- ledger rows ---- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--border); }
.row-line { display: flex; align-items: center; gap: var(--space-3); min-height: 60px; padding: var(--space-3) var(--space-3); margin: 0 calc(var(--space-3) * -1); border-radius: var(--radius-input); color: inherit; text-decoration: none; transition: background var(--dur-fast) var(--ease-out); }
@media (hover: hover) { a.row-line:hover { background: var(--surface-2); } }
a.row-line:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-sub { color: var(--text-muted); font-size: var(--fs-small); }
.row-end { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-variant-numeric: tabular-nums; flex: none; }
.tile { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.tile.tint-1 { color: var(--chart-1); background: color-mix(in srgb, var(--chart-1) 14%, transparent); }
.tile.tint-2 { color: var(--chart-2); background: color-mix(in srgb, var(--chart-2) 14%, transparent); }
.tile.tint-3 { color: var(--chart-3); background: color-mix(in srgb, var(--chart-3) 16%, transparent); }
.tile.tint-4 { color: var(--chart-4); background: color-mix(in srgb, var(--chart-4) 14%, transparent); }
.tile.tint-5 { color: var(--chart-5); background: color-mix(in srgb, var(--chart-5) 14%, transparent); }
.tile.tint-6 { color: var(--chart-6); background: color-mix(in srgb, var(--chart-6) 16%, transparent); }
.chip { display: inline-flex; align-items: center; margin-left: var(--space-2); padding: 3px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted); font: 600 var(--fs-caption)/1 var(--font-sans); vertical-align: 2px; }
.add-card { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-4); padding: var(--space-4) var(--space-6); border: 1.5px dashed var(--border-strong); border-radius: var(--radius-card); color: var(--text); text-decoration: none; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); }
.add-card > span:last-child { display: grid; gap: 2px; }
.add-card .sub { margin: 0; }
.add-card-plus { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
@media (hover: hover) { .add-card:hover { background: var(--surface); border-color: var(--accent); } }
.add-card:active { transform: scale(0.99); transition-duration: var(--dur-instant); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile--large { width: 64px; height: 64px; border-radius: 16px; }
.tile--large .icon { width: 28px; height: 28px; }
.date-col { width: 6.2rem; flex: none; color: var(--text-muted); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.overdue { color: var(--negative); }
.mini-empty { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; color: var(--text-muted); font-size: var(--fs-small); }
.mini-empty .icon { flex: none; }

/* ---- toolbar above lists ---- */
.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-4); }
.toolbar { justify-content: space-between; }
.search { position: relative; flex: 1 1 14rem; max-width: 26rem; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search .input { padding-left: 44px; min-height: 44px; }

/* ---- investment detail ---- */
.back { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--text-muted); text-decoration: none; font-size: var(--fs-small); min-height: var(--tap-min); transition: color var(--dur-fast) var(--ease-out); }
.back:hover { color: var(--text); }
.detail-head { display: flex; gap: var(--space-4); align-items: center; }
.detail-head + .statement-label { margin-top: var(--space-6); }
.tabs { position: relative; display: flex; gap: var(--space-6); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::after { content: ""; position: absolute; bottom: 0; left: 0; width: var(--ind-w, 0); height: 2px; background: var(--accent); border-radius: 2px; opacity: var(--ind-o, 0); transform: translateX(var(--ind-x, 0)); transition: transform var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out); }
.tabs button { min-height: var(--tap-min); border: 0; background: none; color: var(--text-muted); font: 500 var(--fs-body) var(--font-sans); cursor: pointer; white-space: nowrap; padding: 0; transition: color var(--dur-fast) var(--ease-out); touch-action: manipulation; }
.tabs button[aria-selected="true"] { color: var(--text); }
.defs { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr; margin: 0; border-top: 1px solid var(--border); }
.defs dt, .defs dd { margin: 0; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.defs dt { color: var(--text-muted); font-size: var(--fs-small); padding-right: var(--space-3); }
.defs dd { overflow-wrap: anywhere; }
.scroll-x { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.table th, .table td { padding: var(--space-3) var(--space-3) var(--space-3) 0; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--text-muted); font-weight: 500; }
.prose { max-width: 38rem; margin: 0; font-family: var(--font-serif); line-height: 1.65; }
.note-box { padding: var(--space-3) var(--space-4); border-left: 3px solid var(--accent); background: var(--accent-soft); font-size: var(--fs-small); border-radius: 0 var(--radius-input) var(--radius-input) 0; }
.working { font-size: var(--fs-small); }
.working ul { margin: var(--space-2) 0 0; padding-left: 1.2rem; color: var(--text-muted); }
.working li + li { margin-top: var(--space-2); }

/* ---- empty states ---- */
.empty { text-align: center; padding: var(--space-12) var(--space-4); max-width: 30rem; margin: 0 auto; }
.empty--hero { max-width: none; padding: var(--space-16) var(--space-6); }
.empty h2 { font-size: var(--fs-h2); }
.empty p { color: var(--text-muted); max-width: 26rem; margin: var(--space-3) auto 0; }
.empty .row { justify-content: center; margin-top: var(--space-6); }
.empty-art { position: relative; display: grid; place-items: center; width: 84px; height: 84px; margin: 0 auto var(--space-6); border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.empty-art::before { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); animation: spin 28s linear infinite; }

/* ---- skeleton page shapes (shimmer itself is in motion.css) ---- */
.sk-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; }
.sk-row + .sk-row { border-top: 1px solid var(--border); }
.sk-lines { flex: 1; }
.sk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-top: var(--space-6); }
.skeleton-search { height: 50px; border-radius: var(--radius-input); }
.skeleton-block.short { height: 8rem; }
.w20 { width: 20%; } .w30 { width: 30%; } .w35 { width: 35%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w60 { width: 60%; } .w65 { width: 65%; } .w70 { width: 70%; } .w80 { width: 80%; }
.h-title { height: 1.7rem; }

/* ---- settings ---- */
.settings-grid { display: grid; gap: var(--space-6); align-items: start; }
.settings-col { display: grid; gap: var(--space-6); min-width: 0; }
@media (min-width: 1100px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.settings .panel > h2 { font-size: var(--fs-h3); }
.settings .input { min-height: 46px; }
.settings .stack { gap: var(--space-4); }
.panel--danger { border-color: color-mix(in srgb, var(--negative) 35%, var(--border)); background: color-mix(in srgb, var(--negative) 4%, var(--surface)); }
.panel--danger > h2 { color: var(--negative); }
.settings .panel > h2 + * { margin-top: var(--space-4); }
.settings .stack > .btn { width: auto; }
.settings .row > .btn { flex: 0 1 auto; }
.profile-head { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-4); }
.profile-head h2 { font-size: var(--fs-h3); }
.theme-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.theme-opt { display: flex; flex-direction: column; gap: var(--space-2); align-items: stretch; padding: var(--space-2); border-radius: var(--radius-input); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 var(--fs-small) var(--font-sans); cursor: pointer; text-align: center; transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); touch-action: manipulation; }
.theme-opt:active { transform: scale(0.97); transition-duration: var(--dur-instant); }
.theme-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-prev { display: grid; gap: 4px; align-content: center; height: 54px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(128, 128, 128, 0.25); }
.theme-prev i { display: block; height: 6px; border-radius: 3px; }
.theme-prev i:nth-child(1) { width: 40%; } .theme-prev i:nth-child(2) { width: 75%; } .theme-prev i:nth-child(3) { width: 55%; }
.theme-prev--light { background: #F7F4EC; } .theme-prev--light i { background: #14181B; opacity: 0.8; } .theme-prev--light i:nth-child(2) { background: #0F5C45; opacity: 1; }
.theme-prev--dark { background: #0B0F0D; } .theme-prev--dark i { background: #F3F0E7; opacity: 0.8; } .theme-prev--dark i:nth-child(2) { background: #58B8A0; opacity: 1; }
.theme-prev--system { background: linear-gradient(115deg, #F7F4EC 50%, #0B0F0D 50%); } .theme-prev--system i { background: #8A918B; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(5.4rem + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: var(--space-3); overflow: hidden; background: var(--text); color: var(--bg); padding: var(--space-3) var(--space-4); border-radius: var(--radius-input); box-shadow: var(--shadow-3); font-size: var(--fs-small); max-width: calc(100vw - 2rem); }
.toast .icon { flex: none; color: color-mix(in srgb, var(--bg) 60%, var(--positive)); }
.toast.out { animation: toast-out var(--dur-fast) var(--ease-out) forwards; }
.toast .toast-btn { color: var(--bg); text-decoration-color: color-mix(in srgb, var(--bg) 50%, transparent); }
.toast-timer { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; background: color-mix(in srgb, var(--bg) 55%, transparent); animation: toast-timer var(--ttl, 3.8s) linear forwards; }
.toast:hover .toast-timer, .toast:focus-within .toast-timer { animation-play-state: paused; }
@keyframes toast-timer { to { transform: scaleX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); } }
@media (min-width: 1024px) { .toast { bottom: var(--space-8); } }

/* ---- vertical rhythm inside a view ---- */
.flow > * + * { margin-top: var(--space-8); }
.flow > .back + * { margin-top: var(--space-2); }
.ws-outlet > .flow, .ws-outlet > div { display: block; }

/* ---- search and commands (Ctrl+K) ---- */
.palette-btn { display: inline-flex; }
.ws.is-focus .palette-btn { display: none; } /* a form is open: do not offer a jump away from it */
.side-top { display: flex; flex-direction: column; gap: var(--space-4); }
.side-search { display: none; align-items: center; gap: var(--space-3); width: 100%; min-height: 44px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-input); background: var(--surface); color: var(--text-muted); font: 400 var(--fs-small) var(--font-sans); cursor: pointer; text-align: left; transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.side-search-text { flex: 1; }
@media (hover: hover) { .side-search:hover { border-color: color-mix(in srgb, var(--text-muted) 55%, var(--border-strong)); color: var(--text); } }
@media (min-width: 1024px) { .side-search { display: flex; } .palette-btn { display: none; } }
.ws.is-focus .side-search { opacity: 0.5; pointer-events: none; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5em; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); color: var(--text-muted); font: 500 var(--fs-caption)/1.2 var(--font-sans); }

.palette-scrim { position: fixed; inset: 0; z-index: 110; display: flex; align-items: flex-start; justify-content: center; padding: calc(var(--space-4) + env(safe-area-inset-top)) var(--space-4) var(--space-4); background: var(--overlay); animation: fade var(--dur-base) var(--ease-out) both; }
.palette-scrim.out { animation: fade-out var(--dur-fast) var(--ease-out) forwards; }
.palette { display: flex; flex-direction: column; width: 100%; max-width: 36rem; max-height: min(34rem, calc(100dvh - 2rem)); overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-highlight), var(--shadow-3); animation: dialog-in var(--dur-base) var(--ease-out) both; }
.palette-scrim.out .palette { animation: dialog-out var(--dur-fast) var(--ease-out) forwards; }
.palette-search { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) 0 var(--space-4); border-bottom: 1px solid var(--border); color: var(--text-muted); }
.palette-search > .icon { flex: none; }
.palette-input { flex: 1; min-width: 0; min-height: 56px; border: 0; background: transparent; color: var(--text); font: 400 max(16px, var(--fs-body)) var(--font-sans); }
.palette-input::placeholder { color: color-mix(in srgb, var(--text-muted) 75%, transparent); }
.palette-input:focus, .palette-input:focus-visible { outline: none; }
.palette-search:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.palette-close { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--radius-input); background: transparent; color: var(--text-muted); cursor: pointer; }
@media (hover: hover) { .palette-close:hover { background: var(--surface-2); color: var(--text); } }
.palette-list { flex: 1; min-height: 0; margin: 0; padding: var(--space-2); overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.palette-group { padding: var(--space-3) var(--space-3) var(--space-1); color: var(--text-muted); font: 600 var(--fs-caption)/1 var(--font-sans); letter-spacing: 0.04em; text-transform: uppercase; }
.palette-item { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-input); cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.palette-ico { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--accent); }
.palette-item[aria-selected="true"] .palette-ico { background: var(--surface); }
.palette-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-sub { color: var(--text-muted); font-size: var(--fs-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-go { flex: none; color: var(--accent); opacity: 0; transform: translateX(-4px); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.palette-item[aria-selected="true"] .palette-go { opacity: 1; transform: none; }
.palette-none { padding: var(--space-6) var(--space-4); color: var(--text-muted); font-size: var(--fs-small); text-align: center; }
.palette-keys { display: none; margin: 0; padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-caption); gap: var(--space-4); }
.palette-keys span { display: inline-flex; align-items: center; gap: 4px; }
@media (hover: hover) and (min-width: 640px) { .palette-keys { display: flex; } }
@media (min-width: 640px) { .palette-scrim { padding-top: max(var(--space-8), 12vh); } }

/* ---- getting-started checklist (Home) ---- */
.setup-head { margin-bottom: var(--space-3); align-items: flex-start; }
.setup-head .sub { margin-top: 2px; }
.setup-bar { height: 4px; margin-bottom: var(--space-2); border-radius: 2px; background: var(--border); overflow: hidden; }
.setup-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform var(--dur-slow) var(--ease-out); animation: setup-fill var(--dur-hero) var(--ease-out) both; }
@keyframes setup-fill { from { transform: scaleX(0); } }
.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-step { display: flex; align-items: center; gap: var(--space-3); min-height: 60px; padding: var(--space-3) 0; }
.setup-step + .setup-step { border-top: 1px solid var(--border); }
.setup-check { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border: 1.5px solid var(--border-strong); border-radius: 50%; color: var(--on-accent); transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.setup-step.is-done .setup-check { border-color: var(--accent); background: var(--accent); }
.setup-text { flex: 1; min-width: 0; }
.setup-title { margin: 0; font-weight: 600; }
.setup-step.is-done .setup-title { color: var(--text-muted); font-weight: 500; }
.setup-text .sub { margin-top: 2px; }
.setup-step > .btn { flex: none; }
@media (max-width: 519.98px) { .setup-step { flex-wrap: wrap; } .setup-text { flex-basis: calc(100% - 26px - var(--space-3)); } .setup-step > .btn { margin-left: calc(26px + var(--space-3)); } }
.mini-empty--action { flex-wrap: wrap; }
.mini-empty--action .link-btn { min-height: 0; padding: 0; }

/* ---- small phones: keep the top bar on one line ---- */
@media (max-width: 380px) { .chip-status { display: none; } .topbar-actions { gap: 0; } }
@media (max-width: 340px) { .topbar .icon-btn { width: 40px; } }
/* First-run card on phones: the two buttons sit one above the other at full width, so their labels stay on one line. */
@media (max-width: 519.98px) { .empty--hero .row { flex-direction: column; } .empty--hero .row > .btn { flex: none; width: 100%; } }

/* ======== 4E: Home ======== */
.home-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.home-greet { margin: 0 0 2px; color: var(--text-muted); font-size: var(--fs-small); font-weight: 500; }
.chip--plain { margin-left: 0; padding: 6px 12px; font-size: var(--fs-caption); vertical-align: baseline; }

.qa-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-2); margin-top: var(--space-6); }
.qa { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: 0; border: 0; background: none; color: var(--text); text-decoration: none; cursor: pointer; font: 500 var(--fs-caption)/1.2 var(--font-sans); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.qa-ico { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--accent); transition: transform var(--dur-base) var(--ease-spring), background var(--dur-fast) var(--ease-out); }
.qa:active .qa-ico { transform: scale(0.92); transition-duration: var(--dur-instant); }
@media (hover: hover) { .qa:hover .qa-ico { background: var(--accent-soft); } }
.qa-label { color: var(--text-muted); }
.growth-note--plain { margin: var(--space-4) 0 0; max-width: none; text-align: left; }

.see-all { display: inline-flex; align-items: center; min-height: var(--tap-min); color: var(--accent); font: 500 var(--fs-small) var(--font-sans); text-decoration: none; }
.cards { display: flex; gap: var(--space-3); margin: 0 calc(var(--space-4) * -1); padding: 0 var(--space-4) var(--space-2); list-style: none; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--space-4); scrollbar-width: none; }
.cards::-webkit-scrollbar { display: none; }
.cards > li { flex: none; scroll-snap-align: start; }
@media (min-width: 1024px) { .cards { margin-inline: 0; padding-inline: 0; scroll-padding-inline: 0; } }
.inv-card { display: flex; flex-direction: column; align-items: flex-start; width: 11.5rem; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--card-highlight), var(--shadow-1); color: inherit; text-decoration: none; transition: transform var(--dur-base) var(--ease-spring), border-color var(--dur-fast) var(--ease-out); }
.inv-card:active { transform: scale(0.98); transition-duration: var(--dur-instant); }
@media (hover: hover) { .inv-card:hover { border-color: var(--border-strong); } }
.inv-card .tile { margin-bottom: var(--space-3); }
.inv-card-name, .inv-card-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-card-name { font-weight: 600; }
.inv-card-sub { color: var(--text-muted); font-size: var(--fs-caption); }
.inv-card-val { margin: var(--space-3) 0 var(--space-2); font: 500 var(--fs-h3)/1.2 var(--font-serif); }

/* The checklist is one slim line; it opens in place. */
.setup { padding: var(--space-2) var(--space-4); }
.setup-toggle { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 60px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.setup-toggle-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.setup-toggle-text .sub { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-toggle > .icon { flex: none; color: var(--text-muted); transition: transform var(--dur-base) var(--ease-out); }
.setup-toggle[aria-expanded="true"] > .icon { transform: rotate(90deg); }
.setup-ring { position: relative; flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p, 0) * 1turn), var(--border) 0); font: 600 11px var(--font-sans); font-variant-numeric: tabular-nums; }
.setup-ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.setup-ring > span { position: relative; }
.setup-more { padding-bottom: var(--space-2); }
.setup-foot { display: flex; justify-content: flex-end; }

.dash-main, .dash-side { grid-template-columns: minmax(0, 1fr); } /* a wide child (the cards strip) must scroll inside its own box, never stretch the page */
.dash-main > *, .dash-side > * { min-width: 0; }

/* ---- Settings: text size slider and its live preview ---- */
.size-control { display: grid; gap: var(--space-4); }
.size-preview { --pv: 1; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-2); overflow: hidden; }
.size-preview > p { margin: 0; }
.size-preview-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); font: 600 calc(0.8125rem * var(--pv))/1.2 var(--font-sans); letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); transition: font-size var(--dur-fast) var(--ease-out); }
.size-preview-name { color: var(--accent); }
.size-preview-amount { margin: var(--space-3) 0 var(--space-2); font: 500 calc(1.9rem * var(--pv))/1.15 var(--font-serif); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; transition: font-size var(--dur-fast) var(--ease-out); }
.size-preview-amount .dec { font-size: 0.55em; color: var(--text-muted); font-weight: 400; }
.size-preview-text { font: 400 calc(1rem * var(--pv))/1.5 var(--font-sans); color: var(--text-muted); transition: font-size var(--dur-fast) var(--ease-out); }


/* Layout guards: nothing inside a page may be wider than the page. Without these a long field or a long label pushes the whole
   screen sideways (and the tab bar with it). */
.ws-main, .ws-outlet, .flow, .flow > *, .panel, .stack > *, fieldset { min-width: 0; }
.panel .input, .panel .seg, .panel select { max-width: 100%; }

/* ---- Outlook charts (band and stacked areas). Colours are tokens only; no motion, so Reduce Motion needs nothing extra ---- */
.chart .band { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: none; }
.chart .band-edge { fill: none; stroke: var(--accent); stroke-opacity: 0.45; stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart .line-base { fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .layer { stroke: var(--surface); stroke-width: 1; fill-opacity: 0.88; }
.chart .layer-1 { fill: var(--chart-1); } .chart .layer-2 { fill: var(--chart-2); } .chart .layer-3 { fill: var(--chart-3); }
.chart .layer-4 { fill: var(--chart-4); } .chart .layer-5 { fill: var(--chart-5); } .chart .layer-6 { fill: var(--chart-6); }
.chart .bar-in { fill: var(--accent); } .chart .bar-out { fill: var(--chart-5); }
.chart .hit:focus { outline: none; }
.chart .hit:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.legend-inline .band-key::before { width: 18px; height: 10px; border: 0; border-radius: 3px; background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---- Swipe actions on investment list rows (touch). The row slides over two buttons; reduced motion removes the slide ---- */
.swipe-row { position: relative; overflow: hidden; margin: 0 calc(var(--space-3) * -1); border-radius: var(--radius-input); }
.swipe-row .row-line { margin: 0; }
.swipe-actions { position: absolute; inset: 0 0 0 auto; display: flex; width: calc(var(--swipe-w, 168px)); }
.swipe-btn { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0 var(--space-2); background: var(--accent); color: var(--on-accent); font-size: var(--fs-caption); font-weight: 600; text-align: center; text-decoration: none; }
.swipe-btn--alt { background: var(--accent-soft); color: var(--accent-strong); }
.swipe-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -4px; }
.swipe-front { position: relative; background: var(--surface); transform: translateX(var(--swipe-x, 0px)); transition: transform var(--dur-base) var(--ease-out); touch-action: pan-y; }
.swipe-front.dragging { transition: none; }
@media (prefers-reduced-motion: reduce) { .swipe-front { transition: none; } }
.swipe-hint { display: none; margin: 0 0 var(--space-2); }
@media (pointer: coarse) { .swipe-hint { display: block; } }
