:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #ecebe4;
  --line: rgba(14, 21, 38, 0.1);
  --text: #0e1526;
  --text-soft: #52514e;
  --muted: #6b6a66;
  --blue: #378add;
  --teal: #0f6e56;
  --teal-bright: #1d9e75;
  --teal-pale: #e1f5ee;
  --purple: #7f77dd;
  --orange: #f97316;
  --yellow: #eab308;
  --amber: #ba7517;
  --amber-ink: #8a5510;
  --amber-pale: #faeeda;
  --coral: #d85a30;
  --coral-ink: #b84a24;
  --red: #dc2626;
  --green: #16a34a;
  --slate: #6b6a66;
  /* expense types: fixed green, variable red, extra orange */
  --fixed: #2f6bd8;
  --variable: #6fa3ee;
  --extra: #b9d3f7;
  --fixed-ink: #1d4a9c;
  --wealth-ink: #6d46b8;
  --variable-ink: #2a5fbf;
  --extra-ink: #3f72c9;
  --fixed-grad: linear-gradient(135deg, #4a86f2 0%, #2f6bd8 55%, #2252b8 100%);
  --variable-grad: linear-gradient(135deg, #93bdf5 0%, #6fa3ee 55%, #5a8fe4 100%);
  --extra-grad: linear-gradient(135deg, #dbe9fc 0%, #b9d3f7 55%, #9cbff2 100%);
  --navy: #0e1526;
  --navy-active: #1a2440;
  --on-hero-muted: #9c9b96;
  --on-accent: #0e1526; /* text on a --blue fill: AA in both themes */
  /* Income: one hue (slate blue), a tone per source, as the expenses are tones of blue. */
  --income-1: #6f83a6;
  --income-2: #8d9eba;
  --income-3: #abb8cc;
  --income-4: #c7d0dd;
  --income-5: #dde3eb;
  /* Free liquidity (money outside every pot): one hue everywhere it appears. Layers bring their own colour. */
  --layer-free: #c98500;
  --shadow: 0 16px 40px rgba(14, 21, 38, 0.08);
  --soft-shadow: 0 8px 22px rgba(14, 21, 38, 0.06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #141c30;
  --surface-2: #0f1626;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f2f1ec;
  --text-soft: #b9b7b0;
  --muted: #97948d;
  --blue: #6fa8e6;
  --teal: #5dcaa5;
  --teal-bright: #1d9e75;
  --teal-pale: rgba(29, 158, 117, 0.16);
  --purple: #9a93e8;
  --orange: #fb923c;
  --yellow: #facc15;
  --amber: #e0a53c;
  --amber-ink: #e0a53c;
  --amber-pale: rgba(186, 117, 23, 0.18);
  --coral: #e08064;
  --coral-ink: #e68a6f;
  --red: #f87171;
  --green: #34d399;
  --slate: #8b8a85;
  --fixed: #4a86f2;
  --variable: #82b0f2;
  --extra: #b9d3f7;
  --fixed-ink: #9cc0f7;
  --wealth-ink: #c0aef2;
  --variable-ink: #b2cff8;
  --extra-ink: #d3e4fb;
  --fixed-grad: linear-gradient(135deg, #6a9df5 0%, #4a86f2 55%, #3069d6 100%);
  --variable-grad: linear-gradient(135deg, #a6c8f7 0%, #82b0f2 55%, #6a9be8 100%);
  --extra-grad: linear-gradient(135deg, #e1edfd 0%, #b9d3f7 55%, #a0c2f3 100%);
  --navy: #070a12;
  --navy-active: #141c30;
  --on-accent: #070a12;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --soft-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: 2px;
}

html {
  min-width: 320px;
  /* Reserve the scrollbar's space so filtering cards never shifts the layout sideways. */
  scrollbar-gutter: stable;
}

/* Every box that scrolls on its own (sheets, lists, panels) keeps its bar's room too: the content never narrows when it appears. */
.modal-card:not(.sheet-form),
.sheet-body,
.drawer-body,
.bank-picker-list,
.account-choice {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

/* Browsers without scrollbar-gutter keep the bar always there instead, so it never pops in and squeezes the page.
   The page still scrolls on the window, never on body: body clipping sideways on its own would make it a scroll box
   and every sticky part (the road's rail and its deck of stages, the top bar) would scroll away.
   It goes after the body rule so its overflow-x wins over body's own. */
@supports not (scrollbar-gutter: stable) {
  html { overflow-x: hidden; overflow-y: scroll; }
  body { overflow-x: visible; }
}

[data-icon] svg {
  width: 1em;
  height: 1em;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-icon="spark"] svg {
  fill: currentColor;
  stroke: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(245, 247, 251, 0.9);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  backdrop-filter: blur(16px);
}

.app-header h1,
.page-title h2,
.hero-summary h2,
.panel h3,
.entity-card h3,
.bank-card h3,
.modal h3,
.side-drawer h2 {
  margin: 0;
  line-height: 1.1;
}

.app-header h1 {
  font-size: clamp(1.1rem, 2vw, 1.45rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 14px;
  color: #f2f1ec;
  background: var(--navy);
}

/* On a wide screen the sidebar is pinned to the window: it always reaches the bottom, however long the page
   grows (a list opening, an animation still running) and whatever the browser does with sticky. */
@media (min-width: 1181px) {
  .sidebar {
    position: fixed;
    z-index: 10;
    top: 0;
    bottom: 0;
    left: 0;
    width: 236px;
    height: auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .app-shell > .content {
    grid-column: 2;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 2px;
}

.brand-mark {
  width: 28px;
  height: 35px;
  display: grid;
  flex: 0 0 auto;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-mark .on-dark,
html[data-theme="dark"] .brand-mark .on-light { display: none; }
html[data-theme="dark"] .brand-mark .on-dark { display: block; }

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand small {
  margin-top: 2px;
  font-size: 0.72rem;
  color: #9a9890;
}

.nav-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  color: #9a9890;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-list a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-list a.active {
  color: #fff;
}

/* The active pill is its own element so it can glide between links on navigation. */
.nav-list a { position: relative; z-index: 0; }
.nav-list a > .nav-pill {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: auto;
  height: auto;
  background: var(--navy-active);
  border-radius: 8px;
  view-transition-name: nav-pill;
}

/* Sections: "Flujo mensual" (what comes in and goes out each month) and "Patrimonio" (what is held).
   Each folds (the button) with 1fr -> 0fr; what the user left folded is an attribute on <html> (head script of base.html),
   so it is right from the first paint. The group with the active page never folds. */
.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 10px 0 2px;
  padding: 6px 10px;
  color: #6f6d66;
  font: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.nav-section:hover { color: #a9a79f; }

.nav-section-chevron {
  display: inline-grid;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  transform: rotate(90deg);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.nav-section-chevron svg { width: 100%; height: 100%; }

.nav-group-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.2, 0, 0, 1), visibility 0.3s;
}

.nav-group-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

html[data-nav-flujo-cerrado] .nav-group[data-nav-group="flujo"] .nav-group-body,
html[data-nav-patrimonio-cerrado] .nav-group[data-nav-group="patrimonio"] .nav-group-body {
  grid-template-rows: 0fr;
  visibility: hidden;
}

html[data-nav-flujo-cerrado] .nav-group[data-nav-group="flujo"] .nav-section-chevron,
html[data-nav-patrimonio-cerrado] .nav-group[data-nav-group="patrimonio"] .nav-section-chevron {
  transform: none;
}

/* The group holding the active page stays open: its title doesn't act. */
html[data-nav-activo="flujo"] .nav-group[data-nav-group="flujo"] .nav-section,
html[data-nav-activo="patrimonio"] .nav-group[data-nav-group="patrimonio"] .nav-section {
  cursor: default;
}

@media (pointer: coarse) {
  .nav-section { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-group-body, .nav-section-chevron { transition: none; }
}

.nav-list a.nav-settings {
  margin-top: auto;
}

/* Account and theme live at the foot of the sidebar, under a hairline. */
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar .user-chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar .user-chip-email {
  flex: 1;
  min-width: 0;
  max-width: none;
  color: #c9c7bf;
}

.sidebar .user-chip-out {
  flex: 0 0 auto;
  color: #9a9890;
}

.sidebar .user-chip-out:hover {
  color: var(--coral);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .theme-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: #c9c7bf;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  cursor: pointer;
}

.sidebar .theme-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar .theme-toggle [data-icon] {
  width: 16px;
  height: 16px;
}

.nav-list a > span {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

/* a column whose last child, the footer, is pushed to the bottom of the screen on short pages */
.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 28px 20px;
}

.content > * {
  flex-shrink: 0;
}

html {
  scroll-padding-top: calc(var(--topbar-offset, 0px) + 80px);
}

/* sticky top bar: page title on the left, account + theme on the right; the border shows once scrolled */
.content-topbar {
  position: sticky;
  top: var(--topbar-offset, 0px);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  margin: -28px -28px 0;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  /* a barely-there line at rest; it firms up once the content scrolls beneath */
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Screens without a title (the dashboard) need no top bar: account and theme now live in the sidebar. */
.content-topbar:has(.topbar-title:empty) {
  display: none;
}

.content-topbar.is-scrolled {
  border-bottom-color: var(--line);
  box-shadow: 0 6px 18px rgba(14, 21, 38, 0.04);
}

.topbar-title {
  min-width: 0;
}

.topbar-title:has(.topbar-back) {
  display: flex;
  align-items: center;
}

/* The page's «Volver» arrow, docked beside the title once its own bar scrolls away. */
.topbar-back {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 0;
  height: 34px;
  margin-right: 0;
  overflow: hidden;
  border-radius: 999px;
  color: var(--text);
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition:
    width 320ms cubic-bezier(0.2, 0, 0, 1),
    margin-right 320ms cubic-bezier(0.2, 0, 0, 1),
    opacity 320ms cubic-bezier(0.2, 0, 0, 1),
    transform 320ms cubic-bezier(0.2, 0, 0, 1),
    background-color 160ms ease;
}

.topbar-back:hover {
  background: var(--line);
}

.content-topbar.has-back .topbar-back {
  width: 34px;
  margin-right: 8px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .topbar-back {
    transition: none;
  }
}

.topbar-title h2 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-topbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.45rem);
  line-height: 1;
}

.theme-toggle {
  width: 42px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-soft);
  background: var(--surface);
}

.theme-toggle span {
  position: absolute;
}

html[data-theme="dark"] .theme-toggle .moon-icon,
html[data-theme="light"] .theme-toggle .sun-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html[data-theme="dark"] .theme-toggle .sun-icon,
html[data-theme="light"] .theme-toggle .moon-icon {
  opacity: 0;
  transform: rotate(-45deg) scale(0.7);
}

.page-title,
.hero-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.page-title h2,
.hero-summary h2 {
  font-size: clamp(1.7rem, 3vw, 2.7rem);
}

.hero-summary {
  padding: 26px;
  background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--teal-pale) 55%, var(--surface)) 54%, color-mix(in srgb, var(--blue) 7%, var(--surface)) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
}

.hero-balance,
.mini-stat {
  min-width: 280px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 8px;
}

.hero-balance span,
.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.hero-balance strong,
.mini-stat strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.hero-balance small,
.mini-stat small {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  white-space: nowrap;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

.button:active {
  transform: scale(0.98);
  box-shadow: none;
}

/* Clickable cards: one hover for all (lift, soft shadow, blue border), and no lift while pressed. */
:where(.inc-card, .exp-card, .acc-card, .tree-node, .category-tile, .dash-card.js-open-dialog, .dash-card.js-card-filter, a.budget-card) {
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.3s cubic-bezier(0.2, 0, 0, 1), border-color 0.3s cubic-bezier(0.2, 0, 0, 1);
}

:is(.inc-card, .exp-card, .acc-card, .tree-node, .category-tile, .dash-card.js-open-dialog, .dash-card.js-card-filter, a.budget-card):is(:hover, :focus-visible) {
  transform: translateY(-1px);
  box-shadow: var(--soft-shadow);
}

/* The account card keeps its bank's border, the plain one (Cuentas) its hairline like Inversiones, and the member node its own colour. */
:is(.inc-card, .exp-card, .category-tile, .dash-card.js-open-dialog:not(.acc-card.is-plain), .dash-card.js-card-filter):is(:hover, :focus-visible) {
  border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
}

:is(.inc-card, .exp-card, .acc-card, .tree-node, .category-tile, .dash-card.js-open-dialog, .dash-card.js-card-filter, a.budget-card):active {
  transform: scale(0.985);
  box-shadow: none;
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.12s cubic-bezier(0.2, 0, 0, 1), border-color 0.12s cubic-bezier(0.2, 0, 0, 1);
}

/* Small buttons are pressed in too. */
.icon-button:active {
  transform: scale(0.985);
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-reduced-motion: reduce) {
  .button:hover,
  .button:active { transform: none; }

  :where(.inc-card, .exp-card, .acc-card, .tree-node, .category-tile, .dash-card.js-open-dialog, .dash-card.js-card-filter, a.budget-card),
  :is(.inc-card, .exp-card, .acc-card, .tree-node, .category-tile, .dash-card.js-open-dialog, .dash-card.js-card-filter, a.budget-card):is(:hover, :focus-visible, :active) {
    transform: none;
    transition: none;
  }
}

.button.primary {
  background: var(--navy);
  color: #fff;
}

.button.subtle {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-soft);
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
}

.button.danger {
  background: color-mix(in srgb, var(--red) 14%, var(--surface));
  color: color-mix(in srgb, var(--red) 80%, var(--text));
}

.button.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.header-actions,
.row-actions,
.drawer-actions,
.modal-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.panel,
.entity-card,
.item-card,
.bank-card,
.control-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  overflow: hidden;
  position: relative;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 5px solid var(--accent, var(--blue));
  pointer-events: none;
}

.metric-card span,
.metric-card small,
.entity-card p,
.bank-card p,
.mini-metrics,
.drawer-metrics span,
.comparison-grid span,
.split-grid span,
.item-amounts span,
.wealth-grid span,
.money-pair span {
  color: var(--muted);
}

.metric-card strong {
  display: block;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.metric-card.income { --accent: var(--green); }
.metric-card.income-soft { --accent: var(--teal); }
.metric-card.expense { --accent: var(--orange); }
.metric-card.expense-blue { --accent: var(--blue); }
.metric-card.warning { --accent: var(--yellow); }
.metric-card.investment { --accent: var(--purple); }
.metric-card.savings { --accent: var(--teal); }
.metric-card.liquidity { --accent: var(--blue); }
.metric-card.asset { --accent: var(--slate); }
.metric-card.debt { --accent: var(--red); }
.metric-card.emergency { --accent: var(--green); }
.metric-card.net { --accent: #0f172a; }

.dashboard-grid,
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.wide-panel {
  min-height: 270px;
}

.panel-header,
.layer-header,
.item-card-head,
.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-header {
  margin-bottom: 16px;
}

.chip,
.badge,
.pill,
.status,
.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.chip {
  background: #eef2f7;
  color: #334155;
}

.chip.active,
.chip:hover {
  background: var(--text);
  color: #fff;
}

.badge.soft {
  background: #eef6ff;
  color: #1d4ed8;
}

.badge.dark {
  background: #111827;
  color: #fff;
}

.badge.violet {
  background: #f0e7ff;
  color: #6d28d9;
}

.pill.fixed {
  background: #eaf1ff;
  color: #1d4ed8;
}

.pill.variable {
  background: #fff1e8;
  color: #c2410c;
}

.pill.extra {
  background: #fef9c3;
  color: #854d0e;
}

.status.good {
  background: #dcfce7;
  color: #166534;
}

.status.warn,
.status.risk {
  background: #fef3c7;
  color: #92400e;
}

.status.info {
  background: #dbeafe;
  color: #1d4ed8;
}

.status.muted {
  background: #f1f5f9;
  color: #64748b;
}

.category-badge {
  color: #0f172a;
  background: color-mix(in srgb, var(--badge-color) 16%, white);
  border-color: color-mix(in srgb, var(--badge-color) 34%, white);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: middle;
}

.stacked-bar {
  display: flex;
  width: 100%;
  height: 22px;
  overflow: hidden;
  background: #eef2f7;
  border-radius: 999px;
}

.stacked-bar span {
  min-width: 3px;
}

.legend-grid,
.split-grid,
.comparison-grid,
.wealth-grid,
.drawer-metrics,
.money-pair,
.item-amounts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.legend-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.legend-grid div,
.split-grid div,
.comparison-grid div,
.wealth-grid div,
.drawer-metrics div,
.money-pair div,
.item-amounts div,
.preview-card div {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid #edf2f7;
  border-radius: 8px;
  min-width: 0;
}

.legend-grid strong,
.legend-grid small,
.split-grid strong,
.split-grid small,
.comparison-grid strong,
.wealth-grid strong,
.drawer-metrics strong,
.money-pair strong,
.item-amounts strong {
  display: block;
  overflow-wrap: anywhere;
}

.donut-layout {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 18px;
  align-items: center;
}

.donut-ring {
  width: 170px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
}

.donut-ring::after {
  content: "";
  position: absolute;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-ring span {
  position: relative;
  z-index: 1;
  max-width: 95px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.donut-list,
.bar-list,
.ratio-list,
.alert-list,
.plan-flow,
.timeline,
.csv-list,
.layer-stack {
  display: grid;
  gap: 12px;
}

.bar-row,
.ratio-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
}

.bar-row .progress,
.ratio-row .progress {
  grid-column: 1 / -1;
}

.progress {
  height: 9px;
  overflow: hidden;
  background: #eaf0f6;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--blue);
  border-radius: 999px;
}

.progress.violet span {
  background: var(--purple);
}

.progress.orange span {
  background: var(--orange);
}

.progress.teal span {
  background: var(--teal);
}

.progress.tiny {
  height: 6px;
}

.hero-progress {
  height: 12px;
  margin-bottom: 16px;
}

.big-progress {
  display: grid;
  gap: 14px;
}

.alert {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.alert.good {
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
}

.alert.warn {
  border-color: color-mix(in srgb, var(--amber) 40%, transparent);
  background: var(--amber-pale);
}

.alert.risk,
.alert.error {
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
  background: color-mix(in srgb, var(--red) 11%, var(--surface));
}

.alert.info {
  border-color: color-mix(in srgb, var(--blue) 35%, transparent);
  background: color-mix(in srgb, var(--blue) 10%, var(--surface));
}

.plan-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.plan-step small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.plan-step.negative strong {
  color: var(--red);
}

.plan-step.positive strong {
  color: var(--green);
}

.plan-step.investment strong {
  color: var(--purple);
}

.timeline {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.timeline-item {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid #edf2f7;
  border-radius: 8px;
}

.timeline-item span,
.timeline-item small {
  display: block;
  color: var(--muted);
}

.timeline-item strong {
  display: block;
  margin: 5px 0;
}

.control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.control-bar.stacked {
  display: grid;
  justify-content: stretch;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-input,
.filters input,
.filters select,
label input,
label select,
label textarea,
.csv-row input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.search-input {
  max-width: 360px;
}

.search-input:focus,
label input:focus,
label select:focus,
label textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent);
}

.entity-grid,
.expense-grid,
.wallet-grid,
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.expense-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.wallet-grid {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.entity-card,
.bank-card,
.item-card {
  min-height: 220px;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.entity-card h3,
.bank-card h3 {
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.avatar {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-weight: 700;
}

.avatar.large {
  width: 58px;
  height: 58px;
  font-size: 1.4rem;
}

.profile-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-strip p {
  margin: 6px 0 0;
  color: var(--muted);
}

.mini-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
}

.mini-metrics span {
  padding: 5px 8px;
  background: #f1f5f9;
  border-radius: 999px;
}

.expense-amount strong,
.wallet-balance {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
}

.expense-amount span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.split-line {
  display: flex;
  min-height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.split-line span {
  min-width: 28px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
}

.split-line span:first-child {
  background: var(--blue);
}

.split-line span:last-child {
  background: var(--teal);
}

.bank-card {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 58%, #0f766e 100%);
  border-color: transparent;
}

.bank-card:nth-child(3n + 2) {
  background: linear-gradient(135deg, #172554 0%, #7c3aed 55%, #0f766e 100%);
}

.bank-card:nth-child(3n) {
  background: linear-gradient(135deg, #111827 0%, #475569 48%, #f97316 100%);
}

.bank-card p,
.bank-card .mini-metrics,
.bank-card .status {
  color: rgba(255, 255, 255, 0.82);
}

.bank-card .status {
  background: rgba(255, 255, 255, 0.18);
}

.bank-card-glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 42%);
  pointer-events: none;
}

.wallet-balance {
  margin-top: 8px;
}

.layer-stack {
  gap: 18px;
}

.layer-panel {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--layer-color);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.layer-header h3 {
  margin: 4px 0 6px;
}

.layer-header p {
  margin: 0;
  color: var(--muted);
}

.layer-order {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--layer-color) 16%, white);
  color: var(--layer-color);
  font-weight: 700;
}

.layer-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.layer-summary div {
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.item-card.good {
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
}

.item-card.warn {
  border-color: color-mix(in srgb, var(--amber) 40%, transparent);
}

.item-card.risk {
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
}

/* Empty state (_empty_state.html): icon, title, one sentence and the primary button of the screen. */
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  list-style: none;
}

.empty-state h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  max-width: 46ch;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.empty-state .button {
  margin-top: 8px;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  padding: 11px;
  color: var(--slate);
  background: color-mix(in srgb, var(--slate) 14%, transparent);
  border-radius: 12px;
}

.empty-state-icon svg { width: 100%; height: 100%; }

.empty-state.compact {
  padding: 16px 14px;
  gap: 4px;
}

.empty-state.compact h3 {
  font-size: 0.92rem;
}

.empty-state.compact p {
  font-size: 0.82rem;
}

.empty-state.compact .empty-state-icon {
  width: 32px;
  height: 32px;
  padding: 8px;
  border-radius: 10px;
}

.empty-state[hidden] {
  display: none;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 500;
}

label.span-2,
.span-2 {
  grid-column: 1 / -1;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.check-line input {
  width: auto;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  max-height: min(86vh, 880px);
  padding: 0;
  border: 0;
  background: transparent;
}

.modal.wide {
  width: min(960px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(5px);
}

.modal-card {
  display: grid;
  gap: 16px;
  max-height: min(86vh, 880px);
  overflow: auto;
  padding: 20px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.compact-card {
  max-width: 460px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
}

.preview-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.preview-card span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.preview-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.flash-stack {
  display: grid;
  gap: 10px;
}

/* Test mode (app/sandbox.py): always in sight, never in the way. */
.sandbox-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--amber-pale);
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  color: var(--text);
  font-size: 0.9rem;
}

.sandbox-banner > [data-icon] {
  flex: none;
  color: var(--amber);
}

.sandbox-banner p {
  flex: 1;
  margin: 0;
  color: var(--text-soft);
}

.sandbox-banner strong {
  color: var(--amber);
}

.sandbox-banner form {
  flex: none;
}

.sandbox-reset {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sandbox-reset:hover {
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber-pale) 60%, var(--surface));
}

@media (max-width: 640px) {
  .sandbox-banner {
    flex-wrap: wrap;
  }
}

/* Touch screens: every control reaches 44 px without changing how it looks (the extra hit area is invisible). */
@media (pointer: coarse) {
  .button,
  .button.small {
    min-height: 44px;
  }

  .icon-button,
  .sandbox-reset {
    position: relative;
  }

  .icon-button::after,
  .theme-toggle::after,
  .sidebar .theme-toggle::after,
  .sandbox-reset::after {
    content: "";
    position: absolute;
    inset: -4px;
  }

  .sandbox-reset::after {
    inset: -6px;
  }

  .theme-toggle,
  .sidebar .theme-toggle {
    position: relative;
  }
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.22);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.drawer-backdrop.open {
  opacity: 1;
}

.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(460px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 44px rgba(15, 23, 42, 0.14);
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.side-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  padding: 20px;
  overflow: auto;
}

.drawer-section {
  display: grid;
  gap: 16px;
}

.drawer-note {
  margin: 0;
  padding: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid #edf2f7;
  border-radius: 8px;
}

.drawer-actions {
  margin-top: 18px;
}

.inline-form {
  display: inline-flex;
}

.settings-form {
  display: grid;
  gap: 16px;
}

.csv-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto minmax(220px, 1.4fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid #edf2f7;
  border-radius: 8px;
}

.csv-row form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.muted-text {
  margin: 0;
  color: var(--muted);
}

.button [data-icon],
.header-actions [data-icon] {
  width: 1rem;
  height: 1rem;
  margin-right: 7px;
}

.theme-toggle [data-icon] {
  margin-right: 0;
}

.dashboard-hero {
  min-height: 300px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.36fr);
  gap: 28px;
  align-items: stretch;
  padding: 30px;
  color: #fff;
  background:
    radial-gradient(circle at 78% 20%, rgba(255, 255, 255, 0.18), transparent 28%),
    linear-gradient(135deg, #111827 0%, #17213a 48%, #3156b7 100%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-copy {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 18px;
}

.hero-copy strong {
  font-size: clamp(3rem, 7vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 600;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.hero-pill [data-icon] {
  width: 15px;
  height: 15px;
}

.hero-pill img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
}

.hero-balance-rail {
  display: grid;
  gap: 10px;
  width: min(760px, 100%);
  margin-top: 8px;
}

.hero-balance-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto minmax(120px, 1fr);
  gap: 8px 14px;
  align-items: baseline;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.82rem;
  font-weight: 700;
}

.hero-balance-row strong {
  font-size: 1rem;
  line-height: 1;
  color: #fff;
  text-align: right;
}

.hero-split-bar,
.composition-track {
  display: flex;
  width: 100%;
  height: 13px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.hero-split-bar span,
.composition-track span {
  min-width: 3px;
}

.hero-split-bar .asset-segment {
  background: linear-gradient(90deg, #22c55e, #2dd4bf);
}

.hero-split-bar .debt-segment {
  background: linear-gradient(90deg, #fca5a5, #ef4444);
}

.hero-glance {
  display: grid;
  align-content: center;
  gap: 0;
  padding: 8px 0 8px 24px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.glance-row {
  display: grid;
  gap: 9px;
  padding: 17px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.glance-row:last-child {
  border-bottom: 0;
}

.glance-row span,
.glance-row strong {
  display: block;
}

.glance-row span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 700;
}

.glance-row strong {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1;
}

.glance-meter {
  height: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.glance-meter span {
  height: 100%;
  min-width: 2px;
  background: #60a5fa;
  border-radius: inherit;
}

.glance-row.violet .glance-meter span {
  background: #a78bfa;
}

.glance-row.teal .glance-meter span {
  background: #2dd4bf;
}

.integrated-dashboard {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 1.18fr) minmax(280px, 0.92fr);
  gap: 16px;
}

.finance-band {
  min-width: 0;
  min-height: 330px;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--blue) 4%), var(--surface));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.wealth-band {
  border-color: color-mix(in srgb, var(--blue) 28%, var(--line));
}

.flow-band {
  border-color: color-mix(in srgb, var(--teal) 28%, var(--line));
}

.safety-band {
  border-color: color-mix(in srgb, var(--green) 28%, var(--line));
}

.band-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.band-header h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.1;
}

.band-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.band-metric-grid.compact {
  grid-template-columns: 1fr;
  gap: 12px;
}

.metric-line {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding-left: 12px;
  border-left: 3px solid color-mix(in srgb, var(--blue) 48%, var(--line));
}

.metric-line.featured {
  border-left-color: var(--text);
}

.metric-line.danger {
  border-left-color: var(--red);
}

.metric-line span,
.metric-line small,
.flow-headline span,
.flow-headline small,
.flow-matrix span,
.flow-matrix small,
.safety-copy span,
.safety-copy p {
  color: var(--muted);
}

.metric-line span,
.flow-headline span,
.flow-matrix span,
.safety-copy span {
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-line strong,
.flow-headline strong,
.flow-matrix strong,
.safety-copy strong {
  display: block;
  color: var(--text);
  line-height: 1;
  overflow-wrap: normal;
  white-space: nowrap;
}

.metric-line strong {
  font-size: clamp(1.1rem, 1.55vw, 1.45rem);
}

.metric-line.featured strong {
  font-size: clamp(1.35rem, 2.1vw, 1.95rem);
}

.metric-line small,
.flow-matrix small {
  font-size: 0.8rem;
  font-weight: 600;
}

.composition-track {
  height: 15px;
  background: #eaf0f6;
}

.flow-rate {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: #0f766e;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--teal) 24%, var(--line));
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.flow-headline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: end;
}

.flow-headline strong {
  margin-top: 7px;
  font-size: clamp(1.55rem, 2.9vw, 2.35rem);
}

.flow-stack {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.flow-matrix {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.flow-matrix div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.flow-matrix strong {
  font-size: 1.12rem;
}

.safety-layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.radial-meter {
  --value: 0;
  width: 116px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--green) 0 calc(var(--value) * 1%), #eaf0f6 0 100%);
}

.radial-meter::after {
  content: "";
  position: absolute;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

.radial-meter span,
.radial-meter small {
  position: relative;
  z-index: 1;
  line-height: 1;
}

.radial-meter span {
  align-self: end;
  font-size: 2rem;
  font-weight: 700;
}

.radial-meter small {
  align-self: start;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 700;
}

.safety-copy {
  min-width: 0;
}

.safety-copy strong {
  margin-top: 7px;
  font-size: clamp(1.55rem, 2.6vw, 2.1rem);
}

.safety-copy p {
  margin: 9px 0 0;
  font-weight: 600;
}

.kpi-icon,
.panel-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  border-radius: 8px;
}

.clean-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.72fr);
  gap: 18px;
}

.clean-dashboard-grid.insight-grid {
  grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.35fr);
}

.clean-dashboard-grid.lower-grid {
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.45fr);
}

.clean-panel {
  min-height: 260px;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.clean-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.clean-panel-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.clean-panel-header > strong {
  font-size: 1.4rem;
}

.flow-panel {
  min-height: 250px;
}

.stacked-bar.large {
  height: 20px;
}

.inline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.inline-legend.compact {
  justify-content: center;
}

.inline-legend.compact-left {
  justify-content: flex-start;
}

.inline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-legend i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
}

.donut-center {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
  min-height: 190px;
}

.clean-donut {
  width: 158px;
}

.expense-donut {
  width: 150px;
}

.expense-bars {
  display: grid;
  gap: 15px;
}

.expense-row {
  display: grid;
  gap: 8px;
}

.expense-row > div:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.expense-row span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.expense-row i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
}

.expense-row strong {
  white-space: nowrap;
}

.emergency-panel {
  min-height: 210px;
  align-content: center;
}

.emergency-panel p {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.clean-alerts .alert {
  border-radius: 8px;
}

.vertical-timeline {
  position: relative;
  display: grid;
  gap: 14px;
  padding-left: 18px;
}

.vertical-timeline::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 7px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.vertical-timeline div {
  position: relative;
  display: grid;
  gap: 3px;
}

.vertical-timeline div::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 0 0 3px var(--surface);
}

.vertical-timeline span,
.vertical-timeline small {
  color: var(--muted);
}

html[data-theme="dark"] .hero-summary,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .entity-card,
html[data-theme="dark"] .item-card,
html[data-theme="dark"] .modal-card,
html[data-theme="dark"] .control-bar,
html[data-theme="dark"] .finance-band,
html[data-theme="dark"] .clean-panel,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .panel {
  background-color: var(--surface);
}

html[data-theme="dark"] .button.subtle,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .legend-grid div,
html[data-theme="dark"] .split-grid div,
html[data-theme="dark"] .comparison-grid div,
html[data-theme="dark"] .wealth-grid div,
html[data-theme="dark"] .drawer-metrics div,
html[data-theme="dark"] .money-pair div,
html[data-theme="dark"] .item-amounts div,
html[data-theme="dark"] .preview-card div,
html[data-theme="dark"] .plan-step,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .csv-row,
html[data-theme="dark"] .drawer-note {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .hero-balance,
html[data-theme="dark"] .mini-stat {
  background: rgba(17, 24, 39, 0.72);
  border-color: var(--line);
}

html[data-theme="dark"] .composition-track,
html[data-theme="dark"] .radial-meter {
  background-color: var(--surface-2);
}

html[data-theme="dark"] .radial-meter::after {
  background: var(--surface);
}

html[data-theme="dark"] .kpi-card.selected,
html[data-theme="dark"] .kpi-card.danger-soft,
html[data-theme="dark"] .kpi-card.good-soft {
  background: var(--surface);
}

html[data-theme="dark"] .search-input,
html[data-theme="dark"] .filters input,
html[data-theme="dark"] .filters select,
html[data-theme="dark"] label input,
html[data-theme="dark"] label select,
html[data-theme="dark"] label textarea,
html[data-theme="dark"] .csv-row input[type="file"],
html[data-theme="dark"] .icon-button {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .donut-ring::after {
  background: var(--surface);
  border-color: var(--line);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1380px) {
  .integrated-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .safety-band {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .safety-band .band-metric-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The sidebar becomes a top bar: brand and account on one row, the menu scrolling sideways below. */
  .sidebar {
    min-width: 0;
    position: sticky;
    z-index: 20;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 10px;
  }

  .sidebar .nav-list {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .sidebar-footer {
    grid-column: 2;
    grid-row: 1;
    padding-top: 0;
    border-top: 0;
  }

  .sidebar .user-chip-email {
    max-width: 22ch;
  }

  .nav-group,
  .nav-group-body,
  .nav-group-inner {
    display: contents;
  }

  /* The folds don't exist in the top bar: whatever was left folded shows. */
  html .nav-group[data-nav-group] .nav-group-body {
    visibility: visible !important;
  }

  /* Section titles shrink to a thin divider between the groups. */
  .nav-section {
    flex: 0 0 auto;
    align-self: center;
    width: 1px;
    height: 18px;
    min-height: 0;
    margin: 0 6px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 0;
    pointer-events: none;
  }

  .nav-section > span {
    display: none;
  }

  .nav-list {
    flex-direction: row;
    gap: 4px;
    margin: 0 -16px;
    padding: 0 16px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-list a {
    flex: 0 0 auto;
    min-height: 34px;
  }

  .nav-list a.nav-settings {
    margin-top: 0;
  }

  .metric-grid,
  .metric-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .two-column,
  .clean-dashboard-grid,
  .clean-dashboard-grid.insight-grid,
  .clean-dashboard-grid.lower-grid {
    grid-template-columns: 1fr;
  }

  .integrated-dashboard {
    grid-template-columns: 1fr;
  }

  .safety-band {
    grid-column: auto;
  }

  .safety-band .band-metric-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-header,
  .page-title,
  .hero-summary,
  .control-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    padding: 0;
  }

  .app-header {
    padding: 16px 18px;
  }

  .content {
    padding: 18px;
  }

  .content-topbar {
    min-height: 56px;
    margin: -18px -18px 0;
    padding: 10px 18px;
  }

  .sidebar .user-chip-email {
    display: none;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .hero-glance {
    padding: 8px 0 0;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
  }

  .hero-copy strong {
    font-size: clamp(2.6rem, 14vw, 4.2rem);
  }

  .hero-balance-row,
  .flow-headline,
  .safety-layout {
    grid-template-columns: 1fr;
  }

  .hero-balance-row strong {
    text-align: left;
  }

  .band-metric-grid,
  .safety-band .band-metric-grid.compact,
  .flow-matrix {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .metric-grid.compact,
  .legend-grid,
  .split-grid,
  .comparison-grid,
  .wealth-grid,
  .drawer-metrics,
  .money-pair,
  .item-amounts,
  .preview-card,
  .form-grid,
  .layer-summary {
    grid-template-columns: 1fr;
  }

  .donut-layout {
    grid-template-columns: 1fr;
  }

  .donut-ring {
    margin: 0 auto;
  }

  .search-input {
    max-width: none;
  }

  .csv-row,
  .csv-row form {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (max-width: 480px) {
  .band-metric-grid,
  .safety-band .band-metric-grid.compact,
  .flow-matrix,
  .entity-grid,
  .expense-grid,
  .wallet-grid,
  .item-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Dashboard (pantalla principal) ---------- */

.tone-blue { background: var(--blue); }
.tone-purple { background: var(--purple); }
.tone-teal { background: var(--teal-bright); }
.tone-slate { background: var(--slate); }
.tone-coral { background: var(--coral); }
.tone-goods { background: linear-gradient(135deg, #d39a45, #b0762a); }
.tone-fixed { background: var(--fixed-grad); }
.tone-variable { background: var(--variable-grad); }
.tone-extra { background: var(--extra-grad); }

.type-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; }

.dash-hero,
.dash-card strong,
.dash-milestone {
  font-variant-numeric: tabular-nums;
}

.dash-hero {
  padding: 26px 28px;
  color: #fff;
  background: var(--navy);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .dash-hero {
  background: #101830;
  border: 1px solid var(--line);
}

.dash-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.hero-link { color: inherit; text-decoration: none; background: color-mix(in srgb, var(--teal-bright) 18%, transparent); border-color: color-mix(in srgb, var(--teal-bright) 45%, transparent); transition: background 0.15s ease, border-color 0.15s ease; }
.hero-link:hover { background: color-mix(in srgb, var(--teal-bright) 28%, transparent); border-color: color-mix(in srgb, var(--teal-bright) 70%, transparent); }

/* The stage reads in white wherever it appears; green stays for the good state. */

.hero-link small { font-size: 0.7rem; color: rgba(255, 255, 255, 0.6); }
.hero-link .stage-badge-go { width: 12px; height: 12px; margin-right: -4px; color: rgba(255, 255, 255, 0.6); }
.dash-badge img {
  width: 18px;
  height: 18px;
  border-radius: 5px;
}

.dash-networth-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: #9c9b96;
}

.dash-networth-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.dash-networth-row strong {
  font-size: clamp(2.3rem, 6vw, 3.5rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
}

.dash-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #9fe1cb;
  background: rgba(29, 158, 117, 0.18);
  border-radius: 6px;
}

.dash-trend.neutral {
  color: #c9c8c2;
  background: rgba(255, 255, 255, 0.08);
}

.dash-trend.down {
  color: #f2b29c;
  background: rgba(216, 90, 48, 0.18);
}

.dash-trend.warn {
  color: color-mix(in srgb, var(--amber) 55%, #fff);
  background: color-mix(in srgb, var(--amber) 22%, transparent);
}

.dash-trend svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
}

.dash-spark {
  width: 210px;
  flex-shrink: 0;
}

.dash-spark svg {
  width: 100%;
  height: 64px;
  display: block;
  overflow: visible;
}

.dash-spark polyline,
.dash-spark line {
  fill: none;
  stroke: var(--teal-bright);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.dash-spark circle {
  fill: var(--teal-bright);
}

.dash-spark span {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: #7d7c78;
  text-align: center;
}

.dash-composition {
  margin-top: 24px;
}

.dash-composition-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  color: #9c9b96;
}

.dash-composition-bar {
  display: flex;
  gap: 2px;
  height: 13px;
  overflow: hidden;
  border-radius: 7px;
}

.dash-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-soft);
}

.dash-legend.on-dark {
  color: var(--on-hero-muted);
}

.dash-legend.on-dark .current {
  font-weight: 600;
}

.dash-legend.centered {
  justify-content: center;
}

.dash-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
}

.dash-hero-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dash-hero-kpis span {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: #9c9b96;
}

.dash-hero-kpis strong {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.dash-milestones {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.dash-milestone {
  flex: 1 1 260px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.dash-milestone p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  font-weight: 500;
}

.dash-milestone p span {
  font-weight: 400;
  color: var(--text-soft);
}

.dash-milestone-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 50%;
}

.dash-milestone-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dash-milestone-icon.good { color: var(--teal); background: var(--teal-pale); }
.dash-milestone-icon.warn { color: var(--amber); background: var(--amber-pale); }
.dash-milestone-icon.info { color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, transparent); }
.dash-milestone-icon.risk { color: var(--coral); background: color-mix(in srgb, var(--coral) 14%, transparent); }

/* "+N · Ver todos": opens the notices modal when the strip can't show them all */

.dash-milestone.more {
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 92px;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dash-milestone.more b { font-size: 1rem; line-height: 1.1; }
.dash-milestone.more span { font-size: 0.72rem; color: var(--text-soft); }
.dash-milestone.more:hover { border-color: color-mix(in srgb, var(--teal-bright) 40%, var(--line)); box-shadow: var(--soft-shadow); }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dash-card {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.dash-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.dash-eyebrow {
  margin: 0 0 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.dash-card h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dash-chip {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
}

.dash-chip.good { color: var(--teal); background: var(--teal-pale); }
.dash-chip.warn { color: var(--amber); background: var(--amber-pale); }

.dash-delta {
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 600;
  color: var(--teal);
}

.dash-delta.down {
  color: var(--coral);
}

.dash-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin: 16px 0 4px;
}

.dash-stats span,
.dash-muted-label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.dash-stats strong {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dash-stats .dash-delta {
  margin-left: 6px;
}

.dash-flow-bar {
  display: flex;
  gap: 2px;
  height: 9px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 5px;
}

.dash-subbars,
.dash-card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.dash-subbars,
.dash-categories {
  display: grid;
  gap: 12px;
}

.dash-categories {
  margin-top: 16px;
}

.dash-subbar-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.dash-subbar-row strong {
  font-weight: 600;
  color: var(--text);
}

.dash-categories .dash-subbar-row {
  font-size: 0.82rem;
  color: var(--text);
}

.dash-track {
  height: 6px;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 3px;
}

.dash-track span {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.dash-cat-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dash-cat-name i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dash-card-foot,
.dash-note {
  margin-bottom: 0;
  font-size: 0.76rem;
  color: var(--text-soft);
}

.dash-note {
  margin-top: 2px;
}

.dash-insight {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  font-size: 0.76rem;
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 9px;
}

.dash-insight svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--teal);
  stroke-width: 2;
}

@media (max-width: 900px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .dash-hero {
    padding: 20px 18px;
    border-radius: 16px;
  }

  .dash-spark {
    width: 100%;
  }

  .dash-hero-kpis {
    grid-template-columns: 1fr 1fr;
  }

  .dash-hero-kpis > div:first-child {
    grid-column: 1 / -1;
  }

  .dash-card {
    padding: 18px 16px;
  }
}

@media (max-width: 360px) {
  .dash-hero-kpis {
    grid-template-columns: 1fr;
  }
}

/* ---------- Ingresos ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2.2rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.page-head .button [data-icon] {
  margin-right: 6px;
}

/* floating "add" button: the page's main create action, bottom right */
.fab {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--teal-bright);
  box-shadow: 0 10px 24px rgba(14, 21, 38, 0.22), 0 2px 6px rgba(14, 21, 38, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.fab [data-icon] {
  width: 24px;
  height: 24px;
}

.fab svg {
  width: 100%;
  height: 100%;
  stroke-width: 2.4;
}

.fab:hover {
  background: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(14, 21, 38, 0.28), 0 3px 8px rgba(14, 21, 38, 0.14);
}

.fab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal-bright) 45%, transparent);
  outline-offset: 3px;
}

.content:has(> .fab) {
  padding-bottom: 20px;
}

@media (max-width: 480px) {
  .fab { right: 16px; bottom: 16px; }
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  position: relative;
  min-width: 0;
  padding: 18px 20px 18px 22px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--kpi-accent, var(--teal-bright));
}

.kpi-card.blue { --kpi-accent: var(--blue); }
.kpi-card.amber { --kpi-accent: var(--amber); }

.kpi-card span {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
}

.kpi-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.kpi-card small {
  font-size: 0.74rem;
  color: var(--text-soft);
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 10px;
}

.segmented button {
  min-height: 32px;
  padding: 0 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.segmented button.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(14, 21, 38, 0.12);
}

.search-field {
  flex: 0 1 280px;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.84rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
}

.inc-card {
  cursor: pointer;
}

.inc-mini {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inc-mini div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 9px;
}

.inc-mini span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
}

.inc-mini strong {
  display: block;
  margin-top: 2px;
  font-size: 0.98rem;
  font-weight: 600;
}

.inc-mini small {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--text-soft);
}

/* a rented good's income: shown with the incomes, edited in Bienes */
.rent-card {
  display: block;
  color: inherit;
  text-decoration: none;
}

.dash-chip.rent {
  color: color-mix(in srgb, var(--stream) 75%, var(--text));
  background: color-mix(in srgb, var(--stream) 14%, var(--surface));
}

.rent-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--blue);
}

.rent-link [data-icon] { width: 12px; height: 12px; }

/* a card reached through a link (…#bien-3) flashes once */
.is-linked { animation: linked-card 1.6s ease; }
@keyframes linked-card {
  0%, 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 45%, transparent); }
  100% { box-shadow: none; }
}

.inc-mini strong.muted { color: var(--muted); }

/* modal */

.sheet {
  width: min(780px, calc(100vw - 24px));
}

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  font-variant-numeric: tabular-nums;
}

.sheet-form > .modal-header,
.sheet-form > .sheet-actions {
  flex-shrink: 0;
  padding: 16px 24px;
  background: var(--surface);
}

.sheet-form > .modal-header {
  border-bottom: 1px solid var(--line);
}

.sheet-form > .sheet-actions {
  border-top: 1px solid var(--line);
}

.sheet-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 14px;
  padding: 20px 24px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-form .modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.sheet-form label,
.field-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-soft);
}

.sheet-form input,
.sheet-form select,
.sheet-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.sheet-form textarea {
  padding: 10px 12px;
}

.sheet-form input:focus,
.sheet-form select:focus,
.sheet-form textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent);
  outline-offset: 0;
  border-color: var(--blue);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-section {
  margin: 6px 0 -4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 8px;
}

.field-hint {
  display: block;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

.month-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.month-picker button {
  min-width: 46px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.month-picker button[aria-pressed="true"] {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.month-picker button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.money-input {
  position: relative;
  display: block;
}

.money-input input {
  padding-right: 30px;
}

/* A figure that comes from elsewhere (a position's capital, from its operations). */
.money-input input[readonly] {
  background: var(--bg);
  color: var(--text-soft);
  cursor: default;
}

.money-input em {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  font-style: normal;
  color: var(--muted);
  pointer-events: none;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--muted);
}

.save-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.save-status[data-kind="busy"]::before { background: var(--amber); }
.save-status[data-kind="ok"]::before { background: var(--teal-bright); }
.save-status[data-kind="ok"] { color: var(--teal); }
.save-status[data-kind="warn"]::before,
.save-status[data-kind="error"]::before { background: var(--coral); }
.save-status[data-kind="warn"],
.save-status[data-kind="error"] { color: var(--coral); }

/* retención: one line with the AEAT estimate, or the payslip's rate when the user sets it */
/* income sheet: nothing worked out to show until there is an amount */
[data-income-form] .calc-summary[data-blank] { display: none; }
.inc-simple-pagas { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; font-weight: 600; color: var(--text-soft); }
.inc-simple-pagas input { width: 72px; }
.sheet-fold-body .month-picker[hidden] { display: none; }

.inc-ret {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--blue) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--line));
  border-radius: 12px;
}

.inc-ret-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.inc-ret-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 40px;
}

.inc-ret-row strong {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.inc-ret-row .money-input {
  width: 130px;
}

.inc-ret-row .money-input input {
  min-height: 40px;
  font-size: 1.1rem;
  font-weight: 600;
}

.inc-ret .button {
  flex-shrink: 0;
}

/* The figures a sheet works out: a soft panel, part of the form rather than a block on top of it. */
.calc-summary {
  padding: 16px;
  color: var(--text);
  background: color-mix(in srgb, var(--navy) 4%, var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
}

html[data-theme="dark"] .calc-summary {
  background: color-mix(in srgb, #ffffff 3%, var(--surface));
}

.calc-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.calc-col {
  min-width: 0;
  padding-left: 14px;
  border-left: 3px solid var(--teal-bright);
}

.calc-col.variable {
  border-left-color: var(--blue);
}

.calc-col span {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
}

.calc-col strong {
  display: block;
  margin: 4px 0;
  font-size: clamp(1.3rem, 3.5vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.025em;
}

.calc-col small {
  font-size: 0.74rem;
  color: var(--muted);
}

.calc-col b {
  color: var(--text);
  font-weight: 600;
}

/* However many figures there are, they share the width. */
.calc-substats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.calc-substats div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.calc-substats div[hidden] {
  display: none;
}

.calc-substats span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.calc-substats b {
  display: block;
  margin-top: 3px;
  font-size: 0.98rem;
  font-weight: 600;
}

.calc-note {
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: var(--text);
  background: color-mix(in srgb, var(--teal-bright) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--teal-bright) 35%, var(--line));
  border-radius: 10px;
}

.calc-note.pay {
  background: color-mix(in srgb, #e0a53c 12%, var(--surface));
  border-color: color-mix(in srgb, #e0a53c 40%, var(--line));
}

.calc-note b {
  font-weight: 600;
}

.sheet-actions {
  justify-content: flex-end;
}

.sheet-spacer {
  flex: 1;
}

@media (max-width: 900px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }

  .calc-substats {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .search-field {
    flex-basis: 100%;
  }

  .sheet-form > .modal-header,
  .sheet-form > .sheet-actions {
    padding: 14px 16px;
  }

  .sheet-body {
    padding: 16px;
  }

  .field-grid,
  .calc-split {
    grid-template-columns: 1fr;
  }

  .inc-ret {
    flex-direction: column;
    align-items: stretch;
  }

  .month-picker button {
    min-width: 0;
    flex: 1 0 calc(16.66% - 6px);
  }
}
.dash-chip.info { color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }

/* ---------- Gastos ---------- */

.kpi-row.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card.coral { --kpi-accent: var(--coral); }
.kpi-card.purple { --kpi-accent: var(--purple); }

.filter-panel {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.filter-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.filter-line > .field-label {
  flex: 0 0 72px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.segmented.scroll {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented.scroll::-webkit-scrollbar {
  display: none;
}

.segmented button {
  flex-shrink: 0;
}

.filter-panel .search-field {
  width: 100%;
  flex: none;
}

.card-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}

.exp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 16px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.exp-card.is-inactive {
  opacity: 0.6;
}

.exp-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

/* who pays, at the card's top right */
.exp-who {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
  margin-left: auto;
}

.exp-cat,
.exp-status {
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 7px;
}

.exp-cat {
  color: color-mix(in srgb, var(--cat) 80%, var(--text));
  background: color-mix(in srgb, var(--cat) 14%, transparent);
}

.exp-status {
  margin-left: 4px;
  color: var(--text-soft);
  background: var(--surface-2);
}

.exp-card h3 {
  font-size: 0.95rem;
}

.exp-meta {
  margin: 3px 0 12px;
  font-size: 0.74rem;
  color: var(--text-soft);
}

.exp-amount {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.exp-amount small {
  margin-left: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.split-bar {
  display: flex;
  height: 7px;
  margin-top: auto;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: 5px;
}

.split-bar.large {
  height: 10px;
  margin: 12px 0 0;
}

.split-bar > span { height: 100%; min-width: 0; }

.split-figs {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.split-mode {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 6px;
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 8px;
}

.split-mode [data-icon],
.split-mode svg {
  width: 100%;
  height: 100%;
}

.badge-stack {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.badge-stack .member-badge + .member-badge {
  margin-right: -6px;
}

/* expense sheet */

.month-picker.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.month-picker.grid button {
  min-width: 0;
}

.split-members {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.split-chip {
  --member: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  opacity: 0.7;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.split-chip.active {
  color: var(--text);
  opacity: 1;
  border-color: color-mix(in srgb, var(--member) 55%, var(--line));
  background: color-mix(in srgb, var(--member) 10%, var(--surface));
}

.split-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 6px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 99px;
}

.split-chip-pct {
  padding: 2px 9px;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: var(--member);
  border-radius: 99px;
}

.split-chip-input {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 2px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--member) 45%, var(--line));
  border-radius: 99px;
}

.split-chip-input input {
  width: 46px;
  padding: 3px 0 3px 6px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
  -moz-appearance: textfield;
}

.split-chip-input input::-webkit-inner-spin-button,
.split-chip-input input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.split-chip-input em { font-style: normal; font-size: 0.76rem; color: var(--muted); }
.split-chip-input:focus-within { border-color: var(--member); box-shadow: 0 0 0 2px color-mix(in srgb, var(--member) 25%, transparent); }
[data-split-note] { margin-top: 8px; }

.calc-shares {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.calc-shares:empty { display: none; }

.calc-shares > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

.calc-shares b,
.calc-shares small { font-variant-numeric: tabular-nums; }

.calc-shares small {
  min-width: 92px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-row input[type="range"] {
  flex: 1;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--blue);
}

.money-input.pct {
  width: 96px;
  flex-shrink: 0;
}

.sheet-form .slider-row input[type="number"] {
  font-weight: 600;
  text-align: center;
  background: var(--surface);
}

.sheet-body > label {
  display: grid;
  gap: 6px;
}

@media (max-width: 1100px) {
  .kpi-row.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .kpi-row.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .kpi-row.four .kpi-card {
    padding: 14px 14px 14px 16px;
  }

  .kpi-row.four .kpi-card strong {
    font-size: 1.15rem;
  }

  .filter-line {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .filter-line > .field-label {
    flex: none;
  }

  .filter-line .segmented {
    width: 100%;
    overflow-x: auto;
  }

}

.sheet-body > .segmented {
  justify-self: start;
}

.calc-summary > .calc-substats:first-child {
  margin-top: 0;
}

.search-row {
  display: flex;
  gap: 10px;
}

.search-row .search-field {
  flex: 1;
  width: auto;
}

.sort-field {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.sort-field [data-icon] {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-soft);
  pointer-events: none;
}

.sort-field select {
  min-height: 38px;
  padding: 0 12px 0 32px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .search-row {
    flex-direction: column;
  }

  .sort-field select {
    width: 100%;
  }
}

/* the expense's good, in its meta line; and the household's other accounts, under their own heading */
.exp-good { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text); }
.exp-good [data-icon], .exp-good svg { width: 12px; height: 12px; }
.account-choice-head {
  padding: 10px 10px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* category icons */

.exp-cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.exp-cat [data-icon] {
  width: 12px;
  height: 12px;
}

.segmented button [data-icon] {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
}

.cat-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  padding: 6px;
  color: color-mix(in srgb, var(--cat) 85%, var(--text));
  background: color-mix(in srgb, var(--cat) 15%, transparent);
  border-radius: 8px;
}

.dash-cat-name {
  gap: 9px;
}

/* ---------- Cuentas ---------- */

.page-toolbar .search-row.grow {
  flex: 1 1 360px;
  justify-content: flex-end;
}

.page-toolbar .search-row .search-field {
  max-width: 320px;
}

.dash-chip.muted {
  color: var(--text-soft);
  background: var(--surface-2);
}

.acc-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.acc-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acc-bank-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  padding: 8px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  border-radius: 10px;
}

.acc-title {
  flex: 1;
  min-width: 0;
}

.acc-title h3 {
  overflow: hidden;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acc-title span {
  font-size: 0.74rem;
  color: var(--text-soft);
}

.acc-balance {
  margin-top: 16px;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.acc-spark {
  height: 44px;
  margin: 8px -2px 0;
  --spark: var(--teal-bright);
}

.acc-spark.down {
  --spark: var(--coral);
}

.acc-spark svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.acc-spark polyline {
  fill: none;
  stroke: var(--spark);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.acc-spark polygon {
  stroke: none;
}

.acc-spark polygon:not([fill]) {
  fill: color-mix(in srgb, var(--spark) 12%, transparent);
}

/* The cards' area fades from the line's colour down to nothing. */
.acc-spark .fill-top { stop-color: var(--spark); stop-opacity: 0.28; }
.acc-spark .fill-bottom { stop-color: var(--spark); stop-opacity: 0; }

.acc-spark.large {
  height: 72px;
  margin: 4px 0 0;
}

/* account sheet */

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.acc-balance-card {
  padding-left: 18px;
}

.api-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--blue) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--blue) 20%, var(--line));
  border-radius: 12px;
}

.api-sync {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.api-sync .button [data-icon] {
  width: 14px;
  height: 14px;
  margin-right: 6px;
}

.acc-history {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.acc-history-list {
  display: grid;
  gap: 0;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.acc-history-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-size: 0.78rem;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
}

.acc-history-list b {
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 600px) {
  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .page-toolbar .search-row .search-field {
    max-width: none;
  }
}

/* ---------- Bancos: iconos y selector ---------- */

.bank-mark {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  aspect-ratio: 1;
  overflow: hidden;
  font-weight: 700;
  letter-spacing: -0.03em;
  border-radius: 28%;
}

.bank-mark.md { width: 42px; font-size: 0.95rem; }
.bank-mark.sm { width: 30px; font-size: 0.72rem; }

.bank-mark.icon {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(14, 21, 38, 0.08), 0 1px 2px rgba(14, 21, 38, 0.08);
}

.bank-mark.icon img {
  display: block;
  width: 70%;
  height: 70%;
  object-fit: contain;
}

.bank-mark.icon.full {
  background: transparent;
  box-shadow: none;
}

.bank-mark.icon.full img {
  width: 100%;
  height: 100%;
}

html:not([data-theme="dark"]) .bank-mark.icon.invert-light {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(14, 21, 38, 0.08), 0 1px 2px rgba(14, 21, 38, 0.08);
}

html:not([data-theme="dark"]) .bank-mark.icon.invert-light img {
  filter: invert(1);
}

html[data-theme="dark"] .bank-mark.icon.white-dark {
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* Any colour becomes white; the white gaps inside the symbol become black, like the tile. */
html[data-theme="dark"] .bank-mark.icon.white-dark img {
  filter: brightness(0) invert(1);
}

html[data-theme="dark"] .bank-mark.icon.invert-dark {
  background: #1d2437;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .bank-mark.icon.invert-dark img {
  filter: invert(1);
}

.bank-mark.monogram {
  color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--bank, var(--slate)) 78%, #fff), var(--bank, var(--slate)) 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 1px 2px rgba(14, 21, 38, 0.12);
}

.bank-mark.monogram.long { letter-spacing: -0.05em; }
.bank-mark.md.monogram.long { font-size: 0.72rem; }
.bank-mark.sm.monogram.long { font-size: 0.56rem; }

.bank-mark.add {
  color: var(--blue);
  font-size: 1rem;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

/* account cards tinted with the bank's colour */

.acc-card {
  --bank: var(--slate);
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--bank) 22%, transparent) 0%, transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--bank) 9%, var(--surface)) 0%, var(--surface) 65%);
  border-color: color-mix(in srgb, var(--bank) 18%, var(--line));
}

.acc-card:hover,
.acc-card:focus-visible {
  border-color: color-mix(in srgb, var(--bank) 45%, var(--line));
}

html[data-theme="dark"] .acc-card {
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--bank) 30%, transparent) 0%, transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--bank) 14%, var(--surface)) 0%, var(--surface) 65%);
}

.acc-top {
  justify-content: space-between;
  min-height: 42px;
}

.acc-title {
  margin-top: 12px;
}

.acc-title h3 span {
  font-weight: 500;
  color: var(--text-soft);
}

/* horizontal account cards: the figures on the left, the trend on the right */

.card-grid.wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
}

@media (max-width: 960px) {
  .card-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .card-grid.wide { grid-template-columns: minmax(0, 1fr); }
}

.card-grid.wide .acc-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 38%);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "top top"
    "balance spark"
    "detail spark"
    "foot foot";
  column-gap: 10px;
  padding: 12px 14px 9px;
}

.card-grid.wide .acc-top { grid-area: top; }
.card-grid.wide .acc-title { margin-top: 0; }

.card-grid.wide .acc-balance {
  grid-area: balance;
  margin-top: 8px;
  font-size: 1.2rem;
}

.card-grid.wide .acc-yield,
.card-grid.wide .inv-figures {
  grid-area: detail;
  justify-content: flex-start;
}

.card-grid.wide .acc-spark {
  grid-area: spark;
  align-self: stretch;
  height: auto;
  min-height: 40px;
  margin: 8px 0 0;
}

/* picker */

.bank-picker {
  position: relative;
  display: grid;
  gap: 6px;
}

.bank-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--text);
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.bank-picker-trigger:focus-visible,
.bank-picker-trigger[aria-expanded="true"] {
  outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent);
  border-color: var(--blue);
}

