/*
 * Synthèses opérationnelles NOURIVOIRE
 * Ces vues sont accessibles uniquement depuis les boutons des journaux concernés.
 * Elles n'altèrent pas le module "Synthèses générales" ni ses sous-modules.
 */
.nrv-op-synth {
  padding: 10px 12px 18px;
  box-sizing: border-box;
}

.nrv-op-synth .nrv-op-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin: 0 0 10px;
  background: #fff;
  border: 1px solid #d5dbe3;
  border-radius: 12px;
}

.nrv-op-synth .nrv-op-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 150px;
}

.nrv-op-synth .nrv-op-field.nrv-op-field-commercial {
  min-width: 230px;
}

.nrv-op-synth .nrv-op-field label {
  font-size: 13px;
  font-weight: 800;
  color: #17202a;
  white-space: nowrap;
}

.nrv-op-synth .nrv-op-field select,
.nrv-op-synth .nrv-op-field input[type="date"] {
  height: 38px;
  min-width: 150px;
  padding: 0 10px;
  border: 1px solid #aeb9c6;
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 700;
  box-sizing: border-box;
}

.nrv-op-synth .nrv-op-field input[readonly] {
  background: #eef2f6;
  color: #273746;
}

.nrv-op-synth .nrv-op-field select:disabled {
  background: #eef2f6;
  color: #273746;
  opacity: 1;
  cursor: not-allowed;
}

.nrv-op-synth .nrv-op-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nrv-op-synth .nrv-op-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #9aa7b5;
  border-radius: 8px;
  background: #f4f6f8;
  color: #101820;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.nrv-op-synth .nrv-op-actions button.nrv-op-primary {
  background: #2d7688;
  border-color: #245f6d;
  color: #fff;
}

.nrv-op-synth .nrv-op-actions button:hover:not(:disabled) {
  filter: brightness(.97);
  transform: translateY(-1px);
}

.nrv-op-synth .nrv-op-actions button:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.nrv-op-synth .nrv-op-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 30px;
  padding: 4px 2px 8px;
}

.nrv-op-synth .nrv-op-message {
  min-height: 20px;
  font-size: 13px;
  font-weight: 800;
  color: #1b5e20;
}

.nrv-op-synth .nrv-op-period-label {
  font-size: 12px;
  font-weight: 800;
  color: #1f4b5c;
  background: #edf7fb;
  border: 1px solid #cfe6ef;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.nrv-op-synth .nrv-op-table-scroll {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 285px);
  min-height: 250px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  overflow-anchor: none;
  background: #fff;
  border: 1px solid #aeb7c1;
  border-radius: 8px;
}

.nrv-op-synth table.nrv-op-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: #fff;
  color: #000;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.nrv-op-synth table.nrv-op-table th,
.nrv-op-synth table.nrv-op-table td {
  min-width: 88px;
  height: 34px;
  padding: 4px 7px;
  border-right: 1px solid #222;
  border-bottom: 1px solid #222;
  text-align: center;
  vertical-align: middle;
  font-size: 12px;
  line-height: 1.15;
  box-sizing: border-box;
  white-space: nowrap;
}

.nrv-op-synth table.nrv-op-table tr > :first-child {
  border-left: 1px solid #222;
}

.nrv-op-synth table.nrv-op-table thead tr:first-child > th {
  border-top: 1px solid #222;
}

.nrv-op-synth table.nrv-op-table thead th {
  position: sticky;
  background: #dce6f1;
  font-weight: 900;
  white-space: normal;
  overflow-wrap: anywhere;
  z-index: 5;
}

.nrv-op-synth table.nrv-op-table thead tr:nth-child(1) th {
  top: 0;
  height: 38px;
}

.nrv-op-synth table.nrv-op-table thead tr:nth-child(2) th {
  top: 38px;
  height: 38px;
}

.nrv-op-synth table.nrv-op-table thead tr:nth-child(3) th {
  top: 76px;
  height: 36px;
}

/*
 * Colonne GAMMES figée.
 * Important : on cible uniquement la première cellule réelle du tableau.
 * Les premiers TH des 2e et 3e lignes d'en-tête (ex. UNITÉS) ne doivent
 * jamais devenir sticky, sinon ils se superposent à la colonne GAMMES.
 */
