/* Marlin: design system
   ------------------------------------------------------------------------------------------
   Design read: a private personal-finance dashboard for one owner who checks it often,
   calm and precise (Linear / Mercury family), built with native CSS tokens, Geist and
   Phosphor icons, no framework.
   Dials (Taste skill): DESIGN_VARIANCE 4, MOTION_INTENSITY 4, VISUAL_DENSITY 6.
   Locks:
     - One accent (blue). Status colors (good / warning / critical) only for state, always with text.
     - One gray family (cool neutral). Never pure #000 or #fff.
     - Radius rule: panels and floating layers 12px, controls 8px, small items (chips, badges,
       menu items, segmented thumb) 6px, logo tiles = size / 4.
     - Theme: follows the system unless Settings pins Light or Dark ([data-theme] on <html>).
   Tokens use light-dark(), so each color is defined once for both themes.
   Full rules for future pages: .claude/skills/finance-app-ui/SKILL.md */

@font-face {
  font-family: 'Geist';
  src: url('/assets/fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  /* Surfaces */
  --page: light-dark(#f4f5f7, #0b0d10);
  --surface: light-dark(#fcfcfd, #14171b);
  --surface-2: light-dark(#f2f4f7, #1b1f24);
  --surface-3: light-dark(#e8ebf0, #242a31);
  --line: light-dark(#e3e6eb, #272c33);
  --line-strong: light-dark(#cbd1d9, #373e47);
  --control: light-dark(#848b96, #6c737e);       /* input and secondary button borders, 3:1 */

  /* Ink */
  --ink: light-dark(#0e1116, #eceef1);
  --ink-2: light-dark(#464d58, #b6bcc5);
  --ink-3: light-dark(#646b77, #8f96a0);          /* muted text, still 4.5:1 on surfaces */

  /* The one accent */
  --accent: light-dark(#2a78d6, #3987e5);         /* chart marks, meters */
  --accent-text: light-dark(#1f63c0, #7db1f2);    /* links, focus rings, active states */
  --accent-wash: light-dark(#e6eefb, #16283f);
  --accent-track: light-dark(#d3e3f8, #1b3353);

  /* Status (never used for identity) */
  --pos: light-dark(#0f7a3e, #48c78a);            /* money in */
  --warn: light-dark(#8a5700, #f2bd4b);
  --warn-fill: light-dark(#e8a317, #f2bd4b);
  --warn-track: light-dark(#f7e6c0, #3a2f16);
  --warn-wash: light-dark(#fff6e0, #2a2112);
  --warn-line: light-dark(#f0d59a, #5a4718);
  --crit: light-dark(#b3261e, #f28b82);
  --crit-fill: light-dark(#d03b3b, #e05252);
  --crit-track: light-dark(#f6d5d5, #3d1f1f);
  --danger-bg: light-dark(#c2362f, #f28b82);
  --danger-ink: light-dark(#fcfcfd, #14171b);

  /* Charts */
  --viz-accent: var(--accent);
  --viz-muted: light-dark(#868d98, #646c77);      /* de-emphasis series */
  /* Categorical series (dataviz reference order, validated against --surface in both modes; the light
     aqua is under 3:1, so every chart using it has direct end labels and a table view) */
  --viz-1: var(--accent);                          /* blue */
  --viz-2: light-dark(#eb6834, #d95926);           /* orange */
  --viz-3: light-dark(#1baf7a, #199e70);           /* aqua */
  --viz-4: light-dark(#eda100, #c98500);           /* yellow (light: under 3:1, labels and table required) */
  --viz-grid: var(--line);
  --viz-axis: var(--line-strong);

  /* Depth: tinted, barely there */
  --shadow-1: 0 1px 2px light-dark(rgb(14 17 22 / 4%), rgb(0 0 0 / 35%));
  --shadow-float: 0 14px 36px -10px light-dark(rgb(14 17 22 / 20%), rgb(0 0 0 / 65%)),
                  0 2px 6px light-dark(rgb(14 17 22 / 6%), rgb(0 0 0 / 35%));

  /* Shape */
  --r-panel: 12px;
  --r-control: 8px;
  --r-small: 6px;

  /* Type */
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 120ms;
  --med: 200ms;

  /* Layout */
  --topbar-h: 60px;
  --tabbar-h: 64px;
  --max: 1280px;
  --gutter: 24px;

  /* Layers */
  --z-header: 20;
  --z-drawer: 35;
  --z-popover: 40;
  --z-tooltip: 50;
  --z-toast: 60;
}
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
::selection { background: var(--accent-wash); }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }
[tabindex='-1']:focus { outline: none; } /* headings focused after navigation */

.icon { width: 16px; height: 16px; flex: none; fill: currentColor; }
.icon-lg { width: 20px; height: 20px; }
.muted { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.pos { color: var(--pos); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: calc(var(--z-header) + 1);
  background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: var(--r-control);
}
.skip-link:focus { top: 12px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--page) 84%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--max); height: 100%; margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 28px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; display: block; }

.nav { display: flex; gap: 2px; }
.nav a {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: var(--r-control); color: var(--ink-2); font-weight: 500;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current='page'] { background: var(--accent-wash); color: var(--accent-text); }
.nav .icon { width: 17px; height: 17px; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-status { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.sync-status .icon { width: 14px; height: 14px; color: var(--warn); }
.avatar-btn {
  width: 32px; height: 32px; border-radius: var(--r-control); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  display: inline-grid; place-items: center; transition: background var(--fast) var(--ease);
}
.avatar-btn:hover { background: var(--surface-3); }

.tabbar { display: none; }

main { max-width: var(--max); margin: 0 auto; padding: 28px var(--gutter) 72px; outline: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.page-head .sub { margin-top: 4px; color: var(--ink-3); font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.stack { display: grid; gap: 16px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: var(--shadow-1); padding: 20px 22px; min-width: 0;
}
.panel-flush { padding: 0; overflow: clip; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 30px; }
.panel-flush > .panel-head { padding: 16px 22px 0; }
.panel-head h2, .panel-head h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head .tools { display: flex; align-items: center; gap: 6px; }
.panel-foot { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; gap: 28px; flex-wrap: wrap; }
.footnote { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }

/* Figures */
.figure-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hero-figure { font-size: 48px; line-height: 1.05; font-weight: 600; letter-spacing: -0.035em; margin-top: 6px; }
.stat-value { font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -0.025em; margin-top: 4px; }
.mini-stat .label { font-size: 12.5px; color: var(--ink-3); }
.mini-stat .value { font-size: 15px; font-weight: 600; margin-top: 2px; }
.delta { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.delta .icon { width: 14px; height: 14px; }
.split-figures { display: flex; gap: 28px; margin-top: 14px; flex-wrap: wrap; }

/* Net worth panel: figure left, trend right */
.networth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 32px; align-items: end; height: 100%; }
.networth .figures { align-self: start; }
.sparkline { display: block; width: 100%; height: auto; overflow: visible; }
.sparkline .line { fill: none; stroke: var(--viz-muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sparkline .area { fill: var(--viz-muted); opacity: 0.08; }
.sparkline .dot { fill: var(--viz-accent); stroke: var(--surface); stroke-width: 2; }
.trend-caption { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; text-align: right; }
.trend-empty { font-size: 13px; color: var(--ink-3); text-align: right; max-width: 34ch; justify-self: end; }

/* Balances by type */
.type-list { display: grid; gap: 2px; }
.type-row {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 10px; margin: 0 -10px; border-radius: var(--r-control); color: var(--ink);
  transition: background var(--fast) var(--ease);
}
.type-row:hover { background: var(--surface-2); text-decoration: none; }
.type-icon {
  width: 32px; height: 32px; border-radius: var(--r-control); background: var(--surface-2); color: var(--ink-2);
  display: grid; place-items: center;
}
.type-row:hover .type-icon { background: var(--surface-3); }
.type-row .name { font-weight: 500; }
.type-row .meta { font-size: 12.5px; color: var(--ink-3); }
.type-row .amount { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-control); border: 1px solid transparent;
  font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--page)); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--control); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger-ink); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger-bg) 88%, var(--ink)); }
.btn-danger-quiet { background: transparent; color: var(--crit); border-color: color-mix(in srgb, var(--crit) 45%, transparent); }
.btn-danger-quiet:hover:not(:disabled) { background: color-mix(in srgb, var(--crit) 8%, transparent); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn .icon { width: 16px; height: 16px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-text); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--ink-3); }
.input, .select {
  height: 36px; width: 100%; min-width: 0; padding: 0 12px; border-radius: var(--r-control);
  border: 1px solid var(--control); background: var(--surface); color: var(--ink);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:disabled { background: var(--surface-2); color: var(--ink-2); border-color: var(--line); cursor: not-allowed; }
.input:focus-visible, .select:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; border-color: var(--accent-text); }
.input-wrap { position: relative; }
.input-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-wrap .input { padding-left: 34px; }
.input[type='search']::-webkit-search-cancel-button { -webkit-appearance: none; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; }
.select-wrap { position: relative; }
.select-wrap .icon { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }

/* Trigger button that opens a menu (looks like a select) */
.menu-trigger {
  height: 36px; width: 100%; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  border-radius: var(--r-control); border: 1px solid var(--control); background: var(--surface); text-align: left;
  transition: background var(--fast) var(--ease);
}
.menu-trigger:hover { background: var(--surface-2); }
.menu-trigger .label-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-trigger .icon.caret { color: var(--ink-3); }
.menu-trigger[aria-expanded='true'] { border-color: var(--accent-text); }
.menu-trigger.is-active { border-color: var(--accent-text); background: var(--accent-wash); color: var(--accent-text); }

/* Segmented control (radio group) */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-control);
  background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-small); background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-checked='true'] { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-1); }
.segmented .count { color: var(--ink-3); font-weight: 400; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ---------- Popover menus ---------- */
.popover {
  position: fixed; z-index: var(--z-popover); min-width: 240px; max-width: min(360px, calc(100vw - 24px));
  max-height: min(440px, 70vh); overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-float);
  animation: pop-in var(--med) var(--ease) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } }
.menu-group + .menu-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.menu-heading { display: flex; align-items: center; gap: 8px; padding: 8px 10px 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.menu-item {
  width: 100%; min-height: 36px; display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border: 0; border-radius: var(--r-small); background: transparent; color: var(--ink); text-align: left; font-size: 14px;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-text); }
.menu-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .count { color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.menu-item .check { width: 16px; height: 16px; color: var(--accent-text); visibility: hidden; }
.menu-item[aria-checked='true'] .check, .menu-item[aria-selected='true'] .check { visibility: visible; }
.menu-item[aria-checked='true'] { font-weight: 500; }
.menu-item.is-dim .grow { color: var(--ink-3); }
.checkbox {
  width: 16px; height: 16px; flex: none; border-radius: 4px; border: 1px solid var(--control); background: var(--surface);
  display: grid; place-items: center; color: var(--surface);
}
.checkbox .icon { width: 12px; height: 12px; visibility: hidden; }
.menu-item[aria-checked='true'] .checkbox { background: var(--accent-text); border-color: var(--accent-text); }
.menu-item[aria-checked='true'] .checkbox .icon { visibility: visible; }
.menu-foot { display: flex; justify-content: space-between; gap: 8px; padding: 8px 6px 2px; margin-top: 4px; border-top: 1px solid var(--line); }
.menu-note { padding: 8px 10px 4px; font-size: 12.5px; color: var(--ink-3); max-width: 34ch; }
.menu-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 6px 4px; }
.menu-range .btn { grid-column: span 2; }
.user-card { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-card .name { font-weight: 600; }
.user-card .email { font-size: 12.5px; color: var(--ink-3); }
.menu-theme { display: grid; gap: 6px; padding: 6px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-theme-label { padding: 0 4px; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.menu-theme .segmented { display: flex; }
.menu-theme .segmented > button { flex: 1; justify-content: center; }

/* ---------- Logos and avatars ---------- */
.logo {
  --size: 20px;
  width: var(--size); height: var(--size); flex: none; border-radius: calc(var(--size) / 4);
  object-fit: cover; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px light-dark(rgb(14 17 22 / 8%), rgb(255 255 255 / 8%));
}
img.logo { outline: 1px solid light-dark(rgb(14 17 22 / 6%), rgb(255 255 255 / 10%)); outline-offset: -1px; }
.logo-mono {
  display: inline-grid; place-items: center; font-weight: 600; letter-spacing: -0.02em; line-height: 1;
  font-size: calc(var(--size) * 0.44); color: var(--mono-ink, var(--ink-2)); background: var(--mono-bg, var(--surface-3));
}
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: var(--r-control); object-fit: cover; background: var(--surface-2);
}
img.avatar { outline: 1px solid light-dark(rgb(14 17 22 / 6%), rgb(255 255 255 / 10%)); outline-offset: -1px; }
.avatar-icon { display: grid; place-items: center; color: var(--ink-2); }
.avatar-icon .icon { width: 17px; height: 17px; }

/* ---------- Chips and badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; max-width: 100%; padding: 0 8px;
  border-radius: var(--r-small); border: 0; background: var(--surface-2); color: var(--ink-2);
  font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--fast) var(--ease);
}
.chip .icon { width: 14px; height: 14px; color: var(--ink-3); flex: none; }
.chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
button.chip:hover { background: var(--surface-3); color: var(--ink); }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--r-small);
  font-size: 11.5px; font-weight: 500; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--line-strong);
}
.badge .icon { width: 12px; height: 12px; }

/* Account reference inside a transaction row */
.acct-ref {
  vertical-align: middle; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; padding: 3px 6px; margin: -3px -6px;
  border: 0; border-radius: var(--r-small); background: transparent; color: var(--ink-2); font-size: 13px;
}
.acct-ref:hover { background: var(--surface-2); color: var(--ink); }
.acct-ref .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-ref .mono { color: var(--ink-3); }

/* ---------- Filter bar ---------- */
.filters {
  display: grid; grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(150px, 1fr));
  align-items: end; gap: 12px; margin-bottom: 14px;
}
.filter-toggle { display: none; }
.type-filter { display: grid; gap: 6px; justify-items: start; min-width: 0; max-width: 100%; }
.type-filter .label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.results-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 22px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.results-bar .totals { display: flex; gap: 20px; flex-wrap: wrap; }
.results-bar strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  position: sticky; top: var(--topbar-h); z-index: 1; background: var(--surface);
  text-align: left; font-size: 12.5px; font-weight: 500; color: var(--ink-3);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table .right { text-align: right; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.sort-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 4px; margin: -2px -4px;
  border-radius: var(--r-small); font: inherit; color: inherit;
}
.sort-btn:hover { color: var(--ink); background: var(--surface-2); }
.sort-btn .icon { width: 12px; height: 12px; opacity: 0; }
th[aria-sort] .sort-btn { color: var(--ink); }
th[aria-sort] .sort-btn .icon { opacity: 1; }

.txn-table { table-layout: fixed; }
.txn-table col.c-date { width: 92px; }
.txn-table col.c-cat { width: 20%; }
.txn-table col.c-acct { width: 24%; }
.txn-table col.c-amt { width: 132px; }

/* Column resize handles: a hairline shows on header hover, the accent while dragging or focused */
.col-resizer {
  position: absolute; top: 0; bottom: 0; right: 0; width: 9px; z-index: 2;
  cursor: col-resize; touch-action: none; outline: none;
}
.col-resizer::after {
  content: ''; position: absolute; top: 8px; bottom: 8px; right: 0; width: 2px; border-radius: 1px;
  background: var(--line-strong); opacity: 0; transition: opacity var(--fast) var(--ease), background var(--fast) var(--ease);
}
.txn-table thead:hover .col-resizer::after { opacity: 1; }
.col-resizer:hover::after, .col-resizer.is-active::after, .col-resizer:focus-visible::after { opacity: 1; background: var(--accent); }
.col-resizer:focus-visible::before {
  content: ''; position: absolute; inset: 2px 0; border-radius: var(--r-small); outline: 2px solid var(--accent-text);
}
.is-col-resizing, .is-col-resizing * { cursor: col-resize !important; user-select: none; }
.txn-desc { display: flex; align-items: center; gap: 12px; min-width: 0; }
.txn-desc .text { min-width: 0; display: grid; }
.txn-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.txn-name > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-name .badge { flex: none; }
.txn-meta { display: none; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-date { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-refreshing { opacity: 0.55; transition: opacity var(--med) var(--ease); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }

/* Compact list of transactions (overview) */
.txn-list { list-style: none; margin: 0; padding: 0; }
.txn-list li {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.txn-list li:last-child { border-bottom: 0; padding-bottom: 2px; }
.txn-list .main { min-width: 0; display: grid; }
.txn-list .sub { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; min-width: 0; }
.txn-list .sub .text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-list .right { text-align: right; display: grid; }
.txn-list .when { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart:focus-visible { outline-offset: 4px; border-radius: var(--r-small); }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .base-line { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-emph { stroke: var(--viz-accent); }
.chart .series-muted { stroke: var(--viz-muted); }
.chart .area-emph { fill: var(--viz-accent); opacity: 0.1; }
.chart .end-dot, .chart .hover-dot { stroke: var(--surface); stroke-width: 2; }
.chart .end-dot.emph, .chart .hover-dot.emph { fill: var(--viz-accent); }
.chart .hover-dot.muted { fill: var(--viz-muted); }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.line-key { width: 16px; height: 2px; border-radius: 1px; background: var(--viz-muted); }
.line-key.emph { background: var(--viz-accent); }
/* Series tones for trendChart: emph (the accent with an area wash) and categorical v1 to v3 */
.chart .tone-emph, .line-key.tone-emph { --tone: var(--viz-accent); }
.chart .tone-v1, .line-key.tone-v1 { --tone: var(--viz-1); }
.chart .tone-v2, .line-key.tone-v2 { --tone: var(--viz-2); }
.chart .tone-v3, .line-key.tone-v3 { --tone: var(--viz-3); }
.chart .tone-v4, .line-key.tone-v4 { --tone: var(--viz-4); }
.chart .tone-muted, .line-key.tone-muted { --tone: var(--viz-muted); }
.chart .series[class*='tone-'] { stroke: var(--tone); }
.chart .series.dashed { stroke-dasharray: 4 4; }
.chart .end-dot[class*='tone-'], .chart .hover-dot[class*='tone-'] { fill: var(--tone); }
.chart .end-dot.open { fill: var(--surface); stroke: var(--tone); }
.line-key[class*='tone-'] { background: var(--tone); }
.line-key.dashed { background: repeating-linear-gradient(90deg, var(--tone, var(--viz-muted)) 0 4px, transparent 4px 7px); }
.chart-tip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none; min-width: 150px;
  padding: 8px 10px; border-radius: var(--r-control); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-float); font-size: 12.5px;
}
.chart-tip .row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tip-head { color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }
.chart-tip .tip-note { color: var(--ink-3); margin-top: 6px; max-width: 26ch; }
.chart-tip .tip-note + .tip-note { margin-top: 2px; }
.chart-tip .row + .row { margin-top: 4px; }
.chart-tip strong { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.chart-tip .lbl { color: var(--ink-3); }
.chart-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chart-table th, .chart-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; }
.chart-table th { color: var(--ink-3); font-weight: 500; }
.chart-table-wrap { max-height: 264px; overflow: auto; }

/* Category bars: bar length carries the value; no background track */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.bar-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-control); color: var(--ink);
  transition: background var(--fast) var(--ease);
}
a.bar-row:hover { background: var(--surface-2); text-decoration: none; }
.bar-row .label { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; }
.bar-row .label .icon { color: var(--ink-3); }
.bar-row .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: span 2; height: 8px; }
.bar-row .fill { display: block; height: 8px; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--viz-accent); }
.bar-row.rest .fill { background: var(--viz-muted); }

/* Meter (credit used vs limit): track is a lighter step of the fill's own hue */
.meter { height: 6px; border-radius: 3px; background: var(--accent-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter.warn { background: var(--warn-track); }
.meter.warn > span { background: var(--warn-fill); }
.meter.crit { background: var(--crit-track); }
.meter.crit > span { background: var(--crit-fill); }

/* ---------- Accounts ---------- */
.acct-group { padding: 0; overflow: clip; }
.acct-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.acct-group-head h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.acct-group-head .total { font-weight: 600; font-variant-numeric: tabular-nums; }
.acct-group-head .count { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.acct-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(0, 220px) 130px; align-items: center; gap: 16px;
  padding: 14px 22px; color: var(--ink); border-bottom: 1px solid var(--line); transition: background var(--fast) var(--ease);
}
.acct-row:last-child { border-bottom: 0; }
.acct-row:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); text-decoration: none; }
.acct-row .name { font-weight: 500; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.acct-row .name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-row .sub { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-row .balance { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.acct-row .balance .sub { font-weight: 400; }
.acct-row .usage { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.acct-row .usage .line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.usage .warn-text { color: var(--warn); display: inline-flex; align-items: center; gap: 4px; }
.usage .crit-text { color: var(--crit); display: inline-flex; align-items: center; gap: 4px; }
.usage .icon { width: 13px; height: 13px; }
.stale { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-size: 12.5px; }
.stale .icon { width: 13px; height: 13px; }

/* ---------- Settings ---------- */
.settings { display: grid; gap: 16px; max-width: 920px; }
.conn-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.conn-row:last-child { border-bottom: 0; }
.conn-row .name { font-weight: 500; }
.conn-row .sub { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 12px; flex-wrap: wrap; }
.conn-row .status-fail { color: var(--crit); display: inline-flex; align-items: center; gap: 4px; }
.conn-row .status-fail .icon { width: 13px; height: 13px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.setting-row .text { max-width: 60ch; }
.setting-row .title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.setting-row .desc { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.danger-zone { border-color: color-mix(in srgb, var(--crit) 35%, var(--line)); }
.danger-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.danger-form .field { width: 200px; }

/* ---------- Banners, empty states, skeletons, toasts ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; margin-bottom: 16px;
  border-radius: var(--r-panel); background: var(--warn-wash); border: 1px solid var(--warn-line); color: var(--ink);
}
.banner > .icon { color: var(--warn); margin-top: 2px; }
.banner .body { font-size: 13.5px; }
.banner .body .muted { color: var(--ink-2); }

.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 40px 20px; }
.empty .empty-icon {
  width: 44px; height: 44px; border-radius: var(--r-panel); background: var(--surface-2); color: var(--ink-2);
  display: grid; place-items: center; margin-bottom: 6px;
}
.empty .empty-icon .icon { width: 22px; height: 22px; }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { color: var(--ink-3); max-width: 46ch; font-size: 13.5px; }
.empty .btn { margin-top: 10px; }

.skeleton { background: var(--surface-2); border-radius: var(--r-small); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
.sk-line { height: 12px; }
.sk-fig { height: 44px; width: 60%; margin-top: 10px; }
.sk-chart { height: 220px; margin-top: 12px; }
.sk-row { height: 52px; border-radius: var(--r-control); }

.toasts {
  position: fixed; z-index: var(--z-toast); right: 20px; bottom: calc(20px + var(--sel-space, 0px)); display: grid; gap: 8px; justify-items: end;
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: var(--r-panel); background: var(--ink); color: var(--surface);
  box-shadow: var(--shadow-float); font-size: 13.5px; animation: toast-in 260ms var(--ease) both;
}
.toast .icon { width: 16px; height: 16px; }
.toast.is-error { background: var(--danger-bg); color: var(--danger-ink); }
.toast-action {
  margin-left: 4px; padding: 3px 10px; border-radius: var(--r-control); border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
  background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.toast-action:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.toast-action:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.toast.is-leaving { animation: toast-out 200ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }

/* View entrance: a short fade so a route change reads as a change of place */
.view-enter { animation: view-in 280ms var(--ease) both; }
.view-enter .stagger { animation: view-in 320ms var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .f-search { grid-column: 1 / -1; }
}
@media (max-width: 1023px) {
  .span-8, .span-7, .span-5, .span-4 { grid-column: span 12; }
  .topbar-inner { gap: 16px; }
  .sync-status { display: none; }
  .nav a { padding: 0 10px; }
  .acct-row { grid-template-columns: 36px minmax(0, 1fr) 130px; }
  .acct-row .usage { grid-column: 2 / span 2; grid-row: 2; }
}
@media (max-width: 767px) {
  :root { --gutter: 16px; --topbar-h: 56px; }
  .nav, .sync-status { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-header);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); min-height: var(--tabbar-h);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: var(--r-control);
    color: var(--ink-3); font-size: 11.5px; font-weight: 500;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current='page'] { color: var(--accent-text); }
  main { padding: 20px var(--gutter) calc(var(--tabbar-h) + 40px + env(safe-area-inset-bottom)); }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom) + var(--sel-space, 0px)); justify-items: center; }
  .hero-figure { font-size: 40px; }
  .networth { grid-template-columns: 1fr; gap: 12px; }
  .trend-caption { text-align: left; }
  .panel:not(.panel-flush):not(.acct-group) { padding: 16px; }
  .panel-flush > .panel-head { padding: 14px 16px 0; }
  .results-bar, .table-foot { padding-left: 16px; padding-right: 16px; }

  .filters { grid-template-columns: minmax(0, 1fr) auto; }
  .filters .f-search { grid-column: 1; grid-row: 1; }
  .filter-toggle { display: inline-flex; grid-column: 2; grid-row: 1; align-self: end; }
  .filters .f-period, .filters .f-accounts, .filters .f-category, .filters .f-tags { grid-column: 1 / -1; }
  .filters:not(.is-open) .f-period, .filters:not(.is-open) .f-accounts,
  .filters:not(.is-open) .f-category, .filters:not(.is-open) .f-tags { display: none; }
  .type-filter { width: 100%; }

  /* Transactions table becomes a list of two-line rows */
  .txn-table, .txn-table tbody { display: block; }
  .txn-table thead, .txn-table colgroup { display: none; }
  .txn-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'desc amount' 'desc date';
    column-gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  }
  .txn-table tr:last-child { border-bottom: 0; }
  .txn-table td { padding: 0; border: 0; }
  .txn-table td:first-child, .txn-table td:last-child { padding: 0; }
  .txn-table td.c-date { grid-area: date; text-align: right; font-size: 12.5px; color: var(--ink-3); }
  .txn-table td.c-desc { grid-area: desc; }
  .txn-table td.c-amt { grid-area: amount; }
  .txn-table td.c-cat, .txn-table td.c-acct { display: none; }
  .txn-meta { display: block; }

  .acct-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; padding: 14px 16px; }
  .acct-row .name { flex-wrap: wrap; row-gap: 0; }
  .acct-row .name > span:first-child, .acct-row .sub { white-space: normal; }
  .acct-group-head { padding: 14px 16px; }
  .conn-row { grid-template-columns: 36px minmax(0, 1fr); padding: 14px 16px; }
  .conn-row .actions { grid-column: 2; }
}
@media (max-width: 479px) {
  .brand-name { display: none; }
  .page-head .actions .btn-label { display: none; }
  .segmented .count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
@media (forced-colors: active) {
  .meter > span, .bar-row .fill { background: CanvasText; }
  .chart .series-emph { stroke: Highlight; }
}

/* Small layout helpers used by views */
.month-nav { display: flex; gap: 6px; }
.legend-spaced { margin-top: 18px; }
.section-gap { margin-top: 16px; }
.btn[aria-disabled='true'] { pointer-events: none; opacity: 0.45; }
.panel-intro { padding: 0 22px 14px; font-size: 13px; color: var(--ink-3); max-width: 80ch; }
.conn-list { border-top: 1px solid var(--line); }
.danger-title { font-size: 15px; }
.danger-desc { margin-top: 4px; font-size: 13px; color: var(--ink-3); max-width: 62ch; }
.acct-main { min-width: 0; }
.acct-row { row-gap: 8px; }
.acct-row .balance { grid-column: -2 / -1; }
.acct-group { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.acct-group-head .type-icon { width: 28px; height: 28px; }
.acct-group-head .total .muted { font-weight: 400; font-size: 13px; }
@media (max-width: 1023px) {
  .acct-row .usage { grid-column: 2 / -1; grid-row: 2; }
}
@media (max-width: 767px) {
  .panel-intro { padding: 0 16px 12px; }
}

/* ---------- Transaction editing ---------- */
.txn-open {
  display: grid; min-width: 0; width: 100%; padding: 2px 4px; margin: -2px -4px; border: 0; border-radius: var(--r-small);
  background: transparent; color: inherit; text-align: left; font: inherit;
}
.txn-open:hover .txn-name > span:first-child { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; max-width: 100%; padding: 0 7px;
  border-radius: var(--r-small); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-chip .icon { width: 12px; height: 12px; color: var(--ink-3); }
.tag-chip span { overflow: hidden; text-overflow: ellipsis; }
.tag-chip.is-link { cursor: pointer; transition: background var(--fast) var(--ease); }
.tag-chip.is-link:hover { background: var(--surface-2); color: var(--ink); }
.tag-chip button { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: -3px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--ink-3); }
.tag-chip button:hover { background: var(--surface-3); color: var(--ink); }

.drawer {
  position: fixed; z-index: var(--z-drawer); top: calc(var(--topbar-h) + 12px); right: 12px; bottom: 12px;
  width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-float);
  animation: drawer-in 240ms var(--ease) both;
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(16px); } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-title { flex: 1; min-width: 0; }
.drawer-title h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-title p { font-size: 12.5px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px; display: grid; align-content: start; gap: 20px; }
.drawer-facts { display: grid; grid-template-columns: auto 1fr; gap: 12px 24px; padding: 14px 16px; border-radius: var(--r-control); background: var(--surface-2); }
.drawer-facts > div { display: grid; gap: 2px; min-width: 0; }
.drawer-facts .wide { grid-column: 1 / -1; }
.drawer-facts .label { font-size: 12px; color: var(--ink-3); }
.drawer-facts .muted { font-size: 13px; overflow-wrap: anywhere; }
.acct-line { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; min-width: 0; }
.tag-editor { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; align-items: center; font-size: 13px; }
.tag-add { display: flex; gap: 8px; }
.tag-add .input { flex: 1; }
.pick-add { display: flex; gap: 8px; align-items: center; }
.pick-add .select-wrap { flex: 1; min-width: 0; }
.pick-add .btn { flex: none; }
.check-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); font-size: 13.5px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent-text); flex: none; }
.drawer-foot { display: flex; gap: 8px; padding-top: 4px; }

/* Account rows: the name link covers the row; the rename button sits above it */
.acct-row { position: relative; }
.acct-row.is-linked:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.acct-link { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-link:hover { text-decoration: none; }
.acct-link::after { content: ''; position: absolute; inset: 0; }
.acct-link:focus-visible { outline: none; }
.acct-link:focus-visible::after { outline: 2px solid var(--accent-text); outline-offset: -2px; border-radius: var(--r-small); }
.rename-btn { position: relative; z-index: 1; width: 26px; height: 26px; margin: -4px 0; color: var(--ink-3); opacity: 0.55; }
.acct-row:hover .rename-btn, .rename-btn:focus-visible { opacity: 1; }
.rename-form { position: relative; z-index: 1; display: grid; gap: 6px; }
.rename-form > label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.rename-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rename-controls .input { flex: 1; min-width: 160px; height: 32px; }
.rename-form .help { font-size: 12.5px; color: var(--ink-3); }

/* Tag filter menu and tag settings */
.menu-mode { display: grid; gap: 6px; padding: 8px 6px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-mode .label { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.tag-row-setting { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.tag-row-setting:last-child { border-bottom: 0; }
.tag-row-setting .actions { margin-left: auto; display: flex; gap: 4px; }

@media (hover: none) { .rename-btn { opacity: 1; } }
@media (max-width: 767px) {
  .drawer { top: 0; right: 0; bottom: 0; width: 100vw; border-radius: 0; border: 0; z-index: calc(var(--z-header) + 5); }
  .drawer-body { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .tag-row-setting { padding: 12px 16px; }
  .tag-row-setting .actions { margin-left: 0; width: 100%; }
}
.txn-desc .text { flex: 1; grid-template-columns: minmax(0, 1fr); }

/* Demo instance banner */
.demo-bar {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px var(--gutter);
  background: var(--accent-wash); color: var(--accent-text); font-size: 13px; font-weight: 500; text-align: center;
}
.demo-bar .icon { width: 15px; height: 15px; flex: none; }

/* ---------- Budget ---------- */
.banner-info { background: var(--surface); border-color: var(--line); }
.banner-info > .icon { color: var(--ink-3); }
.banner .btn-link { margin-left: 4px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.empty-actions .btn { margin-top: 10px; }

.budget-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.budget-summary .tile { padding: 2px 20px; border-left: 1px solid var(--line); min-width: 0; }
.budget-summary .tile:first-child { border-left: 0; padding-left: 0; }
.tile .label { font-size: 12.5px; color: var(--ink-3); }
.tile .value { font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.tile .value-status { font-size: 16px; min-height: 29px; display: flex; align-items: center; }
.tile .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.summary-meter { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

.bstatus { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; max-width: 100%; }
.bstatus > span { overflow: hidden; text-overflow: ellipsis; }
.bstatus .icon { width: 15px; height: 15px; flex: none; }
.bstatus.ok .icon { color: var(--pos); }
.bstatus.warn { color: var(--warn); }
.bstatus.crit { color: var(--crit); }
.bstatus.muted { color: var(--ink-3); }
.bstatus.big { font-size: 16px; font-weight: 600; gap: 8px; }
.bstatus.big .icon { width: 18px; height: 18px; }
.bstatus.big.ok { color: var(--ink); }
.crit-text { color: var(--crit); }
.status-with-tool { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.order-btn { width: 26px; height: 26px; color: var(--ink-3); }

.pace-meter { position: relative; height: 8px; border-radius: 4px; background: var(--accent-track); }
.pace-meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); max-width: 100%; }
.pace-meter.warn { background: var(--warn-track); }
.pace-meter.warn .fill { background: var(--warn-fill); }
.pace-meter.crit { background: var(--crit-track); }
.pace-meter.crit .fill { background: var(--crit-fill); }
.pace-meter .today { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); }
.pace-meter.slim { height: 6px; }
.meter-caption { display: flex; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
.meter-caption strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.carry-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.carry-list li { display: flex; align-items: center; gap: 8px; }
.carry-list .icon { width: 14px; height: 14px; color: var(--ink-3); }
.carry-list strong { margin-left: auto; font-weight: 600; }
.plan-warning { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--warn); }
.plan-warning .icon { flex: none; }

/* Budget tables: name, monthly, % of income, annual, this month, status */
.bsec .panel-head { margin-bottom: 10px; }
.sec-total { font-weight: 600; color: var(--ink-2); }
.btable { table-layout: fixed; }
.btable col.c-num { width: 116px; }
.btable col.c-pct { width: 96px; }
.btable col.c-status { width: 204px; }
.btable th { position: static; }
.btable td, .btable tbody th { padding-top: 11px; padding-bottom: 11px; }
.btable .c-name { overflow: hidden; }
.line-btn, .group-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; padding: 2px 4px; margin: -2px -4px;
  border: 0; border-radius: var(--r-small); background: transparent; color: var(--ink); font: inherit; font-weight: 500; text-align: left;
}
.line-btn .nm, .group-btn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.line-btn:hover .nm { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.group-btn:hover { background: var(--surface-2); }
.group-btn .caret { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--fast) var(--ease); }
.group-btn[aria-expanded='true'] .caret { transform: rotate(90deg); }
.group-btn .count { font-size: 12px; font-weight: 500; color: var(--ink-3); background: var(--surface-2); border-radius: var(--r-small); padding: 0 6px; }
.line-label { font-weight: 500; }
.btable .rate { font-weight: 400; font-size: 13px; }
.btable .child-row .c-name { padding-left: 50px; }
.btable .sub-row td { padding-top: 7px; padding-bottom: 7px; font-size: 13px; color: var(--ink-2); border-bottom-style: dashed; }
.btable .sub-row .c-name { padding-left: 38px; }
.btable .sub-row .bstatus { font-size: 12.5px; }
.btable .sub-label { display: inline-flex; align-items: center; gap: 6px; }
.btable tbody tr.meter-row:hover, .btable tbody tr.sub-row:hover { background: transparent; }
.btable .meter-row td { padding-top: 0; padding-bottom: 14px; }
.btable tr.bl-row:has(+ .meter-row) td { border-bottom: 0; padding-bottom: 8px; }
.btable tfoot tr th, .btable tfoot tr td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; background: var(--surface-2); text-align: left; }
.btable tfoot tr td.right { text-align: right; }
.btable tfoot tr th { font-size: 13px; color: var(--ink); padding-left: 22px; }
.btable .stack-foot tr + tr th, .btable .stack-foot tr + tr td { border-top-color: var(--line); }
.btable .bmeta { display: none; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btable .c-t { font-weight: 500; }
.kind-tag { font-size: 11.5px; font-weight: 500; color: var(--ink-3); border: 1px solid var(--line); border-radius: var(--r-small); padding: 0 6px; white-space: nowrap; }
.tag-changed { font-size: 11.5px; font-weight: 500; color: var(--accent-text); background: var(--accent-wash); border-radius: var(--r-small); padding: 1px 6px; white-space: nowrap; }
.bsec-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 22px 16px; font-size: 13.5px; }
.bsec .panel-intro { padding-top: 0; }

/* Catch-up and surplus */
.resolve-card { margin-top: 16px; border-color: var(--warn-line); }
.resolve-head { display: flex; align-items: center; gap: 10px; }
.resolve-head .icon { width: 20px; height: 20px; color: var(--warn); flex: none; }
.resolve-head.is-good .icon { color: var(--pos); }
.resolve-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.resolve-card > .muted { margin: 6px 0 14px; font-size: 13.5px; }
.resolve-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 28px; align-items: start; }
.resolve-grid fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.resolve-grid legend { padding: 0; margin-bottom: 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.choice-chips, .month-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.choice-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--control); border-radius: var(--r-control); font-size: 13px; cursor: pointer; background: var(--surface); }
.choice-chip input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent-text); }
.choice-chip:has(input:checked) { border-color: var(--accent-text); background: var(--accent-wash); color: var(--accent-text); }
.choice-chip:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.month-picks { margin-top: 10px; }
.resolve-preview { margin-top: 16px; padding: 12px 14px; border-radius: var(--r-control); background: var(--surface-2); font-size: 13.5px; }
.resolve-preview ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.resolve-preview li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
.resolve-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.resolve-options { display: grid; gap: 8px; }
.option-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); cursor: pointer; flex-wrap: wrap; }
.option-card:has(input:checked) { border-color: var(--accent-text); background: var(--accent-wash); }
.option-card input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-text); flex: none; }
.option-card .text { display: grid; flex: 1; min-width: 180px; font-size: 13.5px; }
.option-card .text .muted { font-size: 12.5px; }
.option-card .select-wrap { width: min(240px, 100%); }

/* Suggestions */
.suggest-list { list-style: none; margin: 0; padding: 0; display: grid; }
.suggest-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.suggest-list li:first-child { border-top: 0; padding-top: 0; }
.suggest-icon { width: 32px; height: 32px; border-radius: var(--r-control); background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; }
.suggest-text { font-size: 13.5px; }
.suggest-actions { display: flex; gap: 6px; }

/* Cash check and history */
.cash-list { display: grid; }
/* Cash check tones: cash (green), still to pay (amber), cards (red). Each group is also named in text. */
.cash-list .tone-cash { --tone: var(--pos); }
.cash-list .tone-due { --tone: var(--warn); }
.cash-list .tone-card { --tone: var(--crit); }
.cash-group { display: flex; align-items: center; gap: 6px; padding: 14px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--tone); }
.cash-group:first-child { padding-top: 2px; }
.cash-group .icon { width: 15px; height: 15px; }
.cash-block { border-bottom: 1px solid var(--line); box-shadow: inset 3px 0 0 var(--tone); padding-left: 9px; }
.cash-row { display: grid; grid-template-columns: 22px 14px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 7px 0; font-size: 13.5px; }
.cash-row .sign { color: var(--ink-3); text-align: center; }
.cash-row .num { font-variant-numeric: tabular-nums; font-weight: 500; }
.cash-block .cash-row > .num { color: var(--tone); }
.cash-block.is-zero .cash-row > .num { color: var(--ink-3); }
.cash-label { display: grid; min-width: 0; }
.cash-meta { font-size: 12.5px; color: var(--ink-3); }
.cash-row.cash-total { padding: 12px 0 0 12px; font-weight: 600; font-size: 14.5px; }
.cash-row.cash-total .num { font-weight: 600; }
.cash-detail { padding: 0 0 10px 42px; }
.cash-items { list-style: none; margin: 0; padding: 0; display: grid; }
.cash-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--line); }
.cash-item:first-child { border-top: 0; }
.cash-item-name { display: grid; flex: 1; min-width: 0; }
.cash-item-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cash-item-name .muted { font-size: 12.5px; }
.cash-item > .num { color: var(--ink-2); }
.cash-logo-space { width: 20px; flex: none; }
.cash-access { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; margin-bottom: 10px; border-radius: var(--r-control);
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.cash-access > .icon { width: 16px; height: 16px; color: var(--accent-text); flex: none; }
.cash-access > span { flex: 1 1 220px; }
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card-block { padding: 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); display: grid; gap: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-name { flex: 1; min-width: 0; font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-balance { display: grid; justify-items: end; font-size: 12px; }
.card-balance .num { font-size: 14px; font-weight: 600; color: var(--crit); }
.card-why { margin: 0; }
.card-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.card-facts .fact { display: grid; gap: 2px; min-width: 0; }
.card-facts dt { font-size: 12px; color: var(--ink-3); }
.card-facts dd { margin: 0; display: grid; font-size: 13.5px; }
.card-facts dd .num { font-weight: 500; }
.card-facts dd .muted { font-size: 12px; }
.card-interest { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 13px; color: var(--ink-2); }
.card-interest .icon { width: 15px; height: 15px; flex: none; margin-top: 2px; color: var(--ink-3); }
.card-interest.crit-text, .card-interest.crit-text .icon { color: var(--crit); }
@media (max-width: 480px) {
  .card-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cash-detail { padding-left: 12px; }
}
.small { font-size: 13px; }
.hist-list { border-top: 1px solid var(--line); max-height: 520px; overflow: auto; }
.hist-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) minmax(0, auto); align-items: center; gap: 16px;
  padding: 11px 22px; border-bottom: 1px solid var(--line); color: var(--ink); transition: background var(--fast) var(--ease);
}
.hist-row:last-child { border-bottom: 0; }
.hist-row:hover { background: var(--surface-2); text-decoration: none; }
.hist-row.is-current { background: var(--accent-wash); }
.hist-month { display: grid; min-width: 0; }
.hist-month strong { font-weight: 500; }
.hist-month .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-result { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.start-form { grid-template-columns: 1fr; }
.start-form .btn { grid-column: auto; }

/* Line editor (wider drawer) */
.drawer-wide { width: min(480px, calc(100vw - 24px)); }
.form-error { color: var(--crit); font-size: 13px; }
.push-right { margin-left: auto; }
.input-money { position: relative; }
.input-money > span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-money .input { padding-left: 24px; font-variant-numeric: tabular-nums; }
.input-day { width: 64px; padding: 0 8px; text-align: center; }
.inline-fields { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); }
.row-list { display: grid; gap: 8px; }
.list-row { display: grid; grid-template-columns: auto minmax(0, 1fr) 30px; gap: 8px; align-items: center; }
.rules { border: 1px solid var(--line); border-radius: var(--r-control); padding: 12px 14px 14px; margin: 0; min-width: 0; display: grid; gap: 10px; }
.rules legend { padding: 0 4px; margin-left: -4px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.rules .help { margin-top: -6px; }
.rules-match { display: flex; align-items: center; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.rule-list { display: grid; gap: 8px; }
.rule-list:empty { display: none; }
.rule-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px; gap: 8px; align-items: center; }
.rules > .btn { justify-self: start; }
.le-due { display: grid; gap: 20px; }
.le-intro { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-control); background: var(--accent-wash); font-size: 13px; }
.le-intro .icon { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--accent-text); }
.le-month { padding: 12px 14px; border-radius: var(--r-control); background: var(--surface-2); display: grid; gap: 8px; }
.le-month h3 { font-size: 13px; font-weight: 600; }
.le-list { list-style: none; margin: 0; padding: 0; display: grid; }
.le-list > li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--line); }
.le-list > li:first-child { border-top: 0; }
.le-list .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.le-list > li:has(.le-txn) { padding: 0; }
.le-txn { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 6px 4px; margin: 0 -4px; border: 0; background: transparent; border-radius: var(--r-small); font: inherit; font-size: 13px; color: inherit; text-align: left; }
.le-txn:hover { background: var(--surface-3); }
.le-txn-name { display: grid; min-width: 0; }
.le-txn-name .muted { font-size: 12px; }
.le-txns { display: grid; gap: 6px; max-height: 280px; overflow: auto; }
.le-once { border: 1px solid var(--line); border-radius: var(--r-control); }
.le-once summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; font-size: 13.5px; font-weight: 500; list-style: none; }
.le-once summary::-webkit-details-marker { display: none; }
.le-once summary .icon { color: var(--ink-3); }
.le-once-body { padding: 0 14px 14px; display: grid; gap: 12px; }
.le-once-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.check-row.compact { padding: 8px 10px; margin-top: 8px; font-size: 13px; }

/* Recommendations */
.reco-mode { display: flex; align-items: end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 16px; }
.reco-target { display: flex; align-items: end; gap: 8px; }
.reco-target .input-money { width: 140px; }
.reco-target-note { display: flex; align-items: flex-start; gap: 8px; margin: -4px 0 16px; padding: 10px 12px; border-radius: var(--r-control); background: var(--surface-2); font-size: 13.5px; }
.reco-target-note .icon { flex: none; margin-top: 2px; color: var(--pos); }
.reco-target-note.is-warn .icon { color: var(--warn); }
.reco-summary { padding-top: 16px; border-top: 1px solid var(--line); }
.reco-fit { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13.5px; }
.reco-fit.is-ok .icon { color: var(--pos); }
.reco-fit.is-warn { color: var(--warn); }
.reco-fit .icon { flex: none; }
.reco-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.reco-item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 132px 190px; align-items: center; gap: 16px;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
}
.reco-item:last-child { border-bottom: 0; }
.reco-item.is-kept { color: var(--ink-2); }
.reco-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-text); }
.reco-lock .icon { width: 18px; height: 18px; color: var(--pos); }
.reco-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reco-name strong { font-weight: 500; }
.reco-name label { cursor: pointer; }
.reco-note { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.chip-status { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); white-space: nowrap; }
.chip-status .icon { width: 12px; height: 12px; }
.chip-status.is-new { color: var(--accent-text); }
.chip-status.is-update { color: var(--warn); }
.reco-amount { display: flex; align-items: center; gap: 8px; }
.reco-amount .input-money { width: 112px; flex: none; }
.reco-amount .unit { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.reco-else { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; font-size: 13.5px; }
.reco-else p + p { margin-top: 8px; }
.minibars { display: block; overflow: visible; }
.minibars .bar { fill: var(--viz-muted); opacity: 0.55; }
.minibars .bar-emph { fill: var(--viz-accent); }
.minibars .mark { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.reco-bar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px 16px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-float);
  font-size: 13.5px; color: var(--ink-2);
}

/* Members and transfers (Settings) */
.member-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row .who { display: grid; min-width: 0; }
.member-row .who strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.member-row .who .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-avatar { width: 36px; height: 36px; border-radius: var(--r-control); background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; font-size: 12.5px; font-weight: 600; }
.invite-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: end; padding: 14px 22px; border-top: 1px solid var(--line); }
.invite-note { margin: 0 22px 16px; padding: 10px 12px; border-radius: var(--r-control); background: var(--accent-wash); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.invite-note .icon { flex: none; margin-top: 2px; color: var(--accent-text); }
.xfer-summary { padding: 0 22px 14px; font-size: 13.5px; color: var(--ink-2); display: flex; gap: 18px; flex-wrap: wrap; }
.xfer-summary strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.xfer-item { padding: 12px 22px; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 13.5px; }
.xfer-item .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.xfer-cands { display: flex; flex-wrap: wrap; gap: 6px; }
.xfer-head { padding: 10px 22px 6px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); border-top: 1px solid var(--line); }

/* Transfer link shown on a transaction */
.badge-link { border-style: solid; border-color: var(--line); }
.link-box { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-control); font-size: 13.5px; }
.link-box .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.link-box .icon { color: var(--ink-3); }
.link-cands { display: grid; gap: 6px; }

@media (max-width: 1023px) {
  .budget-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 0; }
  .budget-summary .tile:nth-child(3) { border-left: 0; padding-left: 0; }
  .btable col.c-pct { width: 72px; }
  .btable col.c-num { width: 100px; }
  .reco-item { grid-template-columns: 28px minmax(0, 1fr) 190px; }
  .reco-item .reco-evidence { display: none; }
}
@media (max-width: 767px) {
  .budget-summary .tile { padding: 2px 0 2px 14px; }
  .budget-summary .tile:nth-child(odd) { border-left: 0; padding-left: 0; }
  .tile .value { font-size: 20px; }
  .resolve-grid { grid-template-columns: 1fr; }
  .suggest-list li { grid-template-columns: 32px minmax(0, 1fr); }
  .suggest-actions { grid-column: 2; }
  /* Budget tables become two-line rows: name and status, then plan figures and this month */
  .btable, .btable tbody, .btable tfoot { display: block; }
  .btable thead, .btable colgroup { display: none; }
  .btable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name actual' 'name status'; column-gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
  .btable td, .btable tbody th, .btable tfoot th, .btable tfoot td { padding: 0 !important; border: 0 !important; background: transparent; }
  .btable .c-name { grid-area: name; align-self: center; }
  .btable .c-t { grid-area: actual; }
  .btable .c-s { grid-area: status; text-align: right; }
  .btable .c-m, .btable .c-p, .btable .c-a { display: none; }
  .btable .bmeta { display: block; }
  .btable .line-btn, .btable .group-btn { margin-top: 0; }
  .btable .child-row { padding-left: 34px; }
  .btable .sub-row { padding-left: 30px; border-bottom-style: dashed; }
  .btable .sub-row .c-m { display: none; }
  .btable tr.meter-row { display: block; padding-top: 0; }
  .btable tr.bl-row:has(+ .meter-row) { border-bottom: 0; padding-bottom: 6px; }
  .btable tfoot tr { background: var(--surface-2); }
  .bsec-empty { padding: 4px 16px 14px; }
  .hist-row { grid-template-columns: minmax(0, 1fr) auto; padding: 11px 16px; }
  .hist-meter { display: none; }
  .invite-form { grid-template-columns: 1fr; padding: 14px 16px; }
  .member-row, .xfer-item, .xfer-head { padding-left: 16px; padding-right: 16px; }
  .xfer-summary { padding: 0 16px 12px; }
  .invite-note { margin: 0 16px 14px; }
  .reco-item { grid-template-columns: 24px minmax(0, 1fr); padding: 12px 16px; row-gap: 8px; }
  .reco-item .reco-amount { grid-column: 2; }
  .reco-else { grid-template-columns: 1fr; }
  .reco-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
  .drawer-wide { width: 100vw; }
  .rule-row { grid-template-columns: minmax(0, 1fr) 30px; }
  .rule-row .rule-value { grid-column: 1; grid-row: 2; }
  .rule-row [data-rule-remove] { grid-row: 1; grid-column: 2; }
}
@media (max-width: 479px) {
  .page-head .actions .btn-label { display: none; }
}

/* Budget rows: options menu, switched-off rows */
.btable col.c-act { width: 44px; }
.btable .c-x { padding-left: 0 !important; padding-right: 10px !important; text-align: right; }
.row-menu { width: 30px; height: 30px; color: var(--ink-3); }
.row-menu:hover, .row-menu[aria-expanded='true'] { color: var(--ink); }
.btable tr.is-off .line-btn .nm, .btable tr.is-off .num, .btable tr.is-off .rate { color: var(--ink-3); }
.btable tr.is-off .line-btn .nm { text-decoration: line-through; text-decoration-color: var(--line-strong); }
.menu-item.is-danger { color: var(--crit); }
.menu-item.is-danger .icon { color: var(--crit); }
.menu-item.is-armed { background: color-mix(in srgb, var(--crit) 10%, transparent); font-weight: 500; }
.bsec .panel-head .tools { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 767px) {
  .btable tr { grid-template-columns: minmax(0, 1fr) auto 32px; grid-template-areas: 'name actual x' 'name status x'; }
  .btable .c-x { grid-area: x; display: flex; align-items: center; justify-content: flex-end; padding: 0 !important; }
  .bsec .panel-head { flex-wrap: wrap; }
}

/* Selecting transactions to change together */
.txn-table col.c-sel { width: 46px; }
.txn-table th.c-sel, .txn-table td.c-sel { padding: 0; }
.sel-hit { display: flex; align-items: center; padding: 12px 8px 12px 22px; cursor: pointer; }
.sel-box { width: 16px; height: 16px; margin: 0; accent-color: var(--accent-text); cursor: pointer; flex: none; }
.sel-box:disabled { cursor: default; }
.txn-table tbody tr.is-selected { background: color-mix(in srgb, var(--accent-wash) 75%, transparent); }
.txn-table tbody tr.is-selected:hover { background: var(--accent-wash); }
.sel-bar {
  position: sticky; bottom: 16px; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px 10px 16px; border-radius: var(--r-panel); background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float); font-size: 13.5px; color: var(--ink-2);
}
.sel-info { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.sel-info strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-form { display: grid; gap: 10px; padding: 8px 6px 6px; }
.menu-form + .menu-group { margin-top: 6px; padding-top: 4px; border-top: 1px solid var(--line); }
@media (max-width: 767px) {
  .txn-table tr { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'sel desc amount' 'sel desc date'; }
  .txn-table td.c-sel { grid-area: sel; display: flex; align-items: center; }
  .txn-table td[colspan] { grid-column: 1 / -1; }
  .txn-table .sel-hit { padding: 8px 12px 8px 0; margin-left: -2px; }
  .sel-bar { bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); padding: 10px 12px; }
  .sel-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .sel-actions .btn { justify-content: center; }
}

