:root {
  color-scheme: dark;

  /* Slate finance palette. Law: DESIGN.md. Color means something:
     accent = action, positive/danger = money only, gold = rare warning. */
  --ink: #0e141b;
  --ink-raised: #171e27;
  --ink-raised-hover: #212a35;
  --rule: #313d4a;
  --paper: #e8eef4;
  --text-muted: #8b98a6;
  --accent: #3c7ea6;
  --positive: #3f9d72;
  --danger: #d06558;
  --gold: #c4a15a;

  --font-sans:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Recharts gives bars/pie slices a native tabIndex for accessibility, which
   pulls in the browser's default blue focus ring on click in some engines —
   :focus-visible alone doesn't suppress it for arbitrary SVG elements the
   way it does for form controls. Chart segments already signal
   interactivity via cursor + tooltip, so they don't need a focus ring. */
.recharts-wrapper *:focus {
  outline: none;
}

/* Recharts' default tooltip ships its own light background with no text
   color of its own — it was inheriting this app's light "paper" body text
   color straight into that light box, making every tooltip (the hovered
   bar's date/value, etc.) illegible. Also raise it above the legend, which
   otherwise paints on top of it when a chart's legend sits directly below
   the plot area and the tooltip appears near that seam. */
.recharts-tooltip-wrapper {
  z-index: 50;
}
.recharts-default-tooltip {
  background: var(--ink-raised) !important;
  border: 1px solid var(--rule) !important;
  color: var(--paper) !important;
}
.recharts-tooltip-label {
  color: var(--paper) !important;
}
.recharts-tooltip-item {
  color: var(--paper) !important;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  font-family: var(--font-sans);
  background: var(--ink);
  color: var(--paper);
}

body.nav-drawer-open {
  overflow: hidden;
}

/* Pluggy Connect mounts a fixed iframe/modal on body. Our sticky topbar
   (z-index 100) and drawer (160) steal taps on mobile if the widget layer
   sits underneath — lock scroll and force the Connect chrome above chrome. */
body.pluggy-connect-open {
  overflow: hidden !important;
  touch-action: none;
}

body.pluggy-connect-open .topbar,
body.pluggy-connect-open .nav-drawer,
body.pluggy-connect-open .nav-drawer-scrim {
  pointer-events: none;
  z-index: 1;
}

body.pluggy-connect-open iframe,
body.pluggy-connect-open [id*="pluggy"],
body.pluggy-connect-open [class*="pluggy"] {
  z-index: 10000 !important;
  pointer-events: auto !important;
}

h1,
h2,
h3,
.brand {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 100;
  min-width: 0;
  overflow: visible;
}

.topbar .brand {
  display: none;
  font-size: 16px;
  flex-shrink: 0;
  white-space: nowrap;
}

.topbar-actions .person-switcher-trigger {
  max-width: 40vw;
}

.topbar-actions .person-switcher-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.topbar-nav-desktop {
  display: none;
  gap: 16px;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.topbar-nav-desktop a,
.nav-drawer a {
  color: var(--text-muted);
}

.topbar-nav-desktop a:hover,
.nav-drawer a:hover {
  color: var(--paper);
}

.topbar-nav-desktop a.active,
.nav-drawer a.active {
  color: var(--paper);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.topbar-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.nav-drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 150;
  border: none;
  padding: 0;
  margin: 0;
  background: color-mix(in srgb, var(--ink) 70%, transparent);
  cursor: pointer;
}

.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 160;
  width: min(20rem, 88vw);
  height: 100%;
  background: var(--ink-raised);
  border-left: 1px solid var(--rule);
  padding: 72px 16px 0;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 200ms ease;
  pointer-events: none;
}

.nav-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.nav-drawer-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
}

.nav-drawer-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--rule);
  padding: 12px 0 24px;
}

.nav-drawer a {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 1.05rem;
}

