/* App shell: sidebar + canvas (+ right rail) on desktop, top bar + menu sheet on mobile.
   Breakpoints (from the Figma desktop 1440 / mobile 390 frames, interpolated):
   ≥1280 full · 1140–1279 narrower rail · 900–1139 rail stacks under main · <900 mobile shell · <600 phone */

html, body { height: 100%; }
body.app-body { overflow: hidden; }

.app { display: flex; height: 100dvh; padding: 12px 12px 12px 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px 16px;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
  view-transition-name: sidebar;
}
.sidebar::-webkit-scrollbar { display: none; }
/* Logo — Figma "Logo / Lockup — horizontal" (651:2393): the mark + the custom wordmark, 162×24 at the 24px base.
   --logo-h scales the whole lockup with Figma's proportions (mark 24.2 wide, wordmark from 20.91% of the width,
   128.1×21.2, centred). The wordmark is a mask, so it takes the text colour; the word stays in the DOM for readers. */
.logo, .lockup { --logo-h: 24px; display: inline-flex; align-items: center; gap: calc(var(--logo-h) * 0.40313); color: var(--vm-text-primary); }
.logo { padding-left: 12px; }
.logo .ic, .lockup .ic { width: calc(var(--logo-h) * 1.0083); height: var(--logo-h); }
.logo:hover .ic { transform: rotate(-6deg); }
.logo-word {
  flex-shrink: 0; width: calc(var(--logo-h) * 5.33883); height: calc(var(--logo-h) * 0.88393);
  font-size: 0; line-height: 0; overflow: hidden; background-color: currentColor;
  -webkit-mask: url(/assets/icons/wordmark.svg) center / 100% 100% no-repeat;
  mask: url(/assets/icons/wordmark.svg) center / 100% 100% no-repeat;
}

.nav { display: flex; flex-direction: column; gap: 2px; position: relative; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px; border-radius: var(--vm-radius-md);
  font-size: 14px; font-weight: 500; color: var(--vm-text-secondary);
  transition: color var(--dur-2) ease, background-color var(--dur-2) ease;
}
.nav-item > span:not(.ic):not(.badge) { flex: 1; min-width: 0; }
.nav-item .ic { --s: 20px; }
.nav-item:hover { color: var(--vm-text-primary); background: rgba(255, 255, 255, 0.5); }
/* Sidebar icons use the shared quiet hover motion (components.css): home lifts, funds tilts left, the list
   slides, updates tilts right, documents nods, the gear turns, help hops, log out heads out */
.nav-item:hover .ic { transform: var(--hm); animation: var(--ha); }
.nav-item.is-active { color: var(--vm-text-primary); background: transparent; }
/* The white active pill is its own element so it can glide between items across page loads */
.nav-pill {
  position: absolute; inset: 0; z-index: -1;
  background: var(--vm-surface-page); border-radius: var(--vm-radius-md);
  box-shadow: var(--vm-shadow-nav);
  view-transition-name: nav-pill;
}
.nav-item { isolation: isolate; }
.nav-item:active { transform: scale(0.985); }
.sidebar-spacer { flex: 1; }

/* Profile block (Figma "Sidebar"): black avatar, name and status on the app background. Display only. */
.user {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 6px 6px 8px; margin: -6px 0 0;
  text-align: left; cursor: default; user-select: none; -webkit-user-select: none;
}
.user-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-status { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--vm-text-secondary); white-space: nowrap; }