.bank-picker-current {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 500;
}

.bank-picker-placeholder {
  font-weight: 400;
  color: var(--muted);
}

.bank-picker-caret {
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}

.bank-picker-panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.sheet-form .bank-picker-search {
  min-height: 38px;
}

.bank-picker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  max-height: 280px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.bank-picker-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 9px;
  cursor: pointer;
}

.bank-picker-list li:hover,
.bank-picker-list li:focus {
  background: var(--surface-2);
}

.bank-picker-list li[aria-selected="true"] {
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

.bank-picker-list .bank-picker-custom {
  grid-column: 1 / -1;
  color: var(--blue);
  border-top: 1px solid var(--line);
  border-radius: 0 0 9px 9px;
}

.bank-picker-manual {
  display: grid;
  gap: 6px;
}

@media (max-width: 600px) {
  .bank-picker-list {
    grid-template-columns: 1fr;
  }
}

/* joint account owners */

.member-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.member-picker button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px 0 6px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.member-dot {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
  border-radius: 50%;
}

.member-picker button[aria-pressed="true"] {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 45%, var(--line));
}

.member-picker button[aria-pressed="true"] .member-dot {
  color: #fff;
  background: var(--blue);
}

/* balance source (manual / API) */

.acc-chips {
  display: flex;
  align-items: center;
  gap: 6px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

/* Beside another field (a position's capital): the pill mustn't make its label taller than a plain one. */
.label-with-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 1.2em;
}

.label-with-pill .source-pill {
  padding-block: 0;
}

/* Side by side with hints of different length: each field keeps its input right under its label. */
[data-investment-form] .field-grid > label {
  align-content: start;
}

.source-pill [data-icon] {
  width: 12px;
  height: 12px;
}

.source-pill.manual {
  color: var(--text-soft);
  background: color-mix(in srgb, var(--surface) 70%, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--line);
}

.source-pill.api {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 25%, transparent);
}

.balance-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.segmented button [data-icon] {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: -2px;
}

/* ---------- Inversiones ---------- */

.inv-figures {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.inv-figures .pos { color: var(--teal); }
.inv-figures .neg { color: var(--coral); }
.inv-figures .muted { font-weight: 500; color: var(--muted); }

.calc-substats b.pos { color: var(--teal); }
.calc-substats b.neg { color: var(--coral); }

.dash-cat-name .bank-mark.sm {
  width: 22px;
}

.type-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}

.type-picker button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.type-picker button [data-icon] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--purple);
}

.type-picker button[aria-checked="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--purple) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--purple) 55%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--purple) 40%, transparent);
}

.term-picker {
  flex-wrap: wrap;
}

.member-picker [data-member-other] .member-dot {
  font-size: 0.9rem;
}

.deposit-panel {
  display: grid;
  gap: 12px;
}

.deposit-panel[hidden] {
  display: none;
}

.deposit-panel .field-section {
  margin-bottom: 0;
}

.term-picker {
  width: fit-content;
  max-width: 100%;
}

.segmented button[aria-checked="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(14, 21, 38, 0.12);
}

/* ---------- Miembros: insignias ---------- */

.member-badge {
  --member: var(--slate);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  aspect-ratio: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #fff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--member) 72%, #fff), var(--member) 72%);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(14, 21, 38, 0.18);
  font-variant-numeric: normal;
}

.member-badge.sm { width: 22px; font-size: 0.58rem; }
.member-badge.md { width: 38px; font-size: 0.82rem; }
.member-badge.lg { width: 52px; font-size: 1.05rem; }