.nav-drawer a:hover,
.nav-drawer a.active {
  background: color-mix(in srgb, var(--paper) 5%, transparent);
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.period-picker {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.period-picker--prominent {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}

.period-picker-nav {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
}

.period-picker-nav--custom {
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .period-picker-nav--custom {
    flex-direction: column;
    align-items: stretch;
  }

  .period-picker-nav--custom input[type="date"] {
    width: 100%;
    min-height: 44px;
  }
}

.period-picker-arrow {
  flex-shrink: 0;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--ink-raised);
  color: var(--paper);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.period-picker-arrow:hover {
  background: var(--ink-raised-hover);
}

.period-picker-arrow:active {
  transform: scale(0.96);
}

.period-picker-label {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--ink-raised);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

.period-picker-label-text {
  font-size: 1rem;
  font-weight: 600;
  text-transform: capitalize;
  text-align: center;
}

.period-picker-hint {
  font-size: 0.7rem;
  font-weight: 400;
}

.period-picker-month-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: none;
}

@media (min-width: 768px) {
  .topbar {
    gap: 24px;
    padding: 16px 24px;
  }

  .topbar .brand {
    display: block;
    font-size: 18px;
  }

  .topbar-actions .person-switcher-trigger {
    max-width: none;
  }

  .topbar-nav-desktop {
    display: flex;
  }

  .topbar-burger,
  .nav-drawer,
  .nav-drawer-scrim {
    display: none !important;
  }
}

/* Lock/unlock control (components/LockControl.tsx) — the shackle is a
   separate path from the body so it alone can swing open on a hinge at its
   own bottom-left anchor, like a real latch, rather than the whole glyph
   spinning in place. transform-box: view-box makes the pixel-unit
   transform-origin below resolve against the SVG's own 24x24 coordinate
   space instead of the shackle path's local bounding box. */
.lock-glyph {
  color: var(--text-muted);
  transition: color 200ms ease;
  /* The open shackle's rotated arc pokes a sliver above the 0–24 viewBox
     (rotate(-35deg) around its hinge carries the top of the arc to a
     slightly negative y) — invisible at the small 18px header size, an
     obvious flat cut at the large 64px size used by the full-page
     transition overlay. SVGs clip to their viewBox by default; this turns
     that off. */
  overflow: visible;
}

.lock-glyph.is-unlocked {
  color: var(--accent);
}

.lock-glyph__shackle {
  transform-box: view-box;
  transform-origin: 7px 10px;
  transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1); /* slight overshoot — a "pop", not a glide */
}

.lock-glyph.is-unlocked .lock-glyph__shackle {
  transform: translate(-1px, -1px) rotate(-35deg);
}

.lock-glyph__keyhole {
  transition: opacity 150ms ease;
}

.lock-glyph.is-unlocked .lock-glyph__keyhole {
  opacity: 0; /* nothing left to turn a key in, once it's open */
}

.lock-glyph__body {
  transform-box: view-box;
  transform-origin: 12px 15px;
}

.lock-control {
  position: relative;
}

/* One gold burst, exactly once, the moment the vault actually unlocks — see
   LockControl.tsx for why this never fires on re-lock. */
.lock-control--glint::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--gold) 55%, transparent) 0%,
    transparent 70%
  );
  animation: lock-glint 700ms ease-out forwards;
  pointer-events: none;
}

@keyframes lock-glint {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  35% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lock-glyph__shackle {
    transition: none;
  }
  .lock-control--glint::before {
    animation: none;
    display: none;
  }
}

/* Full-page lock/unlock transition (lib/vaultTransition.tsx) — a single
   LockGlyph instance, rendered once at a fixed native size and positioned
   with a translate+scale transform (FLIP technique: starts matching the
   real origin icon's exact screen position/size, ends at an approximate
   destination). The scrim's visibility and the icon's move-to-destination
   are independent toggles (is-visible / is-moved), not nested, because
   locking and unlocking order them differently: locking travels first and
   only locks once it arrives, unlocking unlocks in place first and only
   then travels — see runLock/runUnlock. The real screen swap (vault-status
   cache update) always happens while the scrim is opaque, so it's never
   seen, only the travelling icon and the darkening/lightening page are. */
