/* A single actionable figure inside the unified finance summary surface. */
#view-finance #fin-drag-container:not(.edit-mode) {
  grid-template-rows: 48px auto auto auto;
}

#view-finance #fin-drag-container:not(.edit-mode)::before {
  grid-row: 1 / 5;
}

#view-finance #fin-drag-container:not(.edit-mode) > #fin-monthend-band {
  box-sizing: border-box;
  grid-column: 1 / -1;
  grid-row: 3;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  min-width: 0;
  margin: 0 18px;
  padding: 15px 4px;
  border-top: 1px solid var(--ci-border);
  color: var(--ci-dark);
}

#view-finance #fin-drag-container:not(.edit-mode) > [data-block="averages"] {
  grid-row: 4;
}

.fin-monthend-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.fin-monthend-label {
  color: var(--ci-red);
  font-size: 15px;
  font-weight: 750;
}

.fin-monthend-note {
  color: #71665a;
  font-size: 12px;
  line-height: 1.45;
}

.fin-monthend-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-width: min(100%, 410px);
}

.fin-monthend-figure {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.fin-monthend-figure small {
  color: #71665a;
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.fin-monthend-figure strong {
  font-size: clamp(20px, 2vw, 28px);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.fin-monthend-gap-figure strong { color: #a32d2d; }
.fin-monthend-gap-figure.is-enough strong { color: #3b6d11; }

#fin-monthend-total {
  color: var(--ci-red);
}

@container page (max-width: 1079px) {
  #view-finance #fin-drag-container:not(.edit-mode) {
    grid-template-rows: 48px auto auto auto auto;
  }
  #view-finance #fin-drag-container:not(.edit-mode)::before { grid-row: 1 / 6; }
  #view-finance #fin-drag-container:not(.edit-mode) > #fin-monthend-band { grid-row: 4; }
  #view-finance #fin-drag-container:not(.edit-mode) > [data-block="averages"] { grid-row: 5; }
}

@container page (max-width: 759px) {
  #view-finance #fin-drag-container:not(.edit-mode) {
    grid-template-rows: 46px auto auto auto auto auto;
  }
  #view-finance #fin-drag-container:not(.edit-mode)::before { grid-row: 1 / 7; }
  #view-finance #fin-drag-container:not(.edit-mode) > #fin-monthend-band {
    grid-column: 1;
    grid-row: 5;
    align-items: flex-start;
    flex-direction: column;
    margin: 0 15px;
    padding: 14px 0;
  }
  #view-finance #fin-drag-container:not(.edit-mode) > [data-block="averages"] { grid-row: 6; }
  .fin-monthend-figures { width: 100%; min-width: 0; }
  .fin-monthend-figure:first-child { align-items: flex-start; }
  .fin-monthend-figure:first-child small { text-align: left; }
  .fin-monthend-figure strong { font-size: clamp(18px, 5.3vw, 28px); }
}

#view-finance #fin-drag-container.edit-mode > #fin-monthend-band {
  display: none;
}

@media print {
  #view-finance #fin-drag-container:not(.edit-mode) > #fin-monthend-band {
    margin: 0 0 16px;
  }
}