.member-stack {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.member-stack .member-badge + .member-badge {
  margin-left: -6px;
}

/* ---------- Árbol familiar ---------- */

.family-tree {
  overflow: hidden;
}

.tree-canvas {
  position: relative;
  display: grid;
  gap: 48px;
  margin-top: 18px;
  padding: 8px 4px 12px;
  overflow-x: auto;
}

.tree-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.tree-lines path {
  fill: none;
  stroke: color-mix(in srgb, var(--member, var(--muted)) 55%, var(--line));
  stroke-width: 2;
  stroke-linejoin: round;
}

.tree-generation {
  position: relative;
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 28px;
  min-width: max-content;
}

.tree-unit {
  display: flex;
  align-items: center;
  gap: 0;
}

.tree-couple-link {
  width: 26px;
  height: 2px;
  background: var(--line);
  position: relative;
}

.tree-couple-link::after {
  content: "♥";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -55%);
  font-size: 0.6rem;
  color: var(--coral);
  background: var(--surface);
  padding: 0 2px;
}

.tree-node {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: 150px;
  padding: 14px 10px 12px;
  text-align: center;
  color: var(--text);
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--member) 16%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--member) 30%, var(--line));
  border-radius: 16px;
}

.tree-node.inactive {
  opacity: 0.55;
}

.tree-name {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

.tree-name small {
  font-weight: 500;
  color: var(--text-soft);
}

.tree-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
}

.user-pill [data-icon] { width: 10px; height: 10px; }
.user-pill.invited { color: var(--amber); background: var(--amber-pale); }
.user-pill.registered { color: var(--teal); background: var(--teal-pale); }

/* ---------- Perfiles ---------- */

.member-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.member-profile-head h3 {
  font-size: 1rem;
}

.member-profile-head span {
  font-size: 0.74rem;
  color: var(--text-soft);
}

/* ---------- Ficha de miembro ---------- */

.member-sheet-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatches button,
.color-custom {
  position: relative;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--swatch);
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.color-swatches button[aria-checked="true"],
.color-custom.active {
  box-shadow: 0 0 0 2px var(--text);
}

.color-custom {
  display: grid;
  place-items: center;
  color: var(--text-soft);
  background: var(--swatch, transparent);
  border-style: dashed;
  border-color: var(--line);
}

.color-custom.active span { display: none; }

.color-custom input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.member-picker button .member-badge {
  margin-left: -2px;
}

.member-picker button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.member-picker button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--member, var(--blue)) 55%, var(--line));
  background: color-mix(in srgb, var(--member, var(--blue)) 12%, var(--surface));
  color: var(--text);
}

.member-active {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-soft);
}

@media (max-width: 600px) {
  .badge-editor {
    grid-template-columns: 1fr;
  }

  .tree-generation {
    justify-content: flex-start;
  }

  .tree-node {
    width: 128px;
  }
}

/* member badges inside other components */

.owner-line,
.split-figs span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.owner-line .member-badge,
.split-figs .member-badge {
  box-shadow: 0 0 0 1.5px var(--surface);
}

.segmented button .member-badge {
  margin: -2px 6px -2px -6px;
  vertical-align: middle;
}

.member-picker button .member-badge.sm {
  width: 26px;
  font-size: 0.62rem;
}

.sheet-form input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 18px;
  min-height: 0;
  height: 18px;
  padding: 0;
  cursor: pointer;
  border: 1.5px solid var(--muted);
  border-radius: 5px;
  background: var(--blue) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / 0 0 no-repeat;
  background-color: transparent;
  transition:
    border-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    background-size 0.42s cubic-bezier(0.2, 0, 0, 1),
    transform 0.32s cubic-bezier(0.2, 0, 0, 1);
}

.sheet-form input[type="checkbox"]:checked {
  border-color: var(--blue);
  background-color: var(--blue);
  background-size: 12px 12px;
}

.sheet-form input[type="checkbox"]:active {
  transform: scale(0.88);
}

.sheet-form input[type="checkbox"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .toggle-chip span,
  .toggle-chip span::before,
  .sheet-form input[type="checkbox"] {
    transition: none;
  }
}

.member-active {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* owner badges overlapping the bottom-right corner of the bank icon */

.owned-mark {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.owned-by {
  position: absolute;
  right: -7px;
  bottom: -6px;
  display: inline-flex;
}

.owned-by .member-badge {
  box-shadow: 0 0 0 2px var(--surface), 0 1px 3px rgba(14, 21, 38, 0.2);
}

.owned-by .member-badge + .member-badge { margin-left: -9px; }
.member-badge.more { --member: var(--slate); letter-spacing: -0.04em; }

/* a required field left empty when trying to close a sheet */

.sheet-form .is-missing,
.sheet-form .is-missing .bank-picker-trigger {
  border-color: var(--coral) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--coral) 22%, transparent) !important;
  background: color-mix(in srgb, var(--coral) 6%, var(--surface));
}
.sheet-form .is-missing { animation: login-shake 0.4s ease both; }
.sheet-form [data-bank-picker].is-missing, .sheet-form [data-option-picker].is-missing { border-color: transparent !important; box-shadow: none !important; background: none; }
.sheet-form label:has(> .is-missing) { color: var(--coral); }
.sheet-form [data-bank-picker].is-missing .field-label, .sheet-form [data-option-picker].is-missing .field-label { color: var(--coral); }
@media (prefers-reduced-motion: reduce) { .sheet-form .is-missing { animation: none; } }

/* ---------- Préstamos ---------- */

/* simulador de amortización anticipada, dentro de la ficha */
.loan-sim {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: 14px;
}

.loan-sim-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.loan-sim-head .field-section {
  margin: 0;
}

.loan-sim-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
}

.loan-sim-row label {
  flex: 1 1 160px;
  min-width: 0;
}

.loan-sim-row .segmented {
  margin-bottom: 2px;
}