.vault-transition-scrim {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: color-mix(in srgb, var(--ink) 94%, transparent);
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: auto;
}

.vault-transition-scrim.is-visible {
  opacity: 1;
}

.vault-transition-scrim.is-revealing {
  opacity: 0;
}

.vault-transition-icon-wrap {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(var(--start-x), var(--start-y)) scale(var(--start-scale));
  transition:
    transform 520ms cubic-bezier(0.65, 0, 0.35, 1),
    opacity 240ms ease;
  color: var(--text-muted);
}

.vault-transition-icon-wrap.is-moved {
  transform: translate(var(--end-x), var(--end-y)) scale(var(--end-scale));
}

.vault-transition-icon-wrap.is-revealing {
  opacity: 0;
}

.vault-transition-icon-wrap .lock-glyph.is-unlocked {
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .vault-transition-scrim,
  .vault-transition-icon-wrap {
    transition: none;
  }
}

/* The one-time recovery code / API key display — set like a printed credential: */
.recovery-code,
.api-key-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.04em;
  background: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 14px 16px;
  word-break: break-all;
  user-select: all;
}

main {
  padding: 16px;
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  min-width: 0;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  main {
    padding: 24px;
  }
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 32px;
  width: min(400px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.auth-card > svg.lock-glyph {
  align-self: center;
}

.auth-card input {
  padding: 8px 10px;
}

.auth-card button {
  margin-top: 8px;
  padding: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="password"],
select {
  background: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 6px 10px;
  color: var(--paper);
}

select {
  cursor: pointer;
}

input[type="range"],
input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Button hierarchy: the bare element is primary (the one filled action in
   a context); .secondary is a quiet outline for lesser actions; .danger is
   rust for destructive ones; .link-button stays inline/textual. The
   transparent border keeps every variant the exact same height. */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 7px 13px;
  color: #f4f8fb;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease;
}

button:hover {
  background: color-mix(in srgb, var(--accent) 85%, var(--paper));
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button.link-button {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0;
  font-weight: 400;
}

button.link-button:hover {
  background: none;
  color: var(--paper);
}

button.secondary {
  background: none;
  border-color: var(--rule);
  color: var(--text-muted);
  font-weight: 500;
}

button.secondary:hover {
  background: var(--ink-raised-hover);
  border-color: var(--text-muted);
  color: var(--paper);
}

button.danger {
  background: none;
  border-color: transparent;
  color: var(--danger);
}

button.danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

/* Square sizing for icon-only buttons; combines with any variant. */
button.icon {
  padding: 7px;
}

/* Same look as button.secondary.icon, but for an actual <a> (the settings
   nav link) — button's element-scoped rules above don't match an anchor. */
a.secondary.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 7px;
  color: var(--text-muted);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

a.secondary.icon:hover {
  background: var(--ink-raised-hover);
  border-color: var(--text-muted);
  color: var(--paper);
}

a.secondary.icon.active {
  color: var(--paper);
  border-color: var(--accent);
}

/* A link that reads as the primary button — for navigations that start an
   action (e.g. "Add person" leading to the new-person form). */
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 7px 13px;
  color: #f4f8fb;
  font-weight: 600;
  transition: background 120ms ease;
}

a.button:hover {
  background: color-mix(in srgb, var(--accent) 85%, var(--paper));
}

/* A collapsible section's header — reads as a heading, acts as a button. */
button.disclosure {
  background: none;
  border: none;
  padding: 0;
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

button.disclosure:hover {
  background: none;
  color: var(--accent);
}

button.disclosure svg {
  color: var(--text-muted);
}

/* Segmented toggle: one bordered group, the active segment raised — for
   mutually exclusive views (By card / By category, period granularity). */
.toggle-group {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  border-radius: 4px;
  max-width: 100%;
}

.toggle-group button {
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  font-weight: 500;
  padding: 7px 12px;
}

.toggle-group button + button {
  border-left: 1px solid var(--rule);
}

.toggle-group button:first-child {
  border-radius: 3px 0 0 3px;
}

.toggle-group button:hover {
  background: color-mix(in srgb, var(--paper) 5%, transparent);
  color: var(--paper);
}

.toggle-group button.active {
  background: var(--ink-raised-hover);
  color: var(--paper);
  font-weight: 600;
}

/* The group's overflow: hidden would clip the default offset ring. */
.toggle-group button:focus-visible {
  outline-offset: -2px;
}

/* Custom dropdown (components/Dropdown) — trigger is a button.secondary;
   these style the floating option list. */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  min-width: 100%;
  margin-top: 4px;
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
}

.dropdown-menu button:hover {
  background: var(--ink-raised-hover);
  color: var(--paper);
}

.dropdown-menu button.selected {
  color: var(--paper);
  font-weight: 600;
}

.dropdown-menu button:focus-visible {
  outline-offset: -2px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 0;
}

/* Shared form vocabulary — one grid for field groups, one row for actions,
   one voice for hints and inline save/test feedback, so every settings form
   lays out and reports back the same way. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.status-ok,
.status-error {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
}

.status-ok {
  color: var(--accent);
}

.status-error {
  color: var(--danger);
}

/* Icon-button clusters at the end of a table row. */
.row-actions {
  display: inline-flex;
  gap: 6px;
  white-space: nowrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
}

/* :not(:has(tr:hover)) keeps an outer row from lighting up its whole
   expanded sub-table region when the hover is really on an inner row. */
tbody tr:hover:not(:has(tr:hover)) {
  background: color-mix(in srgb, var(--paper) 3%, transparent);
}

tbody tr:last-child > td {
  border-bottom: none;
}

th {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Every money figure gets tabular numerals in a monospace face — real
   ledgers align decimal points; this is functional, not decorative. */
td.money,
.value,
.money {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 20px;
}

.debt-tile {
  cursor: pointer;
  transition:
    border-color 120ms ease,
    background 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.debt-tile:hover {
  border-color: var(--text-muted);
  background: var(--ink-raised-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.debt-tile:active {
  transform: translateY(-1px);
}

.debt-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card > h2 {
  margin: 0 0 14px;
  font-size: 19px;
}

.card > h2 + p.muted {
  margin-top: -8px;
}

/* Heading + lede grouped at the top of (or between sections inside) a form
   card — same scale as .card > h2, for when the heading can't be a direct
   child because it sits inside the form's own grid. */
.card-intro h2,
.card-intro h3 {
  margin: 0;
  font-size: 19px;
}

.card-intro h3 {
  font-size: 16px;
}

.card-intro p.muted {
  margin-top: 4px;
}

.card p.muted {
  line-height: 1.55;
  max-width: 78ch;
}

.card > p.muted {
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

/* /config's side-tab shell — narrow sticky nav on the left, content on the
   right. The nav hangs its tabs on a vertical rule, like the margin rule on
   ledger paper; the active tab pins onto it with a ledger-green tick — the
   same accent-edge language as the topbar underline and the verdict tiles. */
.config-shell {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.config-shell > nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 180px;
  flex-shrink: 0;
  position: sticky;
  top: 88px;
  border-left: 1px solid var(--rule);
}

.config-shell > nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  margin-left: -1px; /* the tab's edge sits on the rule, covering it when active */
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  color: var(--text-muted);
  font-size: 15px;
}

.config-shell > nav a:hover {
  background: var(--ink-raised-hover);
  color: var(--paper);
}

.config-shell > nav a.active {
  border-left-color: var(--accent);
  background: var(--ink-raised);
  color: var(--paper);
  font-weight: 600;
}

.config-shell > .config-content {
  flex: 1;
  min-width: 0;
}

/* Every config tab (and the person profile page) opens with the same header:
   serif title, one muted lede, and optionally one action on the right. */
.config-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.config-header h2 {
  margin: 0;
  font-size: 23px;
}

.config-header p.muted {
  margin-top: 6px;
  max-width: 64ch;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .config-shell {
    flex-direction: column;
  }

  .config-shell > nav {
    flex-direction: row;
    width: 100%;
    position: static;
    overflow-x: auto;
    gap: 6px;
    border-left: none;
    border-bottom: none;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .config-shell > nav a {
    margin-left: 0;
    border-left: none;
    border-radius: 6px;
    white-space: nowrap;
    min-height: 44px;
    font-size: 15px;
    background: var(--ink-raised);
    border: 1px solid var(--rule);
    padding: 10px 14px;
  }

  .config-shell > nav a.active {
    border-color: var(--accent);
    background: var(--ink-raised-hover);
  }
}

/* People list as mobile cards (table only as desktop fallback). */
.config-people-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-person-card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-person-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-person-card-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.config-person-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.config-person-card-actions .button,
.config-person-card-actions button,
.config-person-card-actions a.button,
.config-person-card-actions a.secondary {
  min-height: 44px;
  font-size: 15px;
  flex: 1 1 auto;
  justify-content: center;
}

.color-swatch-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch-picker button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}

.color-swatch-picker button.selected {
  border-color: var(--paper);
  box-shadow: 0 0 0 2px var(--accent);
}

.config-advanced details {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  margin-top: 8px;
}

.config-advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  min-height: 36px;
  display: flex;
  align-items: center;
}

@media (min-width: 721px) {
  .config-people-cards-mobile-only {
    display: none;
  }
}

@media (max-width: 720px) {
  .config-people-table-desktop-only {
    display: none;
  }
}

.shortfall {
  color: var(--danger);
  font-weight: 600;
}

.gain {
  color: var(--positive);
  font-weight: 600;
}

.chart-container {
  position: relative;
  height: 260px;
  max-width: 100%;
}

.summary-card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}

.summary-card .label {
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.03em;
}

.summary-card .value {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 600;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.2;
  min-width: 0;
}

.summary-card .caption {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.summary-card.positive .value {
  color: var(--positive);
}

.summary-card.negative .value {
  color: var(--danger);
}

/* Verdict tiles: an inset edge (not a border swap) so good/bad stat cards
   keep the exact same footprint as their plain siblings. */
.summary-card.good {
  box-shadow: inset 3px 0 0 var(--positive);
}

.summary-card.good .value {
  color: var(--positive);
}

.summary-card.bad {
  box-shadow: inset 3px 0 0 var(--danger);
}

.summary-card.bad .value {
  color: var(--danger);
}

.badge {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 3px 8px;
}

/* Signature element: a faint ruled-ledger-paper texture, used once on the
   dashboard's main balance/cash-flow chart — not repeated elsewhere. */
.ledger-feature {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 27px,
    var(--rule) 27px,
    var(--rule) 28px
  );
  background-position: 0 44px;
}

/* --- Dashboard V2 (simple family panel) — mobile-first -------------- */

.v2-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  padding-bottom: 24px;
}

.v2-viz-card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px;
}

.v2-viz-card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.v2-viz-sub {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.35;
}

.v2-viz-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.v2-viz-footer {
  margin: 10px 0 0;
  font-size: 13px;
}

.v2-hero-card {
  padding: 14px 12px;
}

.v2-hero-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.v2-hero-value {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.25rem, 6vw, 2rem);
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.v2-hero-value.good {
  color: var(--positive);
}

.v2-hero-value.bad {
  color: var(--danger);
}

.v2-hero-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.v2-hero-month-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.v2-hero-total-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.v2-hero-total-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  font-weight: 600;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.v2-stat-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.v2-stat-cell {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.v2-stat-label {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
}

.v2-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-donut-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.v2-donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-donut-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 2.5rem auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  border-radius: 4px;
  padding: 4px 2px;
  color: var(--paper);
  font: inherit;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  min-height: 32px;
}

.v2-donut-legend-row:disabled {
  cursor: default;
  opacity: 1;
}

.v2-donut-legend-row.selected {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.v2-donut-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.v2-donut-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-pace-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--ink);
  border: 1px solid var(--rule);
  overflow: hidden;
}