/* Budget tables: sort and your own order */
.btable tbody.bblock:not(:last-of-type) > tr:last-child > td { border-bottom: 1px solid var(--line); }
.btable .name-cell { display: flex; align-items: center; gap: 2px; min-width: 0; margin-left: -18px; }
.btable .child-row .name-cell, .btable .group-row .name-cell { margin-left: -18px; }
.drag-handle {
  flex: none; display: inline-grid; place-items: center; width: 18px; height: 26px; padding: 0; border: 0; border-radius: var(--r-small);
  background: transparent; color: var(--ink-3); cursor: grab; touch-action: none; opacity: 0.55;
  transition: opacity var(--fast) var(--ease), background var(--fast) var(--ease);
}
.drag-handle .icon { width: 14px; height: 14px; }
.btable tr:hover .drag-handle, .drag-handle:focus-visible { opacity: 1; }
.drag-handle:hover { background: var(--surface-2); color: var(--ink); }
.btable.is-sorted .drag-handle { visibility: hidden; }
.is-row-dragging, .is-row-dragging * { cursor: grabbing !important; user-select: none; }
.btable .is-dragging, .btable .is-dragging > tr { background: var(--accent-wash) !important; }
.btable .is-dragging .drag-handle { opacity: 1; color: var(--accent-text); }
.btable th .sort-btn { font-weight: inherit; }
.order-reset .icon { color: var(--accent-text); }
.sort-menu-btn { display: none; }
.icon.invisible { visibility: hidden; }
@media (max-width: 767px) {
  .sort-menu-btn { display: inline-flex; }
  .btable .name-cell, .btable .child-row .name-cell, .btable .group-row .name-cell { margin-left: -6px; gap: 4px; }
  .btable .name-cell + .bmeta { padding-left: 20px; }
  .drag-handle { opacity: 0.8; width: 22px; height: 32px; }
}
@media (hover: none) { .drag-handle { opacity: 0.8; } }