/* ---------- Canvas ---------- */
.canvas {
  flex: 1; min-width: 0; position: relative;
  background: var(--vm-surface-page); border-radius: var(--vm-radius-2xl);
  box-shadow: var(--vm-shadow-control);
  overflow: hidden;
  view-transition-name: canvas;
}
.canvas-scroll { height: 100%; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.page { display: flex; min-height: 100%; align-items: stretch; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 32px; padding: 32px 36px 36px; }
.rail {
  width: var(--rail-w); flex-shrink: 0;
  display: flex; flex-direction: column; gap: 22px;
  padding: 32px 28px 28px; border-left: 1px solid var(--vm-border-subtle);
}
.rail-spacer { flex: 1; }
/* Desktop: the right rail stays put and fits the window — sticky, its own scroll when it's taller than the
   window. No scrollbar of its own (it sat next to the page's and read as a double scroll); instead the edge
   with more content behind it fades out (app.js sets .is-more-above / .is-more-below). The 1px mask strip
   on the left keeps the border solid. */
@property --rail-fade-t { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --rail-fade-b { syntax: "<length>"; inherits: false; initial-value: 0px; }
@media (min-width: 1140px) {
  .rail {
    position: sticky; top: 0; align-self: flex-start; height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto;
    scrollbar-width: none;
    -webkit-mask: linear-gradient(#000, #000) left / 1px 100% no-repeat, linear-gradient(transparent, #000 var(--rail-fade-t), #000 calc(100% - var(--rail-fade-b)), transparent);
    mask: linear-gradient(#000, #000) left / 1px 100% no-repeat, linear-gradient(transparent, #000 var(--rail-fade-t), #000 calc(100% - var(--rail-fade-b)), transparent);
    transition: --rail-fade-t var(--dur-3) ease, --rail-fade-b var(--dur-3) ease;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail.is-more-above { --rail-fade-t: 36px; }
  .rail.is-more-below { --rail-fade-b: 56px; }
}

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-head-titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-title { font-size: 26px; font-weight: 600; letter-spacing: -0.52px; }
.page-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--vm-text-secondary); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.back-btn { margin-right: 16px; }
.back-btn .ic { transition: transform var(--dur-2) var(--ease-out); }
.back-btn:hover .ic { transform: translateX(-2px); }

/* ---------- Mobile top bar, floating tab bar, More sheet ---------- */
.topbar, .tabbar, .menu-sheet, .more-scrim { display: none; }

/* Floating tab bar (≤899px): a fully rounded white bar floating above the page — Overview · Funds · Transactions · More.
   Same language as the sidebar, inverted: a grey pill on white marks the active tab. */
.tabbar {
  --tb-pad: 6px;
  /* four equal cells — the active pill and the hover shape are the same size on every tab */
  grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px;
  position: fixed; z-index: 55; left: 0; right: 0; bottom: calc(var(--tabbar-gap) + env(safe-area-inset-bottom));
  width: calc(100% - 2 * var(--tabbar-gap)); max-width: var(--tabbar-max); height: var(--tabbar-h); margin: 0 auto;
  padding: var(--tb-pad);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border: 1px solid rgba(26, 23, 18, 0.06); border-radius: 999px;
  box-shadow: var(--vm-shadow-menu);
  view-transition-name: tabbar;
}
.tabbar.is-open { z-index: 58; }
.tab {
  position: relative; z-index: 1; min-width: 0; padding: 0 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-radius: 999px; color: var(--vm-text-secondary);
  font-size: 10px; font-weight: 500; line-height: 1;
  transition: color var(--dur-2) ease, background-color var(--dur-2) ease, transform var(--dur-1) ease;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
.tab .ic { --s: 22px; }
.tab-label { max-width: 100%; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.is-active { color: var(--vm-text-primary); }
.tab:active { transform: scale(0.94); }
/* hover (mouse only) fills the same cell the active pill does */
@media (hover: hover) {
  .tab:not(.tab-more):hover .ic { transform: var(--hm); animation: var(--ha); }
  .tab:hover { color: var(--vm-text-primary); }
  .tab:not(.is-active):hover { background: var(--vm-hover-soft); }
  .tabbar.is-open .tab-more:hover { background: none; }
}
.tab-pill {
  position: absolute; z-index: 0; top: var(--tb-pad); bottom: var(--tb-pad); left: 0; width: 0;
  border-radius: 999px; background: var(--vm-surface-card);
  transition: transform 420ms var(--ease-out), width 420ms var(--ease-out), opacity var(--dur-2) ease;
  view-transition-name: tab-pill;
}
/* More: the grid turns into a close mark while its sheet is open */
.tab-icons { position: relative; width: 22px; height: 22px; }
.tab-icons .ic { position: absolute; inset: 0; transition: transform 340ms var(--ease-out), opacity var(--dur-2) ease; }
.tab-ic-close { opacity: 0; transform: rotate(-90deg); }
.tabbar.is-open .tab-ic-more { opacity: 0; transform: rotate(90deg); }
.tabbar.is-open .tab-ic-close { opacity: 1; transform: none; }

/* More sheet: a floating card that rises from the tab bar */
.more-scrim {
  position: fixed; inset: 0; z-index: 56; background: var(--vm-scrim); touch-action: none;
  animation: vm-fade 260ms ease both;
}
.more-scrim.is-closing { animation: vm-fade 200ms ease reverse forwards; }
.menu-sheet {
  flex-direction: column; gap: 2px;
  position: fixed; z-index: 57; left: 0; right: 0; margin: 0 auto;
  bottom: calc(var(--tabbar-gap) + var(--tabbar-h) + 8px + env(safe-area-inset-bottom));
  width: calc(100% - 2 * var(--tabbar-gap)); max-width: var(--tabbar-max);
  max-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 40px); overflow-y: auto; overscroll-behavior: contain;
  padding: 8px; background: var(--vm-surface-page); border-radius: var(--vm-radius-2xl);
  box-shadow: var(--vm-shadow-pop);
  transform-origin: 90% 100%;
  animation: vm-more-in 380ms var(--ease-out) both;
}
.menu-sheet.is-closing { animation: vm-more-out 200ms var(--ease-in-out) forwards; }
@keyframes vm-more-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
@keyframes vm-more-out { to { opacity: 0; transform: translateY(10px) scale(0.98); } }
.menu-sheet > * { animation: vm-rise 380ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms + 50ms); }
.menu-sheet .user { margin: 0; padding: 10px 10px 14px; border-bottom: 1px solid var(--vm-border-default); margin-bottom: 6px; }
.menu-sheet .nav-item { height: 48px; }
.menu-sheet .nav-item:hover { background: var(--vm-hover-soft); }
.menu-sheet .nav-pill { background: var(--vm-surface-card); box-shadow: none; view-transition-name: none; }
.menu-sheet-sep { height: 1px; margin: 6px 0; background: var(--vm-border-default); }

/* ---------- Prototype navigator (demo helper) ---------- */
/* Compact circle in the bottom-right corner; expands to show its label on hover */
.proto-fab {
  position: fixed; z-index: 65; right: 22px; bottom: 22px;
  display: inline-flex; align-items: center; gap: 0; height: 34px; min-width: 34px; padding: 0 11px;
  border-radius: 17px; background: rgba(26, 25, 23, 0.82); color: #fff; font-size: 12px; font-weight: 500; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.35);
  opacity: 0.5; transition: opacity var(--dur-2) ease, gap var(--dur-3) var(--ease-out);
  animation: vm-fade 600ms ease 1.2s both;
}
.proto-fab-label { max-width: 0; overflow: hidden; transition: max-width var(--dur-3) var(--ease-out); }
.proto-fab:hover, .proto-fab.is-active, .proto-fab:focus-visible { opacity: 1; gap: 8px; }
.proto-fab:hover .proto-fab-label, .proto-fab.is-active .proto-fab-label, .proto-fab:focus-visible .proto-fab-label { max-width: 80px; }
.proto-fab-dot { width: 12px; height: 12px; flex-shrink: 0; background:
  radial-gradient(circle, #fff 1.6px, transparent 2px) 0 0 / 6px 6px; }
@media (max-width: 899px) {
  /* sits just above the floating tab bar (or a page's own floating action bar) */
  .proto-fab { right: 14px; bottom: calc(var(--tabbar-gap) + var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
  /* sign-in / onboarding screens keep their bottom links clear on phones */
  .auth-body .proto-fab { display: none; }
}
.proto-pop { z-index: 96; }
.proto-nav { width: 260px; max-height: min(560px, calc(100dvh - 80px)); overflow-y: auto; padding: 8px; }
.proto-group { padding: 4px 0 6px; }
.proto-group + .proto-group { border-top: 1px solid var(--vm-border-default); }
.proto-group p { padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--vm-text-tertiary); }
.proto-nav .menu-item { padding: 7px 10px; font-weight: 400; }
.proto-nav .menu-item.is-here { background: var(--vm-surface-card); font-weight: 500; }
.proto-hide { width: 100%; margin-top: 4px; padding: 8px; border-top: 1px solid var(--vm-border-default); font-size: 12px; color: var(--vm-text-tertiary); }
.proto-hide:hover { color: var(--vm-text-primary); }
.popover { z-index: 85; }

/* ---------- Responsive ---------- */
@media (max-width: 1279px) {
  :root { --rail-w: 300px; }
  .main { padding: 28px 28px 32px; }
  .rail { padding: 28px 24px 24px; }
}
@media (max-width: 1139px) {
  .page { flex-direction: column; }
  .rail { width: auto; border-left: 0; border-top: 1px solid var(--vm-border-subtle); padding: 28px; display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 22px 28px; }
  .rail-spacer { display: none; }
}
@media (max-width: 899px) {
  body.app-body { overflow: auto; background: var(--vm-surface-page); }
  .app { display: block; height: auto; padding: 0; }
  .sidebar { display: none; }
  .canvas { border-radius: 0; box-shadow: none; overflow: visible; }
  .canvas-scroll { height: auto; overflow: visible; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50; height: var(--topbar-h); padding: 0 20px;
    background: rgba(255, 255, 255, 0.86); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--vm-border-default);
    view-transition-name: topbar;
  }
  .topbar .logo { padding-left: 0; }
  .topbar-actions { display: flex; align-items: center; gap: 8px; }
  .tabbar { display: grid; }
  .menu-sheet { display: flex; }
  .more-scrim { display: block; }
  /* leave room under the last section for the floating tab bar */
  .app-body .canvas-scroll { padding-bottom: calc(var(--tabbar-h) + var(--tabbar-gap) * 2 + env(safe-area-inset-bottom)); }
  .app-body .toasts { bottom: calc(var(--tabbar-gap) + var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }
  .main { padding: 12px 20px 32px; gap: 24px; }
  /* when the stacked rail follows, the main column ends one content gap (24px) above the divider — same as below it */
  .page > .main:not(:last-child) { padding-bottom: 24px; }
  .page-actions { display: none; }
  .page-actions.keep-mobile { display: flex; }
  .rail { padding: 24px 20px 32px; }
}
@media (max-width: 639px) {
  .rail { display: flex; flex-direction: column; align-items: stretch; border-top: 0; padding-top: 0; }
  .rail::before { content: ""; height: 1px; background: var(--vm-border-default); margin-bottom: 2px; }
}