.v2-pace-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 200ms ease;
}

.v2-pace-fill.over {
  background: var(--danger);
}

.v2-pace-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}

.v2-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.v2-header-titles h1 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
}

.v2-header-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.v2-header-controls .v2-field,
.v2-account-filter {
  width: 100%;
}

.v2-help {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.v2-card {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 14px 16px;
  background: var(--ink-raised);
}

.v2-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.v2-section-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.v2-section-hint {
  font-size: 0.75rem;
  line-height: 1.3;
  max-width: 14rem;
  text-align: right;
}

.v2-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.v2-kpi-grid .summary-card {
  padding: 8px 10px;
}

.v2-kpi-grid .summary-card .label {
  font-size: 11px;
  letter-spacing: 0;
}

.v2-kpi-grid .summary-card .value {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.v2-kpi-grid .summary-card .caption {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.v2-breakdown-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.v2-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.v2-chips button,
.v2-filter-chip {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--paper);
  border-radius: 4px;
  padding: 4px 8px;
  min-height: 28px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.v2-chips button.active,
.v2-filter-chip {
  border-color: var(--accent);
  color: var(--accent);
}

.v2-income-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

.v2-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.v2-field input,
.v2-field select {
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1rem;
  width: 100%;
}

.v2-income-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.v2-income-actions button {
  min-height: 44px;
  padding: 10px 18px;
}

.v2-envelopes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.v2-envelope-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.v2-envelope-track {
  height: 8px;
  background: color-mix(in srgb, var(--rule) 80%, var(--ink));
  border-radius: 2px;
  overflow: hidden;
}

.v2-envelope-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 200ms ease;
}

.v2-envelope-fill.over {
  background: var(--danger);
}

.v2-envelope-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
}

/* Ranked bars -------------------------------------------------------- */

.v2-rank-list,
.v2-tx-list,
.v2-accordion {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.v2-rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(48px, 1fr) 2.5rem minmax(5.5rem, auto);
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 4px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

button.v2-rank-row {
  cursor: pointer;
  min-height: 44px;
}

button.v2-rank-row:hover,
button.v2-rank-row.selected {
  background: color-mix(in srgb, var(--paper) 5%, transparent);
}

button.v2-rank-row.selected {
  box-shadow: inset 2px 0 0 var(--accent);
}

.v2-rank-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
}

.v2-rank-track {
  height: 6px;
  background: color-mix(in srgb, var(--rule) 70%, transparent);
  border-radius: 2px;
  overflow: hidden;
}

.v2-rank-fill {
  display: block;
  height: 100%;
  border-radius: 2px;
  min-width: 0;
}

.v2-rank-pct {
  font-size: 0.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.v2-rank-value {
  font-size: 0.875rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Accordion card × category ------------------------------------------ */

.v2-accordion-item {
  border-bottom: 1px solid var(--rule);
}

.v2-accordion-item:last-child {
  border-bottom: none;
}

.v2-accordion-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.v2-accordion-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.9rem;
}

.v2-accordion-chevron {
  color: var(--text-muted);
  width: 1.25rem;
  text-align: center;
}

.v2-accordion-body {
  padding: 0 0 12px 8px;
}

.v2-accordion-hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
}

/* Transaction rows --------------------------------------------------- */

.v2-tx-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
  min-height: 64px;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
}