/* Finding a payment for a line */
.le-find { border-top: 1px solid var(--line); padding-top: 6px; }
.le-find summary { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--accent-text); list-style: none; }
.le-find summary::-webkit-details-marker { display: none; }
.le-find summary .icon { width: 14px; height: 14px; }
.le-find-body { display: grid; gap: 10px; padding-top: 4px; }
.le-find-list { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.le-find-list.is-refreshing { opacity: 0.6; }
.le-cand .where { color: var(--ink-3); }
.le-cand[aria-pressed='true'] { background: var(--accent-wash); box-shadow: inset 0 0 0 1px var(--accent-text); }
.le-cand:disabled { opacity: 0.6; cursor: default; }
.le-cand:disabled:hover { background: transparent; }
.le-find-pick { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-control); background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.le-find-pick .check-row.compact { margin-top: 0; }
.le-list > li:has([data-unmatch]) { align-items: center; gap: 4px; }
.learned-list > li { align-items: center; }

/* Income and savings lines fold their paychecks and transfers, like bill groups */
.expand-btn {
  flex: none; display: inline-grid; place-items: center; width: 22px; height: 24px; padding: 0; border: 0; border-radius: var(--r-small);
  background: transparent; color: var(--ink-3);
}
.expand-btn:hover { background: var(--surface-2); color: var(--ink); }
.expand-btn .caret { width: 14px; height: 14px; transition: transform var(--fast) var(--ease); }
.expand-btn[aria-expanded='true'] .caret { transform: rotate(90deg); }
.expand-space { flex: none; width: 22px; }
.btable .sub-row .c-name { padding-left: 64px; }
@media (max-width: 767px) { .btable .sub-row { padding-left: 50px; } }

/* Cash flow check: plan or follow a payoff path */
.cash-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 14px; padding: 10px 12px; border-radius: var(--r-control);
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.cash-cta > .icon { width: 16px; height: 16px; flex: none; color: var(--accent-text); }
.cash-cta > span { flex: 1 1 220px; }
.cash-cta.crit > .icon { color: var(--crit); }

/* Payoff path panel */
.payoff .drawer-body { gap: 22px; }
.po-section { display: grid; gap: 10px; }
.po-section h3, .po-progress h3 { font-size: 14px; font-weight: 600; }
.po-countdown { display: grid; gap: 12px; padding: 14px 16px; border-radius: var(--r-control); background: var(--surface-2); border: 1px solid var(--line); }
.po-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--crit-track); }
.po-seg { display: block; height: 100%; transition: width var(--fast) var(--ease); }
.po-seg.sav, .po-key.sav { background: var(--pos); }
.po-seg.fut, .po-key.fut { background: var(--accent); }
.po-seg.left { background: var(--crit-fill); }
.po-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; vertical-align: 1px; }
.po-steps { display: grid; margin: 0; }
.po-steps > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 6px 0; font-size: 13.5px; border-top: 1px solid var(--line); }
.po-steps > div:first-child { border-top: 0; padding-top: 0; }
.po-steps dt .muted { font-size: 12.5px; }
.po-steps dd { margin: 0; font-weight: 500; }
.po-steps .po-big dt { font-weight: 600; }
.po-steps .po-big dd { font-size: 20px; font-weight: 600; }
.po-steps .po-end dt { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.po-steps .po-end .icon { width: 15px; height: 15px; }
.po-steps .po-end.ok dt .icon { color: var(--pos); }
.po-steps .po-end.crit, .po-steps .po-end.crit dd { color: var(--crit); }
.po-cards, .po-sched, .po-pay, .po-prog-list { list-style: none; margin: 0; padding: 0; display: grid; }
.po-cards { gap: 8px; }
.po-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-control); display: grid; gap: 8px; }
.po-card-head { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.po-card-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-card-head .num { font-weight: 600; color: var(--crit); }
.po-card-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.po-card-facts dt { font-size: 12px; color: var(--ink-3); }
.po-card-facts dd { margin: 0; font-size: 13px; }
.po-card .small .icon, .po-month .small .icon { width: 13px; height: 13px; vertical-align: -2px; }
.po-sav { display: grid; gap: 12px; }
.po-opts { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; }
.po-opt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--r-control); cursor: pointer; font-size: 13.5px; }
.po-opt:hover { background: var(--surface-2); }
.po-opt.is-on, .po-opt:has(input:checked) { border-color: var(--accent-text); background: var(--accent-wash); }
.po-opt input { accent-color: var(--accent); margin: 0; }
.po-opt-main { display: grid; min-width: 0; }
.po-opt-main .muted { font-size: 12.5px; }
.po-opt-side { display: grid; justify-items: end; gap: 2px; font-size: 12.5px; color: var(--ink-2); }
.po-opt-side .bstatus { font-size: 12px; }
.po-sched-title { font-size: 13px; font-weight: 600; margin-top: 4px; }
.po-sched { gap: 8px; }
.po-month { padding: 10px 12px; border-radius: var(--r-control); background: var(--surface-2); display: grid; gap: 6px; }
.po-month-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.po-month-head .num { font-weight: 600; }
.po-pay li { display: flex; gap: 6px; font-size: 13px; }
.po-pay li .num { margin-left: auto; }
.po-month .small, .po-card .small { margin: 0; }
.warn-text { color: var(--warn); }
.po-progress { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--r-control); border: 1px solid var(--line); }
.po-progress p { margin: 0; }
.po-prog-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto 110px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--line); }
.po-prog-list li:first-child { border-top: 0; }
@media (max-width: 480px) {
  .po-opt { grid-template-columns: auto minmax(0, 1fr); }
  .po-opt-side { grid-column: 2; justify-items: start; }
  .po-prog-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .po-prog-list li .bstatus { grid-column: 1 / -1; }
}