.loan-sim-result {
  margin: 12px 0 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.loan-sim-result b {
  color: var(--text);
  font-weight: 600;
}

.chart-tip-swatch.variable { opacity: 0.45; }

/* ----- chart tooltip (charts.js): one for every chart in the app ----- */

.chart-tip {
  position: fixed;
  z-index: 1000;
  display: grid;
  gap: 2px;
  min-width: 150px;
  max-width: 280px;
  padding: 10px 12px 11px;
  font-size: 0.74rem;
  color: #c3c2b7;
  /* a step lighter than the navy heroes, so it lifts off them as well as off the light pages */
  background: rgba(30, 40, 66, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  box-shadow: 0 12px 32px rgba(7, 10, 18, 0.28), 0 2px 6px rgba(7, 10, 18, 0.18);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transform-origin: bottom left;
  transition: opacity 0.14s ease, transform 0.14s cubic-bezier(0.2, 0, 0, 1);
}

.chart-tip.is-visible {
  opacity: 1;
  transform: none;
}

html[data-theme="dark"] .chart-tip {
  background: rgba(38, 50, 80, 0.97);
}

.chart-tip-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  color: #e1e0da;
}

.chart-tip-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-tip-swatch {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  background-size: 12px 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.chart-tip-swatch.blank { visibility: hidden; }
.chart-tip-swatch.line { height: 3px; border-radius: 2px; background: #fff; box-shadow: none; }

.chart-tip-value {
  margin-top: 3px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}

.chart-tip-note {
  font-size: 0.7rem;
  color: #9c9b96;
}

.chart-tip-rows {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-tip-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.chart-tip-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-tip-row b {
  font-weight: 600;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.chart-tip-row.muted span { color: #a9a8a1; }
.chart-tip-row.muted b { color: #d3d2cc; }

/* line charts: a hairline and a dot on the nearest point */
[data-spark] {
  position: relative;
  cursor: crosshair;
}

.spark-marker {
  position: absolute;
  width: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.spark-marker.is-visible { opacity: 1; }
.dash-hero .spark-marker-dot { border-color: var(--navy); }
html[data-theme="dark"] .dash-hero .spark-marker-dot { border-color: #101830; }

.spark-marker-line {
  position: absolute;
  inset: 0 auto 0 -0.5px;
  width: 1px;
  background: color-mix(in srgb, currentColor 35%, transparent);
}

.spark-marker-dot {
  position: absolute;
  top: var(--dot-y, 50%);
  left: -5px;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  background: currentColor;
  border: 2px solid var(--surface);
  border-radius: 50%;
}

/* marks with a tooltip show they can be explored */
.dash-composition-bar > span,
.savings-flow-bar > span {
  transition: filter 0.12s ease;
}

.dash-composition-bar > span:hover,
.savings-flow-bar > span:hover {
  filter: brightness(1.12) saturate(1.05);
}

@media (prefers-reduced-motion: reduce) {
  .chart-tip { transition: none; transform: none; }
}

/* ---------- Ahorro ---------- */

.tone-amber { background: var(--amber); }

.savings-toolbar .segmented button {
  display: inline-flex;
  align-items: center;
}

.savings-toolbar .segmented button [data-icon] {
  width: 15px;
  height: 15px;
  margin-right: 6px;
}

.savings-options,
.savings-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-chip {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.toggle-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-chip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition:
    color 0.36s cubic-bezier(0.2, 0, 0, 1),
    border-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    box-shadow 0.36s cubic-bezier(0.2, 0, 0, 1),
    transform 0.32s cubic-bezier(0.2, 0, 0, 1);
}

.toggle-chip:hover span {
  border-color: color-mix(in srgb, var(--teal-bright) 35%, var(--line));
}

.toggle-chip:active span {
  transform: scale(0.96);
}

/* the box fills with colour and the tick draws in (background-size 0 → 10px) */
.toggle-chip span::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--muted);
  border-radius: 4px;
  background: var(--teal-bright) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / 0 0 no-repeat;
  background-color: transparent;
  transition:
    border-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    background-color 0.36s cubic-bezier(0.2, 0, 0, 1),
    background-size 0.42s cubic-bezier(0.2, 0, 0, 1),
    transform 0.42s cubic-bezier(0.2, 0, 0, 1);
}

.toggle-chip input:checked + span {
  color: var(--text);
  border-color: color-mix(in srgb, var(--teal-bright) 55%, var(--line));
  background: color-mix(in srgb, var(--teal-bright) 10%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal-bright) 10%, transparent);
}

.toggle-chip input:checked + span::before {
  border-color: var(--teal-bright);
  background-color: var(--teal-bright);
  background-size: 10px 10px;
  transform: scale(1.08);
}

.toggle-chip input:focus-visible + span {
  outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent);
}

.savings-gauge {
  position: relative;
  width: 116px;
  height: 116px;
  flex-shrink: 0;
}

.savings-gauge svg {
  width: 100%;
  height: 100%;
}

.savings-gauge circle {
  fill: none;
  stroke-width: 10;
}

.savings-gauge .track { stroke: rgba(255, 255, 255, 0.1); }
.savings-gauge .fill { stroke: var(--teal-bright); stroke-linecap: round; transition: stroke-dasharray 0.3s ease; }
.savings-gauge.negative .fill { stroke: var(--coral); }

.savings-gauge > div {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.savings-gauge b {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.savings-gauge span {
  font-size: 0.62rem;
  color: #9c9b96;
}

.savings-flow {
  margin-top: 22px;
}

.savings-flow-bar {
  display: flex;
  gap: 2px;
  height: 16px;
  overflow: hidden;
  border-radius: 8px;
}

.savings-flow-bar .savings-seg {
  border-radius: 0 8px 8px 0;
}

/* Ahorro: the steps as plain cards (the .budget-card look), two columns on a tablet, three on a desktop */
.savings-section-title { margin: 22px 0 12px; font-size: 0.92rem; font-weight: 600; color: var(--text-soft); }
.budget-card.type-financing { --type-ink: var(--amber); }
.budget-card.type-investing { --type-ink: var(--purple); }
.budget-card.type-result { --type-ink: var(--teal); }
.budget-card.type-deficit { --type-ink: var(--coral); }
.budget-card.type-deficit .budget-head h3 { color: var(--coral-ink); }
@media (min-width: 701px) and (max-width: 1179px) { .budgets-three.savings-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-card.savings-members, .dash-card.emergency-card { margin-top: 16px; border-color: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 18px; box-shadow: none; }
html[data-theme="dark"] :is(.dash-card.savings-members, .dash-card.emergency-card) { border-color: var(--line); }

.savings-compare {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.savings-member {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.savings-member.active { border-color: color-mix(in srgb, var(--teal-bright) 55%, var(--line)); }

.savings-member-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
}

.savings-member-head [data-icon] {
  width: 22px;
  height: 22px;
  padding: 4px;
  border-radius: 50%;
  background: var(--surface-2);
}

.savings-member-head strong {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.savings-member-head .pos { color: var(--teal); }
.savings-member-head .neg { color: var(--coral); }

.goal-target {
  font-weight: 400;
  color: var(--muted);
}

.savings-settings {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  /* Not a sheet: without this the sheet's rounded clipping eats the first label's initial. */
  overflow: visible;
  border-radius: 0;
}

.savings-settings .modal-actions {
  justify-content: flex-end;
}

.emergency-months-field {
  max-width: 220px;
}

.savings-settings .emergency-recommendation {
  margin-top: 4px;
}

/* Until the recommendation exists the advice slot is shown as a quiet placeholder. */
.emergency-recommendation.pending {
  font-style: italic;
}

.emergency-recommendation.pending svg {
  stroke: var(--muted);
}

.emergency-recommendation b {
  color: var(--text);
  font-weight: 600;
}

/* small square icon button next to a title (layers) */

.brand > span {
  min-width: 0;
}

.brand small[data-sidebar-family] {
  max-width: 150px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hero-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

/* Cuentas, Inversiones, Bienes: the trend sits right of the total; on narrow screens it takes its own row below. */
.hero-split.with-trend {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "figure trend gauge";
  align-items: center;
  gap: 18px 32px;
}

.hero-split.with-trend > :first-child { grid-area: figure; min-width: 0; }
.hero-split.with-trend .savings-gauge { grid-area: gauge; }

.hero-trend {
  grid-area: trend;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.hero-trend-chart {
  position: relative;
  width: 100%;
  height: 72px;
}

.hero-trend-chart svg { height: 100%; }
.hero-trend-chart .area { stroke: none; }
.hero-trend-chart .fill-top { stop-color: var(--teal-bright); stop-opacity: 0.32; }
.hero-trend-chart .fill-bottom { stop-color: var(--teal-bright); stop-opacity: 0; }

.tenor-pills {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tenor-pills::-webkit-scrollbar { display: none; }

.tenor-pills button {
  flex: none;
  min-height: 24px;
  padding: 0 8px;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.55);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s cubic-bezier(0.2, 0, 0, 1), color 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.tenor-pills button:hover:not(:disabled) { color: #fff; }
.tenor-pills button.active { color: #fff; background: rgba(255, 255, 255, 0.14); }
.tenor-pills button:disabled { opacity: 0.35; cursor: default; }
.tenor-pills button:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 1px; }

.hero-trend-change {
  font-size: 0.75rem;
  color: #9c9b96;
  text-align: right;
}

.hero-trend-change b { font-weight: 600; }
.hero-trend-change b.pos { color: var(--teal-bright); }
.hero-trend-change b.neg { color: var(--coral); }

@media (max-width: 900px) {
  .hero-split.with-trend {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "figure gauge" "trend trend";
  }

  .hero-trend { margin-top: 6px; }
  .hero-trend-chart { height: 120px; }
  .tenor-pills { justify-content: flex-start; }
  .hero-trend-change { text-align: left; }
}

@media (max-width: 600px) {
  .hero-split.with-trend { display: flex; flex-wrap: wrap; }
  .hero-split.with-trend > .hero-trend { order: 1; flex-basis: 100%; }
  .hero-trend-chart { height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .tenor-pills button { transition: none; }
}


/* layer cards */

.layer-number {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--layer);
  border-radius: 8px;
}

.layer-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.layer-picker button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.layer-picker .layer-number {
  width: 22px;
  height: 22px;
  font-size: 0.68rem;
  border-radius: 6px;
}

.layer-picker button[aria-checked="true"] {
  color: var(--text);
  border-color: color-mix(in srgb, var(--layer) 60%, var(--line));
  background: color-mix(in srgb, var(--layer) 10%, var(--surface));
}

.calc-substats.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* A bolsa of Gastos or the emergency fund: always there, only its accounts are chosen. */
.pot-fixed-note { margin: 0; padding: 10px 12px; color: var(--text-soft); background: var(--surface-2); border-radius: 10px; }
.sheet-form.pot-locked [data-delete] { display: none; }

.segmented.pot-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segmented.pot-rules button {
  padding: 0 6px;
}

.pot-sources {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.pot-sources li {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pot-source-toggle {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 22px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  text-align: left;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.pot-sources li.selected .pot-source-toggle,
.pot-source-toggle[aria-selected="true"] {
  color: var(--text);
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
}

.pot-source-order {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--on-accent);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.pot-sources li.selected .pot-source-order,
.pot-source-toggle[aria-selected="true"] .pot-source-order {
  background: var(--blue);
  border-color: var(--blue);
}

.pot-source-toggle .bank-mark.sm {
  width: 26px;
}

.pot-source-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pot-source-name small {
  display: block;
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--muted);
}

.pot-source-amount {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.pot-source-move {
  display: flex;
  flex-direction: column;
  gap: 2px;
  visibility: hidden;
}

.pot-sources li.selected .pot-source-move {
  visibility: visible;
}

.pot-source-move button {
  width: 24px;
  height: 18px;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 0;
  border-radius: 5px;
}

.pot-source-move button:disabled {
  opacity: 0.35;
}

.pot-draws:empty {
  display: none;
}

@media (max-width: 600px) {

  .segmented.pot-rules {
    grid-template-columns: 1fr 1fr;
  }
}

/* ----- Configuración ----- */
.settings-form { display: contents; } /* its sections are laid out by .settings-page */
.dash-card-head .save-status:empty { display: none; }
.weight-list { display: grid; gap: 10px; }
.weight-row {
  display: grid;
  grid-template-columns: auto minmax(70px, 120px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}
.weight-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weight-track { height: 8px; overflow: hidden; background: var(--surface-2); border-radius: 99px; }
.weight-track i { display: block; height: 100%; border-radius: 99px; transition: width 0.2s; }
.weight-row input:disabled { opacity: 0.6; }

.category-tile-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 15%, transparent);
  border-radius: 11px;
}
.category-tile-icon [data-icon] svg { width: 20px; height: 20px; }
.category-tile-icon.inactive { filter: grayscale(1); opacity: 0.6; }

.category-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cat, #2563eb) 12%, var(--surface)), var(--surface) 75%);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-picker button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
}
.icon-picker button [data-icon] svg { width: 19px; height: 19px; }
.icon-picker button[aria-checked="true"] {
  color: var(--surface);
  background: var(--text);
}

/* ----- Sesión ----- */
.header-actions { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
}
.user-chip .member-badge { width: 26px; font-size: 0.66rem; }
.user-chip-email { overflow: hidden; max-width: 22ch; font-size: 0.8rem; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
.user-chip-out {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.user-chip-out:hover { color: var(--coral); background: var(--surface-2); }
.user-chip-out [data-icon] svg { width: 16px; height: 16px; }
@media (max-width: 600px) { .user-chip-email { display: none; } }

.login-page { min-height: 100vh; margin: 0; background: var(--bg); }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }

.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding: 36px clamp(32px, 5vw, 64px);
  overflow: hidden;
  color: #f2f1ec;
  background:
    radial-gradient(circle at 88% 12%, rgba(29, 158, 117, 0.3), transparent 42%),
    radial-gradient(circle at 6% 96%, rgba(83, 74, 183, 0.34), transparent 48%),
    var(--navy);
}
.login-hero::before {
  /* faint grid so the navy reads as a canvas, fading towards the bottom */
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
  pointer-events: none;
}
.login-hero > * { position: relative; }

.login-logo { display: flex; align-items: center; gap: 10px; }
.login-logo .brand-mark { width: 32px; height: 40px; }
.login-logo strong { font-size: 1.15rem; letter-spacing: -0.02em; }

.login-pitch { display: grid; justify-items: center; margin-top: auto; text-align: center; }
.login-pitch h1 { max-width: 16ch; margin: 0 0 14px; text-wrap: balance; font-size: clamp(2rem, 3.3vw, 2.9rem); font-weight: 600; line-height: 1.06; letter-spacing: -0.04em; }
.login-pitch p { max-width: 42ch; margin: 0; font-size: 1rem; line-height: 1.55; color: rgba(242, 241, 236, 0.66); }

.login-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  width: min(100%, 560px);
  margin: 0 auto auto;
}
.login-glass {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: login-float 7s ease-in-out infinite;
}
.login-glass-sim { margin-top: 38px; animation-delay: -3.5s; }
.login-glass-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.74rem; font-weight: 600; color: rgba(242, 241, 236, 0.72); }
.login-glass-head [data-icon] { color: var(--teal-bright); }
.login-glass-head [data-icon] svg { width: 15px; height: 15px; }
.login-avatars { display: flex; }
.login-avatars i {
  display: grid; place-items: center; width: 22px; height: 22px; margin-left: -6px;
  font-size: 0.56rem; font-style: normal; font-weight: 700; color: #fff;
  background: var(--c); border: 2px solid #182037; border-radius: 50%;
}
.login-flow { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.login-flow li { display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; font-size: 0.72rem; color: rgba(242, 241, 236, 0.62); }
.login-flow b { font-weight: 600; color: #f2f1ec; font-variant-numeric: tabular-nums; }
.login-flow em { grid-column: 1 / -1; height: 7px; background: rgba(255, 255, 255, 0.07); border-radius: 99px; overflow: hidden; }
.login-flow em::before {
  content: ""; display: block; width: var(--w); height: 100%;
  background: var(--c); border-radius: inherit;
  transform-origin: left; animation: login-grow 1.1s cubic-bezier(.2, .8, .2, 1) both;
}
.login-flow li:nth-child(2) em::before { animation-delay: 0.12s; }
.login-flow li:nth-child(3) em::before { animation-delay: 0.24s; }
.login-flow li:nth-child(4) em::before { animation-delay: 0.36s; }
.login-sim-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.72rem; color: rgba(242, 241, 236, 0.62); }
.login-sim-label b { font-size: 1.05rem; font-weight: 600; color: #f2f1ec; font-variant-numeric: tabular-nums; }
.login-sim-track { position: relative; height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; }
.login-sim-track em { position: absolute; inset: 0 40% 0 0; background: var(--purple); border-radius: inherit; animation: login-slide 1.4s 0.5s cubic-bezier(.2, .8, .2, 1) both; }
.login-sim-track i {
  position: absolute; top: 50%; left: 60%; width: 16px; height: 16px; margin: -8px 0 0 -8px;
  background: #fff; border: 3px solid var(--purple); border-radius: 50%;
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--purple) 25%, transparent);
  animation: login-knob 1.4s 0.5s cubic-bezier(.2, .8, .2, 1) both;
}
.login-sim-result { display: flex; align-items: center; gap: 8px; font-size: 0.74rem; color: rgba(242, 241, 236, 0.72); }
.login-sim-result b { color: var(--teal-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.login-sim-result [data-icon] { display: grid; place-items: center; width: 24px; height: 24px; color: var(--teal-bright); background: rgba(29, 158, 117, 0.14); border-radius: 7px; }
.login-sim-result [data-icon] svg { width: 14px; height: 14px; }
.login-sim-note { margin: -6px 0 0; font-size: 0.66rem; color: rgba(242, 241, 236, 0.45); }

.login-points { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; color: rgba(242, 241, 236, 0.76); }
.login-points li { display: flex; align-items: center; gap: 8px; }
.login-points [data-icon] {
  display: grid; place-items: center; width: 28px; height: 28px;
  color: var(--teal-bright); background: rgba(255, 255, 255, 0.07); border-radius: 8px;
}
.login-points [data-icon] svg { width: 15px; height: 15px; }

.login-panel { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 24px 24px 32px; }
.login-panel-top { display: flex; align-items: center; justify-content: flex-end; width: 100%; }
.login-card-brand { display: none; align-items: center; gap: 10px; margin-right: auto; }
.login-card-brand strong { font-size: 1.05rem; letter-spacing: -0.02em; }

.login-card {
  display: grid;
  gap: 16px;
  width: min(100%, 400px);
  margin-block: auto;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: login-rise 0.5s cubic-bezier(.2, .8, .2, 1) both;
}
.login-card-head { display: grid; gap: 6px; margin-bottom: 4px; }
.login-card h2 { margin: 0; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.035em; }
.login-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.login-card > label:not(.toggle-chip) { display: grid; gap: 7px; font-size: 0.8rem; font-weight: 500; color: var(--text-soft); }
.login-input {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 6px 0 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.login-input:hover { border-color: color-mix(in srgb, var(--text) 22%, transparent); }
.login-input:focus-within { background: var(--surface); border-color: var(--teal-bright); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal-bright) 20%, transparent); }
.login-input > [data-icon] { display: grid; color: var(--muted); transition: color 0.15s; }
.login-input:focus-within > [data-icon] { color: var(--teal-bright); }
.login-input [data-icon] svg { width: 18px; height: 18px; }
.login-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  min-height: 0;
  padding: 0;
  font-size: 0.95rem;
  color: var(--text);
  background: transparent;
  border: 0;
  box-shadow: none;
  outline: none;
}
.login-input input::placeholder { color: var(--muted); opacity: 0.7; }
.login-reveal {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  color: var(--muted); background: transparent; border: 0; border-radius: 9px; cursor: pointer;
}
.login-reveal:hover { color: var(--text); }
.login-reveal[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }
.login-remember { justify-self: start; }
.login-submit { gap: 6px; height: 48px; margin-top: 4px; font-size: 0.95rem; border-radius: 12px; }
.login-submit [data-icon] svg { width: 16px; height: 16px; transition: transform 0.16s ease; }
.login-submit:hover [data-icon] svg { transform: translateX(3px); }
html[data-theme="dark"] .login-submit { color: var(--navy); background: #f2f1ec; }
html[data-theme="dark"] .login-hero { border-right: 1px solid var(--line); }
.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.86rem;
  color: var(--coral);
  background: color-mix(in srgb, var(--coral) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--coral) 30%, transparent);
  border-radius: 10px;
  animation: login-shake 0.4s ease both;
}
.login-error [data-icon] svg { width: 16px; height: 16px; }
.login-foot { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 0.78rem; color: var(--muted); }
.login-foot [data-icon] svg { width: 14px; height: 14px; }

@keyframes login-float { 50% { transform: translateY(-8px); } }
@keyframes login-grow { from { transform: scaleX(0); } }
@keyframes login-slide { from { right: 60%; } }
@keyframes login-knob { from { left: 40%; } }
@keyframes login-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes login-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  .login-glass, .login-flow em::before, .login-card, .login-error, .login-sim-track em, .login-sim-track i { animation: none; }
}

@media (max-width: 1100px) {
  .login-showcase { grid-template-columns: minmax(0, 1fr); width: min(100%, 340px); }
  .login-glass-sim { display: none; }
}
@media (max-width: 860px) {
  .login-shell { grid-template-columns: minmax(0, 1fr); }
  .login-hero { display: none; }
  .login-card-brand { display: flex; }
  .login-panel { padding: 16px 16px 28px; }
  .login-panel-top { justify-content: space-between; }
  .login-card { margin-top: 8vh; margin-bottom: 0; }
  .login-foot { margin-top: auto; }
}
@media (max-width: 480px) {
  .login-card { padding: 24px 20px; border-radius: 16px; }
}

.login-back { display: inline-flex; align-items: center; gap: 4px; margin-right: auto; font-size: 0.82rem; font-weight: 500; color: var(--text-soft); }
.login-back:hover { color: var(--text); }
.login-back [data-icon] svg { width: 15px; height: 15px; transform: rotate(180deg); }
.login-logo { color: inherit; }

/* brand and sign-in button shared by the public pages (the landing has its own landing.css) */

.landing-brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; }
.landing-brand strong { font-size: 1.1rem; letter-spacing: -0.02em; }
.landing-nav-cta { color: var(--navy); background: #f2f1ec; }

/* children and dependents */

.dependent-card { display: grid; gap: 14px; align-content: start; }
.dependent-card .member-profile-head { align-items: center; }
.dependent-card .member-profile-head .dash-chip { margin-left: auto; white-space: nowrap; }
.dependent-expenses,
.dependent-suggestions ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 0.86rem; }
.dependent-expenses li,
.dependent-suggestions li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dependent-expenses b,
.dependent-suggestions li b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dependent-expenses .more { color: var(--muted); font-size: 0.78rem; }
.dependent-suggestions { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 10px; }
.dependent-suggestions summary { cursor: pointer; font-size: 0.84rem; font-weight: 600; }
.dependent-suggestions summary small { margin-left: 6px; font-weight: 500; color: var(--muted); }
.dependent-suggestions li > span:first-child { display: grid; min-width: 0; }
.dependent-suggestions li small { color: var(--muted); font-weight: 400; font-size: 0.72rem; }
.dependent-suggestions li.is-added { opacity: 0.6; }
.dependent-suggestions li form { margin: 0; }
.dependent-suggestions li b { margin-left: auto; }
.dependent-card .inc-mini { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Gastos: the four groups as plain cards. The colour sits in what they say (title, thin bar), not in the decoration. */
.budgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 18px; }
@media (max-width: 700px) { .budgets { grid-template-columns: 1fr; } }
.budget-card { --type-ink: var(--fixed-ink); display: grid; gap: 14px; align-content: start; padding: 22px; color: var(--text); text-decoration: none; background: var(--surface); border-color: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 18px; box-shadow: none; }
.budget-card.type-variable { --type-ink: var(--variable-ink); }
.budget-card.type-extra { --type-ink: var(--extra-ink); }
.budget-card.type-investment { --type-ink: var(--teal); }
html[data-theme="dark"] .budget-card { border-color: var(--line); }
.budget-head { display: flex; align-items: center; gap: 8px; }
.budget-symbol { flex-shrink: 0; width: 16px; height: 16px; color: var(--type-ink); }
.budget-symbol svg { width: 100%; height: 100%; }
.budget-head h3 { margin: 0; font-size: 0.92rem; font-weight: 600; color: var(--type-ink); }
.budget-open { margin-left: auto; flex-shrink: 0; width: 14px; height: 14px; color: var(--muted); }
.budget-open svg { width: 100%; height: 100%; }
.budget-total { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.budget-total small { margin-left: 4px; font-size: 0.8rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.budget-total .budget-tag { margin-left: 6px; font-size: 0.78rem; }
.budget-bar { display: flex; gap: 2px; height: 6px; overflow: hidden; border-radius: 999px; }
.budget-bar span { min-width: 3px; }
.budget-bar.is-track { background: var(--surface-2); }
.budget-bar.is-track span { border-radius: 999px; }
.budget-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
.budget-rows li { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.88rem; }
.budget-name { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.budget-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-text small { font-size: 0.78rem; color: var(--muted); }
.budget-dot { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; }
.budget-amount { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.budget-amount b { font-weight: 500; }
.budget-amount small { min-width: 32px; text-align: right; font-size: 0.74rem; color: var(--muted); }
.budget-more { justify-content: flex-start; color: var(--muted); font-size: 0.8rem; }
.budget-card > .dash-card-foot { margin: 0; color: var(--muted); }
/* the group's own page opens with its figure alone, no link */
.budget-head-card { margin: 0 0 16px; }
/* Ingresos: three groups, the colour of each in its title, thin bar and dots (the tokens, light and dark) */
.budget-card.type-trabajo { --type-ink: var(--teal); }
.budget-card.type-patrimonio { --type-ink: var(--wealth-ink); }
.budget-card.type-otros { --type-ink: var(--slate); }
.budget-card.type-loan { --type-ink: var(--coral); cursor: pointer; }
.budget-card.type-loan .budget-head h3 { color: var(--coral-ink); }
.budgets-three { grid-template-columns: 1fr; }
@media (min-width: 1180px) { .budgets-three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* what only work has, under the figure of its page: label and value, the not guaranteed one in grey */
.budget-facts { display: grid; gap: 8px; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.86rem; }
.budget-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.budget-facts dt { color: var(--text-soft); }
.budget-facts dt small { margin-left: 6px; font-size: 0.74rem; color: var(--muted); }
.budget-facts dd { margin: 0; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
/* the card of an income: title, small avatar, grey meta */
.inc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.inc-includes { margin: 4px 0 0; font-size: 0.74rem; color: var(--muted); }
.inc-card-head h3 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* the calendars of cobros and cuotas: twelve thin bars in one tone (--bar-tone); only the current month and the strong ones get colour and figure */
.bar-calendar-card { --bar-tone: var(--income-1); }
.bar-calendar-card.is-debt { --bar-tone: var(--coral); }
.bar-calendar-card .bar-chart { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; height: 226px; margin-top: 4px; padding-top: 42px; }
.bar-calendar-card .bar-grid { position: absolute; inset: 42px 0 26px; display: grid; grid-template-rows: repeat(4, 1fr); pointer-events: none; }
.bar-calendar-card .bar-grid span { border-top: 1px dashed color-mix(in srgb, var(--line) 70%, transparent); }
.bar-calendar-card .bar-grid span:last-child { border-bottom: 1px solid var(--line); }
.bar-calendar-card .bar-col { position: relative; display: grid; grid-template-rows: 1fr auto; min-width: 0; cursor: default; }
.bar-calendar-card .bar-col::before { content: ""; position: absolute; inset: -4px -5px; border-radius: 10px; background: transparent; transition: background 0.12s ease; }
.bar-calendar-card .bar-col:hover::before,
.bar-calendar-card .bar-col:focus-visible::before { background: color-mix(in srgb, var(--text) 5%, transparent); }
.bar-calendar-card .bar-track { position: relative; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.bar-calendar-card .bar-stack { position: relative; display: flex; flex-direction: column; width: min(100%, 14px); min-height: 0; }
.bar-calendar-card .bar-seg { flex: 1 1 auto; min-height: 3px; background: color-mix(in srgb, var(--bar-tone) 48%, var(--surface-2)); border-radius: 5px 5px 0 0; transition: background 0.35s cubic-bezier(0.2, 0, 0, 1); }
.bar-calendar-card .bar-col.current .bar-seg,
.bar-calendar-card .bar-col.strong .bar-seg,
.bar-calendar-card .bar-col:hover .bar-seg,
.bar-calendar-card .bar-col:focus-visible .bar-seg { background: var(--bar-tone); }
.bar-calendar-card .bar-label { position: relative; padding-top: 8px; font-size: 0.7rem; text-align: center; color: var(--muted); }
.bar-calendar-card .bar-label small { margin-left: 2px; font-size: 0.6rem; }
.bar-calendar-card .bar-col.current .bar-label { font-weight: 700; color: var(--text); }
/* the figure sits right on top of its bar, and only the current month and the strong ones show it */
.bar-calendar-card .bar-total { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 4px; font-size: 0.68rem; font-weight: 600; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-soft); visibility: hidden; }
.bar-calendar-card .bar-col.current .bar-total,
.bar-calendar-card .bar-col.strong .bar-total { visibility: visible; color: var(--text); }
/* the mark of a loan that ends: always on top of its bar, with the figure above it */
.bar-calendar-card .bar-flag { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); width: 11px; height: 11px; padding-bottom: 3px; box-sizing: content-box; color: var(--bar-tone); }
.bar-calendar-card .bar-flag svg { width: 100%; height: 100%; }
.bar-calendar-card .bar-flag + .bar-total { bottom: calc(100% + 15px); }
@media (max-width: 780px) {
  .bar-calendar-card .bar-chart { gap: 4px; }
  .bar-calendar-card .bar-total { font-size: 0.56rem; letter-spacing: -0.02em; }
  .bar-calendar-card .bar-label small { display: none; }
}
/* on a phone the figures would touch: only the current month and the nearest peak keep theirs */
@media (max-width: 480px) { .bar-calendar-card .bar-col.strong:not(.peak):not(.current) .bar-total { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .bar-calendar-card .bar-seg { transition: none; } }
/* Gastos: the search under the group cards; the matches show right below it. */
.expense-search { margin: -4px 0 18px; }
/* nothing to search while the invitation to add the first expense shows */
.expense-search:has(~ .budgets-region > .empty-state) { display: none; }
.expense-results { margin: 18px 0; }
/* with a category picked, its label on each expense card says nothing new */
[data-live="filters"]:has(.js-card-filter[data-key="category"].active:not([data-value=""])) ~ #expense-cards .exp-cat.is-category { display: none; }

/* card header: type icon tile in the type's gradient (the tiles of the expense sheet) */
.type-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 9px;
  color: #fff;
  background: var(--type-grad);
  border-radius: 11px;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--type) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.type-icon svg { width: 100%; height: 100%; stroke-width: 2.2; }

/* allowance (paga / bolsa) cards in the expense detail */
.allowance-tag { display: inline-flex; align-items: center; gap: 6px; padding-left: 3px; --cat: var(--orange); }
.allowance-tag .member-badge.sm { width: 16px; font-size: 0.46rem; box-shadow: none; }

.allowance-form { display: grid; gap: 14px; width: min(420px, calc(100vw - 32px)); }
.allowance-form > label { display: grid; gap: 8px; font-weight: 600; }
.allowance-form .money-input input { min-height: 46px; font-size: 1.25rem; text-align: right; }

/* a lone last card in a two-column grid takes the whole row */
.dash-grid > .dash-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

/* goods (bienes): flat kind tile, like .bank-mark: the kind colour (--bank) only in the icon and a light tint */
.good-mark {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 9px;
  color: var(--bank);
  background: color-mix(in srgb, var(--bank) 14%, var(--surface));
  border-radius: 28%;
}
.good-mark svg { width: 100%; height: 100%; stroke-width: 2; }
[data-usage-picker] button[hidden] { display: none; }

/* settings hero: who is in the family, linking to the members screen */
.hero-link { margin-top: 14px; padding-left: 6px; }
.hero-link .badge-stack .member-badge { box-shadow: 0 0 0 2px var(--navy); }

/* back to the parent screen, left of the page title in the top bar */
.topbar-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.back-button {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 9px;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.back-button:hover { color: var(--text); border-color: color-mix(in srgb, var(--teal-bright) 40%, var(--line)); }
.back-button [data-icon], .back-button svg { width: 100%; height: 100%; }
.back-button svg { transform: rotate(180deg); stroke-width: 2.4; }

/* settings hero: the family name is edited in place */
.settings-hero .dash-networth-label { display: flex; align-items: center; gap: 10px; }
.settings-hero .save-status { color: rgba(255, 255, 255, 0.6); }
.hero-name { position: relative; display: inline-flex; align-items: center; gap: 10px; max-width: 100%; margin: 4px 0 10px; cursor: text; }
.hero-name input {
  flex: 0 1 auto;
  min-width: 4ch;
  width: 100%;
  field-sizing: content;
  margin: 0 0 0 -10px;
  padding: 2px 10px;
  font: inherit;
  font-size: clamp(2.3rem, 6vw, 3.5rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.035em;
  color: #fff;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.hero-name input::placeholder { color: rgba(255, 255, 255, 0.35); }
.hero-name:hover input { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.12); }
.hero-name input:focus { background: rgba(255, 255, 255, 0.08); border-color: color-mix(in srgb, var(--teal-bright) 70%, transparent); }
.hero-name [data-icon] { flex-shrink: 0; width: 18px; height: 18px; color: rgba(255, 255, 255, 0.45); transition: color 0.15s ease; }
.hero-name:hover [data-icon], .hero-name:focus-within [data-icon] { color: #5dcaa5; }
/* settings: each section is a collapsible card with a one-line summary */
.settings-panel { padding: 0; }
.settings-panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  list-style: none;
  cursor: pointer;
  border-radius: 14px;
  transition: background 0.15s ease;
}
.settings-panel-head::-webkit-details-marker { display: none; }
.settings-panel-head:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.settings-panel-head:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal-bright) 40%, transparent); outline-offset: 2px; }
.settings-panel-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 9px;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal-bright) 13%, transparent);
  border-radius: 11px;
}
.settings-panel-icon svg, .settings-panel-chevron svg { width: 100%; height: 100%; }
.settings-panel-title { display: grid; min-width: 0; }
.settings-panel-title .dash-eyebrow { margin: 0; }
.settings-panel-title strong { font-size: 0.98rem; }
.settings-panel-summary { margin-left: auto; overflow: hidden; font-size: 0.82rem; color: var(--text-soft); text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.settings-panel-head .save-status { flex-shrink: 0; }
.settings-panel-chevron { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); transform: rotate(90deg); transition: transform 0.32s cubic-bezier(0.2, 0, 0, 1); }
.settings-panel[open]:not(.is-collapsing) .settings-panel-chevron { transform: rotate(-90deg); }
.settings-panel[open] .settings-panel-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.settings-panel-body { display: grid; gap: 14px; padding: 4px 20px 20px; border-top: 1px solid var(--line); padding-top: 18px; }
@media (max-width: 640px) {
  .settings-panel .settings-panel-summary { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .settings-panel-chevron { transition: none; }
}

/* members: compact member cards, with the family tree folded below them */
.member-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }
.member-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.member-chip:hover, .member-chip:focus-visible { border-color: color-mix(in srgb, var(--member) 55%, var(--line)); box-shadow: var(--soft-shadow); }
.member-chip.inactive { opacity: 0.6; }
.member-chip-text { display: grid; min-width: 0; flex: 1; }
.member-chip-text strong { overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.member-chip-text strong small { font-weight: 500; color: var(--text-soft); }
.member-chip-text > span { overflow: hidden; font-size: 0.74rem; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.member-chip .user-pill { flex-shrink: 0; margin: 0; padding: 5px; border-radius: 50%; }
.member-chip .user-pill.none { color: var(--muted); background: var(--surface-2); }
.tree-panel { margin-top: 14px; border-top: 1px solid var(--line); }
.tree-panel > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 2px 2px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-soft);
  list-style: none;
  cursor: pointer;
}
.tree-panel > summary::-webkit-details-marker { display: none; }
.tree-panel > summary:hover { color: var(--text); }
.tree-panel > summary [data-icon]:first-child { width: 16px; height: 16px; }
.tree-panel > summary small { font-weight: 400; color: var(--muted); }
.tree-panel > summary .settings-panel-chevron { margin-left: auto; }
.tree-panel[open]:not(.is-collapsing) .settings-panel-chevron { transform: rotate(-90deg); }

.family-badge { display: inline-flex; }
.badge-stack .family-badge + .family-badge { margin-right: -6px; }
.family-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.family-badges .member-badge { box-shadow: 0 0 0 3px var(--navy), 0 6px 14px rgba(0, 0, 0, 0.25); }

/* breadcrumb in the top bar: "‹ Configuración / Miembros" */
.breadcrumb .back-button {
  width: auto;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px 0 8px;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}
.breadcrumb .back-button [data-icon] { width: 14px; height: 14px; }
.breadcrumb-sep { font-size: 1.2rem; color: var(--muted); }
@media (max-width: 480px) {
  .breadcrumb .back-button span:last-child { display: none; }
  .breadcrumb .back-button { padding: 0 9px; }
}

/* ---------- Page transitions (cross-document view transitions) ----------
   The frame (sidebar, top bar) stays put, the active menu pill glides, the navy hero morphs into the
   next page's hero and the rest of the content slides 12 px in the direction of travel. Only transform
   and opacity are animated; reduced-motion users and browsers without support get a plain navigation. */
.sidebar { view-transition-name: sidebar; }
.content-topbar { view-transition-name: topbar; }
.dash-hero { view-transition-name: page-hero; }
.fab { view-transition-name: fab; }

::view-transition-group(*) { animation-duration: 0.3s; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }
/* The sidebar doesn't move at all: the new one shows at once, no cross-fade (only its pill glides). */
::view-transition-group(sidebar) { animation: none; }
::view-transition-old(sidebar) { display: none; }
::view-transition-new(sidebar) { animation: none; }
::view-transition-old(topbar),
::view-transition-new(topbar) { animation-duration: 0.18s; }
::view-transition-group(nav-pill) { z-index: 0; }

/* The hero box resizes; its content keeps its size and cross-fades instead of being stretched. */
::view-transition-group(page-hero) { overflow: clip; border-radius: 18px; }
::view-transition-old(page-hero),
::view-transition-new(page-hero) { width: 100%; height: 100%; object-fit: none; object-position: left top; }
/* The outgoing snapshots stay opaque underneath while the incoming ones fade in on top, so the
   cross-fade never dips through to the blank canvas (that was a brief white flash). */
::view-transition { background: var(--bg); }
::view-transition-old(root), ::view-transition-new(root),
::view-transition-old(page-hero), ::view-transition-new(page-hero) { mix-blend-mode: normal; }
::view-transition-old(page-hero) { animation: vt-hold 0.26s both; }
::view-transition-new(page-hero) { animation: vt-fade-in 0.26s ease both; }

::view-transition-old(root) { animation: vt-hold 0.26s both; }
::view-transition-new(root) { animation: vt-fade-in 0.26s ease both; }
html:active-view-transition-type(forward)::view-transition-new(root) { animation: vt-fade-in 0.26s ease both, vt-from-below 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
html:active-view-transition-type(backward)::view-transition-new(root) { animation: vt-fade-in 0.26s ease both, vt-from-above 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

@keyframes vt-hold { to { opacity: 1; } }
@keyframes vt-fade-in { from { opacity: 0; } }
@keyframes vt-from-below { from { transform: translateY(12px); } }
@keyframes vt-from-above { from { transform: translateY(-12px); } }

/* Sheets and dialogs: they enter from below on a phone and with a scale of .98 + fade on a desktop, and leave the
   same way backwards (@starting-style + discrete transitions of display and overlay, CSS only: the close() calls
   don't change). Browsers without those keep the short scale + fade on opening. */
dialog.modal[open] { animation: modal-in 0.2s cubic-bezier(0.2, 0.7, 0.2, 1); }
dialog.modal[open]::backdrop { animation: vt-fade-in 0.2s ease; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(0.97); } }

@supports (transition-behavior: allow-discrete) {
  dialog.modal[open], dialog.modal[open]::backdrop { animation: none; }

  dialog.modal {
    opacity: 0;
    transform: scale(0.98);
    transition:
      opacity 0.32s cubic-bezier(0.2, 0, 0, 1),
      transform 0.32s cubic-bezier(0.2, 0, 0, 1),
      overlay 0.32s allow-discrete,
      display 0.32s allow-discrete;
  }

  dialog.modal[open] {
    opacity: 1;
    transform: none;
  }

  dialog.modal::backdrop {
    opacity: 0;
    transition:
      opacity 0.32s ease,
      overlay 0.32s allow-discrete,
      display 0.32s allow-discrete;
  }

  dialog.modal[open]::backdrop { opacity: 1; }

  @starting-style {
    dialog.modal[open] { opacity: 0; transform: scale(0.98); }
    dialog.modal[open]::backdrop { opacity: 0; }
  }

  @media (max-width: 600px) {
    dialog.modal { transform: translateY(40px); }
    @starting-style {
      dialog.modal[open] { transform: translateY(40px); }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.modal, dialog.modal[open], dialog.modal::backdrop, dialog.modal[open]::backdrop { animation: none; transition: none; }
}

/* a member still to pick: its chips turn coral */
.sheet-form [data-member-chips].is-missing { border-color: transparent !important; box-shadow: none !important; background: none; }
.sheet-form [data-member-chips].is-missing .split-chip,
.sheet-form .member-picker[data-member-chips].is-missing button { border-color: var(--coral); color: var(--coral); opacity: 1; }
/* seven kinds in two columns on a phone: the last one takes the whole row, no orphan tile */
@media (max-width: 560px) { .kind-tiles button:last-child:nth-child(odd) { grid-column: 1 / -1; } }

/* savings by member: picking a member dims the others */
.savings-flow-bar > span.dimmed,
.savings-flow .dash-legend .dimmed { opacity: 0.35; }

/* ---------- Estructura común: hero + filtro de vista ---------- */

/* Every page hero has the same height: figure on top, KPIs at the bottom, whatever sits in between. */
:root { --page-hero-height: 372px; }
@media (max-width: 900px) { :root { --page-hero-height: 480px; } }
@media (max-width: 600px) { :root { --page-hero-height: 640px; } }

.dash-hero.page-hero-std {
  display: flex;
  flex-direction: column;
  min-height: var(--page-hero-height);
}

.dash-hero.page-hero-std > .dash-hero-kpis {
  margin-top: auto;
}

/* Gastos has less to show than the hero's height: the bar sits centred between the figure and the KPIs. */
.dash-hero.page-hero-std.summary-hero { min-height: 0; }
.dash-hero.page-hero-std.summary-hero > .dash-composition { margin-block: 22px 0; }
.dash-hero.page-hero-std.summary-hero > .dash-hero-kpis { margin-top: 22px; }

/* Gastos: this month and the next two, with the charges that aren't monthly by name. */
.upcoming-charges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.upcoming-charges ul.upcoming-named { max-width: 240px; margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.upcoming-named li { display: flex; justify-content: space-between; gap: 8px; min-width: 0; max-width: 100%; font-size: 0.74rem; color: #c9c8c2; }
.upcoming-named li span { display: inline; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: inherit; color: inherit; }
.upcoming-named li b { font-weight: 600; font-variant-numeric: tabular-nums; }
.upcoming-named li.upcoming-more { color: #9c9b96; }
.upcoming-undated { margin: 12px 0 0; font-size: 0.74rem; color: #9c9b96; }

/* On a phone each month is one compact row: its name and total, the named charges in a line under them. */
@media (max-width: 720px) {
  .dash-hero-kpis.upcoming-charges { grid-template-columns: 1fr; gap: 0; }
  .dash-hero-kpis.upcoming-charges > div:first-child { grid-column: auto; }
  .upcoming-charges > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 12px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
  .upcoming-charges > div:first-child { padding-top: 0; border-top: 0; }
  .upcoming-charges > div > span { margin: 0; }
  .upcoming-charges > div > strong { font-size: 1.05rem; }
  .upcoming-charges ul.upcoming-named { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 12px; max-width: none; margin: 2px 0 0; }
  .upcoming-named li { gap: 5px; }
}

/* Breathing room above the KPIs when the hero's own content is already as tall as the standard. */
.dash-hero.page-hero-std > :nth-last-child(2) {
  margin-bottom: 22px;
}

/* Member and period, right under the hero, the same on every page. */
.view-filter {
  margin-top: -6px;
}

.view-filter .segmented a {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 8px;
}

.view-filter .segmented a:hover { color: var(--text); }

.view-filter .segmented a[aria-current="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(14, 21, 38, 0.12);
}

/* The picked option's pill is one thumb that slides between options (motion.js). */
:is(.view-filter .segmented, [data-pill]).has-thumb { position: relative; }
:is(.view-filter .segmented, [data-pill]).has-thumb :is(a, button) { position: relative; z-index: 1; transition: color 0.3s ease; }
:is(.view-filter .segmented, [data-pill]).has-thumb :is(a, button):is([aria-current="true"], [aria-pressed="true"], .active) { background: transparent; box-shadow: none; }
.segmented-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(14, 21, 38, 0.12);
  pointer-events: none;
  z-index: 0;
}

/* Drag (motion.js): the pill follows the finger; the nearest option takes the active colour. */
:is(.view-filter .segmented, [data-pill]) :is(a, button) { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
:is(.view-filter .segmented, [data-pill]) { touch-action: pan-y; }
:is(.view-filter .segmented, [data-pill]).scroll { touch-action: auto; }
:is(.view-filter .segmented, [data-pill]).scroll :is(a, button):is([aria-current="true"], [aria-pressed="true"], .active) { touch-action: pan-y; }
:is(.view-filter .segmented, [data-pill]) :is(a, button).is-hover { color: var(--text); }
:is(.view-filter .segmented, [data-pill]).is-dragging :is(a, button):is([aria-current="true"], [aria-pressed="true"]):not(.is-hover) { color: var(--text-soft); }
:is(.view-filter .segmented, [data-pill]).is-dragging { cursor: grabbing; }
:is(.view-filter .segmented, [data-pill]).is-dragging .segmented-thumb { will-change: translate, scale; }
/* Breathing room so the swollen pill is not clipped by the scrolling rail. */
:is(.view-filter .segmented, [data-pill]).scroll { padding-block: 5px; }
:is(.view-filter .segmented, [data-pill]).scroll .segmented-thumb { top: 5px; bottom: 5px; }
@media (pointer: coarse) {
  :is(.view-filter .segmented, [data-pill]) :is(a, button) { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.view-filter .segmented, [data-pill]).has-thumb :is(a, button) { transition: none; }
}

:is(.view-filter .segmented, [data-pill]) :is(a, button) [data-icon] { width: 15px; height: 15px; }
:is(.view-filter .segmented, [data-pill]) :is(a, button) .member-badge { margin: -2px 0 -2px -6px; }

.view-filter-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

@media (max-width: 600px) {
  .view-filter { align-items: stretch; }
  .view-filter > .segmented { max-width: 100%; }
  .view-filter-extra { margin-left: 0; }
}

/* Screen-to-screen loader (motion.js): a thin teal bar that sweeps along the top edge. */
.nav-loader {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1000;
  height: 3px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.nav-loader.active { opacity: 1; }

.nav-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--teal-bright), transparent);
  transform: translateX(-100%);
}

.nav-loader.active::before { animation: nav-loader-sweep 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite; }

@keyframes nav-loader-sweep { to { transform: translateX(250%); } }

@media (prefers-reduced-motion: reduce) {
  .nav-loader.active::before { animation: none; width: 100%; transform: none; opacity: 0.7; }
}

/* ---------- Pie común: año, marca y enlaces de ayuda y legales ---------- */

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 40px;
  padding: 18px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.site-footer-brand { display: inline-flex; align-items: center; gap: 10px; }
.site-footer-brand img { flex: none; width: 20px; height: 25px; }

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.site-footer-links a {
  color: var(--text-soft);
  text-decoration: none;
  transition: color 0.16s ease;
}

.site-footer-links a:hover,
.site-footer-links a:focus-visible,
.site-footer-links a[aria-current="page"] {
  color: var(--text);
}

/* keep the last links clear of the floating "+" button */
.content:has(> .fab) .site-footer { padding-right: 76px; }

.content > .site-footer {
  margin-top: auto;
}

/* at least this much air between the last card and the footer */
.content > .site-footer-spacer {
  flex: 0 0 22px;
  margin-bottom: -18px;
}

.site-footer.in-landing {
  width: var(--lp-w);
  margin: 0 auto;
  padding: 24px 0 40px;
}

.site-footer.in-login {
  justify-content: center;
  margin-top: auto;
  padding-top: 14px;
  border-top: 0;
  text-align: center;
}

.site-footer.in-login .site-footer-note { display: none; }

@media (max-width: 600px) {
  .site-footer { flex-direction: column; align-items: flex-start; }
  .site-footer .site-footer-note { display: none; }
  .site-footer.in-login { align-items: center; }
}

/* ---------- Páginas de ayuda y legales ---------- */

.public-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 clamp(16px, 4vw, 40px);
  background: var(--bg);
}

.public-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 20px 0;
}

.public-main {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 18px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.public-title h2 {
  margin: 12px 0 0;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 600;
}

.public-page .site-footer {
  width: min(760px, 100%);
  margin: 40px auto 0;
  padding-bottom: 32px;
}

.info-doc {
  max-width: 760px;
  padding: clamp(18px, 3vw, 28px);
  line-height: 1.6;
}

.info-lead {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text);
}

.info-doc section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.info-doc section:first-of-type { border-top: 0; }

.info-doc h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
}

.info-doc p,
.info-doc li {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.info-doc ul {
  margin: 6px 0;
  padding-left: 18px;
}

.info-doc p + ul,
.info-doc ul + p { margin-top: 6px; }

.info-doc a { color: var(--blue); }

.info-doc code {
  padding: 1px 5px;
  font-size: 0.8rem;
  background: var(--surface-2);
  border-radius: 5px;
}

.info-updated {
  margin-top: 8px !important;
  font-size: 0.74rem !important;
  color: var(--muted) !important;
}

/* ---------- Cuentas: previsión, grupos que rinden / no rinden ---------- */

.acc-outlook {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--amber-pale) 70%, var(--surface));
  border-color: color-mix(in srgb, var(--amber) 25%, transparent);
}

html[data-theme="dark"] .acc-outlook {
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
}

.acc-outlook-icon {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 14%, transparent);
  border-radius: 9px;
}

.acc-outlook-icon svg { width: 17px; height: 17px; }

.acc-outlook p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.acc-outlook b {
  color: var(--text);
  font-weight: 600;
}

.acc-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 4px 2px 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  list-style: none;
}

.acc-group-head::-webkit-details-marker { display: none; }

.acc-group-chevron {
  align-self: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transform: rotate(90deg);
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), color 0.16s ease;
}

.acc-group-chevron svg { width: 100%; height: 100%; }
.acc-group-head:focus-visible { outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .acc-group-chevron { transition: none; } }
.acc-group[open]:not(.is-collapsing) .acc-group-chevron { transform: rotate(-90deg); }
.acc-group-head:hover .acc-group-chevron { color: var(--text); }

.acc-group-body { padding-top: 10px; }

.acc-group-head h3 {
  margin: 0 auto 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.acc-yield {
  margin: 2px 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}

.acc-yield b {
  color: var(--teal);
  font-weight: 600;
}

html[data-theme="dark"] .acc-yield b { color: #5dcaa5; }
.acc-yield b.neg,
html[data-theme="dark"] .acc-yield b.neg { color: var(--coral-ink); }

.acc-yield.idle {
  color: var(--muted);
}

/* the TIN chip stays neutral (black on white) so the bank colours carry the card */
.dash-chip.acc-tin {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}

/* small "Mayor a menor / Menor a mayor" switch in a card head */
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.sort-toggle:hover,
.sort-toggle:focus-visible { color: var(--text); }

.sort-toggle [data-icon] svg { width: 14px; height: 14px; transition: transform 0.16s ease; }

.sort-toggle.is-asc [data-icon] svg { transform: scaleY(-1); }

/* ---------- Ingresos: the cards are the expenses' (exp-card), titled, with the member as a small avatar ---------- */

.inc-card { color: inherit; text-decoration: none; }
.inc-card .exp-meta:empty::before { content: "\00a0"; }

/* the good's sheet: its expenses from Gastos */
.good-costs { display: grid; justify-items: start; gap: 8px; }
.good-costs-list { display: grid; gap: 4px; width: 100%; margin: 0; padding: 0; list-style: none; font-size: 0.8rem; }
.good-costs-list li { display: flex; justify-content: space-between; gap: 12px; color: var(--text-soft); }
.good-costs-list b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.good-costs-list li { align-items: center; }
.good-costs-list li span { flex: 1; min-width: 0; }
.good-cost-remove {
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.good-cost-remove:hover, .good-cost-remove:focus-visible { background: var(--surface-2); color: var(--text); }
.good-cost-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 120px); gap: 8px; width: 100%; align-items: center; }
.good-cost-add .segmented, .good-cost-add .button { grid-column: 1 / -1; justify-self: start; }
@media (min-width: 640px) {
  .good-cost-add { grid-template-columns: minmax(0, 1fr) 110px auto auto; }
  .good-cost-add .segmented, .good-cost-add .button { grid-column: auto; }
}
[data-linked-costs] { display: grid; align-content: start; gap: 4px; }
[data-linked-costs] strong { font-size: 1rem; font-variant-numeric: tabular-nums; }

/* the income sheet: an amount that changes asks why (correction or update), and the changes kept */
.inc-change {
  display: grid;
  grid-template-rows: 0fr;
  margin-top: -14px; /* closed, it takes no gap in the sheet */
  opacity: 0;
  transition: grid-template-rows 0.38s cubic-bezier(0.2, 0, 0, 1), margin-top 0.38s cubic-bezier(0.2, 0, 0, 1), opacity 0.28s ease;
}

.inc-change.is-open { grid-template-rows: 1fr; margin-top: 0; opacity: 1; }
.inc-change-body { min-height: 0; overflow: hidden; }

.inc-change-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--line));
  border-radius: 12px;
}

.inc-change.is-missing .inc-change-card { animation: login-shake 0.4s ease both; border-color: var(--coral); }

.inc-change-text { display: grid; gap: 2px; font-size: 0.84rem; }
.inc-change-text span { font-size: 0.76rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.inc-change-actions,
.inc-change-update { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.inc-change-update select {
  width: auto;
  min-height: 32px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.inc-history { display: grid; gap: 6px; }

.inc-history ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.inc-history li { display: flex; justify-content: space-between; gap: 12px; color: var(--text-soft); }
.inc-history li b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .inc-change { transition: none; }
}

/* ---------- Ahorro: fondo de emergencia en una tarjeta plegable ---------- */

/* Folded: importe, meses and % cubierto on the right of the summary row. */
.emergency-figures {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-left: auto;
}

.emergency-figures > span:not(.dash-chip) { display: grid; text-align: right; }

.emergency-figures strong {
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.emergency-figures .dash-chip { white-space: nowrap; }

.emergency-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
}

.emergency-status {
  display: grid;
  align-content: start;
  gap: 8px;
}

.emergency-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.emergency-amount {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.emergency-amount .goal-target {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0;
}

.emergency-status .dash-card-foot { margin: 2px 0 0; }

.emergency-status .dash-card-foot b { color: var(--text); font-weight: 600; }

.emergency-settings.savings-settings {
  margin-top: 0;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

@media (max-width: 640px) {
  .emergency-card .settings-panel-head { flex-wrap: wrap; }
  .emergency-card .settings-panel-chevron { margin-left: auto; }
  .emergency-figures { order: 3; width: 100%; justify-content: space-between; gap: 12px; }
  .emergency-figures > span:not(.dash-chip) { text-align: left; }
}

@media (max-width: 780px) {
  .emergency-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .emergency-settings.savings-settings { padding: 18px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

/* owners fixed by a joint account: the chosen holders stay highlighted, the rest fade, none can be toggled */
.member-picker button:disabled { cursor: default; opacity: 1; }
.member-picker button:disabled[aria-pressed="false"] { opacity: 0.45; }
.joint-lock { margin-top: 6px; color: var(--text-soft); }

/* ===== Assisted summary: glasses, stages and the road ahead (frontend/front/resumen.js, path.js) ===== */
/* The glasses in the logo's colours, by theme: the light range on light cards, the dark one over dark. */
:root { --glass-operativa: #5aa8ff; --glass-estrategica: #2f7bf2; --glass-inversion: #2456d6; --glass-prevision: #2a2fa6; }
/* The same blues as text and symbol (AA, 4.5:1, on the card). */
:root { --glass-operativa-ink: #1d63b4; --glass-estrategica-ink: #1b57c4; --glass-inversion-ink: #2456d6; --glass-prevision-ink: #2a2fa6; }
html[data-theme="dark"] { --glass-operativa-ink: #8cc8ff; --glass-estrategica-ink: #6aaeff; --glass-inversion-ink: #8aa9ff; --glass-prevision-ink: #a0a4ff; }
html[data-theme="dark"] { --glass-operativa: #8cc8ff; --glass-estrategica: #4e9bff; --glass-inversion: #2f6bf5; --glass-prevision: #3b40c9; }

/* The verdict sentence and its button (the Resumen and Horizontes heroes). */
.path-verdict { margin: 8px 0 0; font-size: clamp(1.2rem, 2.2vw, 1.6rem); font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; text-wrap: balance; }
.path-verdict b { color: #f2b94b; white-space: nowrap; }
.path-verdict em { font-style: normal; font-weight: 700; color: #7fe0bd; }
.path-hero-spread { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 22px; font: inherit; font-size: 0.94rem; font-weight: 600; color: #06101f; cursor: pointer; background: #4e9bff; border: 0; border-radius: 999px; transition: background-color 0.2s; }
.path-hero-spread[hidden] { display: none; }
a.path-hero-spread { text-decoration: none; }
.path-hero-spread:hover { background: #8cc8ff; }
.path-hero-spread [data-icon], .hero-stage-line a [data-icon] { width: 14px; height: 14px; }

.wf-view { display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 999px; }
.wf-view[hidden] { display: none; }
.wf-view button { min-height: 38px; padding: 0 16px; font: inherit; font-size: 0.8rem; font-weight: 600; color: rgba(255, 255, 255, 0.68); cursor: pointer; background: transparent; border: 0; border-radius: 999px; transition: background-color 0.25s, color 0.25s; }
.wf-view button[aria-pressed="true"] { color: #fff; background: rgba(255, 255, 255, 0.14); }

/* The cascade (cascade.js): four bars on one euro scale, each with its line, over a dark hero. */
.wf { position: relative; display: grid; gap: 14px; }
.wf-row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: start; }
/* The layer of the logo the glass is: bowls that grow from top to bottom. */
.wf-icon { justify-self: center; width: var(--w); height: calc(var(--w) / 2); margin-top: 6px; background: var(--wf-grad); border-radius: 0 0 999px 999px; }
.wf-main { min-width: 0; }
.wf-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.wf-top b { font-size: 0.84rem; font-weight: 600; color: rgba(255, 255, 255, 0.72); }
.wf-top strong { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; color: #fff; font-variant-numeric: tabular-nums; }
.wf-track { position: relative; height: 14px; margin: 7px 0 6px; background: rgba(255, 255, 255, 0.05); border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
/* Each glass's gradient, lighter at the start: the same as the logo's pieces on the landing (landing.js, mix). */
.wf-row, .wf-drop { --wf-grad: linear-gradient(90deg, color-mix(in srgb, var(--c) 70%, #fff) 0%, var(--c) 60%, color-mix(in srgb, var(--c) 85%, #000) 100%); }
.wf-fill { position: absolute; inset: 0 auto 0 0; background: var(--wf-grad); border-radius: 3px; }
.wf-line { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 1.5px solid rgba(255, 255, 255, 0.8); }
.wf-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 0.72rem; color: rgba(255, 255, 255, 0.5); font-variant-numeric: tabular-nums; }
.wf-status { font-weight: 600; transition: color 0.3s ease; }
.wf-status.over { color: #f2b94b; }
.wf-status.ok { color: #7fe0bd; }
.wf-axis { position: relative; height: 14px; margin-left: 34px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.wf-axis span { position: absolute; top: 4px; font-size: 0.62rem; color: rgba(255, 255, 255, 0.45); font-variant-numeric: tabular-nums; white-space: nowrap; transform: translateX(-50%); }
.wf-axis span:first-child { transform: none; }
/* What Para el mes hands out, cut into what each glass receives: striped while it waits, solid in its glass's colour
   once it lands. Each piece keeps its width on the way down, because every bar shares the scale. */
.wf-drops { position: absolute; inset: 0; pointer-events: none; }
.wf-drop { position: absolute; isolation: isolate; display: grid; place-items: center; height: 14px; overflow: hidden; font-size: 0.6rem; font-style: normal; font-weight: 600; color: #fff; white-space: nowrap; font-variant-numeric: tabular-nums; border-radius: 2px; transition: transform 0.9s cubic-bezier(0.65, 0, 0.35, 1) var(--d); }
.wf-drop::before, .wf-drop::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; }
.wf-drop::before { background: repeating-linear-gradient(135deg, rgba(242, 185, 75, 0.55) 0 3px, rgba(242, 185, 75, 0.18) 3px 7px); box-shadow: inset 0 0 0 1px rgba(242, 185, 75, 0.6); }
.wf-drop::after { background: var(--wf-grad); opacity: 0; transition: opacity 0.35s ease calc(var(--d) + 0.6s); }
.is-spread .wf-drop { transform: translate(var(--dx), var(--dy)); }
.is-spread .wf-drop::after { opacity: 1; }
[data-cascade]:not(.is-spread) .wf-drop, [data-cascade]:not(.is-spread) .wf-drop::after { transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) { .wf-drop, .wf-drop::after { transition: none; } }

/* The Resumen: a verdict with one button and four figures in the dark hero, then cards (the cascade is the first). */
.overview-hero { display: grid; justify-items: start; gap: 0; }
.overview-verdict { margin: 10px 0 0; max-width: 28ch; font-size: clamp(1.5rem, 2.5vw, 2.1rem); font-weight: 700; line-height: 1.16; letter-spacing: -0.02em; text-wrap: balance; }
.overview-zero { margin-top: 14px; font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.overview-actions { display: flex; margin-top: 22px; }
.overview-how { width: 100%; margin-top: 14px; }
.overview-how > summary { display: inline-flex; gap: 8px; color: var(--on-hero-muted); }
.overview-how > summary:hover { color: inherit; }
.overview-how > summary:focus-visible { outline-color: var(--blue); }
.overview-how p { margin: 0; max-width: 60ch; font-size: 0.94rem; line-height: 1.55; color: rgba(255, 255, 255, 0.7); }
.overview-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 12px; width: 100%; margin: 22px 0 0; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.overview-kpis[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.overview-kpis > div { min-width: 0; }
.overview-kpis dt { margin-bottom: 4px; font-size: 0.72rem; color: var(--on-hero-muted); }
.overview-kpis dd { display: grid; gap: 2px; margin: 0; }
.overview-kpis strong { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.overview-kpis small { font-size: 12px; line-height: 1.35; color: var(--on-hero-muted); }
/* The state is a short word and a dot: the colour never goes to the figure. */
.kpi-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; color: var(--on-hero-muted); }
.kpi-state i { flex: none; width: 7px; height: 7px; background: var(--income-2); border-radius: 50%; }
.kpi-state.is-warn { color: color-mix(in srgb, var(--layer-free) 70%, #fff); }
.kpi-state.is-warn i { background: var(--layer-free); }
.kpi-state.is-low { color: color-mix(in srgb, var(--coral) 62%, #fff); }
.kpi-state.is-low i { background: var(--coral); }

.overview-card { margin-top: 16px; }
.dash-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.dash-grid-2 > .overview-card { min-width: 0; }
.overview-card .dash-card-head { align-items: center; }
.overview-card .dash-card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
.overview-card .dash-card-head a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 0.86rem; font-weight: 600; color: var(--text-soft); text-decoration: none; transition: color 0.2s; }
.overview-card .dash-card-head a:hover { color: var(--text); }
.overview-card .dash-card-head a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.overview-card .dash-card-head a [data-icon] { width: 14px; height: 14px; }
.overview-card .wf-view { align-self: start; justify-self: start; background: var(--surface-2); border-color: var(--line); }
.overview-card .wf-view button { color: var(--text-soft); }
.overview-card .wf-view button[aria-pressed="true"] { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.overview-card .wf-top b { color: var(--text-soft); }
.overview-card .wf-top strong { color: var(--text); }
.overview-card .wf-track { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.overview-card .wf-line { border-left-color: var(--text); }
.overview-card .wf-meta, .overview-card .wf-axis span { color: var(--muted); }
.overview-card .wf-axis { border-top-color: var(--line); }
.overview-card .wf-status.over { color: var(--amber-ink); }
.overview-card .wf-status.ok { color: var(--teal); }
.wf-drop.is-tight { color: transparent; }
.wf-spread-note { display: none; margin: 0; font-size: 0.9rem; color: var(--text-soft); }
.wf-spread-note b { color: var(--text); white-space: nowrap; }
.wf-spread-note em { font-style: normal; font-weight: 700; color: var(--text); }
[data-cascade].is-spread .wf-spread-note { display: block; }
.overview-card .hero-stage-now { color: var(--text-soft); }
.overview-card .hero-stage-now strong { color: var(--text); }
.overview-card .hero-stage-dots i { background: var(--line); }
.overview-card .hero-stage-dots i.done { background: var(--blue); }
.overview-card .hero-stage-dots i.current { background: var(--layer-free); }
.overview-charges { display: grid; margin: 0; padding: 0; list-style: none; }
.overview-charges > :first-child { border-top: 0; }
.overview-none { margin: 0; font-size: 0.94rem; color: var(--muted); }
@media (max-width: 700px) {
  .dash-grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .overview-kpis, .overview-kpis[data-count="3"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-kpis > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .overview-actions, .overview-actions .path-hero-spread { width: 100%; }
  .overview-actions .path-hero-spread { justify-content: center; }
}

.hero-stage-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.hero-stage-now { display: flex; align-items: center; gap: 12px; font-size: 0.82rem; color: rgba(255, 255, 255, 0.65); }
.hero-stage-now strong { font-weight: 600; color: #fff; }
.hero-stage-dots { display: flex; flex: none; gap: 5px; }
.hero-stage-dots i { width: 8px; height: 8px; background: rgba(255, 255, 255, 0.18); border-radius: 50%; }
.hero-stage-dots i.done { background: #8cc8ff; }
.hero-stage-dots i.current { background: #f2b94b; }
.hero-stage-line a { display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; font-weight: 600; color: #8cc8ff; text-decoration: none; transition: color 0.2s; }
.hero-stage-line a:hover { color: #fff; }

.path-status { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; }
.path-status::before { content: ""; flex: none; width: 8px; height: 8px; background: currentColor; border-radius: 50%; }
.path-status.ok { color: var(--teal); }
.path-status.over { color: var(--amber); }
.path-status.short { color: var(--coral); }
.path-status.free { font-weight: 500; color: var(--muted); }
.path-status small { font-weight: 500; color: var(--muted); }

.path-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.path-chart-head p { max-width: 520px; margin: 4px 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--text-soft); }
.path-chart-head h3 { margin: 0; }

/* Patrimonio financiero: a plain card like .budget-card (hairline, no shadow, no gradients); the glasses draw as stacked
   lines and areas in the --glass-* tokens, the band is the prudent-to-optimistic range; horizons zoom the axis (path.js). */
.path-graph {
  --pg-ease: cubic-bezier(0.2, 0, 0, 1);
  display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 22px; color: var(--text);
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-radius: 18px; box-shadow: none;
}
.path-graph-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.path-graph-head h3 { margin: 0; }
.path-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; max-width: 100%; }
.path-term { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; }
.path-term-label { flex: none; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
/* The segmented group (Plazo, Euros de hoy | De cada año): a rail and a pill that glides under the pressed button. */
.path-horizons { position: relative; display: inline-flex; max-width: 100%; padding: 4px; overflow-x: auto; scrollbar-width: none; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; }
.path-horizons::-webkit-scrollbar { display: none; }
.path-horizons button { position: relative; z-index: 1; min-height: 36px; flex: none; padding: 6px 13px; font: inherit; font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text-soft); background: none; border: 0; border-radius: 999px; cursor: pointer; transition: color 0.3s var(--pg-ease); }
.path-horizons button:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: -2px; }
.path-horizons button:hover { color: var(--text); }
.path-horizons b { display: none; font-weight: inherit; }
.path-horizons button[aria-pressed="true"] { color: var(--text); }
@media (pointer: coarse) { .path-horizons button { min-height: 44px; } }

/* The readout, as the hero of Cuentas: when, the big figure with the stage chip and the change, a grey line. */
.path-readout { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.path-read-when { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.path-read-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.path-read-total { font-size: clamp(2rem, 6vw, 3rem); font-weight: 600; line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.path-read-delta { font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--teal); }
.path-read-delta.down { color: var(--coral-ink); }
.path-read-delta:empty { display: none; }
.path-read-stage { padding: 4px 10px; font-size: 0.78rem; font-weight: 600; color: var(--amber-ink); background: var(--amber-pale); border-radius: 999px; }
.path-read-range { font-size: 0.92rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.path-read-range[hidden] { display: none; }
.path-read-note { font-size: 0.88rem; color: var(--muted); }

.path-graph .path-chart-wrap { position: relative; margin: 0 -4px; border-radius: 10px; transition: opacity 0.15s cubic-bezier(0.2, 0, 0, 1); }
.path-chart-wrap:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }
.path-chart-wrap svg { display: block; width: 100%; overflow: visible; cursor: crosshair; touch-action: pan-y; user-select: none; }
.path-chart-wrap text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.k-op { --k: var(--glass-operativa); }
.k-est { --k: var(--glass-estrategica); }
.k-inv { --k: var(--glass-inversion); }
.k-prev { --k: var(--glass-prevision); }
.pg-grid { stroke: var(--line); stroke-dasharray: 2 5; }
.pg-axis { font-size: 11px; fill: var(--muted); }
/* Always there: the stacked layers (no glow) and the next stage's pin. */
.pg-line { fill: none; stroke: var(--k); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.pg-area { fill: var(--k); fill-opacity: 0.28; stroke: none; }
.pg-band { fill: var(--blue); fill-opacity: 0.12; stroke: none; }
html[data-theme="dark"] .pg-band { fill-opacity: 0.08; }
/* In the background: one quiet tone and a thin stroke; each one names itself only when the cursor is close. */
.pg-baseline, .pg-threshold, .pg-plan, .pg-stage { fill: none; stroke: var(--muted); stroke-opacity: 0.55; stroke-width: 1; stroke-dasharray: 3 4; }
.pg-plan-dot { fill: var(--muted); fill-opacity: 0.7; }
.pg-hint, .pg-plan-label { font-size: 10.5px; font-weight: 600; fill: var(--text-soft); opacity: 0; transition: opacity 0.3s var(--pg-ease); pointer-events: none; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.pg-hint.on, .pg-plan-label.on { opacity: 1; }
/* The stages still ahead, pinned on the road where they begin (path.js) */
.pg-pin-ground { fill: var(--text); fill-opacity: 0.18; }
.pg-pin-head { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; }
.pg-pin-icon { fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pg-pin.next .pg-pin-head { fill: var(--amber); stroke: var(--amber); }
.pg-pin.next .pg-pin-icon { stroke: var(--navy); }
.pg-pin-label, .pg-pin-year { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.pg-pin-label { font-size: 10.5px; font-weight: 700; fill: var(--text); }
.pg-pin-year { font-size: 10px; font-weight: 600; fill: var(--muted); font-variant-numeric: tabular-nums; }
.pg-pin-label.next, .pg-pin-year.next { fill: var(--amber-ink); }
/* On demand («Ver detalles»): the turns of a child's cost, a short tick on the axis and its name. */
.pg-milestone { stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; }
.pg-milestone-label { font-size: 9.5px; font-weight: 600; fill: var(--text-soft); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.pg-milestone.warn { stroke: var(--coral); }
.pg-milestone-label.warn { fill: var(--coral-ink); }
.pg-cursor line { stroke: var(--muted); stroke-width: 1.5; }
.pg-halo { fill: var(--k); opacity: 0.22; }
.pg-dot { fill: var(--k); stroke: var(--surface); stroke-width: 2; }
.pg-cursor [data-tag] rect { fill: var(--text); }
.pg-cursor [data-tag] text { font-size: 11px; font-weight: 700; fill: var(--surface); }

/* The tooltip with each layer's share: under the pointer, or at the cursor while the chart has the keyboard focus. */
.path-tip { position: absolute; z-index: 2; width: max-content; min-width: 176px; padding: 10px 12px; font-size: 0.78rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--soft-shadow); pointer-events: none; }
.path-tip[hidden] { display: none; }
.path-tip strong { display: block; font-size: 0.84rem; }
.path-tip small { display: block; margin-bottom: 4px; color: var(--muted); }
.path-tip div { display: flex; justify-content: space-between; gap: 16px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.path-tip div > span { display: inline-flex; align-items: center; gap: 7px; color: var(--text-soft); }
.path-tip i { width: 8px; height: 8px; background: var(--c); border-radius: 50%; }
.path-tip div.path-tip-total { margin-top: 6px; padding-top: 6px; font-weight: 700; border-top: 1px solid var(--line); }
.path-tip em { display: block; margin-top: 6px; font-style: normal; font-weight: 600; color: var(--text-soft); }

.path-chart-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.path-foot-notes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; min-width: 0; }
.path-band-note { display: inline-flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); }
.path-band-note i { flex: none; width: 16px; height: 10px; background: var(--blue); opacity: 0.12; border-radius: 3px; }
html[data-theme="dark"] .path-band-note i { opacity: 0.08; }
.path-chip { min-height: 32px; padding: 0 14px; font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--text-soft); cursor: pointer; background: transparent; border: 1px solid var(--line); border-radius: 999px; transition: background-color 0.3s var(--pg-ease), color 0.3s var(--pg-ease), border-color 0.3s var(--pg-ease); }
.path-chip:hover { color: var(--text); }
.path-chip[aria-pressed="true"] { color: var(--text); background: var(--surface-2); border-color: var(--muted); }
@media (pointer: coarse) { .path-chip { min-height: 44px; } }

/* The slider: a track filled up to the thumb, the date floating above it and a dot per stage. */
.path-slider { --p: 0; --thumb: 22px; position: relative; }
.path-range { display: block; width: 100%; height: 30px; margin: 0; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; }
.path-range:focus { outline: none; }
.path-range::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px;
  background: linear-gradient(var(--blue), var(--blue)) 0 0 / calc(var(--p) * (100% - var(--thumb)) + var(--thumb) / 2) 100% no-repeat, var(--surface-2);
}
.path-range::-moz-range-track { height: 6px; background: var(--surface-2); border-radius: 999px; }
.path-range::-moz-range-progress { height: 6px; background: var(--blue); border-radius: 999px; }
.path-range::-webkit-slider-thumb {
  width: var(--thumb); height: var(--thumb); margin-top: -8px; background: var(--surface); border: 2px solid var(--blue); border-radius: 50%; -webkit-appearance: none; appearance: none;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 20%, transparent);
  transition: transform 0.3s var(--pg-ease), box-shadow 0.3s var(--pg-ease);
}
.path-range::-moz-range-thumb { width: var(--thumb); height: var(--thumb); box-sizing: border-box; background: var(--surface); border: 2px solid var(--blue); border-radius: 50%; box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 20%, transparent); transition: transform 0.3s var(--pg-ease); }
.path-slider:hover .path-range::-webkit-slider-thumb, .path-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px color-mix(in srgb, var(--blue) 22%, transparent); }
.path-slider:hover .path-range::-moz-range-thumb, .path-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 5px color-mix(in srgb, var(--blue) 22%, transparent); }
.path-slider.dragging .path-range::-webkit-slider-thumb { transform: scale(1.15); }
.path-slider.dragging .path-range::-moz-range-thumb { transform: scale(1.15); }
/* The years the chart shows, as a soft band behind the track: the horizon is a window onto the whole life. */
.path-slider::before {
  content: ""; position: absolute; top: 50%; height: 14px; pointer-events: none;
  left: calc(var(--win-from, 0) * (100% - var(--thumb)) + var(--thumb) / 2);
  width: calc((var(--win-to, 1) - var(--win-from, 0)) * (100% - var(--thumb)));
  background: color-mix(in srgb, var(--text) 5%, transparent); border: 1px solid var(--line); border-radius: 999px; transform: translateY(-50%);
}
.path-slider-ticks { position: absolute; inset: 0; pointer-events: none; }
.path-slider-ticks i { position: absolute; top: 50%; left: calc(var(--at) * (100% - var(--thumb)) + var(--thumb) / 2); width: 4px; height: 4px; background: var(--muted); border-radius: 50%; transform: translate(-50%, -50%); }
.path-bubble {
  position: absolute; bottom: calc(100% - 2px); left: calc(var(--p) * (100% - var(--thumb)) + var(--thumb) / 2); z-index: 1;
  padding: 4px 9px; font-size: 0.74rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
  color: var(--surface); background: var(--text); border-radius: 8px;
  opacity: 0; pointer-events: none; transform: translate(-50%, 6px) scale(0.92);
  transition: opacity 0.25s var(--pg-ease), transform 0.35s var(--pg-ease);
}
.path-slider:hover .path-bubble, .path-slider:focus-within .path-bubble, .path-slider.dragging .path-bubble { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* The legend: a dot, the name and the figure of the month on show; no boxes. */
.path-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 16px; }
.path-legend > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.path-legend span { display: flex; align-items: center; gap: 8px; overflow: hidden; font-size: 0.78rem; white-space: nowrap; text-overflow: ellipsis; color: var(--text-soft); }
.path-legend i { flex: none; width: 8px; height: 8px; background: var(--c); border-radius: 50%; }
.path-legend b { font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.path-graph .path-assumptions { margin: 0; font-size: 0.8rem; line-height: 1.55; color: var(--muted); }
.path-graph .path-assumptions a { color: var(--teal); }
@media (max-width: 560px) {
  .path-graph { padding: 18px 16px; }
  .path-controls { width: 100%; }
  /* The units switch drops to its own row. */
  .path-units { flex: 1 0 100%; }
  .path-units .path-horizons { width: 100%; }
  .path-units .path-horizons button { flex: 1; }
  .path-horizons button span { display: none; }
  .path-horizons button b { display: inline; }
  .path-horizons button { padding: 6px 11px; }
  .path-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .path-horizons button, .path-bubble, .path-range::-webkit-slider-thumb, .path-range::-moz-range-thumb, .path-chip, .pg-hint, .pg-plan-label { transition: none; }
}
.path-empty p { color: var(--text-soft); }

/* ¿Y si…?: plans on the road (frontend/front/resumen.js, path.js). */
.path-plans { display: flex; flex-direction: column; gap: 14px; }
.path-plans-impact { margin: 0; font-size: 0.84rem; color: var(--muted); }
.path-plans-impact.later { color: var(--amber-ink); }
.path-plan-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.path-plan { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: center; padding: 20px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-radius: 18px; }
html[data-theme="dark"] .path-plan { border-color: var(--line); }
.path-plan.off { color: var(--muted); }
.path-plan-open, .path-plan-msg, .path-plan-fixes { transition: opacity 0.3s cubic-bezier(0.2, 0, 0, 1); }
.path-plan-icon { transition: filter 0.3s cubic-bezier(0.2, 0, 0, 1); }
/* A plan that doesn't count only fades: nothing changes size or place. The switch and the date stay at full strength. */
.path-plan.off .path-plan-open, .path-plan.off .path-plan-msg, .path-plan.off .path-plan-fixes { opacity: 0.55; }
.path-plan.off .path-plan-icon { filter: grayscale(1) saturate(0.4); }
/* The lines that change keep their room: the message two lines, the impact one, the fixes a slot. */
.path-plan-msg { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; min-height: 2.9em; }
.path-plan-open > span:last-child { min-width: 0; }
.path-plan-open small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-plan-fixes { min-height: 30px; align-content: flex-start; }
@media (prefers-reduced-motion: reduce) { .path-plan-open, .path-plan-msg, .path-plan-fixes, .path-plan-icon, .path-switch, .path-switch::after { transition: none; } }
.path-plans-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.path-plan-open { display: flex; gap: 10px; align-items: center; min-width: 0; padding: 0; font: inherit; color: inherit; text-align: left; background: none; border: 0; cursor: pointer; }
.path-plan-open strong { display: block; font-size: 0.95rem; color: var(--text); }
.path-plan-open small { display: block; margin-top: 2px; font-size: 0.78rem; color: var(--muted); }
.path-plan-icon { display: grid; flex: none; place-items: center; width: 18px; height: 18px; color: var(--muted); }
.path-plan-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.path-switch { position: relative; width: 40px; height: 24px; padding: 0; background: var(--line); border: 0; border-radius: 999px; cursor: pointer; transition: background-color 0.22s ease; }
.path-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.12); transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1), width 0.2s cubic-bezier(0.2, 0, 0, 1); }
.path-switch[aria-checked="true"] { background: var(--teal-bright); }
.path-switch[aria-checked="true"]::after { transform: translateX(16px); }
/* Held down, the knob stretches a little and goes back on release. */
.path-switch:active::after { width: 23px; }
.path-switch[aria-checked="true"]:active::after { transform: translateX(11px); }
.path-plan-date { display: inline-flex; grid-column: 1 / -1; align-items: center; gap: 4px; justify-self: start; padding: 2px; font-size: 0.8rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
.path-plan-date .path-plan-when { width: auto; min-width: 74px; height: 26px; padding: 0 8px; font-size: 0.8rem; font-weight: 600; color: var(--text); border-radius: 999px; }
.path-plan-date .path-plan-when[aria-expanded="true"] { background: var(--surface-2); }
/* Month picker of a plan's date: a year with its twelve months (path.js openPop). */
.month-pop { position: fixed; z-index: 60; width: 232px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px rgba(15, 22, 38, 0.18), 0 2px 6px rgba(15, 22, 38, 0.08); opacity: 0; transform: translateY(-4px) scale(0.98); transform-origin: top center; transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.22, 1, 0.36, 1); }
.month-pop.above { transform: translateY(4px) scale(0.98); transform-origin: bottom center; }
.month-pop.open { opacity: 1; transform: none; }
.month-pop-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.month-pop-head strong { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.month-pop-head button { width: 30px; height: 30px; padding: 0; font: inherit; font-size: 1.05rem; color: var(--text-soft); background: none; border: 0; border-radius: 50%; cursor: pointer; transition: background 0.15s ease; }
.month-pop-head button:hover:not([disabled]) { background: var(--surface-2); }
.month-pop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.month-pop-grid button { height: 34px; padding: 0; font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text); text-transform: capitalize; background: none; border: 0; border-radius: 10px; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.month-pop-grid button:hover:not([disabled]) { background: var(--surface-2); }
.month-pop-grid button[aria-current] { color: #fff; background: var(--teal-bright); }
.month-pop button[disabled] { opacity: 0.3; cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .month-pop, .month-pop.above { transition: none; transform: none; }
}
.path-plan-date button { width: 26px; height: 26px; padding: 0; font: inherit; font-size: 1rem; color: var(--text-soft); background: none; border: 0; border-radius: 50%; cursor: pointer; }
.path-plan-date button:hover { background: var(--surface-2); }
.path-plan-msg { grid-column: 1 / -1; margin: 0; font-size: 0.82rem; line-height: 1.45; color: var(--muted); }
.path-plan-msg b::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; background: currentColor; border-radius: 50%; }
.path-plan.ok .path-plan-msg b { color: var(--teal); }
.path-plan.warn .path-plan-msg b { color: var(--amber-ink); }
.path-plan.bad .path-plan-msg b { color: var(--coral-ink); }
.path-plan-fixes { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 6px; }
.path-plan-fixes button, .path-plan-fixes span { padding: 5px 10px; font: inherit; font-size: 0.75rem; font-weight: 600; border-radius: 999px; }
.path-plan-fixes button { color: var(--teal); background: var(--surface); border: 1px solid var(--teal-bright); cursor: pointer; }
.path-plan-fixes span { color: var(--text-soft); background: var(--surface-2); }
.path-plan-born { display: inline-flex; grid-column: 1 / -1; justify-self: start; align-items: center; gap: 6px; padding: 5px 12px; font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--teal); background: var(--surface); border: 1px solid var(--teal-bright); border-radius: 999px; cursor: pointer; transition: background 0.2s ease; }
.path-plan-born:hover { background: var(--surface-2); }
.path-plan-born [data-icon], .child-born [data-icon] { width: 14px; height: 14px; }
.path-plans-empty { margin: 0; font-size: 0.86rem; color: var(--text-soft); }
/* An adult's retirement among the plans: always on, with the member's colours. */
.path-retire-badge { width: 28px; height: 28px; font-size: 0.72rem; font-weight: 700; color: #fff; background: var(--member); border-radius: 50%; }
.path-plan-fixed { font-size: 0.72rem; font-weight: 600; color: var(--text-soft); white-space: nowrap; }
.path-plan-msg a { color: var(--teal); }
.path-retire { margin: 0; padding: 10px 14px; font-size: 0.86rem; line-height: 1.5; color: var(--text-soft); background: var(--surface-2); border-radius: 12px; }
.path-retire[hidden] { display: none; }
.path-retire.warn { color: var(--coral-ink); background: color-mix(in srgb, var(--coral) 10%, transparent); }

/* A child's plan: what they cost by stage, from birth to the age they leave home (path.js childCurve). */
.child-curve { display: flex; flex-direction: column; gap: 14px; padding: 16px; background: var(--surface-2); border-radius: 16px; }
.child-curve-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.child-curve-totals div { display: flex; flex-direction: column; gap: 2px; }
.child-curve-totals span { font-size: 0.75rem; color: var(--text-soft); }
.child-curve-totals strong { font-size: 1.3rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.child-curve-bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; }
.child-curve-bar { display: flex; flex: 1 1 0; flex-direction: column; justify-content: flex-end; align-items: stretch; min-width: 0; height: 100%; transition: flex-grow 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
.child-curve-bar i { display: block; min-height: 4px; background: linear-gradient(180deg, var(--teal-bright), var(--teal)); border-radius: 6px 6px 2px 2px; opacity: 0.85; transition: height 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
.child-curve-bar b { margin-bottom: 4px; overflow: hidden; font-size: 0.68rem; font-weight: 700; text-align: center; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.child-curve-bar span { margin-top: 5px; overflow: hidden; font-size: 0.66rem; line-height: 1.2; color: var(--text-soft); text-align: center; white-space: nowrap; text-overflow: ellipsis; }
.child-born { align-self: flex-start; }
@media (prefers-reduced-motion: reduce) {
  .child-curve-bar, .child-curve-bar i { transition: none; }
}
.path-catalog { display: flex; flex-direction: column; gap: 8px; }
.path-catalog-list { display: flex; flex-wrap: wrap; gap: 8px; }
.path-catalog-list button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 5px; font: inherit; font-size: 0.8rem; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.path-catalog-list button:hover { border-color: var(--teal-bright); }
.path-catalog-list .path-plan-icon { width: 18px; height: 18px; }
.path-catalog-list .path-plan-icon svg { width: 14px; height: 14px; }
.path-plan.off .path-plan-msg b { color: var(--muted); }

/* Horizontes in the assisted view: the hero, the meter of each horizon and the rows of what fills it (horizon.html). */
.glass-hero-how { max-width: 460px; margin: 10px 0 0; font-size: 0.86rem; line-height: 1.5; color: #9c9b96; }
.glass-card-help { margin: 0; font-size: 0.8rem; line-height: 1.45; color: var(--muted); }
.glass-card-meter { position: relative; height: 6px; background: color-mix(in srgb, var(--c) 14%, var(--surface-2)); border-radius: 999px; }
.glass-card-meter span { position: absolute; inset: 0 auto 0 0; background: var(--c); border-radius: inherit; transition: width 0.42s cubic-bezier(0.2, 0, 0, 1); }
/* the line of the stage, when the glass overflows it */
.glass-card-meter i { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--text); border-radius: 1px; opacity: 0.55; }
.glass-card-meter i[style*="left: 100%"] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .glass-card-meter span { transition: none; }
}
.glass-rows { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.glass-row, .glass-free { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; font: inherit; color: inherit; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.glass-row { cursor: pointer; transition: border-color 0.2s; }
.glass-row:hover { border-color: var(--c); }
.glass-row.short { border-color: color-mix(in srgb, var(--coral) 45%, var(--line)); }
.glass-row-name { min-width: 0; font-size: 0.88rem; font-weight: 600; }
.glass-row-name small { display: block; margin-top: 2px; overflow: hidden; font-size: 0.74rem; font-weight: 400; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
.glass-row-amount { text-align: right; }
.glass-row-amount b { display: block; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.glass-row-amount small { font-size: 0.72rem; color: var(--muted); }
.glass-row-amount em { font-style: normal; font-weight: 600; color: var(--coral); }
.glass-free { background: transparent; border-style: dashed; }
.glass-free-dot { width: 28px; height: 28px; background: var(--layer-free); border-radius: 50%; opacity: 0.85; }
.glass-add { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; margin-top: auto; padding: 8px 14px; font: inherit; font-size: 0.84rem; font-weight: 600; color: var(--text); background: none; border: 1px dashed var(--c); border-radius: 999px; cursor: pointer; }
.glass-add span { font-size: 1.1rem; line-height: 1; color: var(--c); }

/* Horizontes (asistida): the summary cards (.budget-card in the colour of each horizon) and the screen of one horizon. */
.horizon-card .glass-card-meter { margin-top: -2px; }
:is(.horizon-card, .horizon-head) .budget-tag { font-size: 0.78rem; font-weight: 500; color: var(--muted); }
:is(.horizon-card, .horizon-head) .path-status { font-size: 0.78rem; }
.horizon-wide { grid-column: 1 / -1; }
.horizon-head, .horizon-body { margin-bottom: 16px; }
.horizon-head .budget-head h3 { font-size: 1.05rem; }
.horizon-question { margin: -6px 0 0; font-size: 0.86rem; color: var(--text-soft); }
.horizon-head .glass-card-help { margin: 0; }
.horizon-body { display: grid; gap: 12px; }

/* Settings: how the summary is shown. */
.mode-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode-choice { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s; }
.mode-choice:has(input:checked) { border-color: var(--teal-bright); box-shadow: 0 0 0 4px var(--teal-pale); }
.mode-choice input { position: absolute; opacity: 0; pointer-events: none; }
.mode-choice:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.mode-art { display: flex; align-items: flex-end; gap: 4px; height: 56px; padding: 8px; background: var(--navy); border-radius: 10px; }
.mode-art i { flex: 1; height: 100%; border-radius: 2px 2px 4px 4px; }
.mode-text strong { display: block; font-size: 0.95rem; }
.mode-text small { display: block; margin-top: 3px; font-size: 0.8rem; font-weight: 400; line-height: 1.4; color: var(--text-soft); }
@media (max-width: 560px) { .mode-choices { grid-template-columns: 1fr; } }

/* text-only choices (Ajustes · Ingresos): three side by side, an example amount at the foot */
.mode-choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mode-choice.text-only { grid-template-columns: minmax(0, 1fr); align-items: start; }
.mode-sample { display: block; margin-top: 8px; font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
@media (max-width: 780px) { .mode-choices.three { grid-template-columns: 1fr; } }

/* toasts: server messages and short confirmations (.alert tokens). They leave after 4 s; errors stay until closed. */
.toast-stack { --toast-bottom: max(24px, env(safe-area-inset-bottom)); position: fixed; inset: auto auto var(--toast-bottom) 50%; z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); margin: 0; padding: 0; border: 0; overflow: visible; background: transparent; transform: translateX(-50%); pointer-events: none; }
/* On phones the floating + button sits in the corner: the stack rises above it. */
@media (max-width: 640px) { .toast-stack { --toast-bottom: calc(max(24px, env(safe-area-inset-bottom)) + 56px + 12px); } }
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 12px 12px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  background: var(--surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in 0.36s cubic-bezier(0.2, 0, 0, 1);
  transition: opacity 0.36s cubic-bezier(0.2, 0, 0, 1), transform 0.36s cubic-bezier(0.2, 0, 0, 1);
}
.toast.leaving { opacity: 0; transform: translateY(6px); }
.toast-close { flex: none; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; font-size: 1.2rem; line-height: 1; color: var(--text-soft); background: transparent; border: 0; border-radius: 50%; cursor: pointer; }
.toast-close:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
@media (pointer: coarse) { .toast-close { position: relative; } .toast-close::after { content: ""; position: absolute; inset: -8px; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; transition: none; } }

/* wrapper of a live region that may be empty: invisible to the layout */
.live-slot { display: contents; }

/* only the page's main hero morphs between screens; secondary navy panels keep still */
.dash-hero.path-side { view-transition-name: none; }

/* expense sheet: single-choice pickers (who it's for, category tiles, charge account, split mode) */
.member-picker[data-choice] button[aria-checked="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--member, var(--blue)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--member, var(--blue)) 55%, var(--line));
}
.member-picker[data-choice] .member-dot { padding: 6px; }
.member-picker[data-choice] .member-dot svg { width: 100%; height: 100%; }
.member-picker[data-choice] button[aria-checked="true"] .member-dot { color: #fff; background: var(--blue); }

.choice-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.choice-tiles button {
  --cat: var(--slate);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 10px 7px 7px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.choice-tiles button:hover { border-color: color-mix(in srgb, var(--cat) 40%, var(--line)); }
.choice-tiles button[aria-checked="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--cat) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--cat) 60%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--cat) 35%, transparent);
}
.choice-tiles button.none { color: var(--muted); }
.choice-tiles .cat-icon { width: 28px; height: 28px; padding: 6px; }

/* charge account: a dropdown with a search box */
.account-select { position: relative; }
.account-select-trigger {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 12px 6px 10px;
  font: inherit;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.3s cubic-bezier(0.2, 0, 0, 1);
}
.account-select-trigger:hover,
.account-select.is-open .account-select-trigger { border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); }
.account-select-trigger .bank-mark.sm { width: 26px; }
.account-select-chevron { width: 16px; height: 16px; color: var(--muted); transform: rotate(90deg); transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1); }
.account-select-chevron svg { width: 100%; height: 100%; }
.account-select.is-open .account-select-chevron { transform: rotate(-90deg); }
.account-select-panel {
  margin-top: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--soft-shadow);
}
.account-select-panel:not([hidden]) { animation: date-open 0.3s cubic-bezier(0.2, 0, 0, 1); }
.account-select-panel .search-field { width: 100%; }
.account-select-panel .field-hint { margin: 8px 4px 2px; }
.account-choice { max-height: 240px; overflow-y: auto; overscroll-behavior: contain; }
.account-choice .pot-source-toggle { cursor: pointer; }
.account-choice .pot-source-toggle[aria-selected="true"] .pot-source-order::after { content: "✓"; }
.account-choice .pot-source-toggle:hover:not([aria-selected="true"]) { background: var(--surface-2); }
.account-choice .pot-source-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.picker-current { display: contents; }

/* rich_select / date_field: the account dropdown look without a bank logo */
.account-select.rich .account-select-trigger { grid-template-columns: minmax(0, 1fr) auto auto; }
.account-select.rich .pot-source-toggle { grid-template-columns: 22px minmax(0, 1fr) auto; }
.account-select.rich .pot-source-amount { color: var(--text-soft); }
.account-select.date-field .account-select-trigger { grid-template-columns: minmax(0, 1fr) auto; }
/* In a sheet, rich_select and date_field read as one more field: same label gap and box as a text input. */
.sheet-form .field-block:has(> .account-select.rich, > .account-select.date-field) { display: grid; gap: 6px; }
.sheet-form .account-select.rich .account-select-trigger,
.sheet-form .account-select.date-field .account-select-trigger {
  min-height: 40px;
  padding: 0 12px;
  font-size: 0.92rem;
  background: var(--bg);
  border-radius: 9px;
}
.date-field [data-date-current].is-placeholder { color: var(--muted); }
.account-select.date-field .account-select-chevron,
.account-select.date-field.is-open .account-select-chevron { transform: none; }
/* The calendar floats over the sheet instead of pushing the fields below it. */
.date-panel { position: absolute; z-index: 5; top: 100%; right: 0; width: max(100%, 280px); display: grid; gap: 8px; }
.date-panel:not([hidden]) { animation: date-open 0.3s cubic-bezier(0.2, 0, 0, 1); }
@keyframes date-open { from { opacity: 0; transform: translateY(-6px); } }
.date-head { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 4px; }
.date-nav, .date-title, .date-day {
  font: inherit; color: var(--text); background: transparent; border: 0; border-radius: 10px; cursor: pointer;
}
.date-nav { height: 32px; font-size: 1.1rem; color: var(--text-soft); }
.date-title { height: 32px; font-size: 0.86rem; font-weight: 600; text-transform: capitalize; }
.date-nav:hover, .date-title:hover, .date-day:hover:not(:disabled):not(.is-selected) { background: var(--surface-2); }
.date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.date-grid.pick { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.date-weekday { text-align: center; font-size: 0.68rem; font-weight: 600; color: var(--muted); }
.date-day { min-height: 32px; font-size: 0.8rem; font-variant-numeric: tabular-nums; transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1); }
.date-grid.pick .date-day { min-height: 38px; text-transform: capitalize; }
.date-day.is-today { box-shadow: inset 0 0 0 1px var(--blue); }
.date-day.is-selected { background: var(--blue); color: var(--on-accent); font-weight: 600; }
.date-day:disabled { color: var(--muted); opacity: 0.4; cursor: default; }
.date-nav:focus-visible, .date-title:focus-visible, .date-day:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.date-foot { display: flex; justify-content: space-between; }
@media (prefers-reduced-motion: reduce) {
  .date-panel:not([hidden]), .account-select-panel:not([hidden]) { animation: none; }
  .date-day, .account-select-trigger, .account-select-chevron { transition: none; }
}
/* Touch: targets of at least 44 px. */
@media (pointer: coarse) {
  .account-select-trigger,
  .sheet-form .account-select.rich .account-select-trigger,
  .sheet-form .account-select.date-field .account-select-trigger,
  .date-nav, .date-title, .date-day, .date-grid.pick .date-day,
  .account-choice .pot-source-toggle { min-height: 44px; }
  .date-head { grid-template-columns: 44px minmax(0, 1fr) 44px; }
}
.field-grid.align-start { align-items: start; }

/* status: three tiles with icon and what each one means */
.status-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.status-tiles button { align-items: flex-start; padding: 9px 10px 9px 8px; }
.status-tiles button > span:last-child { display: grid; gap: 2px; min-width: 0; }
.status-tiles small { font-size: 0.7rem; font-weight: 400; line-height: 1.3; color: var(--muted); }
.status-tiles button[aria-checked="true"] .cat-icon { color: #fff; background: var(--cat); }
@media (max-width: 560px) {
  .status-tiles { grid-template-columns: 1fr; }
}

/* expense status: four tiles, two by two */
.status-tiles.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 420px) {
  .status-tiles.four { grid-template-columns: 1fr; }
}

/* expense type: three big tiles with the budget card's own icon and colour */
.type-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type-tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.type-tiles button {
  display: grid;
  justify-items: start;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.type-tiles button.type-fixed { --type: var(--fixed); --type-grad: var(--fixed-grad); }
.type-tiles button.type-variable { --type: var(--variable); --type-grad: var(--variable-grad); }
.type-tiles button.type-extra { --type: var(--extra); --type-grad: var(--extra-grad); }
.type-tiles button > span:last-child { display: grid; gap: 2px; min-width: 0; }
.type-tiles small { font-size: 0.7rem; font-weight: 400; line-height: 1.3; color: var(--muted); }
.type-tiles .type-icon { width: 34px; height: 34px; padding: 8px; border-radius: 11px; opacity: 0.55; filter: saturate(0.6); transition: opacity 0.2s ease, filter 0.2s ease; }
.type-tiles .type-extra .type-icon { color: var(--navy); }
/* account type: flat tokens, no gradient (the Apple rule) */
.type-tiles.account-types button.type-corriente { --type: var(--blue); }
.type-tiles.account-types button.type-remunerada { --type: var(--teal-bright); }
.type-tiles.account-types button.type-ahorro { --type: var(--purple); }
.type-tiles.account-types .type-icon { background: var(--type); box-shadow: none; }
.type-tiles button:hover { border-color: color-mix(in srgb, var(--type) 45%, var(--line)); }
.type-tiles button:hover .type-icon { opacity: 0.8; }
.type-tiles button[aria-checked="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--type) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--type) 65%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--type) 40%, transparent), 0 6px 16px color-mix(in srgb, var(--type) 18%, transparent);
}
.type-tiles button[aria-checked="true"] .type-icon { opacity: 1; filter: none; }
@media (max-width: 420px) {
  .type-tiles button { padding: 10px; }
  .type-tiles small { display: none; }
}

/* expense sheet: the less-used options fold away behind a summary line (app.js FOLDS animates them) */
.sheet-folds { display: grid; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.sheet-fold + .sheet-fold { border-top: 1px solid var(--line); }
.sheet-fold > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  border-radius: 14px;
  transition: background 0.2s ease;
}
.sheet-fold > summary::-webkit-details-marker { display: none; }
.sheet-fold > summary:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.sheet-fold > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.sheet-fold-icon {
  --cat: var(--slate);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 7px;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  border-radius: 9px;
  transition: color 0.25s ease, background 0.25s ease;
}
.sheet-fold-icon svg { width: 100%; height: 100%; }
.sheet-fold-label { font-size: 0.86rem; font-weight: 600; color: var(--text); }
.sheet-fold > summary b {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-soft);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-fold-chevron { flex-shrink: 0; width: 14px; height: 14px; color: var(--muted); transform: rotate(90deg); transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1); }
.sheet-fold-chevron svg { width: 100%; height: 100%; }
.sheet-fold[open]:not(.is-collapsing) .sheet-fold-chevron { transform: rotate(-90deg); }
.sheet-fold-body { display: grid; gap: 12px; padding: 4px 12px 14px; }

/* "hasta fecha": the last month slides open under the status tiles */
.until-picker { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.38s cubic-bezier(0.2, 0, 0, 1), margin 0.38s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s ease; }
.until-picker-inner { display: grid; gap: 6px; min-height: 0; overflow: hidden; }
.until-picker.is-shown { grid-template-rows: 1fr; opacity: 1; }
/* closed, it takes no room in the fold's gap either */
.sheet-fold-body > .until-picker:not(.is-shown) { margin-bottom: -12px; }
.until-picker-card { max-width: 280px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.until-picker-card .month-pop-grid button[aria-checked="true"] { color: #fff; background: var(--blue); }
@media (prefers-reduced-motion: reduce) {
  .until-picker, .type-tiles button, .sheet-fold-chevron { transition: none; }
}

.split-modes { display: flex; flex-wrap: wrap; gap: 8px; }
.split-modes button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.split-modes button.active {
  color: var(--text);
  background: color-mix(in srgb, var(--blue) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 55%, var(--line));
}
.split-modes button.active .split-mode { color: #fff; background: var(--blue); }

/* Tu camino (journey.html, journey_stage.html): the road in brief and one screen per stage. */
.path-stages-link [data-icon] { width: 13px; height: 13px; }
.path-plans-road { display: inline-flex; align-items: center; gap: 4px; justify-self: start; font-size: 0.82rem; font-weight: 600; color: var(--teal); text-decoration: none; }
.path-plans-road:hover { text-decoration: underline; }
.journey-step-next { background: color-mix(in srgb, var(--on-hero-muted) 35%, transparent); }
.journey-steps { gap: 3px; }
.journey-steps span:first-child { border-radius: 7px 0 0 7px; }
.journey-steps span:last-child { border-radius: 0 7px 7px 0; }
.journey-head .dash-networth-row strong { font-size: clamp(1.6rem, 6vw, 2.4rem); line-height: 1.1; }
.journey-head .dash-networth-row { flex-wrap: wrap; }

/* a stage's card on the summary: its years, and how many milestones are done */
.journey-card { transition: border-color 0.3s cubic-bezier(0.2, 0, 0, 1); }
.journey-card:hover, .journey-card:focus-visible { border-color: var(--line); }
.journey-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; font-size: 0.88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.journey-chip { padding: 2px 9px; font-size: 0.74rem; font-weight: 600; color: var(--text-soft); background: var(--surface-2); border-radius: 999px; }
.journey-progress { display: grid; gap: 8px; font-size: 0.82rem; color: var(--text-soft); }

/* a stage's own screen: one card per topic */
.journey-cards { display: grid; gap: 16px; margin: 16px 0 18px; }
.journey-tips, .journey-milestones { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.journey-tips li { position: relative; padding-left: 18px; font-size: 0.88rem; line-height: 1.5; color: var(--text-soft); }
.journey-tips li::before { content: ""; position: absolute; top: 0.62em; left: 4px; width: 6px; height: 6px; background: var(--muted); border-radius: 50%; }
.journey-milestones li { display: flex; gap: 10px; align-items: flex-start; }
.journey-milestones b { display: block; font-size: 0.88rem; font-weight: 600; line-height: 1.4; }
.journey-milestones small { display: block; margin-top: 2px; font-size: 0.78rem; color: var(--muted); }
.journey-check { display: grid; flex: none; place-items: center; width: 18px; height: 18px; margin-top: 1px; border: 1px solid var(--line); border-radius: 50%; }
.journey-check svg { width: 12px; height: 12px; fill: none; stroke: var(--teal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.journey-milestones li.done .journey-check { border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); }

/* the folds of a card ("Ver detalle", "Ver todos"): the body slides open with FOLDS (app.js) */
.journey-fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; font-size: 0.86rem; font-weight: 600; color: var(--text-soft); cursor: pointer; list-style: none; }
.journey-fold > summary::-webkit-details-marker { display: none; }
.journey-fold > summary:hover { color: var(--text); }
.journey-fold > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.journey-fold-chevron { flex: none; width: 14px; height: 14px; color: var(--muted); transform: rotate(90deg); transition: transform 0.38s cubic-bezier(0.2, 0, 0, 1); }
.journey-fold-chevron svg { width: 100%; height: 100%; }
.journey-fold[open]:not(.is-collapsing) .journey-fold-chevron { transform: rotate(-90deg); }
.journey-fold > :not(summary) { padding-top: 8px; }
@media (prefers-reduced-motion: reduce) { .journey-fold-chevron, .journey-card { transition: none; } }

.journey-plan-msg em { font-style: normal; font-weight: 600; }
.journey-best { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-top: 6px; font-size: 0.78rem; line-height: 1.4; }

/* a stage's timeline: one dot per moment on a vertical line, with the money it moves between glasses */
.journey-timeline { position: relative; display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.tl-event { position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; }
/* the line joins each dot to the next one */
.tl-event:not(:last-child)::before { content: ""; position: absolute; top: 32px; bottom: -14px; left: 14px; width: 2px; background: var(--line); border-radius: 1px; }
.tl-dot { --tone: var(--slate); display: grid; place-items: center; width: 30px; height: 30px; padding: 7px; color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); border-radius: 50%; }
.tl-dot svg { width: 100%; height: 100%; }
.tl-plan .tl-dot { --tone: var(--teal); }
.tl-event.ok .tl-dot { --tone: var(--teal-bright); }
.tl-event.warn .tl-dot { --tone: var(--amber); }
.tl-event.bad .tl-dot { --tone: var(--coral); }
.tl-move .tl-dot { --tone: var(--blue); }
.tl-move.warn .tl-dot { --tone: var(--amber); }
.tl-event.off { opacity: 0.55; }
.tl-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding-top: 1px; }
.tl-when { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: capitalize; }
.tl-body b { font-size: 0.88rem; }
.tl-body small { font-size: 0.76rem; line-height: 1.4; color: var(--text-soft); }
.tl-event.ok em { color: var(--teal); }
.tl-event.warn em { color: var(--amber); }
.tl-event.bad em { color: var(--coral); }
.tl-moves { display: grid; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.tl-moves li { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; font-size: 0.78rem; line-height: 1.4; color: var(--text-soft); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.tl-moves li.warn { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.tl-moves li.bad { color: var(--text); border-color: color-mix(in srgb, var(--coral) 55%, var(--line)); }
/* from glass › to glass, as two coloured dots */
.tl-flow { display: inline-flex; flex: none; gap: 2px; align-items: center; height: 1.4em; }
.tl-flow i { width: 9px; height: 9px; background: var(--glass); border-radius: 50%; }
.tl-flow [data-icon] { width: 10px; height: 10px; color: var(--muted); }
.tl-flow [data-icon] svg { width: 100%; height: 100%; }

/* "+" button: it turns into × and shows two light round options (bolsa, gasto) above it */
.fab span[data-icon] { transition: transform 0.2s ease; }
.fab.is-open { background: var(--text); }
.fab.is-open span[data-icon] { transform: rotate(45deg); }
.fab-menu {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 72px);
  z-index: 40;
  display: grid;
  justify-items: end;
  gap: 12px;
}
.fab-menu:not([hidden]) .fab-option { animation: fab-option-in 0.18s ease both; }
.fab-menu:not([hidden]) .fab-option:nth-child(2) { animation-delay: 0.04s; }
@keyframes fab-option-in { from { opacity: 0; transform: translateY(10px) scale(0.92); } }
.fab-option {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  background: none;
  border: 0;
}
.fab-option-label {
  display: grid;
  padding: 6px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: right;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(14, 21, 38, 0.14);
}
.fab-option-label small { font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.fab-option-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-right: 4px;
  padding: 13px;
  color: var(--teal);
  background: color-mix(in srgb, var(--teal-bright) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--teal-bright) 35%, var(--line));
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(14, 21, 38, 0.16);
  transition: transform 0.15s ease, background 0.15s ease;
}
.fab-option-icon svg { width: 100%; height: 100%; }
.fab-option:hover .fab-option-icon,
.fab-option:focus-visible .fab-option-icon { transform: scale(1.06); background: color-mix(in srgb, var(--teal-bright) 26%, var(--surface)); }
.fab-option:focus-visible { outline: none; }
.fab-option:focus-visible .fab-option-icon { outline: 3px solid color-mix(in srgb, var(--teal-bright) 45%, transparent); outline-offset: 2px; }
@media (max-width: 480px) {
  .fab-menu { right: 16px; bottom: 88px; }
}

/* bolsa sheet: several members can be picked */
.member-picker[data-pot-members] button[aria-pressed="true"] {
  color: var(--text);
  background: color-mix(in srgb, var(--member, var(--blue)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--member, var(--blue)) 55%, var(--line));
}
.member-picker[data-pot-members].is-missing button { border-color: var(--coral); }
.period-choice { flex-wrap: nowrap; }

/* ----- Monthly notice: manual balances over a month old (_balance_prompt.html, balance-prompt.js) ----- */

.bp-banner {
  /* Like the toast: above the bottom bar on a phone. */
  --bp-bottom: max(24px, env(safe-area-inset-bottom));
  position: fixed;
  left: calc(236px + 28px);
  right: 28px;
  bottom: var(--bp-bottom);
  z-index: 60;
  width: auto;
  max-width: 620px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: 0 18px 44px rgba(14, 21, 38, 0.16), 0 2px 8px rgba(14, 21, 38, 0.06);
  opacity: 0;
  transform: translateY(24px) scale(0.98);
  transition: opacity 0.42s cubic-bezier(0.2, 0, 0, 1), transform 0.42s cubic-bezier(0.2, 0, 0, 1);
}

.bp-banner.is-in {
  opacity: 1;
  transform: none;
}

.bp-banner-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--amber);
  background: var(--amber-pale);
}

.bp-banner-icon svg { width: 19px; height: 19px; }

.bp-banner-text {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.bp-banner-text strong { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.bp-banner-text span { font-size: 0.78rem; color: var(--muted); }

.bp-banner-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bp-later,
.bp-skip {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.bp-later:hover,
.bp-skip:hover { background: var(--surface-2); color: var(--text); }

html.bp-locked { overflow: hidden; }

.bp-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  transition: background 0.42s cubic-bezier(0.2, 0, 0, 1), backdrop-filter 0.42s cubic-bezier(0.2, 0, 0, 1), -webkit-backdrop-filter 0.42s cubic-bezier(0.2, 0, 0, 1);
}

.bp-overlay.is-open {
  background: rgba(15, 23, 42, 0.32);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
}

/* Every card sits on the same grid cell; data-pos (from the script) says where. */
.bp-stage {
  width: min(420px, 100%);
  display: grid;
  padding-bottom: 28px;
}

.bp-card {
  grid-area: 1 / 1;
  align-self: end;
  display: grid;
  gap: 16px;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(14, 21, 38, 0.22), 0 2px 8px rgba(14, 21, 38, 0.08);
  transform-origin: 50% 100%;
  transition: transform 0.42s cubic-bezier(0.2, 0, 0, 1), opacity 0.42s cubic-bezier(0.2, 0, 0, 1);
}

.bp-card[data-pos="0"] { z-index: 3; }
.bp-card[data-pos="1"] { z-index: 2; transform: translateY(12px) scale(0.95); opacity: 0.75; }
.bp-card[data-pos="2"] { z-index: 1; transform: translateY(24px) scale(0.9); opacity: 0.45; }
.bp-card[data-pos="hidden"] { transform: translateY(24px) scale(0.9); opacity: 0; }
.bp-card[data-pos="gone"] { z-index: 4; transform: translateX(-60px) rotate(-3deg); opacity: 0; pointer-events: none; }
/* Cards behind only show their edge: their content stays out of sight. */
.bp-card:not([data-pos="0"]) > * { opacity: 0; transition: opacity 0.2s ease; }
.bp-card[data-pos="0"] > *,
.bp-card[data-pos="gone"] > * { opacity: 1; transition: opacity 0.3s ease 0.08s; }

/* The overlay itself fades the stack in and out. */
.bp-overlay .bp-stage {
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.42s cubic-bezier(0.2, 0, 0, 1), transform 0.42s cubic-bezier(0.2, 0, 0, 1);
}

.bp-overlay.is-open .bp-stage { opacity: 1; transform: none; }

.bp-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bp-step {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bp-dots {
  flex: 1;
  display: flex;
  gap: 4px;
}

.bp-dots i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  transition: width 0.42s cubic-bezier(0.2, 0, 0, 1), background 0.42s ease;
}

.bp-dots i.done { background: var(--teal-bright); }
.bp-dots i.current { width: 16px; background: var(--text); }

.bp-close { width: 32px; height: 32px; font-size: 1.15rem; margin-left: auto; }

.bp-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.bp-who > div { min-width: 0; display: grid; gap: 2px; }
.bp-who strong { font-size: 1rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-who span { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bp-field { display: grid; gap: 6px; }
.bp-field > span:first-child { font-size: 0.78rem; font-weight: 500; color: var(--text-soft); }

.bp-input { position: relative; display: block; }

.bp-input input {
  width: 100%;
  min-height: 58px;
  padding: 0 40px 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.bp-input input:focus {
  outline: none;
  border-color: var(--bank, var(--blue));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--bank, var(--blue)) 16%, transparent);
}

.bp-input em {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  font-style: normal;
  color: var(--muted);
  pointer-events: none;
}

.bp-last { margin: -8px 0 0; font-size: 0.78rem; color: var(--muted); }
.bp-error { margin: -6px 0 0; font-size: 0.8rem; color: var(--red); }

.bp-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bp-actions .button { min-width: 132px; min-height: 42px; }

.bp-done {
  justify-items: center;
  text-align: center;
  padding: 28px 22px 22px;
}

.bp-done-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--teal);
  background: var(--teal-pale);
}

.bp-done-icon svg { width: 26px; height: 26px; }
.bp-done strong { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.bp-done p { margin: -8px 0 4px; font-size: 0.86rem; line-height: 1.5; color: var(--text-soft); max-width: 300px; }
.bp-done .button { min-width: 160px; min-height: 42px; }

html[data-theme="dark"] .bp-banner,
html[data-theme="dark"] .bp-card { box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3); }
html[data-theme="dark"] .bp-overlay.is-open { background: rgba(3, 6, 14, 0.5); }
html[data-theme="dark"] .bp-dots i.current { background: var(--text); }
html[data-theme="dark"] .bp-banner .button.primary,
html[data-theme="dark"] .bp-card .button.primary { background: var(--text); color: var(--bg); }

@media (max-width: 1180px) {
  .bp-banner { left: 16px; right: 16px; }
}

@media (max-width: 640px) {
  .bp-banner { --bp-bottom: calc(max(24px, env(safe-area-inset-bottom)) + 56px + 12px); }
}

@media (max-width: 520px) {
  .bp-banner { flex-wrap: wrap; gap: 10px 12px; }
  .bp-banner-actions { width: 100%; justify-content: flex-end; }
  .bp-banner-actions .button { flex: 1; }
  .bp-overlay { align-items: end; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .bp-banner,
  .bp-overlay,
  .bp-overlay .bp-stage,
  .bp-card,
  .bp-card > *,
  .bp-dots i { transition: none !important; }
}

/* «Danos tu opinión»: the Tally form inside a modal of the app. */
.modal.feedback-modal {
  width: min(560px, calc(100vw - 28px));
}

.feedback-frame {
  width: 100%;
  height: min(60vh, 560px);
  border: 0;
}

/* Welcome tour (tour.js): the page dims around a soft spotlight that glides from stop to stop,
   with a glass card beside it. */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.32s ease;
}

.tour-layer.is-on { opacity: 1; }
.tour-layer.is-leaving { opacity: 0; transition-duration: 0.24s; }

.tour-dim {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: rgba(8, 12, 24, 0.56);
}

.tour-hole {
  rx: 18px;
  transition: x 0.5s cubic-bezier(0.22, 1, 0.36, 1), y 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.5s cubic-bezier(0.22, 1, 0.36, 1), height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.tour-spot {
  position: fixed;
  border-radius: 18px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 32px 4px rgba(127, 224, 189, 0.18);
  pointer-events: none;
  transition: top 0.5s cubic-bezier(0.22, 1, 0.36, 1), left 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.5s cubic-bezier(0.22, 1, 0.36, 1), height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.tour-layer.is-centered .tour-spot { box-shadow: none; }

.tour-card {
  position: fixed;
  display: grid;
  gap: 8px;
  padding: 18px 18px 14px;
  color: var(--text);
  background: var(--glass-sheet, var(--surface));
  -webkit-backdrop-filter: var(--glass-blur, none);
  backdrop-filter: var(--glass-blur, none);
  border: 1px solid var(--glass-edge, var(--line));
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(8, 12, 24, 0.45);
  opacity: 0;
  transform: translateY(6px) scale(0.985);
  transition: opacity 0.28s ease, transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

.tour-card.is-in { opacity: 1; transform: none; }

.tour-step {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tour-card h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tour-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.tour-skip {
  padding: 6px 2px;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.tour-skip:hover { color: var(--text); }

.tour-dots {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 5px;
}

.tour-dots i {
  width: 5px;
  height: 5px;
  background: var(--line);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}

.tour-dots i.on { width: 14px; background: var(--teal-bright); }

.tour-back {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.tour-back[hidden] { display: none; }
.tour-back svg { width: 16px; height: 16px; transform: rotate(180deg); }
.tour-next { min-width: 104px; }

html[data-theme="dark"] .tour-next { color: var(--navy); background: #f2f1ec; }

@media (prefers-reduced-motion: reduce) {
  .tour-layer, .tour-hole, .tour-spot, .tour-card, .tour-dots i { transition: none; }
}

.tour-replay { gap: 6px; margin-left: auto; }
.tour-replay svg { width: 15px; height: 15px; }

/* Import wizard */
.import-form {
  display: grid;
  gap: 16px;
}

.import-form .dash-note {
  margin: 8px 0 14px;
}

.import-form td {
  vertical-align: middle;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Import modal: the file goes in a drop zone, never the browser's bare "choose file" control. */
.modal.import-modal {
  width: min(520px, calc(100vw - 28px));
}

.import-card {
  gap: 14px;
  padding: 22px;
}

.import-card .dash-eyebrow {
  margin: 0 0 4px;
}

.import-card .muted-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 188px;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: color-mix(in srgb, var(--blue) 3%, var(--surface));
  border: 1.5px dashed color-mix(in srgb, var(--blue) 30%, var(--line));
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.dropzone:hover,
.dropzone:focus-within,
.dropzone.is-dragging {
  background: color-mix(in srgb, var(--blue) 7%, var(--surface));
  border-color: var(--blue);
}

.dropzone:focus-within {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
}

.dropzone.is-dragging {
  border-style: solid;
}

.dropzone.has-file {
  min-height: 0;
  border-style: solid;
  border-color: color-mix(in srgb, var(--teal) 45%, var(--line));
  background: color-mix(in srgb, var(--teal) 5%, var(--surface));
}

/* The real control stays in the page (keyboard, required, drops) but nobody sees it. */
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  pointer-events: none;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.dropzone-icon svg {
  width: 22px;
  height: 22px;
}

.dropzone.is-dragging .dropzone-icon {
  transform: translateY(-3px);
}

.dropzone-empty strong {
  color: var(--text);
  font-size: 0.98rem;
}

.dropzone-empty u {
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.dropzone-empty small {
  margin-top: 6px;
  font-size: 0.76rem;
}

.dropzone-file {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  pointer-events: none;
}

.dropzone-file[hidden],
.dropzone-empty[hidden] {
  display: none;
}

.dropzone-file-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 46px;
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--teal);
  border-radius: 8px;
}

.dropzone-file-text {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 2px;
}

.dropzone-file-text strong {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone-file-text small {
  font-size: 0.78rem;
}

.dropzone-change {
  flex: none;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 600;
}

.import-modal-actions {
  justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
  .dropzone,
  .dropzone-icon {
    transition: none;
  }
}

.segmented button {
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.in-positions,
.in-operations,
:root[data-inv-showing="positions"] .in-accounts,
:root[data-inv-showing="operations"] .in-accounts {
  display: none;
}

:root[data-inv-showing="positions"] .in-positions,
:root[data-inv-showing="operations"] .in-operations,
:root[data-inv-showing="accounts"] .in-accounts {
  animation: inv-view-in 0.28s cubic-bezier(0.2, 0, 0, 1);
}

:root[data-inv-showing="positions"] .in-positions,
:root[data-inv-showing="operations"] .in-operations {
  display: block;
}

@keyframes inv-view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-inv-showing] .in-positions,
  :root[data-inv-showing] .in-operations,
  :root[data-inv-showing] .in-accounts {
    animation: none;
  }
}

.positions-table td strong,
.positions-table td span {
  display: block;
}

.positions-table td strong {
  font-weight: 600;
}

.positions-table td span {
  font-size: 0.74rem;
  color: var(--muted);
}

.positions-table .pos {
  color: var(--teal);
}

.positions-table .neg {
  color: var(--coral);
}

.positions-table tr.closed,
.positions-table tr.unallocated strong {
  color: var(--muted);
}

.positions-table .position-account th,
.positions-table .position-account td {
  padding-top: 18px;
  font-weight: 700;
}

.position-account-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.position-account-name small {
  font-weight: 500;
  color: var(--muted);
}

.positions-table .position-row {
  transition: background-color 0.2s ease;
}


.positions-table .position-empty td {
  color: var(--muted);
}

.account-option small {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.fab-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.import-operation td {
  font-size: 0.82rem;
  color: var(--muted);
}

.picker-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--purple);
  background: color-mix(in srgb, var(--purple) 12%, transparent);
}

.picker-icon svg {
  width: 16px;
  height: 16px;
}

/* An open modal holds the page behind it. Scrolling stays on the window (body must not become a scroll box), so html
   takes the overflow and body gives up its overflow-x while the modal is open. */
html:has(dialog[open]) {
  overflow: hidden;
}

html:has(dialog[open]) body {
  overflow-x: visible;
}

.sort-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px 0 32px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.sort-trigger:hover,
.sort-trigger[aria-expanded="true"] {
  border-color: var(--teal);
}

.sort-field .bank-picker-panel {
  left: auto;
  min-width: 220px;
  z-index: 30;
}

.sort-field .bank-picker-list {
  grid-template-columns: 1fr;
}

/* The cards after it would cover the open panel. */
.filter-panel:has([data-picker-panel]:not([hidden])) {
  position: relative;
  z-index: 30;
}

@media (max-width: 600px) {
  .sort-trigger {
    justify-content: space-between;
    width: 100%;
  }

  .sort-field .bank-picker-panel {
    left: 0;
  }
}

a.acc-card {
  color: inherit;
  text-decoration: none;
}

.account-page-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.positions-table .row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions > div {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.row-actions > div {
  margin-top: -4px;
}

.positions-table .row-actions .icon-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.positions-table .row-actions .icon-button:hover,
.positions-table .row-actions .icon-button:focus-visible {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.row-actions .icon-button svg {
  width: 15px;
  height: 15px;
}

.operation-note {
  max-width: 200px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.positions-table td {
  white-space: nowrap;
}

.positions-table td:first-child {
  min-width: 200px;
  white-space: normal;
}

/* Positions: the table is as wide as its card, never wider (no sideways scroll): see the rule of `.tabla-famfin`. */
.positions-table:not(.operations-table) {
  width: 100%;
  min-width: 0;
}


.positions-table:not(.operations-table) td:first-child {
  min-width: 0;
}

.positions-table.with-origin {
  width: 100%;
}



.positions-table [data-row-link] {
  cursor: pointer;
}

.position-link {
  color: inherit;
  text-decoration: none;
}

.position-link:hover strong,
.position-link:focus-visible strong {
  color: var(--blue);
}

.position-link strong {
  transition: color 0.2s ease;
}

.position-origin {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
}

.positions-table td .position-origin {
  display: inline-flex;
}

.positions-table td .position-origin .bank-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
}

/* The origin's logo sits in the middle of its cell, however tall the row. */
.positions-table.with-origin th:nth-child(2),
.positions-table.with-origin .position-row > td:nth-child(2) {
  text-align: center;
}

.positions-table.with-origin .position-row > td:nth-child(2) {
  vertical-align: middle;
}

.positions-table.with-origin .position-row > td:nth-child(2) .position-origin {
  vertical-align: middle;
}

.column-sort {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
  transition: color 0.2s ease;
}

/* The mark's room is always there, so choosing a column doesn't move the rows. */
.column-sort-mark {
  flex: none;
  width: 14px;
  height: 14px;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-mask: var(--sort-mark) center / contain no-repeat;
  mask: var(--sort-mark) center / contain no-repeat;
  --sort-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4h12M4.5 8h7M7 12h2'/%3E%3C/svg%3E");
}

.column-sort:hover,
.column-sort:focus-visible,
[aria-sort] .column-sort {
  color: var(--text);
}

.column-sort:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.column-sort:hover .column-sort-mark,
.column-sort:focus-visible .column-sort-mark {
  opacity: 0.7;
}

[aria-sort] .column-sort .column-sort-mark {
  opacity: 1;
  --sort-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v12M3.5 9.5 8 14l4.5-4.5'/%3E%3C/svg%3E");
}

[aria-sort="ascending"] .column-sort .column-sort-mark {
  transform: rotate(180deg);
}

/* The history scrolls down inside its card and never sideways: columns are dropped by priority (`.tabla-famfin`). */
.table-wrap.operations-scroll {
  max-height: 440px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.operations-table {
  width: 100%;
  min-width: 0;
}

.operations-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}


.operations-table td.op-gain small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.operations-table td:first-child {
  min-width: 0;
  white-space: nowrap;
}

.operations-table td.op-asset {
  white-space: normal;
}

.operations-table td.op-kind {
  white-space: normal;
}

.operations-table .operation-note {
  max-width: none;
}

/* With every asset in it, the name takes the room of the note, which stays in the asset's own page. */
.operations-table.with-asset .op-note {
  display: none;
}

.dash-hero.page-hero-std.account-hero {
  min-height: 0;
}

/* An asset's own page */
.hero-edit {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  align-self: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  transition: color 300ms cubic-bezier(0.2, 0, 0, 1), background 300ms cubic-bezier(0.2, 0, 0, 1);
}

.hero-edit:hover,
.hero-edit:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}

.hero-edit svg {
  width: 16px;
  height: 16px;
}

@media (prefers-reduced-motion: reduce) {
  .hero-edit { transition: none; }
}

.asset-chart-head {
  align-items: flex-end;
}

.asset-chart-change {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.asset-chart-change .pos {
  color: var(--teal);
}

.asset-chart-change .neg {
  color: var(--coral);
}

.asset-chart-ranges {
  width: fit-content;
  max-width: 100%;
  margin: 12px 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.asset-chart-ranges button {
  flex: none;
  padding: 0 12px;
}

.asset-chart-ranges button:disabled {
  opacity: 0.4;
  cursor: default;
}

.asset-chart {
  height: 320px;
}

.asset-chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  animation: inv-view-in 0.28s cubic-bezier(0.2, 0, 0, 1);
}

.asset-chart-grid {
  stroke: var(--line);
}

.asset-chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.asset-chart-label.cost {
  fill: var(--text-soft);
}

.asset-chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.asset-chart-area {
  fill: color-mix(in srgb, var(--blue) 12%, transparent);
  stroke: none;
}

.asset-chart-cost {
  stroke: var(--text-soft);
  stroke-dasharray: 4 4;
}

.asset-chart-mark {
  fill: var(--surface);
  stroke: var(--blue);
  stroke-width: 2;
}

.asset-positions {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.asset-position + .asset-position {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.asset-position > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.asset-position-origin {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.asset-position-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.asset-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 40px;
}

.asset-figures dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 0;
}

.asset-figures dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.asset-figures dd {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: right;
}

.asset-figures dt.asset-figures-title {
  color: var(--text);
  font-weight: 600;
}

.asset-figures .pos {
  color: var(--teal);
}

.asset-figures .neg {
  color: var(--coral);
}

@media (max-width: 640px) {
  .asset-chart-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .asset-chart-change {
    text-align: left;
  }

  .asset-figures {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .asset-chart svg {
    animation: none;
  }
}

/* ---------- Transferencias ---------- */
.xfer-notices { margin-top: 0; }
.xfer-grid { align-items: start; }
.xfer-grid > .dash-card { grid-column: 1 / -1; }

.xfer-group + .xfer-group { margin-top: 10px; }
.xfer-group-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: 0.84rem; }
.xfer-group-head span:last-child { margin-left: auto; font-weight: 600; color: var(--text-soft); }
.xfer-rows { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.xfer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.5rem; /* fixed amount column: every arrow and destination lines up */
  align-items: center;
  gap: 8px 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.xfer-row:hover { border-color: color-mix(in srgb, var(--text) 22%, var(--line)); }
.xfer-route { display: grid; grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr); align-items: center; gap: 8px; min-width: 0; }
.xfer-end { display: flex; align-items: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.xfer-end .bank-mark.sm { flex-shrink: 0; }
.xfer-end-icon { display: inline-flex; flex-shrink: 0; align-items: center; justify-content: center; width: 30px; height: 30px; color: var(--muted); }
.xfer-end-icon svg { width: 20px; height: 20px; }
.xfer-end-name { display: grid; min-width: 0; font-size: 0.84rem; line-height: 1.25; }
.xfer-end-name b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.xfer-end-name small { overflow: hidden; font-size: 0.72rem; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
.xfer-arrow { display: inline-flex; flex-shrink: 0; color: var(--muted); }
.xfer-arrow svg { width: 14px; height: 14px; }
.xfer-side { display: grid; justify-items: end; gap: 4px; }
.xfer-amount { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.xfer-kind { padding: 3px 9px; font-size: 0.7rem; font-weight: 600; border-radius: 999px; white-space: nowrap; }
.xfer-kind.own { color: var(--text-soft); background: color-mix(in srgb, var(--slate) 14%, transparent); }
.xfer-kind.joint { color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }
.xfer-kind.member { color: var(--amber); background: var(--amber-pale); }

.xfer-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; margin: 14px 0 0; padding: 0; list-style: none; }
.xfer-member-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 0.86rem; }
.xfer-member-head .dash-chip { margin-left: auto; }
.xfer-steps { display: grid; gap: 4px; margin: 0; }
.xfer-steps div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; color: var(--text-soft); }
.xfer-steps dt, .xfer-steps dd { margin: 0; }
.xfer-steps dd { font-variant-numeric: tabular-nums; }
.xfer-steps .total { padding-top: 5px; border-top: 1px solid var(--line); color: var(--text); font-weight: 600; }

.xfer-accounts { display: grid; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.xfer-account { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: border-color 0.2s ease; }
.xfer-account:hover { border-color: color-mix(in srgb, var(--text) 22%, var(--line)); }
.xfer-account summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px 14px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.xfer-account summary::-webkit-details-marker { display: none; }
.xfer-account-name { display: grid; min-width: 0; font-size: 0.9rem; }
.xfer-account-name b { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.xfer-account-name small { overflow: hidden; font-size: 0.72rem; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
.xfer-account-figs { display: flex; gap: 20px; }
.xfer-fig { display: grid; justify-items: end; gap: 2px; font-size: 0.86rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.xfer-fig.main { font-size: 1rem; font-weight: 700; }
.xfer-fig.is-zero { color: var(--muted); font-weight: 500; }
.xfer-fig-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.68rem; font-weight: 400; color: var(--muted); white-space: nowrap; }
.xfer-fig-label svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.xfer-account-chevron { display: inline-flex; color: var(--muted); transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.xfer-account-chevron svg { width: 16px; height: 16px; }
.xfer-account[open] .xfer-account-chevron { transform: rotate(90deg); }
.xfer-account::details-content { block-size: 0; overflow: hidden; transition: block-size 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), content-visibility 0.3s allow-discrete; }
.xfer-account[open]::details-content { block-size: auto; }
@supports (interpolate-size: allow-keywords) { .xfer-accounts { interpolate-size: allow-keywords; } }
.xfer-items { display: grid; gap: 2px; margin: 0; padding: 0 14px 12px; list-style: none; }
.xfer-items li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.8rem; border-top: 1px solid var(--line); }
.xfer-items li span small { margin-left: 8px; font-size: 0.7rem; color: var(--muted); }
.xfer-items b { font-weight: 600; font-variant-numeric: tabular-nums; }
.xfer-unassigned { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.xfer-unassigned > p { margin: 0 0 8px; font-size: 0.8rem; color: var(--text-soft); }
.xfer-unassigned .xfer-items { padding: 0; }

/* Mapa de flujo entre cuentas (Sankey sencillo) */
.xfer-flow { margin: 14px 0 6px; }
.xfer-flow-body { display: grid; grid-template-columns: 30% minmax(0, 1fr) 30%; }
.xfer-flow-col { position: relative; }
.xfer-flow-svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.xfer-flow-node { position: absolute; left: 0; right: 0; display: flex; align-items: center; animation: xfer-fade 0.3s ease both; }
.xfer-flow-node::after { content: ""; position: absolute; top: var(--pad, 0); bottom: var(--pad, 0); width: 4px; border-radius: 2px; background: var(--muted); }
.xfer-flow-node.left { justify-content: flex-end; padding-right: 10px; text-align: right; }
.xfer-flow-node.left::after { right: 0; }
.xfer-flow-node.right { justify-content: flex-start; padding-left: 10px; text-align: left; }
.xfer-flow-node.right::after { left: 0; }
.xfer-flow-label { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.xfer-flow-node.left .xfer-flow-label { flex-direction: row-reverse; }
.xfer-flow .bank-mark.sm { width: 20px; flex-shrink: 0; font-size: 0.56rem; }
.xfer-flow-icon { display: inline-flex; flex-shrink: 0; color: var(--muted); }
.xfer-flow-icon svg { width: 18px; height: 18px; }
.xfer-flow-text { display: grid; min-width: 0; }
.xfer-flow-name { overflow: hidden; font-size: 0.8rem; font-weight: 600; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.xfer-flow-text small { font-size: 0.72rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.xfer-ribbon {
  fill: color-mix(in srgb, var(--member) 55%, transparent);
  transition: opacity 0.2s ease;
  animation: xfer-reveal 0.42s cubic-bezier(0.2, 0, 0, 1) both;
  animation-delay: calc(var(--i, 0) * 40ms);
  cursor: pointer;
  outline: none;
}
.xfer-flow-svg:focus, .xfer-flow-svg :focus { outline: none; }
html[data-theme="dark"] .xfer-ribbon { fill: color-mix(in srgb, var(--member) 70%, transparent); }
.xfer-flow.is-dim .xfer-ribbon { opacity: 0.25; }
.xfer-flow.is-dim .xfer-ribbon.is-active { opacity: 1; }
.xfer-flow-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; font-size: 0.78rem; color: var(--text-soft); }
.xfer-flow-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.xfer-row.is-active { background: color-mix(in srgb, var(--member, var(--teal-bright)) 8%, var(--surface)); border-color: color-mix(in srgb, var(--member, var(--teal-bright)) 45%, var(--line)); }
.xfer-row.is-pinned { background: color-mix(in srgb, var(--member, var(--teal-bright)) 13%, var(--surface)); border-color: color-mix(in srgb, var(--member, var(--teal-bright)) 70%, var(--line)); }
.xfer-row[data-flow] { cursor: pointer; }
.xfer-row:focus { outline: none; }
.xfer-row:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }
@keyframes xfer-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes xfer-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .xfer-ribbon, .xfer-flow-node { animation: none; }
}

@media (max-width: 600px) {
  .xfer-flow-body { grid-template-columns: 34% minmax(0, 1fr) 34%; }
  .xfer-flow-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 0.72rem; white-space: normal; overflow-wrap: anywhere; }
  .xfer-flow-node.left { padding-right: 6px; }
  .xfer-flow-node.right { padding-left: 6px; }
  .xfer-row { grid-template-columns: minmax(0, 1fr); }
  .xfer-side { grid-auto-flow: column; justify-content: space-between; align-items: center; justify-items: start; }
  .xfer-account summary { grid-template-columns: auto minmax(0, 1fr) 18px; }
  .xfer-account-figs { grid-row: 2; grid-column: 1 / -1; justify-content: space-between; }
  .xfer-fig { justify-items: start; }
}

/* ── Resultados (P&L) ─────────────────────────────────────────────────────────────── */
.pl-toolbar { gap: 10px 12px; justify-content: flex-start; }
.pl-more { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
.pl-more[hidden] { display: none; }
.pl-more-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.pl-more-toggle [data-icon] svg { width: 15px; height: 15px; }
.pl-more-toggle[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
.pl-stepper { display: inline-flex; align-items: center; gap: 4px; padding: 3px; font-size: 0.84rem; font-weight: 600; background: var(--surface-2); border-radius: 10px; }
.pl-stepper > span { min-width: 9.5em; text-align: center; font-variant-numeric: tabular-nums; }
.pl-step { display: inline-grid; place-items: center; width: 32px; height: 32px; color: var(--text-soft); border-radius: 8px; transition: background 0.2s ease, color 0.2s ease; }
.pl-step:hover { color: var(--text); background: var(--surface); }
.pl-step svg { width: 15px; height: 15px; }
.pl-step.prev svg { transform: rotate(180deg); }
.pl-compare-form label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-soft); white-space: nowrap; }
.pl-compare-form select { min-height: 32px; padding: 0 28px 0 10px; font: inherit; font-weight: 600; color: var(--text); background-color: var(--surface-2); border: 0; border-radius: 9px; }

.pl-card { padding: 18px 22px; background: var(--surface); border-color: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 18px; box-shadow: none; }
html[data-theme="dark"] .pl-card { border-color: var(--line); }
.pl-table { --pl-cols: minmax(0, 1fr) 104px 104px 96px 76px; font-variant-numeric: tabular-nums; }
.pl-row { display: grid; grid-template-columns: var(--pl-cols); align-items: center; gap: 10px; padding: 9px 10px; font-size: 0.86rem; }
.pl-row > span:not(.pl-label) { text-align: right; white-space: nowrap; }
.pl-label { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; min-width: 0; }
.pl-label small { flex-basis: 100%; font-size: 0.72rem; font-weight: 400; color: var(--muted); }
.pl-label small.pl-tag { flex-basis: auto; padding: 1px 7px; font-size: 0.66rem; font-weight: 600; color: var(--text-soft); background: color-mix(in srgb, var(--slate) 12%, transparent); border-radius: 999px; }
.pl-head { padding-top: 12px; padding-bottom: 8px; font-size: 0.72rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.pl-compare, .pl-share { color: var(--text-soft); }
.pl-delta { font-size: 0.78rem; font-weight: 600; }
.pl-delta.good { color: var(--teal); }
.pl-delta.bad { color: var(--coral); }
.pl-delta.muted { color: var(--muted); }

.pl-section { padding: 6px 0; border-bottom: 1px solid var(--line); }
.pl-section-head { font-weight: 600; }
.pl-section-head .pl-label { font-size: 0.9rem; }
.pl-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; }
.pl-chevron { display: inline-flex; color: var(--muted); transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1); }
.pl-chevron svg { width: 14px; height: 14px; }

.pl-group > summary, .pl-fold > summary { list-style: none; cursor: pointer; border-radius: 9px; transition: background 0.2s ease; }
.pl-group > summary::-webkit-details-marker, .pl-fold > summary::-webkit-details-marker { display: none; }
.pl-group > summary:hover, .pl-fold > summary:hover { background: var(--surface-2); }
.pl-group[open] > summary .pl-chevron, .pl-fold[open] > summary .pl-chevron { transform: rotate(90deg); }
.pl-group::details-content, .pl-fold::details-content { block-size: 0; overflow: hidden; transition: block-size 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), content-visibility 0.3s allow-discrete; }
.pl-group[open]::details-content, .pl-fold[open]::details-content { block-size: auto; }
.pl-items { margin: 0 0 4px; padding: 0; list-style: none; }
.pl-item { padding-top: 6px; padding-bottom: 6px; padding-left: 26px; font-size: 0.8rem; color: var(--text-soft); }
.pl-item .pl-amount { color: var(--text); }
.pl-foot { margin: 2px 10px 8px; font-size: 0.74rem; color: var(--muted); }

.pl-result { margin: 8px 0 0; padding-top: 16px; padding-bottom: 12px; font-weight: 700; border-top: 1px solid var(--text); }
.pl-result .pl-label { font-size: 1rem; }
.pl-result .pl-amount b, .pl-result .pl-compare b { font-size: 1.2rem; letter-spacing: -0.01em; }
.pl-balance { margin-top: 16px; }
.pl-card-head { align-items: baseline; margin-bottom: 6px; padding: 0 10px 10px; }
.pl-card-head h3 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
/* Fintech look: no rules between rows, figures that stand out and the changes as pills. */
.pl-balance .pl-compare { color: var(--text); }
.pl-subtotal { margin-top: 6px; border-top: 1px solid var(--line); }
.pl-move { padding-left: 42px; color: var(--muted); }
.pl-balance .pl-group > summary .pl-label { font-weight: 500; color: var(--text); }
.pl-card .pl-head { padding: 0 10px 6px; border-bottom: 0; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.pl-card .pl-section, .pl-card .pl-fold { border-bottom: 0; }
.pl-card .pl-fold > summary { margin: 0; padding-top: 11px; padding-bottom: 11px; }
.pl-card .pl-section-head .pl-amount b { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.pl-card .pl-delta { display: inline-block; padding: 2px 8px; font-size: 0.72rem; border-radius: 999px; }
.pl-card .pl-delta.good { background: var(--teal-pale); }
.pl-card .pl-delta.bad { background: color-mix(in srgb, var(--coral) 13%, transparent); }
.pl-card .pl-delta.muted { background: var(--surface-2); }
.pl-fold { border-bottom: 1px solid var(--line); }
.pl-fold > summary { padding-top: 12px; padding-bottom: 12px; }

.pl-pdf-open { display: inline-flex; align-items: center; gap: 6px; }
.pl-pdf-open [data-icon] svg, .pl-pdf-dialog .button [data-icon] svg { width: 15px; height: 15px; }
.pl-pdf-dialog .button.primary { display: inline-flex; align-items: center; gap: 6px; }
.pl-pdf-label { margin: 4px 0 8px; font-size: 0.78rem; font-weight: 600; color: var(--text-soft); }
.pl-pdf-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pl-pdf-range { margin-bottom: 16px; }
.pl-pdf-breakdown { display: flex; width: 100%; }
.pl-pdf-breakdown label { flex: 1; position: relative; }
.pl-pdf-breakdown input { position: absolute; opacity: 0; pointer-events: none; }
.pl-pdf-breakdown span { display: grid; place-items: center; min-height: 32px; padding: 0 10px; font-size: 0.82rem; font-weight: 500; color: var(--text-soft); border-radius: 8px; cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.pl-pdf-breakdown input:checked + span { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(14, 21, 38, 0.12); }
.pl-pdf-breakdown input:focus-visible + span { outline: 2px solid var(--teal-bright); outline-offset: 1px; }

@media (max-width: 720px) {
  .pl-card { padding: 18px 14px; }
  .pl-table { --pl-cols: minmax(0, 1fr) auto; }
  .pl-row { row-gap: 2px; }
  .pl-row .pl-compare, .pl-row .pl-share, .pl-head .pl-change { display: none; }
  .pl-row .pl-amount { grid-column: 2; grid-row: 1; }
  .pl-row .pl-change { grid-column: 2; grid-row: 2; }
  .pl-row .pl-change:empty { display: none; }
  .pl-card .pl-delta:is(.good, .bad, .muted) { padding: 0; font-size: 0.72rem; font-weight: 400; color: var(--muted); background: none; }
  .pl-card .pl-delta.muted { display: none; }
  .pl-item { padding-left: 14px; }
  .pl-stepper > span { min-width: 0; }
  .pl-balance .pl-row .pl-amount { display: none; }
  .pl-balance .pl-row .pl-compare { display: block; grid-column: 2; grid-row: 1; }
}

/* income: one folding group per type, like the accounts' */

/* Partidas: the small «mover» button at the right of a row opens a menu with the other glasses. */
.glass-rows li.has-move { position: relative; }
.has-move > .glass-row { padding-right: 52px; }
.item-move { position: absolute; top: 50%; right: 10px; z-index: 2; transform: translateY(-50%); }
.item-move[open] { z-index: 6; }
.item-move > summary {
  display: grid; place-items: center; width: 28px; height: 28px; color: var(--muted); list-style: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 50%;
  transition: color 0.3s cubic-bezier(0.2, 0, 0, 1), border-color 0.3s cubic-bezier(0.2, 0, 0, 1), transform 0.3s cubic-bezier(0.2, 0, 0, 1);
}
.item-move > summary::-webkit-details-marker { display: none; }
.item-move > summary svg { width: 14px; height: 14px; }
.item-move > summary:hover, .item-move[open] > summary { color: var(--text); border-color: var(--muted); }
.item-move[open] > summary { transform: rotate(90deg); }
.item-move > summary:focus-visible { outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent); outline-offset: 2px; }
.item-move-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 180px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--soft-shadow);
  transform-origin: top right; animation: item-move-in 0.32s cubic-bezier(0.2, 0, 0, 1);
}
.item-move-menu button {
  display: block; width: 100%; padding: 8px 12px; font: inherit; font-size: 0.84rem; font-weight: 500; color: var(--text);
  text-align: left; white-space: nowrap; background: none; border: 0; border-radius: 8px; cursor: pointer;
  transition: background-color 0.2s cubic-bezier(0.2, 0, 0, 1);
}
.item-move-menu button:hover, .item-move-menu button:focus-visible { background: var(--bg); outline: none; }
@keyframes item-move-in { from { opacity: 0; transform: translateY(-4px) scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .item-move-menu { animation: none; } .item-move > summary { transition: none; } }
.glass-add + .glass-add { margin-top: 8px; }

/* Inside a glass: the objectives and the assets outside them, each folded under its total. */
.glass-fold { border-top: 1px solid var(--line); }
.glass-fold + .glass-fold { margin-top: 2px; }
.glass-fold-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 12px 2px; list-style: none; cursor: pointer;
}
.glass-fold-head::-webkit-details-marker { display: none; }
.glass-fold-title { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; font-weight: 600; }
.glass-fold-title small {
  min-width: 20px; padding: 1px 7px; font-size: 0.72rem; font-weight: 600; color: var(--text-soft); text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.glass-fold-head b { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.glass-fold-chevron { display: inline-flex; width: 16px; height: 16px; color: var(--muted); transform: rotate(90deg); transition: transform 0.36s cubic-bezier(0.2, 0, 0, 1); }
.glass-fold-chevron svg { width: 100%; height: 100%; }
.glass-fold[open]:not(.is-collapsing) .glass-fold-chevron { transform: rotate(-90deg); }
.glass-fold-head:hover .glass-fold-chevron { color: var(--text); }
.glass-fold-head:focus-visible { outline: 2px solid color-mix(in srgb, var(--blue) 50%, transparent); outline-offset: 2px; border-radius: 8px; }
.glass-fold-body { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
@media (prefers-reduced-motion: reduce) { .glass-fold-chevron { transition: none; } }

/* Préstamos: the grey line of the hero, the substats that wrap, and the finished loans as plain rows */
.hero-states { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 0; }
.summary-note { margin: 16px 0 0; font-size: 0.88rem; color: var(--on-hero-muted); font-variant-numeric: tabular-nums; }
.dash-networth-row + .summary-note { margin-top: 0; }
.summary-note > span { white-space: nowrap; }
.calc-substats.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.loan-done { margin-top: 18px; }
.loan-done-list { display: grid; margin: 0; padding: 0; list-style: none; }
.loan-done-row { display: flex; align-items: baseline; gap: 12px; padding: 12px 2px; font-size: 0.88rem; cursor: pointer; border-top: 1px solid var(--line); }
.loan-done-row:first-child { border-top: 0; }
.loan-done-row:hover .loan-done-name, .loan-done-row:focus-visible .loan-done-name { color: var(--text-soft); }
.loan-done-name { flex: 1; min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.loan-done-row b { font-weight: 500; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.loan-done-end { text-align: right; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* "Ver todos" sits on the timeline's line: the stroke runs through its row and on into the events it opens */
.tl-fold > summary { padding-left: 42px; }
.tl-fold > :not(summary) { padding-top: 14px; }
.tl-fold { margin-top: 14px; }
.journey-timeline.tl-more > .tl-event:last-child::before { content: ""; position: absolute; top: 32px; bottom: -58px; left: 14px; width: 2px; background: var(--line); border-radius: 1px; }
.journey-timeline.tl-more:has(+ .tl-fold[open]) > .tl-event:last-child::before { bottom: -72px; }

/* Cuentas and the accounts of Inversiones: plain account cards («Apple» style, like .budget-card): no bank tint, the colour stays in the bank mark. */
.acc-card.is-plain {
  padding: 22px;
  background: var(--surface);
  border-color: color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 18px;
  box-shadow: none;
}

html[data-theme="dark"] .acc-card.is-plain { background: var(--surface); }
html[data-theme="dark"] .acc-card.is-plain:not(:hover):not(:focus-visible) { border-color: var(--line); }

.card-grid.wide .acc-card.is-plain {
  padding: 22px;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "top top"
    "balance spark"
    "detail spark";
}

/* Cuentas: the trend sits right of the total with no gauge, so no empty third column. */
.hero-split.with-trend.no-gauge {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "figure trend";
}

@media (max-width: 900px) {
  .hero-split.with-trend.no-gauge {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "figure" "trend";
  }
}

.acc-group-interest { color: var(--text-soft); font-weight: 400; }

/* Configuración («Ajustes» style): grouped lists inside the plain .budget-card. Rows of 44 px or more, hairlines, a small icon, the value on the right. */
.settings-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.settings-group { gap: 8px; padding-block: 18px; }
.settings-group > .budget-head { min-height: 28px; padding-bottom: 4px; }
.settings-group > .budget-head h3 { color: var(--text); font-size: 1rem; }
.settings-group .save-status { margin: 0 0 0 auto; }
.settings-group .budget-head > .set-value { margin-left: auto; font-size: 0.82rem; }
.set-list { display: grid; margin: 0; padding: 0; list-style: none; }
.set-list > :first-child { border-top: 0; }
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 0; font: inherit; font-size: 0.94rem; color: var(--text); text-align: left; background: none; border: 0; border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); border-radius: 0; cursor: pointer; }
li.set-row { cursor: default; }
html[data-theme="dark"] .set-row { border-top-color: var(--line); }
.set-row:focus-visible { outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent); outline-offset: 2px; border-radius: 8px; }
.set-icon { flex-shrink: 0; width: 18px; height: 18px; color: var(--muted); }
.set-icon svg { width: 100%; height: 100%; }
.set-icon.is-accent { color: var(--teal); }
.set-icon.is-cat { color: var(--cat); }
.set-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.set-name small { display: block; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.set-name small.over { color: var(--coral-ink); }
.set-value { flex-shrink: 0; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.set-chevron { flex-shrink: 0; width: 14px; height: 14px; color: var(--muted); }
.set-chevron svg { width: 100%; height: 100%; }
.set-row.is-inactive .set-icon, .set-row.is-inactive .set-name { opacity: 0.5; }
.set-row select, .set-row input:not([type="file"]) { flex: 0 1 auto; width: auto; min-height: 0; max-width: 55%; padding: 4px 0; font: inherit; font-size: 0.94rem; color: var(--muted); text-align: right; background: none; border: 0; border-radius: 6px; outline: none; }
.set-row input[name="fiscal_year"] { width: 5ch; }
.set-row select:focus-visible, .set-row input:focus-visible { color: var(--text); outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent); }
.set-row form { display: contents; }
.set-row .icon-button { cursor: pointer; }
.set-row .icon-button [data-icon] svg { width: 17px; height: 17px; }
.set-help { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); }
.set-about { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
/* Dark theme paints every `label input/select`; settings rows and the hero name stay borderless like the light theme. */
html[data-theme="dark"] .set-row select, html[data-theme="dark"] .set-row input:not([type="file"]) { background: none; border-color: transparent; }
html[data-theme="dark"] .hero-name input { background: transparent; border-color: transparent; }
html[data-theme="dark"] .hero-name:hover input { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.12); }
html[data-theme="dark"] .hero-name input:focus { background: rgba(255, 255, 255, 0.08); border-color: color-mix(in srgb, var(--teal-bright) 70%, transparent); }
@media (max-width: 480px) { .hero-name input { font-size: 1.85rem; } }

/* Proyección: «Tus hipótesis», the line under the chart that unfolds the three settings that move the road */
.path-chart-wrap.is-recalculating { opacity: 0.5; }
.path-hyp { display: grid; gap: 0; scroll-margin-top: calc(var(--topbar-offset, 0px) + 140px); }
.path-hyp-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 6px 2px; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--text-soft); text-align: left; background: none; border: 0; border-top: 1px solid var(--line); cursor: pointer; }
.path-hyp-toggle:hover { color: var(--text); }
.path-hyp-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.path-hyp-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.path-hyp-dot { flex: none; width: 8px; height: 8px; background: var(--layer-free); border-radius: 50%; }
.path-hyp-dot[hidden] { display: none; }
.path-hyp.is-open .path-hyp-chevron { transform: rotate(-90deg); }
.path-hyp-fold { display: grid; grid-template-rows: 0fr; overflow: hidden; visibility: hidden; transition: grid-template-rows 0.36s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0.36s; }
.path-hyp.is-open .path-hyp-fold { grid-template-rows: 1fr; visibility: visible; transition-delay: 0s; }
.path-hyp.is-settled .path-hyp-fold { overflow: visible; }
.path-hyp-body { min-height: 0; padding-bottom: 6px; }
.path-hyp .set-row { cursor: default; flex-wrap: wrap; }
.path-hyp-picker { flex: 0 0 min(220px, 60%); }
.path-hyp-picker .account-select-trigger { grid-template-columns: minmax(0, 1fr) auto; min-height: 40px; }
.path-hyp-picker .account-select-panel { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 100%; max-height: 260px; overflow-y: auto; }
.path-hyp-tip { flex: 0 0 100%; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 0.8rem; color: var(--muted); }
.path-hyp-tip-use { min-height: 44px; padding: 0 4px; font: inherit; font-weight: 600; color: var(--blue); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.path-hyp-tip-use[hidden] { display: none; }
.path-hyp-tip-use:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.path-hyp-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 6px; font-size: 0.8rem; color: var(--muted); }
.path-hyp-foot .button:disabled { opacity: 0.45; cursor: default; }
@media (prefers-reduced-motion: reduce) { .path-chart-wrap, .path-hyp-fold { transition: none; } }
a.set-row { text-decoration: none; }
/* On a phone the label sits above the picker, so it does not wrap onto three lines. */
@media (max-width: 420px) {
  .path-hyp .set-row { flex-direction: column; align-items: stretch; gap: 4px; padding: 8px 0; }
  .path-hyp-picker { flex: none; width: 100%; }
  .path-hyp-tip { justify-content: space-between; }
}

/* ===== Cards or table in the lists (vista.js; data-vista on <html> comes from the head script of base.html) ===== */

/* The switch: two icons in a glass rail (the pill is the one of motion.js), 44 px targets, top right of the filter row. */
.view-filter-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.view-filter-extra + .view-filter-end { margin-left: 0; }
.view-filter.vista-only { justify-content: flex-end; margin-bottom: 12px; }

.vista-toggle { flex-shrink: 0; }

.vista-toggle button {
  position: relative;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  /* Same size as the options of Mensual | Anual beside it. */
  width: 40px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.vista-toggle button:hover,
.vista-toggle button[aria-pressed="true"] { color: var(--text); }
.vista-toggle button [data-icon] { width: 16px; height: 16px; }
.vista-toggle button svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.vista-toggle:not(.has-thumb) button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--soft-shadow); }
.vista-toggle .segmented-thumb { top: 3px; bottom: 3px; }

/* Positions: the switch only makes sense while the positions list is the one on show. */
html[data-vista-pantalla="posiciones"]:not([data-inv-showing="positions"]) .view-filter-end .vista-toggle { display: none; }

@media (max-width: 600px) {
  .vista-toggle,
  .view-filter.vista-only { display: none; }
  .view-filter-end { margin-left: 0; }
}

/* The header of the table only exists in table mode. */
.lista-cabecera { display: none; }
.lista-cabecera .num { text-align: right; }
.lista-cabecera .num .column-sort { flex-direction: row-reverse; }

#income-cards { --cols: minmax(0, 2fr) 96px minmax(0, 2fr) 132px; }
#expense-cards { --cols: minmax(0, 2.2fr) minmax(0, 1.4fr) minmax(0, 1.6fr) 132px; }
.budgets.lista-vista { --cols: minmax(0, 1.4fr) minmax(140px, 1.2fr) 120px 112px 156px 16px; }

html[data-vista="tabla"] .lista-vista:has(> .lista-cabecera) {
  display: block;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 18px;
  box-shadow: none;
}

html[data-theme="dark"][data-vista="tabla"] .lista-vista:has(> .lista-cabecera) { border-color: var(--line); }

html[data-vista="tabla"] .lista-vista > .lista-cabecera {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 0 16px;
  padding: 12px 18px;
}

html[data-vista="tabla"] .lista-vista > .dash-card {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 0 16px;
  align-content: center;
  align-items: center;
  min-height: 56px;
  margin: 0;
  padding: 8px 18px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  outline-offset: -2px;
}

/* A row has no lift and no shadow (hairline, no shadows): a soft tint, and the same press as a card. The important
   ones beat the hover of the cards, which is more specific. */
html[data-vista="tabla"] .lista-vista > .dash-card:is(:hover, :focus-visible) {
  background: var(--surface-2);
  border-color: var(--line) !important;
  box-shadow: none !important;
  transform: none !important;
}

html[data-vista="tabla"] .lista-vista > .dash-card:active { transform: scale(0.985) !important; }

/* Ingresos */
html[data-vista="tabla"] #income-cards .inc-card-head { display: contents; }
html[data-vista="tabla"] #income-cards h3 { grid-column: 1; margin: 0; overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] #income-cards .exp-who { grid-column: 2; justify-self: start; margin: 0; }
html[data-vista="tabla"] #income-cards .exp-meta { grid-column: 3; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] #income-cards .exp-amount { grid-column: 4; margin: 0; font-size: 0.95rem; text-align: right; }
html[data-vista="tabla"] #income-cards .inc-includes { display: none; }

/* Gastos */
html[data-vista="tabla"] #expense-cards .exp-badges { display: contents; }
html[data-vista="tabla"] #expense-cards h3 { grid-column: 1; grid-row: 1; margin: 0; overflow: hidden; font-size: 0.92rem; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] #expense-cards .exp-cat { grid-column: 2; grid-row: 1; justify-self: start; }
html[data-vista="tabla"] [data-live="filters"]:has(.js-card-filter[data-key="category"].active:not([data-value=""])) ~ #expense-cards .exp-cat.is-category { display: inline-flex; }
html[data-vista="tabla"] #expense-cards .exp-who,
html[data-vista="tabla"] #expense-cards .exp-meta-extra { display: none; }
html[data-vista="tabla"] #expense-cards .exp-meta { display: contents; }
html[data-vista="tabla"] #expense-cards .exp-freq { grid-column: 3; grid-row: 1; min-width: 0; overflow: hidden; font-size: 0.78rem; color: var(--text-soft); text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] #expense-cards .exp-amount { grid-column: 4; grid-row: 1; margin: 0; font-size: 0.95rem; text-align: right; }

/* Préstamos: the name and the figures take the two lines of the row; the thin bar goes under the pending amount. */
html[data-vista="tabla"] .budgets.lista-vista > .budget-card {
  grid-template-rows: auto auto;
  padding-block: 10px;
}
html[data-vista="tabla"] .budgets .budget-head { display: contents; }
html[data-vista="tabla"] .budgets .budget-symbol { display: none; }
html[data-vista="tabla"] .budgets .budget-head h3 { grid-column: 1; grid-row: 1 / 3; align-self: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] .budgets .budget-open { grid-column: 6; grid-row: 1 / 3; align-self: center; justify-self: end; }
html[data-vista="tabla"] .budgets .budget-total { grid-column: 2; grid-row: 1; align-self: end; font-size: 0.95rem; text-align: right; }
html[data-vista="tabla"] .budgets .budget-total small { display: none; }
html[data-vista="tabla"] .budgets .budget-bar { grid-column: 2; grid-row: 2; align-self: start; width: 100%; height: 3px; margin-top: 5px; }
html[data-vista="tabla"] .budgets .budget-rows,
html[data-vista="tabla"] .budgets .budget-rows li { display: contents; }
html[data-vista="tabla"] .budgets .budget-name,
html[data-vista="tabla"] .budgets .budget-more { display: none; }
html[data-vista="tabla"] .budgets .budget-amount { grid-row: 1 / 3; align-self: center; justify-self: end; min-width: 0; font-size: 0.88rem; }
html[data-vista="tabla"] .budgets .row-cuota .budget-amount { grid-column: 3; }
html[data-vista="tabla"] .budgets .row-intereses .budget-amount { grid-column: 4; }
html[data-vista="tabla"] .budgets .row-fin .budget-amount { grid-column: 5; }

/* Posiciones: the table as it is. As cards (the phone, or by choice) each row becomes one: asset, origin, value and
   profit in € and %, with its two buttons beside. The rows are still the same <tr>, so sorting and the link to the
   asset go on working. */
.positions-table .pos-percent { display: none; }

html[data-vista="tarjetas"] .table-wrap:has(> .positions-table:not(.operations-table)) { overflow: visible; }

html[data-vista="tarjetas"] .positions-table:not(.operations-table),
html[data-vista="tarjetas"] .positions-table:not(.operations-table) :is(thead, tbody, tfoot) {
  display: block;
  width: 100%;
  min-width: 0;
}

html[data-vista="tarjetas"] .positions-table:not(.operations-table) thead { display: none; }
html[data-vista="tarjetas"] .positions-table:not(.operations-table) tbody { display: grid; gap: 12px; }

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "origin name actions" "value value profit";
  align-items: start;
  gap: 12px 0;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 18px;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.3s cubic-bezier(0.2, 0, 0, 1);
}

html[data-theme="dark"][data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row { border-color: var(--line); }

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row:hover {
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  transform: translateY(-1px);
}

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row:active {
  box-shadow: none;
  transform: scale(0.985);
  transition-duration: 0.12s;
}

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row > td {
  display: block;
  padding: 0;
  border: 0;
  white-space: normal;
}

html[data-vista="tarjetas"] .positions-table .pos-shares,
html[data-vista="tarjetas"] .positions-table .pos-avg,
html[data-vista="tarjetas"] .positions-table .pos-cost,
html[data-vista="tarjetas"] .positions-table .pos-irr,
html[data-vista="tarjetas"] .positions-table .pos-weight { display: none !important; }

html[data-vista="tarjetas"] .positions-table .pos-name { grid-area: name; min-width: 0; }
html[data-vista="tarjetas"] .positions-table .pos-name strong { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
html[data-vista="tarjetas"] .positions-table .pos-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tarjetas"] .positions-table .pos-origin { grid-area: origin; margin-right: 12px; }
html[data-vista="tarjetas"] .positions-table .pos-value { grid-area: value; align-self: end; font-size: 1.1rem; font-weight: 600; text-align: left; }
html[data-vista="tarjetas"] .positions-table .pos-profit { grid-area: profit; align-self: end; margin-left: 12px; font-size: 0.84rem; text-align: right; }
html[data-vista="tarjetas"] .positions-table .pos-profit.neg { color: var(--coral-ink); }
html[data-vista="tarjetas"] .positions-table .pos-percent { display: inline; font-size: inherit; }
html[data-vista="tarjetas"] .positions-table tr.position-row > .row-actions { grid-area: actions; margin: -4px -6px 0 12px; }
html[data-vista="tarjetas"] .positions-table .row-actions > div { flex-direction: row; margin-top: 0; }
html[data-vista="tarjetas"] .positions-table .row-actions .icon-button { position: relative; width: 32px; height: 32px; }
/* The touch area is 44 px; the icon stays small. */
html[data-vista="tarjetas"] .positions-table .row-actions .icon-button::after { content: ""; position: absolute; inset: -6px; }

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-empty { display: block; padding: 16px; }
html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-empty > td { padding: 0; }

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tfoot tr {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
}

html[data-vista="tarjetas"] .positions-table:not(.operations-table) tfoot :is(th, td) { display: block; padding: 0; }
html[data-vista="tarjetas"] .positions-table:not(.operations-table) tfoot td:empty { display: none; }

/* The press of a row of the table of positions. */
.positions-table .position-row:active { background: var(--surface-2); }

/* Objetivos (Horizontes › Proyección) as a table: Objetivo, Fecha, Estado, Cuenta. The cards are the same elements; the
   fixes and «¿Ya ha nacido?» go under the message (a taller row). The list sits inside its card, with the hairline. */
.path-plan-list.lista-vista { --cols: minmax(0, 2fr) 168px minmax(0, 2.4fr) 90px; }
html .lista-cabecera[hidden] { display: none !important; }

html[data-vista="tabla"] .path-plan-list > .path-plan {
  grid-template-columns: var(--cols);
  gap: 0 16px;
  min-height: 56px;
  padding: 8px 18px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}
html[data-vista="tabla"] .path-plan-list > .path-plan:hover { background: var(--surface-2); }
html[data-vista="tabla"] .path-plan-list > .path-plans-empty { margin: 0; padding: 16px 18px; border-top: 1px solid var(--line); }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-open { grid-column: 1; grid-row: 1; }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-date { grid-column: 2; grid-row: 1; }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-msg { grid-column: 3; grid-row: 1; display: block; min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-vista="tabla"] .path-plan-list > .path-plan > :is(.path-switch, .path-plan-fixed) { grid-column: 4; grid-row: 1; justify-self: end; }
html[data-vista="tabla"] .path-plan-list > .path-plan > :is(.path-plan-born, .path-plan-fixes) { grid-column: 3; grid-row: 2; margin-top: 6px; }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-fixes { min-height: 0; }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-fixes:empty { display: none; }
html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-born { justify-self: start; }
html[data-vista="tabla"] .path-plan-list > .path-plan .path-plan-msg a { pointer-events: auto; }

/* ===== Transitions of the lists ===== */

/* Cards <-> rows: every named element (`item-<n>`, only while the transition runs, vista.js) travels from its card to
   its row; the class `paso-<n>` staggers them ~15 ms each from top to bottom, and the header fades in first. */
@keyframes vt-fade-out { to { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-group(*.item) { animation-duration: 0.32s; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
  ::view-transition-group(*.paso-1) { animation-delay: 15ms; }
  ::view-transition-group(*.paso-2) { animation-delay: 30ms; }
  ::view-transition-group(*.paso-3) { animation-delay: 45ms; }
  ::view-transition-group(*.paso-4) { animation-delay: 60ms; }
  ::view-transition-group(*.paso-5) { animation-delay: 75ms; }
  ::view-transition-group(*.paso-6) { animation-delay: 90ms; }
  ::view-transition-group(*.paso-7) { animation-delay: 105ms; }
  ::view-transition-group(*.paso-8) { animation-delay: 120ms; }
  ::view-transition-group(*.paso-9) { animation-delay: 135ms; }
  /* The group moves and resizes the box; the content isn't stretched: each image keeps its size, top left. */
  ::view-transition-old(*.item), ::view-transition-new(*.item) { width: 100%; height: 100%; object-fit: none; object-position: left top; }
  ::view-transition-old(lista-cabecera) { animation: vt-fade-out 0.12s ease both; }
  ::view-transition-new(lista-cabecera) { animation: vt-fade-in 0.3s ease both; }
  /* The switch stays put: its pill slides live in the new state, with no crossfade of the old one. */
  ::view-transition-group(vista-toggle) { animation: none; }
  ::view-transition-old(vista-toggle) { display: none; }
  ::view-transition-new(vista-toggle) { animation: none; }
}

/* Objetivos: the cards keep their names while the list is drawn again; the rest of the page stays in the live page. */
@media (prefers-reduced-motion: no-preference) {
  html.objetivos-cambiando::view-transition-old(root) { display: none; }
  html.objetivos-cambiando::view-transition-new(root) { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*.item), ::view-transition-group(vista-toggle) { animation: none; }
}

/* On arrival (motion.js marks the first eight): opacity + 6 px, 40 ms apart; never after a filter, never while prerendering. */
@keyframes cascada-in { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: no-preference) {
  [data-cascada] {
    animation: cascada-in 0.4s cubic-bezier(0.2, 0, 0, 1) backwards;
    animation-delay: calc(var(--i, 0) * 40ms);
  }
}

/* While the switch morphs the list, the page's named parts stay in the snapshot of the page (no group of their own). */
html.vista-cambiando :is(.sidebar, .content-topbar, .dash-hero, .fab, .nav-list a > .nav-pill) { view-transition-name: none; }

/* ===== .tabla-famfin: the one look of every table ===================================================
   Same visual language as the lists of Gastos, Ingresos and Préstamos in table mode (`.lista-vista` + `.lista-cabecera`):
   - Container: a white card with hairline and 18 px radius, no padding, nothing inside it with its own background
     (`.dash-card.tabla-card`, or the list itself). Its title row (`.dash-card-head`) is padded as usual.
   - Header: small, grey, spaced capitals, no band; the first row's top hairline separates it from the rows.
   - Rows: 56 px at least, 18 px at the edges, hairline between them, a soft tint on hover. First column in bold and
     text colour; the others regular and grey. Figures: class `num` on <th> and <td> (right, tabular, never cut).
   - Sortable headers (`.column-sort`): no underline; the arrow shows on hover, focus or the sorted column.
     Every table is sortable by default (static/ordenar.js): headers with the macro `sortable(label, kind)` of
     `templates/_tabla.html` (kind: `text`, `number` or `date`), `data-sort-value` on each cell (an unformatted number, an
     ISO date, or the text) and `data-orden="name"` on the <table> (keeps the order through a live refresh). Rows
     that aren't data (`position-empty`, `position-account`, `[data-sort-skip]`) and the <tfoot> don't move. Lists with the switch
     do the same with `sortable_item(label, key, kind)` in `.lista-cabecera` and `data-sort-<key>` on each card.
   - Actions (`.row-actions`): quiet at the end of the row, visible on hover (always on touch), 44 px of touch area.
   NEVER a sideways scroll, at any width: the table is as wide as its card and the columns drop by priority with container
   queries on the card (`@container tabla`, see the block after `.tabla-card > .table-wrap`): give each <th> and its cells
   the same class (`sortable(..., cls='mi-columna')`) and add one `@container tabla (max-width: Npx)` rule that hides
   the least important column first. Names break in up to two lines; figures don't (`num`). Under 600 px the lists are
   cards again (the switch) and a table without switch turns each row into a compact card.
   Any new table: `<section class="dash-card tabla-card"> ... <div class="table-wrap"><table class="tabla-famfin">`. */
.tabla-card,
html[data-vista="tabla"] .lista-vista:has(> .lista-cabecera) {
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 18px;
  box-shadow: none;
}

html[data-theme="dark"] .tabla-card { border-color: var(--line); }

.tabla-card > .dash-card-head { padding: 18px 18px 8px; }
.tabla-card > .dash-note { margin: 0; padding: 4px 18px 16px; }
.tabla-card > .table-wrap { margin-top: 4px; }

/* ----- Never a sideways scroll: columns drop by priority --------------------------------------------------------
   The frame (`.table-wrap` of a table, the list itself in table mode) is a size container named `tabla`: what matters is
   the room of the card, not the window (the sidebar changes it). The least important column goes first, header
   included (the <th> carries the same class as its cells). Under 600 px, or where not even the essentials fit, the
   lists are cards again; Operaciones has no switch and becomes a compact card per row. */
.table-wrap:has(> .tabla-famfin) { overflow-x: clip; container: tabla / inline-size; }
html[data-vista="tabla"] .lista-vista:has(> .lista-cabecera) { container: tabla / inline-size; }

/* Posiciones: % invertido, IRR, coste medio, participaciones, coste. Always: asset, origin, value, profit. */
@container tabla (max-width: 1000px) { .positions-table .pos-weight { display: none; } }
@container tabla (max-width: 900px) { .positions-table .pos-irr { display: none; } }
@container tabla (max-width: 800px) { .positions-table .pos-avg { display: none; } }
@container tabla (max-width: 700px) { .positions-table .pos-shares { display: none; } }
@container tabla (max-width: 600px) { .positions-table .pos-cost { display: none; } }

/* Operaciones: comisión, nota, participaciones, origen, precio. Always: date, asset, kind, total. */
@container tabla (max-width: 1200px) { .operations-table .op-fee { display: none; } }
@container tabla (max-width: 1050px) { .operations-table .op-note { display: none; } }
@container tabla (max-width: 950px) { .operations-table .op-shares { display: none; } }
@container tabla (max-width: 820px) { .operations-table .op-origin { display: none; } }
@container tabla (max-width: 700px) { .operations-table .op-price { display: none; } }

/* Ingresos, Gastos, Préstamos, Objetivos in table mode. */
@container tabla (max-width: 640px) {
  #income-cards > * { --cols: minmax(0, 2fr) 96px 132px; }
  #income-cards > .lista-cabecera > :nth-child(3), #income-cards .exp-meta { display: none; }
  #income-cards .exp-amount { grid-column: 3 !important; }
}
@container tabla (max-width: 700px) {
  #expense-cards > * { --cols: minmax(0, 2.2fr) minmax(0, 1.4fr) 132px; }
  #expense-cards > .lista-cabecera > :nth-child(3), #expense-cards .exp-freq { display: none; }
  #expense-cards .exp-amount { grid-column: 3 !important; }
}
@container tabla (max-width: 900px) {
  .budgets > * { --cols: minmax(0, 1.4fr) minmax(120px, 1.2fr) 120px 156px 16px; }
  .budgets > .lista-cabecera > :nth-child(4), .budgets .row-intereses { display: none !important; }
  .budgets .row-fin .budget-amount { grid-column: 4 !important; }
  .budgets .budget-open { grid-column: 5 !important; }
}
@container tabla (max-width: 760px) {
  .budgets > * { --cols: minmax(0, 1.4fr) minmax(120px, 1.2fr) 156px 16px; }
  .budgets > .lista-cabecera > :nth-child(3), .budgets .row-cuota { display: none !important; }
  .budgets .row-fin .budget-amount { grid-column: 3 !important; }
  .budgets .budget-open { grid-column: 4 !important; }
}
@container tabla (max-width: 640px) {
  .budgets > * { --cols: minmax(0, 1.4fr) minmax(120px, 1.2fr) 16px; }
  .budgets > .lista-cabecera > :nth-child(5), .budgets .row-fin { display: none !important; }
  .budgets .budget-open { grid-column: 3 !important; }
}
@container tabla (max-width: 760px) {
  .path-plan-list > * { --cols: minmax(0, 2fr) 168px 90px; }
  .path-plan-list > .lista-cabecera > :nth-child(3), html[data-vista="tabla"] .path-plan-list > .path-plan > .path-plan-msg { display: none; }
  html[data-vista="tabla"] .path-plan-list > .path-plan > :is(.path-switch, .path-plan-fixed) { grid-column: 3; }
  html[data-vista="tabla"] .path-plan-list > .path-plan > :is(.path-plan-born, .path-plan-fixes) { grid-column: 1 / -1; }
}

/* Operaciones under 600 px: one compact card per row (date and kind above; asset and total below). */
@media (max-width: 600px) {
  .operations-table, .operations-table :is(thead, tbody) { display: block; width: 100%; }
  .operations-table thead { display: none; }
  .operations-table tbody { display: grid; gap: 0; }
  .operations-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 2px 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
  }
  .operations-table td { display: none; height: auto; padding: 0; border: 0; }
  .operations-table td:is(.op-day, .op-kind, .op-asset, .op-total, .op-actions) { display: block; }
  .operations-table td.op-day { grid-column: 1; grid-row: 1; font-size: 0.78rem; color: var(--muted); }
  .operations-table td.op-kind { grid-column: 2; grid-row: 1; font-size: 0.78rem; }
  .operations-table td.op-actions { grid-column: 3; grid-row: 1 / 3; }
  .operations-table td.op-asset { grid-column: 1; grid-row: 2; max-width: none; width: auto; }
  .operations-table td.op-total { grid-column: 2; grid-row: 2; font-weight: 600; color: var(--text); text-align: right; }
}

.tabla-famfin thead th,
html[data-vista="tabla"] .lista-vista > .lista-cabecera {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

table.tabla-famfin {
  min-width: 0;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.tabla-famfin thead th {
  padding: 12px;
  vertical-align: middle;
  white-space: nowrap;
  background: transparent;
  border: 0;
}

.tabla-famfin tbody td,
.tabla-famfin tfoot :is(th, td) {
  height: 56px;
  padding: 8px 12px;
  color: var(--text-soft);
  vertical-align: middle;
  border-top: 1px solid var(--line);
}

.tabla-famfin :is(th, td):first-child { padding-left: 18px; }
.tabla-famfin :is(th, td):last-child { padding-right: 18px; }

/* The row's name goes in bold: the first column, or the asset when the first one is the date (Operaciones). */
.tabla-famfin tbody td:first-child,
.tabla-famfin tbody td:first-child strong,
.tabla-famfin tbody td.op-asset strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.tabla-famfin tbody td.op-day { font-size: inherit; font-weight: 400; color: var(--text-soft); white-space: nowrap; }

/* The name column takes the room: names fit in one or two lines instead of three. */
/* Names take what is left and break in up to two lines (then an ellipsis); the figures never break. */
.tabla-famfin :is(th, td):is(.pos-name, .op-asset) { width: 30%; }
.tabla-famfin td:is(.pos-name, .op-asset) { max-width: 0; }
.tabla-famfin td:is(.pos-name, .op-asset) strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.tabla-famfin td.pos-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabla-famfin td.op-asset > a { display: block; }

.tabla-famfin tfoot :is(th, td) { font-weight: 600; color: var(--text); }

.tabla-famfin :is(th, td).num,
.tabla-famfin :is(td.pos-shares, td.pos-avg, td.pos-cost, td.pos-value, td.pos-profit, td.pos-irr, td.pos-weight, td.op-shares, td.op-price, td.op-fee, td.op-total, td.op-gain) {
  text-align: right;
  white-space: nowrap;
}

.tabla-famfin th.num .column-sort { flex-direction: row-reverse; }

.tabla-famfin tbody tr { transition: background-color 0.2s ease; }
.tabla-famfin tbody tr:hover { background: var(--surface-2); }
.tabla-famfin tbody tr.position-account:hover,
.tabla-famfin tbody tr.position-empty:hover { background: none; }

/* Actions: quiet until the row is pointed at; always there without a hover. */
.tabla-famfin .row-actions .icon-button {
  position: relative;
  width: 28px;
  height: 28px;
}

.tabla-famfin .row-actions .icon-button::after { content: ""; position: absolute; inset: -8px; }

@media (hover: hover) {
  .tabla-famfin .row-actions .icon-button { opacity: 0; transition: opacity 0.2s ease, color 0.2s ease, background-color 0.2s ease; }
  .tabla-famfin tr:hover .row-actions .icon-button,
  .tabla-famfin .row-actions .icon-button:focus-visible { opacity: 1; }
  html[data-vista="tarjetas"] .positions-table .row-actions .icon-button { opacity: 1; }
}

.tabla-famfin .row-actions > div { margin-top: 0; }

/* Positions as cards: the rows are cards again, not table rows. */
html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row:hover { background: var(--surface); }

/* Operations: figures are never cut. */
.operations-table .op-total,
.operations-table .op-price,
.operations-table .op-fee,
.operations-table .op-gain { overflow: visible; }
.operations-table td.op-note { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

/* Positions / Operaciones tabs: the import button sits on the right of the same row. */
.inv-view-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.inv-view-switch > .segmented { min-width: 0; }
.inv-view-switch > .inv-import { flex-shrink: 0; }

html:not([data-inv-showing="positions"]):not([data-inv-showing="operations"]) .inv-import { display: none; }

@media (max-width: 600px) {
  .inv-import { min-width: 44px; min-height: 44px; justify-content: center; }
  .inv-import-label { display: none; }
}

.tabla-famfin tr:is(.closed, .unallocated) td:first-child strong { color: var(--muted); }
html[data-vista="tarjetas"] .positions-table:not(.operations-table) tr.position-row > td { height: auto; }
html[data-vista="tarjetas"] .tabla-card > .table-wrap:has(> .positions-table:not(.operations-table)) { padding: 0 12px 12px; }

/* The groups of the projection are round: so is their pill. */
.path-horizons .segmented-thumb { top: 4px; bottom: 4px; border-radius: 999px; }
/* Panel de control (/admin): la tabla global con unos añadidos mínimos. */
.kpi-state.on-light,
.kpi-state.on-light.is-warn,
.kpi-state.on-light.is-low { color: var(--text-soft); }
.admin-card { margin-bottom: 18px; }




.admin-table { min-width: 0; font-variant-numeric: tabular-nums; }
.admin-table th:first-child, .admin-table td:first-child { font-weight: 600; overflow-wrap: anywhere; }
.admin-table td { vertical-align: middle; }
.admin-note { display: block; margin-top: 2px; font-size: 0.78rem; font-weight: 400; color: var(--text-soft); }
.admin-2fa { max-width: 460px; }
/* Blanco también en modo oscuro y con 12 px de zona silenciosa: sin ella, los lectores no leen el QR. */
.admin-qr { box-sizing: content-box; width: 176px; max-width: calc(100% - 24px); padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.admin-qr svg { display: block; width: 100%; height: auto; }
.admin-secret { display: block; padding: 10px 12px; overflow-wrap: anywhere; font-size: 0.9rem; letter-spacing: 0.06em; background: var(--surface-2); border-radius: 9px; }
.admin-code-form { display: grid; gap: 12px; }
.admin-code-form input { width: 100%; min-height: 44px; padding: 0 12px; font-size: 1.1rem; font-variant-numeric: tabular-nums; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.admin-code-form input[name="code"] { letter-spacing: 0.2em; }
.admin-code-form .button { min-height: 44px; }
@media (max-width: 720px) {
  .admin-table .admin-secondary { display: none; }
}
@media (max-width: 480px) {
  .admin-table .admin-tertiary { display: none; }
}

/* Variable cobrado: the fold of the income's sheet, its panel to note a collection, the card's reminder */
/* A modal dialog stays position: fixed (centred in the viewport); it is the containing block of the panel anyway. */
#income-dialog { overflow: hidden; }
#income-dialog > .sheet-form:not(.vp-panel) {
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.3s cubic-bezier(0.2, 0, 0, 1);
}
#income-dialog.is-vp > .sheet-form:not(.vp-panel) { transform: translateX(-24%); opacity: 0; }
.vp-panel {
  position: absolute;
  inset: 0;
  max-height: none;
  min-height: 460px;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), visibility 0s linear 0.3s;
}
#income-dialog.is-vp .vp-panel {
  transform: none;
  visibility: visible;
  transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
  #income-dialog > .sheet-form:not(.vp-panel), .vp-panel, #income-dialog.is-vp .vp-panel { transition: none; }
}
.vp-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -8px 0 -4px -10px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
}
.vp-back:hover { background: var(--surface-2); }
.vp-back:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.vp-months button { min-height: 44px; }
.vp-months button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.vp-months button.has-payment::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  vertical-align: middle;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}
.vp-list { display: grid; margin: 0; padding: 0; list-style: none; }
.vp-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  align-items: center;
  padding: 9px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
}
.vp-row:hover { background: var(--surface-2); }
.vp-row:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.vp-row span:first-child { font-weight: 600; }
.vp-row span:not(:first-child) { color: var(--text-soft); text-align: right; }
.vp-empty, .vp-line, .vp-suggest p, .vp-live p { margin: 0; font-size: 0.8rem; color: var(--muted); }
.vp-live { display: grid; gap: 4px; min-height: 1.2em; }
.vp-live p { color: var(--text-soft); }
.vp-suggest { display: grid; gap: 6px; justify-items: start; }
.vp-suggest:empty { display: none; }
.vp-suggest p { color: var(--muted); }
.vp-error { margin: 0; font-size: 0.82rem; color: var(--coral-ink); }
.inc-reminder { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: 0.74rem; color: var(--muted); }
.inc-reminder i { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--layer-free); }
@media (max-width: 420px) {
  .vp-row { gap: 8px; font-size: 0.8rem; }
}
@media (pointer: coarse) {
  .bp-later { min-height: 44px; }
}