.v2-tx-row:last-child {
  border-bottom: none;
}

.v2-tx-row-main {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 8px 4px;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: default;
}

.v2-tx-row-clickable .v2-tx-row-main {
  cursor: pointer;
  border-radius: 6px;
}

.v2-tx-row-clickable .v2-tx-row-main:hover,
.v2-tx-row-clickable .v2-tx-row-main:active {
  background: var(--ink-raised-hover);
}

button.v2-tx-row-main:disabled {
  cursor: default;
  opacity: 1;
}

.v2-tx-when {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}

.v2-tx-date {
  font-size: 0.8rem;
  font-weight: 600;
}

.v2-tx-time {
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.v2-tx-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.v2-tx-desc {
  font-size: 0.9rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.v2-tx-meta {
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-tx-amount {
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  white-space: nowrap;
  padding-top: 2px;
}

/* Secondary details -------------------------------------------------- */

.v2-details {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--ink-raised);
  padding: 0 14px;
}

.v2-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 8px 0;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  min-height: 36px;
}

.v2-details > summary::-webkit-details-marker {
  display: none;
}

.v2-details > summary::before {
  content: "▸";
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 400;
  margin-right: 4px;
}

.v2-details[open] > summary::before {
  content: "▾";
}

.v2-details-meta {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.85rem;
  margin-left: auto;
}

.v2-details-body {
  padding: 0 0 16px;
}

.v2-details-body > p:first-child {
  margin-top: 0;
}

.v2-footer {
  margin: 4px 0 8px;
  font-size: 0.9rem;
}

.v2-commitments {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v2-progressive {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--ink-raised);
  padding: 0 14px;
}

.v2-progressive-summary {
  list-style: none;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 8px 0;
}

.v2-progressive-summary::-webkit-details-marker {
  display: none;
}

.v2-progressive-summary::before {
  content: "▸";
  color: var(--text-muted);
  margin-right: 2px;
}

.v2-progressive[open] > .v2-progressive-summary::before {
  content: "▾";
}

.v2-progressive-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
}