.nrv-op-synth table.nrv-op-table thead tr:first-child > th:first-child,
.nrv-op-synth table.nrv-op-table tbody tr:not(.nrv-op-group-row) > td:first-child,
.nrv-op-synth table.nrv-op-table tfoot > tr > td:first-child,
.nrv-op-synth table.nrv-op-table tbody tr.nrv-op-group-row > td.nrv-op-group-label {
  position: sticky;
  left: 0;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  text-align: left;
  font-weight: 800;
  white-space: normal;
  background: #f2f6d5;
  z-index: 4;
}

.nrv-op-synth table.nrv-op-table thead tr:first-child > th:first-child {
  background: #dce6f1;
  z-index: 12;
  text-align: center;
}

/* Ligne de gamme scindée : le libellé reste visible pendant le défilement horizontal. */
.nrv-op-synth table.nrv-op-table tbody tr.nrv-op-group-row > td {
  background: #d9d9d9;
  font-weight: 900;
  text-align: left;
  letter-spacing: .2px;
}

.nrv-op-synth table.nrv-op-table tbody tr.nrv-op-group-row > td.nrv-op-group-label {
  background: #d9d9d9;
  z-index: 7;
  white-space: nowrap;
}

.nrv-op-synth table.nrv-op-table tbody tr.nrv-op-group-row > td.nrv-op-group-fill {
  position: static;
  padding: 0;
}

.nrv-op-synth table.nrv-op-table tbody tr.nrv-op-total-row td {
  background: #e9f1b9;
  font-weight: 900;
}

.nrv-op-synth table.nrv-op-table tbody tr:hover td:not(.nrv-op-no-hover) {
  background-color: #f6fbfd;
}

.nrv-op-synth table.nrv-op-table tbody tr:not(.nrv-op-group-row):hover td:first-child {
  background-color: #edf3bd;
}

.nrv-op-synth table.nrv-op-table tfoot td {
  position: sticky;
  bottom: 0;
  background: #d9d9d9;
  font-weight: 900;
  z-index: 4;
}

.nrv-op-synth table.nrv-op-table tfoot td:first-child {
  background: #d9d9d9;
  z-index: 6;
}

.nrv-op-synth table.nrv-op-table td.nrv-op-negative {
  color: #c00000;
  font-weight: 900;
}

.nrv-op-synth table.nrv-op-table td.nrv-op-zero {
  color: #333;
}

.nrv-op-synth .nrv-op-empty {
  padding: 22px;
  text-align: center;
  color: #566573;
  font-weight: 700;
}

/* Largeurs adaptées à chaque synthèse sans compresser les valeurs. */
#synthese_operationnelle_emballage_stock_usine table.nrv-op-table { min-width: 1260px; }
#synthese_operationnelle_stock_bureau_vente table.nrv-op-table { min-width: 1620px; }
#synthese_operationnelle_vente_versement table.nrv-op-table { min-width: 1850px; }
#synthese_operationnelle_vente_versement table.nrv-op-table th,
#synthese_operationnelle_vente_versement table.nrv-op-table td { min-width: 96px; }

/*
 * La synthèse Emballage / Stock usine est centrée lorsqu'elle tient dans la zone.
 * Si l'écran est plus étroit, le tableau conserve sa largeur et reste défilable.
 */
#synthese_operationnelle_emballage_stock_usine table.nrv-op-table {
  margin-inline: auto;
}

/* Alignement initial fiable de la synthèse Stock bureau / Vente. */
#synthese_operationnelle_stock_bureau_vente .nrv-op-table-scroll {
  scroll-padding-left: 160px;
}

/* Les nouveaux boutons restent accolés au bouton Synthèse d'origine. */
.nrv-op-launch-button {
  margin-left: 6px;
}

@media (max-width: 1100px) {
  .nrv-op-synth .nrv-op-actions {
    width: 100%;
    margin-left: 0;
  }
  .nrv-op-synth .nrv-op-table-scroll {
    max-height: calc(100vh - 340px);
  }
}