/* Overview: 12-month view of the spending panel */
.year-span { font-size: 12.5px; color: var(--ink-3); margin-top: -6px; }
.year-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 12px; }
.year-stats .mini-stat .label { display: inline-flex; align-items: center; gap: 6px; }
.year-stats .mini-stat .value { font-size: 20px; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.year-stats .mini-stat .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
#nwPanel .panel-head .tools, #spendPanel .panel-head .tools, #perfPanel .panel-head .tools { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) {
  #nwPanel .panel-head, #spendPanel .panel-head, #perfPanel .panel-head { flex-wrap: wrap; }
  .year-stats { gap: 16px 24px; }
}
.chart-gap { height: 18px; }
#nwChart { margin-top: 18px; }
#nwLegend:not([hidden]) + #nwChart { margin-top: 0; }
@media (max-width: 480px) { .chart-table .hide-sm { display: none; } }

/* ---------- Investments ---------- */
.inv-banner { align-items: center; }
.inv-banner .body { flex: 1; }
.banner-actions { flex: none; }
.inv-stats { gap: 16px 32px; }
.inv-stats .mini-stat .meta { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.panel-meta { font-size: 12.5px; color: var(--ink-3); }
.inv-accounts { border-top: 1px solid var(--line); margin-top: 14px; }
.inv-row {
  width: 100%; display: grid; grid-template-columns: 32px minmax(0, 1fr) 140px minmax(150px, auto); align-items: center; gap: 14px;
  padding: 12px 22px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: inherit; font: inherit; text-align: left;
  cursor: pointer; transition: background var(--fast) var(--ease);
}
[role='listitem']:last-child .inv-row { border-bottom: 0; border-radius: 0 0 var(--r-panel) var(--r-panel); }
.inv-row:hover { background: var(--surface-2); }
.inv-row.is-on { background: var(--accent-wash); box-shadow: inset 3px 0 0 var(--accent); }
.inv-row:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.inv-row .logo, .inv-row .type-icon { width: 32px; height: 32px; }
.inv-row .main, .inv-row .num { display: grid; min-width: 0; }
.inv-row .num { text-align: right; }
.inv-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-row .meta { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-row .spark .sparkline { width: 140px; height: 36px; }
.hold-table td { font-variant-numeric: tabular-nums; }
.hold-table .sec { display: inline-flex; align-items: center; gap: 8px; }
.hold-table .sec-name { font-weight: 600; }
.hold-table .sub { display: block; font-size: 12.5px; color: var(--ink-3); max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hold-table .pctx { display: block; font-size: 12.5px; color: var(--ink-3); }
.hold-table th.right .sort-btn { flex-direction: row-reverse; }
.hold-note { padding: 0 22px 18px; margin-top: 4px; }
.inv-activity .avatar { flex: none; }
.more-btn { margin-top: 8px; }
@media (max-width: 767px) {
  .inv-row { grid-template-columns: 32px minmax(0, 1fr) auto; padding: 12px 16px; }
  .inv-row .spark { display: none; }
  .hold-note { padding: 0 16px 16px; }
  .inv-banner { flex-wrap: wrap; }
  .banner-actions { width: 100%; padding-left: 30px; }
  /* Holdings become two-line rows: security and value, then shares, price and gain */
  .hold-table, .hold-table tbody { display: block; }
  .hold-table thead { display: none; }
  .hold-table tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'name value' 'name gain';
    gap: 2px 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  }
  .hold-table tr:last-child { border-bottom: 0; }
  .hold-table td { padding: 0; border: 0; }
  .hold-table td:first-child, .hold-table td:last-child { padding: 0; }
  .hold-table td.c-name { grid-area: name; }
  .hold-table td.c-value { grid-area: value; font-weight: 600; }
  .hold-table td.c-gain { grid-area: gain; font-size: 12.5px; }
  .hold-table td.c-gain .pctx { display: inline; margin-left: 6px; }
  .hold-table td.c-quantity, .hold-table td.c-price, .hold-table td.c-cost_basis, .hold-table td.c-weight { display: none; }
}

/* What Plaid shared: one block per account */
.shared-list { display: grid; gap: 0; }
.shared-row { padding: 14px 0; border-top: 1px solid var(--line); }
.shared-row:first-child { border-top: 0; padding-top: 0; }
.shared-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shared-head .name { font-weight: 600; }
.shared-head .meta { font-size: 12.5px; color: var(--ink-3); }
.shared-head .btn { margin-left: auto; }
.shared-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 24px; margin: 12px 0 0; }
.shared-facts dt { font-size: 12.5px; color: var(--ink-3); }
.shared-facts dd { margin: 2px 0 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.shared-note { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.shared-warn { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; color: var(--warn); margin-top: 10px; }
.shared-warn .icon { width: 15px; height: 15px; margin-top: 2px; flex: none; }
.shared-warn span { color: var(--ink); }
@media (max-width: 767px) {
  .shared-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