.v2-progressive-metric {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  text-align: right;
}

.v2-progressive-body {
  padding: 0 0 14px;
}

.v2-progressive-footer {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.v2-commitment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-commitment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
  min-height: 32px;
}

.v2-commitment-row:last-child {
  border-bottom: none;
}

.v2-commitment-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.v2-commitment-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-commitment-meta {
  font-size: 0.75rem;
}

/* Projections page — mobile-first ------------------------------------ */

.projections-page {
  min-width: 0;
  max-width: 100%;
}

.projections-kpi-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.projections-whatif-grid {
  min-width: 0;
}

.projections-whatif-table {
  min-width: 0;
  max-width: 100%;
}

.projections-page .chart-container {
  max-width: 100%;
  min-width: 0;
}

@media (min-width: 768px) {
  .projections-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
  }

  .projections-whatif-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
  }
}

@media (min-width: 768px) {
  .v2-page {
    gap: 20px;
  }

  .v2-commitments {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }

  .v2-header {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }

  .v2-header h1 {
    font-size: 18px;
  }

  .v2-header-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    width: auto;
    max-width: 28rem;
  }

  .v2-header-controls .v2-field,
  .v2-account-filter {
    width: auto;
    min-width: 11rem;
  }

  .v2-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .v2-breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }

  .v2-envelopes {
    grid-template-columns: 1fr 1fr;
  }

  .v2-income-form {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  }

  .v2-card {
    padding: 16px 18px;
  }

  .v2-rank-row {
    grid-template-columns: minmax(0, 1.4fr) minmax(64px, 1.2fr) 2.75rem minmax(6rem, auto);
  }

  .v2-tx-row-main {
    grid-template-columns: 6rem minmax(0, 1fr) auto;
    gap: 14px;
  }
}

