.fs-budget-summary > div:first-child > div > p:first-child {
  color: var(--fipav-navy);
  font-size: 1.125rem;
  line-height: 1.35;
  font-weight: 650;
}

.fs-budget-kpi-area {
  container: budget-stats / inline-size;
}

.fs-budget-kpi-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--fipav-control-border, #d7e4f2);
  border-radius: var(--fipav-radius, 14px);
  background: var(--fipav-control-border, #d7e4f2);
}

.fs-budget-stat {
  min-width: 0;
  padding: 15px clamp(14px, 1.4cqi, 24px);
  background: white;
}

.fs-budget-stat-label {
  color: #526378;
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.4;
}

.fs-budget-stat dd {
  margin: 5px 0 0;
}

.fs-budget-stat-value {
  display: block;
  color: #172b45;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1rem, 1.7cqi, 1.375rem);
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.35;
  white-space: nowrap;
}

.fs-budget-stat-detail {
  display: block;
  margin-top: 6px;
  color: #526378;
  font-size: .75rem;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.fs-budget-stat.is-available {
  background: #edf5fc;
}

.fs-budget-stat.is-available :is(dt, .fs-budget-stat-value) {
  color: var(--fipav-blue, #005ba2);
}

.fs-budget-stat.is-over-budget {
  background: #fff1f2;
}

.fs-budget-stat.is-over-budget :is(dt, .fs-budget-stat-value) {
  color: #9f1239;
}

@container budget-stats (max-width: 53rem) {
  .fs-budget-kpi-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@container budget-stats (max-width: 19.5rem) {
  .fs-budget-kpi-list { grid-template-columns: minmax(0, 1fr); }
  .fs-budget-stat { padding: 12px 14px; }
}

/* Righe azzurre originali del Budget. Il titolo può usare più righe dentro la sua cella. */
.fs-budget-objectives { container: budget-objectives / inline-size; }

#main_content_data .fs-budget-objective-table > thead > tr > th {
  padding: 12px 16px;
  border-right-width: 0;
}
#main_content_data .fs-budget-objective-table > thead > tr > th:first-child h3 {
  white-space: normal;
  overflow-wrap: anywhere;
}
#main_content_data .fs-budget-objective-table > thead > tr > th:last-child {
  padding-inline: 6px;
}

/* Il dettaglio mantiene i codici CONI, la ricerca CRA e lo scorrimento locale. */
.fs-budget-objective-table:has(> thead button[aria-expanded="false"]) { min-width: 0; }
.fs-budget-objective-table:has(> thead button[aria-expanded="true"]) { min-width: 69rem; }
/* Capitoli e CRA condividono le colonne, che si adattano alla larghezza degli importi. */
.fs-budget-objective-table:has(> tbody),
.fs-budget-objective-table table {
  table-layout: auto;
}
.fs-budget-objective-table:has(> tbody) col:first-child,
.fs-budget-objective-table:has(> tbody) > thead > tr > th:first-child {
  width: auto;
}
/* Preventivo, Budget e Disponibile. La descrizione usa lo spazio rimanente. */
.fs-budget-objective-table:has(> tbody) col:is(:nth-child(2), :nth-child(4), :nth-child(6)) {
  width: 14%;
}
#main_content_data .fs-budget-objective-table > tbody > tr > td[colspan="8"] {
  padding-inline: 0;
}
#main_content_data .fs-budget-objective-table > tbody > tr > td { font-variant-numeric: tabular-nums; }
#main_content_data .fs-budget-objective-table .fs-budget-chapter-code {
  margin: 0 0 3px;
  color: #526579;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}
#main_content_data .fs-budget-objective-table > tbody > tr > td:first-child h3 {
  white-space: normal;
  overflow-wrap: anywhere;
}
#app #main_content_data .fs-budget-objective-table input[aria-label="Filtra CRA collegati"] {
  padding-left: 34px !important;
}
.fs-budget-objectives :is(tr,button):focus-visible, .fs-budget-cycle:focus-visible {
  outline: 2px solid var(--fipav-blue,#005ba2);
  outline-offset: -2px;
}

/* Sui display stretti i quattro importi chiusi mantengono l'etichetta sopra il valore. */
@container budget-objectives (max-width: 54rem) {
  .fs-budget-objective-table:has(> thead button[aria-expanded="false"]) {
    display: block;
  }
  .fs-budget-objective-table:has(> thead button[aria-expanded="false"]) > colgroup { display: none; }
  .fs-budget-objective-table > thead:has(button[aria-expanded="false"]) { display: block; }
  .fs-budget-objective-table > thead > tr:has(button[aria-expanded="false"]) {
    position: relative;
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
  }
  #main_content_data .fs-budget-objective-table > thead > tr:has(button[aria-expanded="false"]) > th {
    height: auto;
    width: auto;
    text-align: left;
  }
  .fs-budget-objective-table > thead > tr:has(button[aria-expanded="false"]) > th:first-child {
    grid-column: 1 / -1;
    padding-right: 60px !important;
  }
  .fs-budget-objective-table > thead > tr:has(button[aria-expanded="false"]) > th:last-child {
    position: absolute;
    top: 2px;
    right: 8px;
  }
}
@container budget-objectives (max-width: 35rem) {
  .fs-budget-objective-table > thead > tr:has(button[aria-expanded="false"]) {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}