@media print {
  .nrv-op-synth .nrv-op-toolbar,
  .nrv-op-synth .nrv-op-status-line {
    display: none !important;
  }
  .nrv-op-synth .nrv-op-table-scroll {
    max-height: none;
    overflow: visible;
    border: 0;
  }
  .nrv-op-synth table.nrv-op-table th,
  .nrv-op-synth table.nrv-op-table td,
  .nrv-op-synth table.nrv-op-table tfoot td,
  .nrv-op-synth table.nrv-op-table thead tr:first-child > th:first-child,
  .nrv-op-synth table.nrv-op-table tbody tr > td:first-child,
  .nrv-op-synth table.nrv-op-table tbody tr.nrv-op-group-row > td.nrv-op-group-label {
    position: static !important;
  }
}

/* Correctif ciblé 2026-07-28 : synthèse Vente - Versement. */
#venteForm .vente-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#venteForm .vente-form-actions #syntheseBtnVenteVersementDepuisVente.nrv-op-launch-button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: auto !important;
  min-width: 205px;
  max-width: 100%;
  height: 38px;
  margin: 0 !important;
  padding: 0 16px;
  border: 1px solid #d8b08a;
  border-radius: 10px;
  background: #fff7f2;
  color: #6b3d13;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
  box-sizing: border-box;
}

#venteForm .vente-form-actions #syntheseBtnVenteVersementDepuisVente.nrv-op-launch-button:hover {
  background: #fff0e5;
  border-color: #bd8b5e;
}

/* Colonnes calibrées : les sous-en-têtes ne débordent plus et restent alignés. */
#opVvTable col.nrv-op-vv-col-gamme { width: 165px; }
#opVvTable col.nrv-op-vv-col-unite { width: 88px; }
#opVvTable col.nrv-op-vv-col-montant { width: 126px; }
#opVvTable col.nrv-op-vv-col-creance-debut { width: 150px; }
#opVvTable col.nrv-op-vv-col-pu { width: 142px; }
#opVvTable col.nrv-op-vv-col-recouvrement { width: 150px; }
#opVvTable col.nrv-op-vv-col-creance { width: 158px; }

#synthese_operationnelle_vente_versement table.nrv-op-table {
  min-width: 2210px;
  table-layout: fixed;
}

#synthese_operationnelle_vente_versement table.nrv-op-table th,
#synthese_operationnelle_vente_versement table.nrv-op-table td {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
}

#synthese_operationnelle_vente_versement table.nrv-op-table thead th {
  padding: 4px 5px;
  line-height: 1.08;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

#synthese_operationnelle_vente_versement .nrv-op-vv-creance-heading,
#synthese_operationnelle_vente_versement .nrv-op-vv-money-subhead {
  text-align: center;
  white-space: normal;
}

#synthese_operationnelle_vente_versement .nrv-op-vv-money-subhead {
  background: #dce6f1;
  font-weight: 900;
}

/* Le tableau et les deux barres horizontales repartent toujours de la première colonne. */
#synthese_operationnelle_vente_versement .nrv-op-table-scroll {
  scroll-padding-left: 165px;
}

@media (max-width: 980px) {
  #venteForm .vente-form-actions #syntheseBtnVenteVersementDepuisVente.nrv-op-launch-button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
}

/* ========================================================================
 * Correctif 2026-07-29 : navigation horizontale Synthèse Vente-Versement
 * - le tableau reste strictement contenu dans son cadre ;
 * - la colonne GAMMES conserve une largeur identique dans thead/tbody/tfoot ;
 * - le TOTAL GÉNÉRAL ne se contracte plus et ne laisse plus les cellules
 *   numériques glisser sous son libellé pendant le défilement horizontal.
 * ======================================================================== */
#synthese_operationnelle_vente_versement .nrv-op-table-scroll {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
  isolation: isolate;
}

#synthese_operationnelle_vente_versement #opVvTable {
  width: 2207px;
  min-width: 2207px;
  max-width: none;
  margin: 0;
  table-layout: fixed;
}

