/* Canonical product-page rhythm from the Navorina design system.
 * This file is loaded last by every sidebar route. Page styles own component
 * internals; this contract alone owns the distance between page islands. */

:root {
  --nv-section-island-gap: var(--spacing-2xl, 24px);
  --nv-section-control-gap: var(--spacing-sm, 8px);
  --nv-section-header-gap: var(--spacing-5xl, 40px);
  --nv-section-page-end: var(--spacing-6xl, 48px);
  --nv-viewport-bottom-fade-size: clamp(88px, 11vh, 136px);
}

body.dash-page {
  --dash-island-gap: var(--nv-section-island-gap);
  --dash-main-aside-gap: var(--nv-section-island-gap);
  --dash-shell-content-space: var(--nv-section-header-gap);
  /* Global nested-surface contract. This file is loaded last by every product
     section, so legacy page CSS cannot split the light palette into 4/6/8% grays. */
  --dash-inner-surface: var(--color-surface-inset, var(--color-well));
  --dash-wallet-action-surface: var(--color-surface-inset, var(--color-well));
  --dash-activity-surface: var(--color-surface-inset, var(--color-well));
  --nv-kpi-surface: var(--color-surface-inset, var(--color-well));
  --dash-aside-surface: var(--color-surface-inset, var(--color-well));
  --dash-aside-field: var(--color-surface-inset, var(--color-well));
  --nv-section-surface-soft: var(--color-surface-inset, var(--color-well));
  --nv-section-row-hover: var(--color-surface-inset-hover, var(--color-well-hover));
  --nv-section-row-selected: var(--color-surface-inset-selected, var(--color-well));
  --nv-section-control-surface: var(--color-surface-inset, var(--color-well));
  --nv-section-control-hover: var(--color-surface-inset-hover, var(--color-well-hover));
  --nv-card-tile: var(--color-surface-inset, var(--color-well));
  --nv-card-tile-hover: var(--color-surface-inset-hover, var(--color-well-hover));
  --nv-action-surface: var(--color-surface-inset, var(--color-well));
  --nv-action-surface-hover: var(--color-surface-inset-hover, var(--color-well-hover));
  /* The DS wells (Get started glyphs, welcome, tour, wallet and account pages read --nv-table-well): without it they
     fell back to white at 4%, invisible on a light island (owner 2026-11-06). The same inset as the controls. */
  --nv-table-well: var(--color-surface-inset, var(--color-well));
  /* One plate for every row glyph: merchant logos, monograms, Upcoming and Needs attention icons, account coins and
     Get started glyphs, fully round (owner 2026-11-18). A text tint, the same as the stat icons, so the plate reads on
     an island, a table well and an inset panel alike; a solid inset vanished into the wells (owner 2026-11-18). */
  --nv-row-avatar-bg: color-mix(in srgb, var(--dash-text, #eeeeee) 8%, transparent);
}

/* Light islands have one calm inset at rest. Legacy organisms sometimes used
   the darker hover token for persistent controls and selected states; normalize
   those static fills to the same surface as the Taxes detail cells. The zero-state actions (.nv-zero, table and
   Transactions empty buttons) are not among them: each is the solid inverted pill (nv-zero-state.css), and an inset plate under its light label made it unreadable.
   Nor are the DS choice chips (nv-choice-chips.css): a pick is filled like the owner's chat bubble, with a light label. */
:is(html.light, html.light-theme) body.dash-page :is(
  .nv-o-table__status--neutral,
  .nv-o-table__page[aria-current="page"],
  .nv-m-chip[aria-pressed="true"]:not(.nv-choice-chip),
  .nv-o-topbar__search kbd,
  .nv-o-dialog-sizes__bar,
  .nv-tax-chart .nv-m-tabs__tab[aria-pressed="true"],
  .nv-tax__aside .tax-filing-detail__actions :first-child,
  .acct-detail__button--primary,
  .acct-month-close__button--primary,
  .inc-cat__icon,
  .tx-page-btn.is-active,
  .settings-ds-button:not(.settings-ds-button--primary, .settings-ds-button--danger),
  .settings-ds-billing-plan__status,
  .settings-ds-row__icon,
  .settings-ds-connection__mark,
  .inv-status--draft,
  .pay-status,
  .nv-ntf .nv-m-tabs__tab:is([aria-selected="true"], [aria-pressed="true"]),
  .nv-ntf-tools .nv-m-chip[aria-pressed="true"],
  .api-hub__mark,
  .api-list-row__mark
) {
  background: var(--color-surface-inset, var(--color-well)) !important;
}

/* The calm inset above is the rest state only: secondary buttons still answer hover. */
:is(html.light, html.light-theme) body.dash-page .settings-ds-button:not(.settings-ds-button--primary, .settings-ds-button--danger):hover:not(:disabled) {
  background: color-mix(in srgb, var(--dash-text) 9%, transparent) !important;
}

/* One viewport-level fade for every product section. It belongs to the shell,
   not to a table or island, and the shared runtime only reveals it while the
   active content scroller has more content below the browser edge. */
body.dash-page .dash-main {
  position: relative;
}

body.dash-page .nv-viewport-bottom-fade {
  position: absolute;
  z-index: 8;
  inset-inline: 0;
  inset-block-end: 0;
  block-size: var(--nv-viewport-bottom-fade-size);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  /* The page background (--dash-canvas, gray in the light theme), like the header fade it mirrors: --dash-bg is the
     island white, which laid a white band over the gray page and the rail. */
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--dash-canvas, var(--dash-bg, #050505)) 22%, transparent) 30%,
    color-mix(in srgb, var(--dash-canvas, var(--dash-bg, #050505)) 76%, transparent) 72%,
    var(--dash-canvas, var(--dash-bg, #050505)) 100%
  );
  transition:
    opacity 180ms ease-out,
    visibility 0s linear 180ms;
}

body.dash-page .nv-viewport-bottom-fade.is-visible {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  body.dash-page .nv-viewport-bottom-fade {
    transition: none;
  }
}

/* The shell owns page insets. Keep the visible distance from the header
   controls to the first page island on the same axis as the island stack. */
body.dash-page .dash-main > .dash-workspace-content {
  padding-block-start: 0 !important;
  padding-block-end: var(--nv-section-page-end) !important;
}

/* Settings can render a verified preview instead of the live content root.
   Both branches obey the same shell inset and end-space contract. */
body.dash-page .dash-main > :is(.wsp-preview, .acct-settings-preview) {
  width: min(
    calc(100% - var(--dash-workspace-margin-right) - var(--dash-workspace-margin-right)),
    var(--dash-main-max-width)
  ) !important;
  inline-size: min(
    calc(100% - var(--dash-workspace-margin-right) - var(--dash-workspace-margin-right)),
    var(--dash-main-max-width)
  ) !important;
  margin-inline: auto !important;
  padding-block-start: 0 !important;
  padding-block-end: var(--nv-section-page-end) !important;
  padding-inline: 0 !important;
}

body.dash-page .dash-main > .dash-workspace-content > :last-child {
  margin-block-end: 0 !important;
}

@media (max-width: 800px) {
  :root {
    --nv-section-header-gap: var(--spacing-2xl, 24px);
  }
}

body.dash-page .dash-main > :is(.wsp-preview, .acct-settings-preview) > :last-child {
  margin-block-end: 0 !important;
}

/* Shell content, section stacks, main columns and right rails use one axis. */
body.dash-page .dash-main > .dash-workspace-content,
body.dash-page :is(
  .dash-content--flat-workspace,
  .nv-tx, .nv-pay, .nv-inv, .nv-acc, .nv-ops,
  .nv-bud, .nv-inc, .nv-tax, .nv-acct, .nv-ins,
  .nv-ntf, .nv-hlp,
  .nv-ins__main, .nv-ins__aside, .nv-ins .ins-aside-rest,
  .nv-ins .ins-briefing, .nv-ins .ins-briefing__grid,
  .nv-ins .ins-journal, .nv-ins .ins-journal__workspace,
  .set-main, .set-aside,
  .settings-ds-current__main,
  .settings-ds-current__aside
) {
  gap: var(--nv-section-island-gap) !important;
}

body.dash-page :is(
  .tx-layout, .pay-layout, .inv-layout, .acc-layout, .ops-layout,
  .bud-layout, .inc-layout, .tax-layout, .acct-layout, .ins-layout,
  .nv-ntf__layout, .nv-hlp__layout, .set-layout,
  .settings-ds-current__layout
) {
  column-gap: var(--nv-section-rail-gap, var(--nv-section-island-gap)) !important;
  row-gap: var(--nv-section-island-gap) !important;
}

/* A 24 px frame surrounds content. Use smaller steps for groups and inset wells. */
body.dash-page .dash-workspace-content {
  --nv-island-content-gap: var(--spacing-lg, 16px);
  --nv-island-inset-pad: var(--spacing-md, 12px);
  --nv-island-inset-gap: var(--spacing-sm, 8px);
}

body.dash-page .dash-workspace-content :is(
  .aud-card, .aud-panel, .invd-card, .invd-panel,
  .payd-card, .payd-panel, .txd-card, .txd-panel
):not(.nv-o-table) {
  padding: var(--nv-island-padding, 24px);
}

/* Additional product stacks; landing previews follow the same rhythm as the product. */
body.dash-page :is(
  .api-layout, .api-layout__main, .api-layout__aside, .plan-cards,
  .wsp-preview__content, .aud-layout, .aud-main, .aud-aside,
  .invd-layout, .invd-main, .invd-aside, .payd-layout, .payd-main, .payd-aside,
  .txd-layout, .txd-main, .txd-aside
) {
  gap: var(--nv-section-island-gap) !important;
}

/* The section role covers card and chart heads inside product content. */
@media (width > 800px) {
  body.dash-page {
    --nv-section-island-gap: var(--spacing-4xl, 32px);
    /* The main column and the right rail sit 32px further apart than stacked islands
       (owner 2026-11-18), so the rail reads as context, not a continuation of the main column. */
    --nv-section-rail-gap: calc(var(--nv-section-island-gap) + var(--spacing-4xl, 32px));
    --dash-main-aside-gap: var(--nv-section-rail-gap);
    --nv-section-title-size: 1.375rem;
    --nv-section-title-tracking: -0.018em;
  }

  body.dash-page .dash-workspace-content :is(
    .dash-card__title, .dash-month-summary__head h2,
    .nv-o-table__heading, .nv-o-card__title, .nv-chart__title,
    .set-card__title, .set-panel__title, .prof-card__title, .sec-card__title,
    .bill-card__title, .ops-panel__title, .pay-card__title, .plan-card__name,
    .wsp-preview__section-title, .acct-settings-preview__section-title,
    .aud-card__title, .invd-card__title, .payd-card__title, .txd-card__title
  ):not(:where(dialog *, [role="dialog"] *)) {
    font-size: var(--nv-section-title-size);
    font-weight: var(--nv-type-weight-semibold, 600);
    letter-spacing: var(--nv-section-title-tracking);
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
}

/* Controls are a compact group; their spacing must not inherit island rhythm. */
body.dash-page :is(
  .nv-ntf-bar,
  .nv-hlp-bar,
  .nv-ntf-selects,
  .nv-hlp-tools
) {
  gap: var(--nv-section-control-gap) !important;
}

@media (max-width: 800px) {
  :root {
    --nv-section-island-gap: var(--spacing-lg, 16px);
    --nv-section-page-end: calc(
      var(--dash-content-pad-bottom, var(--dash-tab-bar-height, 72px)) +
      var(--spacing-2xl, 24px)
    );
  }

  body.dash-page .dash-main > .dash-workspace-content {
    padding-inline: var(--dash-mobile-page-x, var(--spacing-lg, 16px)) !important;
  }

  body.dash-page .dash-main > :is(.wsp-preview, .acct-settings-preview) {
    padding-inline: var(--dash-mobile-page-x, var(--spacing-lg, 16px)) !important;
  }
}

/* Proximity: a filter toolbar belongs to the content it filters, so it sits
   12 px above that content while the KPI row above follows the section rhythm. */
:root {
  --nv-section-toolbar-gap: var(--spacing-md, 12px);
}

body.dash-page :is(
  .dash-workspace-content,
  .nv-tx, .nv-pay, .nv-inv, .nv-acc, .nv-ops,
  .nv-bud, .nv-inc, .nv-tax, .nv-acct
) > :is(
  .nv-acc-tools, .nv-ops-tools, .nv-bud-tools, .nv-inc-tools,
  .nv-inv-tools, .nv-tax-tools, .nv-acct-tools
) {
  /* The stack gap stays the single owner; the toolbar only pulls the next
     visible row closer, whatever hidden nodes sit between them in the DOM. */
  margin-block-end: calc(var(--nv-section-toolbar-gap) - var(--nv-section-island-gap)) !important;
}

/* Legacy row avatars share the DS mark and merchant logo plate. */
body.dash-page :is(
  .dash-activity-row__avatar, .dash-account-row__icon, .dash-spending-row__icon,
  .tx-desc__avatar, .tx-account__flag, .pay-recipient__avatar, .pay-account-cell__flag,
  .inv-client__avatar, .acc-account__icon, .acc-activity__icon,
  .bud-cat__icon, .inc-cat__icon, .tax-filing__icon, .rpt-report__icon, .ops-activity__icon
) {
  inline-size: var(--nv-row-avatar-size, 32px);
  block-size: var(--nv-row-avatar-size, 32px);
  min-inline-size: var(--nv-row-avatar-size, 32px);
  flex: none;
  border-radius: 50% !important;
  overflow: hidden;
  /* Pages without ds-support-primitives.css (Home) still get the neutral plate and glyph. */
  background-color: var(--nv-row-avatar-bg, color-mix(in srgb, var(--dash-text) 10%, transparent)) !important;
  color: var(--nv-table-avatar-text, var(--dash-text-muted));

  /* A nested merchant logo owns the only plate. */
  &:has(> .nv-a-logo) {
    background: none !important;
  }
}

/* Full-size empty sections use the same island as the dashboard's empty Activity. */
body.dash-page :is(
  .tx-table-card:has([data-preview-transactions-state]:not([hidden]) [data-preview-transactions-action]:not([hidden])),
  .inv-table-card:has([data-preview-invoices-state]:not([hidden]) [data-preview-invoices-action]:not([hidden])),
  .bud-table-card:has([data-preview-budgets-state]:not([hidden]) [data-preview-budgets-action]:not([hidden])),
  .inc-table-card:has([data-preview-income-state]:not([hidden]) [data-preview-income-action]:not([hidden])),
  .tax-table-card:has([data-preview-taxes-state]:not([hidden]) [data-preview-taxes-action]:not([hidden])),
  [data-inv-domain-zero]:not([hidden]),
  .rpt-library:has(> [data-mbx-empty]:not([hidden], .nv-zero--match)),

  .nv-o-table:has(.nv-o-table__empty > [data-nv-entity-new]),
  .nv-ntf-inbox:has(> [data-notification-empty]:not([hidden], .nv-zero--match))
) {
  background: var(--nv-surface-solid, var(--dash-card-on-workspace));
  /* The zero inside keeps the full DS state (figure, title, one line, action, 468 px) like every section. */
}

body.acc-page .acc-main :is(
  .nv-acc-table:has(#accDataStateRow:not([hidden]) #accDataStateAction:not([hidden])),
  .nv-o-getpaid:has(> .nv-o-getpaid__zero-row),
  .nv-o-wallets:has(> .nv-o-wallets__zero-row)
) {
  background: var(--nv-surface-solid, var(--dash-card-on-workspace));
}

body.mbx-page .rpt-library:has(> [data-mbx-empty]:not([hidden], .nv-zero--match)) {
  container-type: inline-size;
}

/* Landing previews are monochrome like the brand: merchant and provider logos in the demo lose their colour. */
html.dash-landing-preview :is(.nv-a-logo__img, .dash-activity-row__avatar--asset img) {
  filter: grayscale(1);
}

/* Fiat marks are the sign alone (no coin of their own): they sit on the shared row plate and take the same quiet
   silhouette as padded merchant logos, so a € never outshines the icons around it (owner 2026-11-18). */
body.dash-page img[src*="transaction-icons/fiat/"] {
  /* The sign alone at the plate's icon size (16-18 px glyph in a 32 px plate), not edge to edge. */
  inline-size: 75% !important;
  block-size: 75% !important;
  filter: var(--nv-logo-mark-filter, brightness(0) invert(1));
  opacity: var(--nv-logo-mark-opacity, .62);
}

:is(html.light-theme, html.light, :root[data-appearance="light"]) body.dash-page img[src*="transaction-icons/fiat/"] {
  --nv-logo-mark-filter: brightness(0);
  --nv-logo-mark-opacity: .58;
}

/* Shell geometry for every sidebar section (owner 2026-11-18). Above 1280px the content ends at the same
   inset from the right edge as the sidebar items from the left, so a right rail hugs the edge. The main
   column (up to 1040px) is centred in the space between the sidebar and a 376px rail, at least 64px from
   each; the shell starts at the main column's left edge, so the header search, single-column sections
   and the main column of two-column sections share one left axis. The start is a registered length,
   computed once against the dash-main container and inherited as pixels by every layout inside. */
@property --nv-shell-start {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

@media (min-width: 1281px) {
  body.dash-page .dash-main > * {
    --nv-shell-edge: calc(var(--dash-sidebar-outer-gutter, 0px) + var(--spacing-lg, 16px));
    --nv-shell-track: calc(100cqi - var(--nv-shell-edge) - var(--dash-aside-width, 376px));
    --nv-shell-start: calc((var(--nv-shell-track) - min(var(--nv-shell-track) - 2 * var(--spacing-8xl, 64px), var(--nv-shell-main-max, 1040px))) / 2);
  }

  body.dash-page .dash-main > :is(
    .dash-header, main, .dash-content, [class$="-content"], [class*="-content "],
    .wsp-preview, .acct-settings-preview
  ) {
    width: auto !important;
    inline-size: auto !important;
    max-inline-size: none !important;
    margin-inline: var(--nv-shell-start) var(--nv-shell-edge) !important;
  }

  /* Two-column sections: the gap takes what centring leaves, so the rail lands on the right edge. */
  body.dash-page:not([data-nucleus-dashboard-welcome="photos"], [data-nucleus-dashboard-welcome="first"]) :is(
    .dash-content--flat-workspace > .dash-grid,
    .tx-layout, .pay-layout, .inv-layout, .acc-layout, .ops-layout,
    .bud-layout, .inc-layout, .tax-layout, .acct-layout, .ins-layout,
    .nv-ntf__layout, .nv-hlp__layout, .set-layout, .settings-ds-current__layout,
    .rpt-layout, .bill-layout, .aud-layout, .ntc-layout, .int-layout, .payd-layout, .txd-layout,
    .api-layout, .invd-layout
  ) {
    column-gap: var(--nv-shell-start) !important;
  }
}

/* Sections air and type (owner 2026-11-19): every section reads on the Home scale (dashboard-rhythm.css, Home air and
   Home type), wider than the phone.
     island padding  28 px: the canonical token, so card islands, table edges and rail panels move together
     island title    22/600, tables included (they were 24, Insights 16)
     row name        14/20 medium (tables were 15)
     amount          14/20 semibold, tabular figures
     row line        12/16 under a name, a date or an amount; KPI and module captions that were 11 px
   Secondary cells (dates, categories) stay 13 px; calendar chips keep their compact sizes. */
@media (min-width: 801px) {
  body.dash-page:not(.dash-home) {
    --nv-island-padding: 28px;
  }

  body.dash-page:not(.dash-home) .dash-main :is(.nv-o-table__heading, .acct-table-card__title, .acc-panel__title, .nv-o-card__title, .set-card__title, .set-panel__title, .nv-o-mtiles__heading, .ins-money__island > header h2, .nv-inv-cal__titlebar h2) {
    font-size: 22px !important;
    font-weight: var(--nv-type-weight-semibold, 600) !important;
    line-height: 27.5px;
    letter-spacing: -0.018em;
  }

  body.dash-page:not(.dash-home) .dash-main :is(.tx-desc__link, .tx-account__name, .acc-account__link, .acct-filing__link, .bud-cat__name, .inc-cat__link, .inc-cat__name, .inv-client__name, .inv-invoice-detail-link, .inv-due__date, .tax-filing__name, .set-row__label, .acc-activity__account, .nv-m-subs__name, .nv-m-spend__payee-name) {
    font-size: var(--nv-type-body-size, 14px);
    font-weight: var(--nv-type-weight-medium, 500);
    line-height: 20px;
  }

  body.dash-page:not(.dash-home) .dash-main :is(.tx-amount__primary, .acc-balance__primary, .acc-activity__amount, .acct-amount, .inc-money, .inv-amount, .nv-m-subs__amount, .nv-m-spend__payee-amount) {
    font-size: var(--nv-type-body-size, 14px);
    font-weight: var(--nv-type-weight-semibold, 600);
    font-variant-numeric: tabular-nums;
    line-height: 20px;
  }

  body.dash-page:not(.dash-home) .dash-main :is(.tx-desc__sub, .tx-account__mask, .acct-filing__sub, .inc-cat__sub, .inv-amount__sub, .inv-due__sub, .inv-invoice-date, .tax-filing__sub, .tax-due__note, .acc-activity__desc, .nv-o-stat__meta, .nv-m-subs__meta, .nv-m-subs__yearly, .nv-m-spend__payee-meta, .nv-m-donut__share, .nv-m-donut__label) {
    font-size: var(--nv-type-footnote-size, 12px);
    line-height: 16px;
    letter-spacing: 0;
  }

  /* The key figure of an island: Insights' Spending and Subscriptions as on Home. */
  body.dash-page:not(.dash-home) .dash-main :is(.nv-m-spend__value, .nv-m-subs__value) {
    font-size: 28px;
    line-height: 34px;
    letter-spacing: -0.02em;
  }

  /* In a rail (Insights' Subscriptions) the key figure takes the rail size, like Runway on Home, so it never cuts. */
  body.dash-page:not(.dash-home) .dash-main :is(.ins-rail, [class*="__aside"], [class*="-aside"]) :is(.nv-m-spend__value, .nv-m-subs__value) {
    font-size: 20px;
    line-height: 26px;
    letter-spacing: -0.015em;
  }
}