/* Modal sheet — recurring bill add (mobile full-screen / desktop dialog) */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow: auto;
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 12px 12px 0 0;
  padding: 12px 12px 16px;
}

.modal-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-sheet-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.modal-sheet--tall {
  max-height: 90vh;
}

.lay-ai-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, var(--ink-raised));
  color: var(--paper);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.lay-ai-banner:hover {
  background: color-mix(in srgb, var(--accent) 22%, var(--ink-raised));
}

.lay-ai-banner-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}

.lay-ai-banner-cta {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.category-select {
  position: relative;
  min-width: 10rem;
  width: 100%;
}

.category-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--ink-raised);
  color: var(--paper);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.category-select-trigger:hover {
  background: var(--ink-raised-hover);
}

.category-select-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  width: 100%;
  min-width: 14rem;
  max-height: 280px;
  overflow-y: auto;
  margin-top: 4px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--ink-raised);
}

.category-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.95rem;
}

.category-select-option:hover {
  background: var(--ink-raised-hover);
}

.lay-page-head .period-picker--prominent {
  gap: 0;
}

@media (min-width: 768px) {
  .modal-scrim {
    align-items: center;
    padding: 24px;
  }
  .modal-sheet {
    border-radius: 10px;
  }
}

.v2-recurring {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v2-recurring-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.v2-recurring-head h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.v2-recurring-total {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.v2-month-outlook {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v2-month-outlook h2 {
  margin: 0;
  font-size: 1.1rem;
}

.v2-month-outlook h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.v2-subs-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.v2-tx-make-recurring {
  display: inline-block;
  margin-top: 2px;
  font-size: 12px;
}

button.secondary.icon {
  min-width: 36px;
  min-height: 36px;
  padding: 6px;
}

/* Transactions mobile-first */
.txs-filters {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}

.txs-filters-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .txs-filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.txs-mobile-list {
  display: block;
}

.txs-desktop-table {
  display: none;
}

@media (min-width: 768px) {
  .txs-mobile-list {
    display: none;
  }
  .txs-desktop-table {
    display: block;
  }
}

.txs-exclude-icon {
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  white-space: normal;
}

.projections-month-label {
  text-transform: capitalize;
}

.projections-breakdown-mobile {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 768px) {
  .projections-breakdown-mobile {
    display: none;
  }
  .projections-breakdown-desktop {
    display: block;
  }
}

.projections-breakdown-desktop {
  display: none;
}

@media (min-width: 768px) {
  .projections-breakdown-desktop {
    display: block;
  }
}

/* --- Layperson secondary screens (tx / bills / debts / projections) --- */

.lay-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  padding-bottom: 32px;
}

.lay-page > h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.lay-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lay-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.lay-page-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}

.lay-kpi-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lay-kpi {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.lay-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
}

.lay-kpi-value {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.lay-search {
  width: 100%;
  min-height: 44px;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
}

.lay-card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lay-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px;
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-align: left;
  width: 100%;
  color: inherit;
  cursor: pointer;
}

.lay-row:active {
  background: var(--ink-raised-hover);
}

.lay-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lay-row-title {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lay-row-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.lay-row-amount {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  flex-shrink: 0;
}

.lay-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lay-tab {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  cursor: pointer;
}

.lay-tab.active {
  background: var(--ink-raised-hover);
  border-color: var(--accent);
  color: var(--paper);
}

.lay-viz-card {
  background: var(--ink-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 12px;
}

.lay-viz-card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.v2-category-modal-list {
  max-height: 50vh;
  overflow: auto;
  margin-bottom: 8px;
}

.form-grid-mobile {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .form-grid-mobile.form-grid-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.bills-mobile-list {
  display: block;
}

.bills-desktop-table {
  display: none;
}

@media (min-width: 768px) {
  .bills-mobile-list {
    display: none;
  }
  .bills-desktop-table {
    display: block;
  }
}

.goals-mobile-list {
  display: block;
}

.goals-desktop-table {
  display: none;
}

@media (min-width: 768px) {
  .goals-mobile-list {
    display: none;
  }
  .goals-desktop-table {
    display: block;
  }
}
