/* Active Installments register layout contract.
   Keep the page itself naturally scrollable while giving the account register
   its own predictable vertical browsing surface. */

html:has([data-testid="finance-active-installments"]),
body:has([data-testid="finance-active-installments"]),
.bwl-shell:has([data-testid="finance-active-installments"]),
.bwl-shell:has([data-testid="finance-active-installments"]) .bwl-main,
.bwl-shell:has([data-testid="finance-active-installments"]) .bwl-content {
  min-height: 100vh !important;
  height: auto !important;
  max-height: none !important;
  overflow-y: visible !important;
  overflow-x: clip;
}

/* Scope the register rules to this page only so other Finance screens are untouched. */
[data-testid="finance-active-installments"] {
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: visible !important;
}

[data-testid="finance-active-installments"] .finance-accounts__panel {
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: visible !important;
}

/*
 * The register is the scroll surface on desktop/tablet.
 * Rows are content-sized: cards must NEVER be forced to the height of the
 * entire scroll container. That was the source of the oversized/overlapping
 * card behaviour and made information appear to disappear below the viewport.
 */
[data-testid="finance-active-installments"] .finance-accounts__grid {
  display: grid;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: min(68dvh, 58rem);
  max-height: min(68dvh, 58rem);
  min-height: 26rem;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 0.35rem 0.75rem 0.9rem 0.2rem;
  gap: 0.85rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-items: start;
  align-content: start;
}

[data-testid="finance-active-installments"] .finance-accounts__grid > .finance-accounts__card {
  width: 100%;
  min-width: 0;
  min-height: 0 !important;
  height: auto !important;
  align-self: start;
  overflow: visible;
}

[data-testid="finance-active-installments"] .finance-accounts__card-head,
[data-testid="finance-active-installments"] .finance-accounts__facts,
[data-testid="finance-active-installments"] .finance-accounts__actions {
  min-width: 0;
}

[data-testid="finance-active-installments"] .finance-accounts__actions {
  align-items: stretch;
}

[data-testid="finance-active-installments"] .finance-accounts__actions a,
[data-testid="finance-active-installments"] .finance-accounts__actions button {
  min-width: 0;
  max-width: 100%;
}

[data-testid="finance-active-installments"] .finance-accounts__grid::-webkit-scrollbar {
  width: 12px;
}

[data-testid="finance-active-installments"] .finance-accounts__grid::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(23, 99, 60, 0.08);
}

[data-testid="finance-active-installments"] .finance-accounts__grid::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(23, 99, 60, 0.48);
  background-clip: padding-box;
}

[data-testid="finance-active-installments"] .finance-accounts__grid::-webkit-scrollbar-thumb:hover {
  background: rgba(23, 99, 60, 0.68);
  background-clip: padding-box;
}

@media (max-width: 1280px) {
  [data-testid="finance-active-installments"] .finance-accounts__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  [data-testid="finance-active-installments"] .finance-accounts__grid {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
    min-height: 0;
    overflow-y: visible !important;
    overflow-x: visible !important;
    padding-right: 0.15rem;
  }

  html:has([data-testid="finance-active-installments"]),
  body:has([data-testid="finance-active-installments"]),
  .bwl-shell:has([data-testid="finance-active-installments"]) .bwl-main,
  .bwl-shell:has([data-testid="finance-active-installments"]) .bwl-content {
    overflow-y: visible !important;
  }
}