/* Largeur unique de la colonne figée dans toutes les zones du tableau. */
#synthese_operationnelle_vente_versement #opVvTable thead tr:first-child > th:first-child,
#synthese_operationnelle_vente_versement #opVvTable tbody tr:not(.nrv-op-group-row) > td:first-child,
#synthese_operationnelle_vente_versement #opVvTable tbody tr.nrv-op-group-row > td.nrv-op-group-label,
#synthese_operationnelle_vente_versement #opVvTable tfoot > tr > td:first-child {
  left: 0;
  width: 165px !important;
  min-width: 165px !important;
  max-width: 165px !important;
  box-sizing: border-box;
}

/* Le pied reste aligné sur le colgroup, sans chevauchement des cellules. */
#synthese_operationnelle_vente_versement #opVvTable tfoot td {
  bottom: 0;
  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;
  background-clip: padding-box;
}

#synthese_operationnelle_vente_versement #opVvTable tfoot td:first-child {
  z-index: 30;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  background: #d9d9d9 !important;
  box-shadow: 2px 0 0 #222;
}

#synthese_operationnelle_vente_versement #opVvTable tfoot td:not(:first-child) {
  z-index: 8;
}

/* La barre supérieure créée par table_top_navigation.js reste dans le cadre. */
#synthese_operationnelle_vente_versement .ni-top-scroll-nav {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
}


/* ========================================================================
 * Correctif 2026-07-30 : débordement horizontal des synthèses opérationnelles
 * Emballage stock usine / Stock bureau - Vente.
 * ======================================================================== */
#synthese_operationnelle_emballage_stock_usine,
#synthese_operationnelle_stock_bureau_vente {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

#synthese_operationnelle_emballage_stock_usine .nrv-op-table-scroll,
#synthese_operationnelle_stock_bureau_vente .nrv-op-table-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  box-sizing: border-box;
  isolation: isolate;
  scrollbar-gutter: stable;
}

#opSuTable col.nrv-op-col-gamme,
#opSbvTable col.nrv-op-col-gamme { width: 190px; }
#opSuTable col.nrv-op-col-unite,
#opSbvTable col.nrv-op-col-unite { width: 88px; }
#opSuTable col.nrv-op-col-masse,
#opSbvTable col.nrv-op-col-masse { width: 110px; }

#synthese_operationnelle_emballage_stock_usine #opSuTable {
  width: 1378px;
  min-width: 1378px;
  max-width: none;
  margin-inline: auto;
  table-layout: fixed;
}
#synthese_operationnelle_stock_bureau_vente #opSbvTable {
  width: 1774px;
  min-width: 1774px;
  max-width: none;
  margin: 0;
  table-layout: fixed;
}

#opSuTable th, #opSuTable td,
#opSbvTable th, #opSbvTable td {
  min-width: 0 !important;
  max-width: none;
  overflow: hidden;
  text-overflow: clip;
  box-sizing: border-box;
  background-clip: padding-box;
}

#opSuTable thead tr:first-child > th:first-child,
#opSuTable tbody tr:not(.nrv-op-group-row) > td:first-child,
#opSuTable tbody tr.nrv-op-group-row > td.nrv-op-group-label,
#opSuTable tfoot > tr > td:first-child,
#opSbvTable thead tr:first-child > th:first-child,
#opSbvTable tbody tr:not(.nrv-op-group-row) > td:first-child,
#opSbvTable tbody tr.nrv-op-group-row > td.nrv-op-group-label,
#opSbvTable tfoot > tr > td:first-child {
  left: 0;
  width: 190px !important;
  min-width: 190px !important;
  max-width: 190px !important;
  box-sizing: border-box;
  box-shadow: 2px 0 0 #222;
}

#opSuTable tfoot td,
#opSbvTable tfoot td {
  bottom: 0;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
}
#opSuTable tfoot td:first-child,
#opSbvTable tfoot td:first-child {
  z-index: 30;
  background: #d9d9d9 !important;
  text-align: left;
  padding-left: 10px;
}
#opSuTable tfoot td:not(:first-child),
#opSbvTable tfoot td:not(:first-child) { z-index: 8; }

#opSuTable tbody tr.nrv-op-group-row > td.nrv-op-group-label,
#opSbvTable tbody tr.nrv-op-group-row > td.nrv-op-group-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#synthese_operationnelle_emballage_stock_usine .ni-top-scroll-nav,
#synthese_operationnelle_stock_bureau_vente .ni-top-scroll-nav {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
}
