/* Restyle pagina Commesse (docs/AnalisiCommesseGrafica.md, prototipo docs/PropostaCommesseRinnovo.html).
   Ogni regola futura sta sotto body.nh-v2: in produzione il foglio e' inerte e non va mai usato fuori dall'ambiente di test.
   Per tornare indietro: togliere il <link> e la proprieta' CommesseV2CssHref in App.razor, oppure git revert; tag di ritorno pre-restyle-commesse. */

/* ---------- Elenco: binario degli stati (CommesseStageTrack) ---------- */
body.nh-v2 {
  /* Ardesia del costo/ricavi secondari: nessun colore nuovo, e' lo stesso neutro dei badge "neutral" del sito. */
  --cm-slate: #475569;
}

body.nh-v2 .commesse-stages {
  display: flex;
  align-items: stretch;
  margin: 0 0 14px;
  padding: 4px 6px 2px;
}

body.nh-v2 .commesse-stage {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 0 12px 6px 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

body.nh-v2 .commesse-stage:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body.nh-v2 .commesse-stage-line {
  position: relative;
  display: flex;
  align-items: center;
  height: 28px;
}

/* Linea che collega la stazione alla successiva; l'ultima non ne ha. */
body.nh-v2 .commesse-stage-line::after {
  content: "";
  flex: 1;
  height: 3px;
  margin-left: 6px;
  border-radius: 2px;
  background: var(--primary);
}

body.nh-v2 .commesse-stage:last-child .commesse-stage-line::after {
  display: none;
}

body.nh-v2 .commesse-stage-node {
  position: relative;
  flex: none;
  width: 22px;
  height: 22px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: var(--surface);
  transition: background-color .2s, box-shadow .2s;
}

body.nh-v2 .commesse-stage.is-on .commesse-stage-node {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .18);
}

body.nh-v2 .commesse-stage.is-on .commesse-stage-node::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--surface);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

/* Stazione vuota: nodo e linea tratteggiati. */
body.nh-v2 .commesse-stage.is-empty .commesse-stage-node {
  border-style: dashed;
  border-color: var(--border-strong);
}

body.nh-v2 .commesse-stage.is-empty .commesse-stage-line::after {
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 11px);
}

body.nh-v2 .commesse-stage-name {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

body.nh-v2 .commesse-stage:hover .commesse-stage-name,
body.nh-v2 .commesse-stage.is-on .commesse-stage-name {
  color: var(--primary-ink);
}

body.nh-v2 .commesse-stage-vals {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}

body.nh-v2 .commesse-stage-count {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

body.nh-v2 .commesse-stage.is-empty .commesse-stage-count {
  color: var(--muted);
}

body.nh-v2 .commesse-stage-sum {
  color: var(--cm-slate);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  body.nh-v2 .commesse-stage-node {
    transition: none;
  }
}

/* ---------- Elenco: celle ---------- */
body.nh-v2 .commesse-rows-table .commesse-cell-sub {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}

body.nh-v2 .commesse-rows-table .commesse-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

body.nh-v2 .commesse-rows-table .commesse-frozen-lock {
  display: inline-grid;
  color: var(--cm-slate);
}

/* Stato "Chiuso": stessa pillola neutra, attenuata (classe extra is-muted da CommessaEconomicsRules.BadgeExtraClass). */
body.nh-v2 .chip.neutral.is-muted {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

body.nh-v2 .commesse-rows-table .commesse-money {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

body.nh-v2 .commesse-rows-table .commesse-margin {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Margine = successo (scurito per il contrasto sul bianco), negativo = pericolo. */
body.nh-v2 .commesse-rows-table .commesse-margin-amount {
  color: color-mix(in srgb, var(--success) 85%, black);
}

body.nh-v2 .commesse-rows-table .commesse-margin-pct {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

body.nh-v2 .commesse-rows-table .commesse-margin.is-negative .commesse-margin-amount,
body.nh-v2 .commesse-rows-table .commesse-margin.is-negative .commesse-margin-pct {
  color: var(--danger);
}

/* ---------- Elenco: stato vuoto (la riga fantasma e' essa stessa l'azione) ---------- */
body.nh-v2 .commesse-rows-table .smart-table-empty--custom {
  display: block;
  padding: 14px;
}

body.nh-v2 .commesse-empty-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  height: 120px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--primary-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .12s, color .12s, background-color .12s;
}

body.nh-v2 button.commesse-empty-ghost:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

body.nh-v2 .commesse-empty-ghost:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

body.nh-v2 .commesse-empty-ghost:disabled {
  cursor: default;
  opacity: .6;
}

body.nh-v2 .commesse-empty-ghost.is-static {
  color: var(--muted);
  cursor: default;
}

/* =====================================================================================================
   Corpo della commessa v2 (CommessaBodyEditor con UseV2): banda identita', binario delle revisioni,
   conto sticky con lente sul ramo, albero a 6 colonne con peso, pannello laterale della riga.
   Prototipo: docs/PropostaCommesseRinnovo.html. Costo = ardesia (--cm-slate), margine = successo, negativo = pericolo.
   ===================================================================================================== */

body.nh-v2 .commesse-v2-body {
  /* Lo sticky del conto non funziona dentro una scheda con overflow nascosto. */
  overflow: visible !important;
  padding-bottom: 8px;
}

body.nh-v2 .cm-num {
  font-variant-numeric: tabular-nums;
}

body.nh-v2 .cm-back-row {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}

/* ---------- Banda identita' ---------- */
body.nh-v2 .cm-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 28px;
  align-items: start;
  padding-bottom: 16px;
}

body.nh-v2 .cm-band-id {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

body.nh-v2 .cm-band-code {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.01em;
}

body.nh-v2 .cm-band-desc {
  margin-top: 3px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

body.nh-v2 .cm-band-desc2 {
  margin-top: 1px;
  color: var(--cm-slate);
  font-size: 14px;
  font-weight: 600;
}

body.nh-v2 .cm-band-who {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 700;
}

body.nh-v2 .cm-band-who > span {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
}

body.nh-v2 .cm-band-who small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

body.nh-v2 .cm-band-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  margin-top: 10px;
}

body.nh-v2 .cm-band-dates > div {
  display: flex;
  flex-direction: column;
}

body.nh-v2 .cm-band-dates small {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}

body.nh-v2 .cm-band-dates b {
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

body.nh-v2 .cm-band-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

/* ---------- Binario delle revisioni (CommessaRevisionTrack) ---------- */
body.nh-v2 .cm-revs {
  display: flex;
  align-items: center;
  padding-top: 2px;
}

body.nh-v2 .cm-rev-seg {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--border-strong);
}

body.nh-v2 .cm-rev-seg.is-on {
  background: var(--primary);
}

body.nh-v2 .cm-rev {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--cm-slate);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, background-color .2s;
}

body.nh-v2 .cm-rev:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-ink);
}

body.nh-v2 .cm-rev.is-current {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--surface);
}

body.nh-v2 .cm-rev.is-view {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .22);
}

body.nh-v2 .cm-rev:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

body.nh-v2 .cm-rev:disabled {
  cursor: default;
  opacity: .55;
}

/* Lucchetto della revisione congelata: tondo ambra sul bordo, come il lucchetto dell'elenco. */
body.nh-v2 .cm-rev-lock {
  position: absolute;
  right: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--warning);
  color: var(--surface);
  box-shadow: 0 0 0 2px var(--surface);
}

body.nh-v2 .cm-rev-lock svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2.6;
}

body.nh-v2 .cm-rev.is-add {
  border-style: dashed;
  background: var(--surface);
  color: var(--primary-ink);
  font-size: 18px;
}

body.nh-v2 .cm-rev.is-add:hover:not(:disabled) {
  background: var(--primary-soft);
}

body.nh-v2 .cm-revs .cm-rev-freeze {
  margin-left: 14px;
}

/* ---------- Conto della commessa (CommessaAccountBar) ---------- */
body.nh-v2 .cm-account {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  margin: 0 -16px;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(4px);
  box-shadow: 0 10px 18px -14px rgba(15, 23, 42, .35);
}

body.nh-v2 .cm-account-in {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 76px;
  padding: 8px 0 12px;
}

body.nh-v2 .cm-scope {
  flex: none;
  width: 150px;
  color: var(--cm-slate);
  font-size: 15px;
  line-height: 1.25;
}

body.nh-v2 .cm-scope b {
  display: block;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

body.nh-v2 .cm-eq {
  display: flex;
  align-items: center;
  gap: 16px;
}

body.nh-v2 .cm-fig small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.1;
}

body.nh-v2 .cm-fig b {
  display: block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

body.nh-v2 .cm-fig-big b {
  color: color-mix(in srgb, var(--success) 85%, black);
  font-size: 26px;
}

body.nh-v2 .cm-fig-big[data-neg="true"] b {
  color: var(--danger);
}

body.nh-v2 .cm-op {
  color: var(--muted);
  font-size: 22px;
  font-weight: 600;
}

body.nh-v2 .cm-pct {
  margin-left: 6px;
  padding: 3px 12px;
  border: 1px solid color-mix(in srgb, var(--success) 35%, white);
  border-radius: 999px;
  background: var(--success-soft);
  color: color-mix(in srgb, var(--success) 85%, black);
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

body.nh-v2 .cm-pct[data-neg="true"] {
  border-color: color-mix(in srgb, var(--danger) 35%, white);
  background: var(--danger-soft);
  color: color-mix(in srgb, var(--danger) 80%, black);
}

body.nh-v2 .cm-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

/* Barra costo|margine in fondo al conto. Il margine negativo fa tutta la barra in pericolo. */
body.nh-v2 .cm-bar {
  position: absolute;
  inset: auto 0 -1px;
  display: flex;
  height: 5px;
}

body.nh-v2 .cm-bar i {
  display: block;
  height: 100%;
  transition: width .45s cubic-bezier(.16, 1, .3, 1);
}

body.nh-v2 .cm-bar-k {
  background: var(--cm-slate);
}

body.nh-v2 .cm-bar-k[data-neg="true"] {
  background: var(--danger);
}

body.nh-v2 .cm-bar-m {
  background: var(--success);
}

/* Ricerca unica: icona e casella del sito in un riquadro solo. */
body.nh-v2 .cm-search {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 232px;
  padding-left: 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

body.nh-v2 .cm-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .16);
}

body.nh-v2 .cm-search svg {
  flex: none;
}

body.nh-v2 .cm-search .dxbl-text-edit,
body.nh-v2 .cm-search .form-control {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body.nh-v2 .cm-search input {
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
  color: var(--text);
}

/* Riga compatta della revisione in modifica righe. */
body.nh-v2 .cm-meta-edit {
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  padding: 14px 0 4px;
}

/* ---------- Albero a 6 colonne (DxTreeList.commesse-tree-v2) ---------- */
body.nh-v2 .commesse-tree-v2 {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > thead th,
body.nh-v2 .commesse-tree-v2 .dxbl-grid-header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface-soft) !important;
  color: var(--cm-slate) !important;
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  cursor: default;
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr > td {
  padding: 9px 14px;
  border-color: var(--border) !important;
  background: var(--surface) !important;
  color: var(--text);
  font-size: 14px;
  vertical-align: middle;
  transition: background-color .15s;
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr:hover > td {
  background: var(--primary-soft) !important;
}

/* Lente sul ramo: sfondo tenue + filo a sinistra, niente opacita' che sbiadisce le altre righe. */
body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr.in-lens > td {
  background: var(--primary-soft) !important;
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr.in-lens > td:first-child {
  box-shadow: inset 3px 0 0 var(--primary) !important;
}

body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr:has(.cm-row.is-group) > td {
  font-weight: 700;
}

body.nh-v2 .cm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

body.nh-v2 .cm-grp-mark {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--primary);
}

body.nh-v2 .cm-vtext {
  min-width: 0;
}

body.nh-v2 .cm-name {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.nh-v2 .cm-row.is-group .cm-name {
  font-weight: 800;
}

body.nh-v2 .cm-name:hover,
body.nh-v2 .cm-name.is-selected {
  color: var(--primary-ink);
}

body.nh-v2 .cm-name:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

body.nh-v2 .cm-vsub {
  display: flex;
  gap: 4px 10px;
  min-width: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.nh-v2 .cm-vsub-code {
  color: var(--cm-slate);
}

body.nh-v2 .cm-n1 {
  display: block;
  white-space: nowrap;
}

body.nh-v2 .cm-n2 {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

/* Quota sul padre: barra sottile costo|margine allineata a destra. */
body.nh-v2 .cm-peso {
  display: flex;
  justify-content: flex-end;
  height: 4px;
  margin-top: 4px;
}

body.nh-v2 .cm-peso i {
  display: block;
  height: 100%;
  min-width: 2px;
}

body.nh-v2 .cm-peso .is-cost {
  border-radius: 2px 0 0 2px;
  background: var(--cm-slate);
}

body.nh-v2 .cm-peso .is-margin {
  border-radius: 0 2px 2px 0;
  background: var(--success);
}

body.nh-v2 .cm-peso .is-neg {
  border-radius: 2px;
  background: var(--danger);
}

body.nh-v2 .cm-mg {
  display: block;
  white-space: nowrap;
}

body.nh-v2 .cm-mg.is-neg .cm-n1,
body.nh-v2 .cm-mg.is-neg .cm-n2 {
  color: var(--danger);
  font-weight: 800;
}

body.nh-v2 .cm-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Stato vuoto dell'albero: riga fantasma che e' essa stessa l'azione. */
body.nh-v2 .cm-tree-ghost {
  width: calc(100% - 28px);
  height: 72px;
  margin: 14px;
}

/* ---------- Dock ---------- */
body.nh-v2 .cm-dock {
  margin-top: 16px;
}

body.nh-v2 .cm-dock-danger {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* I due Elimina non sono figli diretti di .modal-form-actions.has-danger: stesse regole del sito, con il rosso pieno
   che il tema DevExpress non deve sbiadire. */
body.nh-v2 .cm-dock-danger .btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  min-width: 122px;
  justify-self: start;
}

/* ---------- Pannello laterale della riga ---------- */
body.nh-v2 .cm-node-form {
  grid-template-columns: 1fr 1fr;
  gap: 18px 16px;
}

body.nh-v2 .cm-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
}

body.nh-v2 .cm-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

body.nh-v2 .cm-preview > div {
  min-width: 0;
  padding: 8px 14px;
}

body.nh-v2 .cm-preview > div + div {
  border-left: 1px solid var(--border);
}

body.nh-v2 .cm-preview small {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

body.nh-v2 .cm-preview b {
  display: block;
  font-size: 16px;
  font-weight: 800;
}

body.nh-v2 .cm-preview-margin b {
  color: color-mix(in srgb, var(--success) 85%, black);
}

body.nh-v2 .cm-preview-margin.is-neg b {
  color: var(--danger);
}

/* Conferme: chip con il numero di righe figlie. */
body.nh-v2 .cm-confirm-extra {
  display: inline-block;
  margin: 2px 0 8px;
  padding: 2px 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, white);
  border-radius: 999px;
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 60%, black);
  font-size: 13px;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  body.nh-v2 .cm-rev,
  body.nh-v2 .cm-bar i,
  body.nh-v2 .commesse-tree-v2 .dxbl-grid-table > tbody > tr > td {
    transition: none;
  }
}

/* ---------- Testata: pannello laterale e pagina nuova (stessi gruppi) ---------- */
body.nh-v2 .cm-head-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

body.nh-v2 .cm-head-form > .cm-form-group {
  grid-column: 1 / -1;
  margin: 8px 0 -2px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

body.nh-v2 .cm-head-form > .cm-form-group:first-child {
  margin-top: 0;
}

/* Pagina della commessa nuova: colonna di lettura, dock in fondo. */
body.nh-v2 .cm-new-page .cm-head-form {
  max-width: 880px;
}

body.nh-v2 .cm-new-page .cm-head-dock {
  max-width: 880px;
  margin-top: 20px;
}

/* ---------- Gestione OMZ: grafica del prototipo Commesse_Prototipo (font, token e misure del prototipo; solo area OMZ) ---------- */
body.nh-v2 .cm-o{
  --bg:#EEF1F3; --surface:#FFFFFF; --surface2:#E6EBEE; --line:#D3DBE0; --fg:#16212A; --muted:#5A6A75;
  --accent:#0E6877; --accent-soft:#D9ECF0; --accent-fg:#FFFFFF;
  --buy:#B05C08; --buy-soft:#F9E8D3; --good:#2B7A4B; --good-soft:#DAEFE2; --bad:#B3392F;
  --f-display:'Barlow Semi Condensed','Arial Narrow',sans-serif;
  --f-body:'IBM Plex Sans',system-ui,sans-serif;
  --f-mono:'IBM Plex Mono',ui-monospace,Consolas,monospace;
  display:flex; flex-direction:column; gap:14px; margin:0 0 14px; padding:16px;
  background:var(--bg); color:var(--fg); font:400 14px/1.45 var(--f-body); box-sizing:border-box; max-width:100%;
}
body.nh-v2 .cm-o[data-theme="dark"]{
  --bg:#0E1518; --surface:#162025; --surface2:#1E2B31; --line:#2B3A41; --fg:#E5ECEF; --muted:#8CA0AA;
  --accent:#4DB5C5; --accent-soft:#143840; --accent-fg:#06222A;
  --buy:#E9A24D; --buy-soft:#3B2B15; --good:#5CC389; --good-soft:#163425; --bad:#EF7A70;
  color-scheme:dark;
}
body.nh-v2 .cm-o *{box-sizing:border-box}
/* Come .app del prototipo: contenuto largo al massimo 1500px e centrato (le finestre sovrapposte restano a tutto schermo) */
body.nh-v2 .cm-o>:not(.o-ov){width:100%;max-width:none}
body.nh-v2 .cm-o button,body.nh-v2 .cm-o input,body.nh-v2 .cm-o select{font:inherit;color:inherit}
body.nh-v2 .cm-o button{cursor:pointer;background:none;border:0;padding:0;margin:0;min-height:0;min-width:0;height:auto;box-shadow:none;border-radius:0;line-height:inherit;text-transform:none;letter-spacing:normal;transform:none;filter:none}
body.nh-v2 .cm-o input,body.nh-v2 .cm-o select{min-height:0;height:auto;box-shadow:none;margin:0}
body.nh-v2 .cm-o input[type=checkbox]{appearance:auto;-webkit-appearance:checkbox;width:13px;height:13px;min-width:13px;margin:3px 3px 3px 4px;padding:0;accent-color:var(--accent);background:none;background-image:none;border:0;border-radius:2px;box-shadow:none;transition:none}
/* Il sito impone con !important font di label e campi, colori dei campi disabilitati: dentro l'area OMZ vince il prototipo */
body.nh-v2 .cm-o label{font-family:var(--f-body)!important;font-weight:400!important}
body.nh-v2 .cm-o input,body.nh-v2 .cm-o select{font-family:var(--f-body)!important;font-weight:400!important}
body.nh-v2 .cm-o .o-revsel select{font-weight:500!important}
body.nh-v2 .cm-o select,body.nh-v2 .cm-o input{color:var(--fg)!important;-webkit-text-fill-color:var(--fg)!important}
body.nh-v2 .cm-o .o-fld.f1 input{font-family:var(--f-display)!important;font-weight:600!important}
body.nh-v2 .cm-o input.o-mono,body.nh-v2 .cm-o input.o-num{font-family:var(--f-mono)!important}
body.nh-v2 .cm-o input:disabled,body.nh-v2 .cm-o select:disabled{background:var(--surface)!important;color:var(--fg)!important;-webkit-text-fill-color:var(--fg)!important;opacity:1!important}
body.nh-v2 .cm-o .o-tw td input:disabled,body.nh-v2 .cm-o .o-tw td select:disabled{background:transparent!important}
body.nh-v2 .cm-o :focus-visible{outline:2px solid var(--accent);outline-offset:2px}
body.nh-v2 .cm-o :disabled{cursor:not-allowed}
body.nh-v2 .cm-o .o-num{font-family:var(--f-mono);font-variant-numeric:tabular-nums;text-align:right;white-space:nowrap}
body.nh-v2 .cm-o .o-mono{font-family:var(--f-mono)}
body.nh-v2 .cm-o .o-muted{color:var(--muted)}
body.nh-v2 .cm-o .o-lbl{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:500}
body.nh-v2 .cm-o .o-sp{flex:1}

body.nh-v2 .cm-o .o-top{background:var(--surface);border:1px solid var(--line);border-radius:6px;display:flex;flex-wrap:wrap;gap:12px 26px;align-items:center;padding:12px 16px}
body.nh-v2 .cm-o .o-id{display:flex;flex-direction:column;min-width:0;flex:1 1 300px}
body.nh-v2 .cm-o .o-top h1{font:600 22px/1.15 var(--f-display);margin:2px 0 0;letter-spacing:.01em;color:var(--fg)}
body.nh-v2 .cm-o .o-pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:500;padding:2px 9px;border-radius:99px;background:var(--accent-soft);color:var(--accent);white-space:nowrap}
body.nh-v2 .cm-o .o-pill i{width:7px;height:7px;border-radius:50%;background:currentColor;display:inline-block}
body.nh-v2 .cm-o .o-pill.frz{background:var(--buy-soft);color:var(--buy)}
body.nh-v2 .cm-o .o-kpis{display:flex;gap:24px;flex-wrap:wrap}
body.nh-v2 .cm-o .o-kpi{display:flex;flex-direction:column;gap:1px}
body.nh-v2 .cm-o .o-kpi b{font:500 19px var(--f-mono);font-variant-numeric:tabular-nums}
body.nh-v2 .cm-o .o-kpi.big b{font-size:24px}
body.nh-v2 .cm-o .o-revsel{display:flex;flex-direction:column;gap:2px}
body.nh-v2 .cm-o .o-revsel select{background:var(--surface);border:1px solid var(--line);border-radius:4px;padding:5px 8px;font-weight:500}
body.nh-v2 .cm-o .o-theme{background:transparent;border:1px solid var(--line);border-radius:6px;padding:5px 10px;color:var(--muted);font-size:12px}

body.nh-v2 .cm-o .o-tabs{display:flex;gap:2px;border-bottom:1px solid var(--line);flex-wrap:wrap}
body.nh-v2 .cm-o .o-tabs button{background:transparent;border:0;padding:9px 15px;font-weight:500;color:var(--muted);border-bottom:2px solid transparent;margin-bottom:-1px}
body.nh-v2 .cm-o .o-tabs button[aria-selected=true]{color:var(--accent);border-bottom-color:var(--accent)}
body.nh-v2 .cm-o .o-cnt{font:11px var(--f-mono);background:var(--surface2);border-radius:99px;padding:1px 7px;margin-left:6px;color:var(--muted)}

body.nh-v2 .cm-o .o-banner{background:var(--buy-soft);color:var(--buy);border:1px solid var(--buy);border-radius:6px;padding:8px 14px;display:flex;gap:12px;align-items:center;flex-wrap:wrap}
body.nh-v2 .cm-o .o-banner.err{background:var(--surface);color:var(--bad);border-color:var(--bad)}

body.nh-v2 .cm-o .o-split{display:grid;grid-template-columns:minmax(420px,560px) minmax(0,1fr);gap:14px;align-items:start}
body.nh-v2 .cm-o .o-panel{background:var(--surface);border:1px solid var(--line);border-radius:6px;min-width:0}
body.nh-v2 .cm-o .o-panel-h{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--line);flex-wrap:wrap}
body.nh-v2 .cm-o .o-panel-h h2{font:600 15px var(--f-display);letter-spacing:.04em;text-transform:uppercase;margin:0;flex:1;color:var(--fg)}
body.nh-v2 .cm-o .o-chk{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);margin:0}

body.nh-v2 .cm-o .o-tree{padding:0 4px 6px;max-height:calc(100vh - 260px);min-height:260px;overflow:auto}
body.nh-v2 .cm-o .o-tn{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:4px;cursor:pointer;min-width:0;border:0;background:none;width:100%;text-align:left}
body.nh-v2 .cm-o .o-tn:hover{background:var(--surface2)}
body.nh-v2 .cm-o .o-tn[aria-current=true]{background:var(--accent-soft)}
body.nh-v2 .cm-o .o-tn.art{padding:3px 8px 3px 32px;font-size:12.5px;color:var(--muted)}
body.nh-v2 .cm-o .o-tn.art .o-nm{font-weight:400}
body.nh-v2 .cm-o .o-caret{width:18px;height:18px;flex:none;display:grid;place-items:center;color:var(--muted);border-radius:3px}
body.nh-v2 .cm-o .o-caret:hover{background:var(--line)}
body.nh-v2 .cm-o .o-caret svg{transition:transform .12s}
body.nh-v2 .cm-o .o-caret.open svg{transform:rotate(90deg)}
body.nh-v2 .cm-o .o-nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}
body.nh-v2 .cm-o .o-c-pc{width:44px;text-align:right;font:11px var(--f-mono);color:var(--muted);flex:none}
body.nh-v2 .cm-o .o-c-tot{width:84px;text-align:right;font:12px var(--f-mono);font-variant-numeric:tabular-nums;flex:none}
body.nh-v2 .cm-o .o-sub{display:flex;gap:6px;align-items:center;margin-top:3px}
body.nh-v2 .cm-o .o-tn-head{position:sticky;top:0;z-index:1;display:flex;gap:6px;padding:6px 8px 5px;margin-bottom:2px;background:var(--surface);border-bottom:1px solid var(--line);font-size:10.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:500}
body.nh-v2 .cm-o .o-tag{font:500 10.5px var(--f-mono);padding:1px 6px;border-radius:3px;background:var(--surface2);color:var(--muted);white-space:nowrap}
body.nh-v2 .cm-o .o-tag.db{background:var(--accent-soft);color:var(--accent)}
body.nh-v2 .cm-o .o-kids{margin-left:15px;border-left:1px solid var(--line);padding-left:3px}
body.nh-v2 .cm-o .o-mix{flex:1;height:3px;border-radius:2px;background:var(--buy);overflow:hidden;margin-top:0}
body.nh-v2 .cm-o .o-mix i{display:block;height:100%;background:var(--accent)}
body.nh-v2 .cm-o .o-dotm{width:7px;height:7px;border-radius:2px;flex:none}

body.nh-v2 .cm-o .o-node-h{padding:14px 16px 0;display:flex;flex-direction:column;gap:10px}
body.nh-v2 .cm-o .o-crumbs{font-size:12px;color:var(--muted);display:flex;gap:4px;flex-wrap:wrap;align-items:center}
body.nh-v2 .cm-o .o-crumbs button{background:none;border:0;padding:0;color:var(--muted);text-decoration:underline;text-underline-offset:2px}
body.nh-v2 .cm-o .o-crumbs button:hover{color:var(--accent)}
body.nh-v2 .cm-o .o-node-title{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:10px;align-items:end}
body.nh-v2 .cm-o .o-fld{display:flex;flex-direction:column;gap:3px;min-width:0;margin:0}
body.nh-v2 .cm-o .o-fld input,body.nh-v2 .cm-o .o-fld select{background:var(--surface);border:1px solid var(--line);border-radius:4px;padding:6px 8px;width:100%}
body.nh-v2 .cm-o .o-fld input:hover,body.nh-v2 .cm-o .o-fld select:hover{border-color:var(--muted)}
body.nh-v2 .cm-o .o-fld input:disabled,body.nh-v2 .cm-o .o-fld select:disabled{opacity:1;color:var(--fg);cursor:default}
body.nh-v2 .cm-o .o-fld.f1 input{font:600 18px var(--f-display);letter-spacing:.01em}
body.nh-v2 .cm-o .o-addf{display:flex;gap:8px;flex-wrap:wrap;align-items:flex-end;padding:12px 16px;border-top:1px solid var(--line);background:var(--surface2);border-radius:0 0 6px 6px}
body.nh-v2 .cm-o .o-addf .o-fld{flex:1 1 110px}
body.nh-v2 .cm-o .o-nstats{display:flex;gap:22px;flex-wrap:wrap;padding:12px 16px;align-items:flex-end}
body.nh-v2 .cm-o .o-nstats .o-kpi b{font-size:17px}
body.nh-v2 .cm-o .o-split-bar{flex:1 1 170px;min-width:150px;display:flex;flex-direction:column;gap:4px}
body.nh-v2 .cm-o .o-bar{height:8px;border-radius:4px;background:var(--buy);overflow:hidden;display:flex}
body.nh-v2 .cm-o .o-bar i{display:block;background:var(--accent)}
body.nh-v2 .cm-o .o-legend{display:flex;gap:14px;font-size:12px;color:var(--muted)}
body.nh-v2 .cm-o .o-dot{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:5px}
body.nh-v2 .cm-o .o-dot.m{background:var(--accent)}
body.nh-v2 .cm-o .o-dot.b{background:var(--buy)}
body.nh-v2 .cm-o .o-pg{display:block;width:100%;min-width:56px;height:7px;background:var(--surface2);border-radius:4px;overflow:hidden}
body.nh-v2 .cm-o .o-pg i{display:block;height:100%;background:var(--good)}
body.nh-v2 .cm-o .o-st{font:500 11px var(--f-body);padding:2px 8px;border-radius:99px;background:var(--surface2);color:var(--muted);white-space:nowrap}
body.nh-v2 .cm-o .o-st.w{background:var(--accent-soft);color:var(--accent)}
body.nh-v2 .cm-o .o-st.d{background:var(--good-soft);color:var(--good)}

body.nh-v2 .cm-o .o-subtabs{display:flex;gap:2px;padding:0 12px;border-top:1px solid var(--line);border-bottom:1px solid var(--line);background:var(--surface2)}
body.nh-v2 .cm-o .o-subtabs button{background:transparent;border:0;padding:8px 12px;color:var(--muted);font-weight:500;border-bottom:2px solid transparent;margin-bottom:-1px}
body.nh-v2 .cm-o .o-subtabs button[aria-selected=true]{color:var(--fg);border-bottom-color:var(--accent);background:var(--surface)}
body.nh-v2 .cm-o .o-tools{display:flex;gap:8px;flex-wrap:wrap;padding:12px 16px;align-items:center}
body.nh-v2 .cm-o .o-btn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--surface);border-radius:4px;padding:6px 11px;font-weight:500;color:var(--fg)}
body.nh-v2 .cm-o .o-btn:hover:not(:disabled){border-color:var(--muted)}
body.nh-v2 .cm-o .o-btn:disabled{opacity:.45}
body.nh-v2 .cm-o .o-btn.pri{background:var(--accent);color:var(--accent-fg);border-color:var(--accent)}
body.nh-v2 .cm-o .o-btn.pri:hover:not(:disabled){filter:brightness(1.08)}
body.nh-v2 .cm-o .o-btn.sm{padding:3px 8px;font-size:12px}
body.nh-v2 .cm-o .o-btn.ghost{background:transparent;border-color:transparent;color:var(--muted)}
body.nh-v2 .cm-o .o-btn.ghost:hover:not(:disabled){background:var(--surface2);color:var(--fg);border-color:transparent}

body.nh-v2 .cm-o .o-tw{overflow-x:auto;padding:0 16px 14px}
body.nh-v2 .cm-o .o-tw table{border-collapse:collapse;width:100%;min-width:900px;margin:0;background:transparent}
body.nh-v2 .cm-o .o-tw table.nar{min-width:560px}
body.nh-v2 .cm-o .o-tw th{font:500 11px var(--f-body);letter-spacing:.07em;text-transform:uppercase;color:var(--muted);text-align:left;padding:6px 8px;border-bottom:1px solid var(--line);white-space:nowrap;background:transparent}
body.nh-v2 .cm-o .o-tw th.r{text-align:right}
body.nh-v2 .cm-o .o-tw td{padding:5px 8px;border-bottom:1px solid var(--line);vertical-align:middle;background:transparent;color:var(--fg)}
body.nh-v2 .cm-o .o-tw tr:hover td{background:color-mix(in srgb,var(--surface2) 55%,transparent)}
body.nh-v2 .cm-o .o-tw td.code{font:12px var(--f-mono);color:var(--muted);white-space:nowrap}
body.nh-v2 .cm-o .o-tw tr.child td,body.nh-v2 .cm-o .o-tw tr.gen td{background:var(--surface2)}
body.nh-v2 .cm-o .o-tw tr.child,body.nh-v2 .cm-o .o-tw tr.clk{cursor:pointer}
body.nh-v2 .cm-o .o-tw tr.sum td{border-bottom:0;font-weight:600;padding-top:10px}
body.nh-v2 .cm-o .o-tw td input,body.nh-v2 .cm-o .o-tw td select{background:transparent;border:1px solid transparent;border-radius:3px;padding:3px 6px;width:100%}
body.nh-v2 .cm-o .o-tw td input:hover,body.nh-v2 .cm-o .o-tw td select:hover{border-color:var(--line)}
body.nh-v2 .cm-o .o-tw td input:focus,body.nh-v2 .cm-o .o-tw td select:focus{border-color:var(--accent);background:var(--surface)}
body.nh-v2 .cm-o .o-tw td input.o-num{text-align:right;font-family:var(--f-mono);width:92px}
body.nh-v2 .cm-o .o-tw td input.q,body.nh-v2 .cm-o .o-tw td input.pcin{width:64px}
body.nh-v2 .cm-o .o-tw td.cost{position:relative}
body.nh-v2 .cm-o .o-tw td.cost.act::after{content:"";position:absolute;left:8px;right:8px;bottom:3px;height:2px;border-radius:1px}
body.nh-v2 .cm-o .o-tw td.cost.act.m::after{background:var(--accent)}
body.nh-v2 .cm-o .o-tw td.cost.act.b::after{background:var(--buy)}
body.nh-v2 .cm-o .o-tw td.cost.act .o-num{font-weight:500}
body.nh-v2 .cm-o .o-tw td.cost:not(.act) .o-num{color:var(--muted)}
body.nh-v2 .cm-o .o-na{color:var(--muted);font:12px var(--f-mono);display:block;text-align:right;padding:3px 6px}
body.nh-v2 .cm-o .o-sw{display:inline-flex;border:1px solid var(--line);border-radius:5px;overflow:hidden}
body.nh-v2 .cm-o .o-sw button{border:0;background:var(--surface);padding:3px 10px;font-size:12px;font-weight:500;color:var(--muted)}
body.nh-v2 .cm-o .o-sw button+button{border-left:1px solid var(--line)}
body.nh-v2 .cm-o .o-sw button.on.m{background:var(--accent);color:var(--accent-fg)}
body.nh-v2 .cm-o .o-sw button.on.b{background:var(--buy);color:var(--bg)}
body.nh-v2 .cm-o .o-sw button:disabled{opacity:.4}
body.nh-v2 .cm-o .o-x{background:transparent;border:0;color:var(--muted);padding:4px;border-radius:3px;line-height:0}
body.nh-v2 .cm-o .o-x:hover:not(:disabled){color:var(--bad);background:var(--surface2)}
body.nh-v2 .cm-o .o-x:disabled{opacity:.4}
body.nh-v2 .cm-o .o-lnk{background:transparent;border:0;padding:0;font-weight:500;overflow:hidden;text-overflow:ellipsis;max-width:100%;text-align:left;color:var(--fg)}
body.nh-v2 .cm-o .o-lnk:hover{color:var(--accent);text-decoration:underline}
body.nh-v2 .cm-o .o-hint{font-size:12px;color:var(--muted);padding:0 16px 14px}
body.nh-v2 .cm-o .o-empty{padding:28px 16px;text-align:center;color:var(--muted)}

body.nh-v2 .cm-o .o-docs-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:14px;padding:14px 16px 16px}
body.nh-v2 .cm-o .o-dcol{border:1px solid var(--line);border-radius:6px;min-width:0}
body.nh-v2 .cm-o .o-dcol h3{margin:0;padding:9px 12px;font:600 13px var(--f-display);letter-spacing:.06em;text-transform:uppercase;display:flex;gap:8px;align-items:center;border-bottom:1px solid var(--line);color:var(--fg)}
body.nh-v2 .cm-o .o-drop{display:block;margin:10px 12px 12px;border:1.5px dashed var(--line);border-radius:5px;padding:12px;text-align:center;color:var(--muted);font-size:13px;width:calc(100% - 24px);background:transparent}
body.nh-v2 .cm-o .o-drop.dis{pointer-events:none;opacity:.45}
body.nh-v2 .cm-o .o-c-doc{width:46px;flex:none;text-align:center}
body.nh-v2 .cm-o .o-tag.docs{display:inline-flex;gap:3px;align-items:center}
body.nh-v2 .cm-o .o-ext{flex:none;width:34px;height:40px;border-radius:3px;border:1px solid var(--line);display:grid;place-items:end center;font:500 9px var(--f-mono);padding-bottom:4px;background:var(--surface2);color:var(--muted)}
body.nh-v2 .cm-o .o-ext.pdf{color:var(--bad)}
body.nh-v2 .cm-o .o-ext.dwg{color:var(--accent)}
body.nh-v2 .cm-o .o-drop:hover:not(.dis){border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}
body.nh-v2 .cm-o .o-tw td select,body.nh-v2 .cm-o .o-tw td input[type=text],body.nh-v2 .cm-o .o-tw td input[type=date]{background:var(--surface);border:1px solid var(--line);border-radius:4px;padding:5px 8px}
body.nh-v2 .cm-o .o-tw td select:disabled,body.nh-v2 .cm-o .o-tw td input:disabled{opacity:1;color:var(--fg);cursor:default}

body.nh-v2 .cm-o .o-head-grid{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);gap:14px}
body.nh-v2 .cm-o .o-form{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:14px;padding:16px}
body.nh-v2 .cm-o .o-costbox{padding:16px;display:flex;flex-direction:column;gap:14px}
body.nh-v2 .cm-o .o-crow{display:flex;justify-content:space-between;align-items:baseline;gap:10px;border-bottom:1px solid var(--line);padding-bottom:9px}
body.nh-v2 .cm-o .o-crow:last-child{border-bottom:0;padding-bottom:0}
body.nh-v2 .cm-o .o-crow b{font:500 16px var(--f-mono);font-variant-numeric:tabular-nums}
body.nh-v2 .cm-o .o-crow.tot b{font-size:24px}
body.nh-v2 .cm-o .o-stack{display:flex;flex-direction:column;gap:14px;min-width:0}

body.nh-v2 .cm-o .o-rgrid{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:14px}
body.nh-v2 .cm-o .o-rrow{display:grid;grid-template-columns:minmax(0,1.2fr) minmax(90px,1fr) 100px 48px;gap:12px;align-items:center;padding:10px 16px;border-bottom:1px solid var(--line)}
body.nh-v2 .cm-o .o-rrow:last-of-type{border-bottom:0}
body.nh-v2 .cm-o .o-scen{display:grid;gap:10px;padding:14px 16px}
body.nh-v2 .cm-o .o-scen>div{display:flex;justify-content:space-between;align-items:baseline;gap:10px}
body.nh-v2 .cm-o .o-t5{display:flex;gap:10px;justify-content:space-between;padding:8px 16px;border-bottom:1px solid var(--line);align-items:center}
body.nh-v2 .cm-o .o-t5:last-child{border-bottom:0}
body.nh-v2 .cm-o .o-t5>div{min-width:0}
body.nh-v2 .cm-o .o-t5 b{font-weight:500;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
body.nh-v2 .cm-o .o-t5 span.s{font-size:12px;color:var(--muted)}
body.nh-v2 .cm-o .o-kstrip{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:14px}
body.nh-v2 .cm-o .o-kcard{background:var(--surface);border:1px solid var(--line);border-radius:6px;padding:12px 14px;display:flex;flex-direction:column;gap:6px}
body.nh-v2 .cm-o .o-kcard b{font:500 22px var(--f-mono);font-variant-numeric:tabular-nums}
body.nh-v2 .cm-o .o-kcard small{color:var(--muted);font-size:12px}
body.nh-v2 .cm-o .o-two{display:grid;grid-template-columns:repeat(auto-fit,minmax(380px,1fr));gap:14px}

body.nh-v2 .cm-o .o-ov{position:fixed;inset:0;background:rgba(8,14,18,.55);display:grid;place-items:center;padding:16px;z-index:20}
body.nh-v2 .cm-o .o-modal{background:var(--surface);border:1px solid var(--line);border-radius:8px;width:min(720px,100%);max-height:min(640px,90vh);display:flex;flex-direction:column;color:var(--fg)}
body.nh-v2 .cm-o .o-modal.s{width:min(460px,100%)}
body.nh-v2 .cm-o .o-modal header{display:flex;gap:10px;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line)}
body.nh-v2 .cm-o .o-modal header h3{font:600 17px var(--f-display);letter-spacing:.03em;text-transform:uppercase;flex:1;margin:0;color:var(--fg)}
body.nh-v2 .cm-o .o-modal .body{padding:16px;display:flex;flex-direction:column;gap:14px}
body.nh-v2 .cm-o .o-modal .body p{margin:0}
body.nh-v2 .cm-o .o-modal .acts{display:flex;gap:8px;justify-content:flex-end}

@media (max-width:980px){body.nh-v2 .cm-o .o-split{grid-template-columns:1fr}}
@media (max-width:900px){body.nh-v2 .cm-o .o-head-grid,body.nh-v2 .cm-o .o-rgrid{grid-template-columns:1fr}}
@media (max-width:480px){body.nh-v2 .cm-o .o-two{grid-template-columns:1fr}}

/* Con la gestione OMZ la testata sta nella barra del pannello: della banda classica resta solo codice, stato e modifica testata */
body.nh-v2 .cm-band:has(~ .cm-o) :is(.cm-band-desc,.cm-band-desc2,.cm-band-who,.cm-band-dates,.cm-band-codes,.cm-band-side){display:none}

/* Strumenti righe dell'host (Modifica righe, Nuova riga): stesso aspetto dei pulsanti del prototipo */
body.nh-v2 .cm-o .o-tools-host{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin:0 0 10px;width:100%}
body.nh-v2 .cm-o .o-tools-host :is(button,.btn){display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--surface);color:var(--fg);border-radius:4px;padding:6px 11px;font:500 13px var(--f-body);box-shadow:none;min-height:0;height:auto}
body.nh-v2 .cm-o .o-tools-host :is(button,.btn):hover:not(:disabled){border-color:var(--muted)}
body.nh-v2 .cm-o .o-tools-host :is(button,.btn):disabled{opacity:.45}
body.nh-v2 .cm-o{padding:12px}

/* ---------- OMZ: resa viva (19/10/2026). Stessa struttura e misure del prototipo; palette teal/ambra piu satura, niente grigio spento ---------- */
body.nh-v2 .cm-o{
  --bg:#f6f8fb; --surface:#FFFFFF; --surface2:#f8fafc; --line:#e2e8f0; --fg:#0f172a; --muted:#64748b;
  --accent:#dc2626; --accent-soft:#fee2e2; --accent-fg:#FFFFFF; --accent-deep:#991b1b;
  --buy:#b45309; --buy-soft:#fef3c7; --good:#059669; --good-soft:#ecfdf5; --bad:#dc2626;
  background:#f6f8fb;
}
body.nh-v2 .cm-o .o-top{background:linear-gradient(105deg,var(--accent-deep) 0%,var(--accent) 100%);border:0;color:#fff;box-shadow:0 6px 18px -8px rgba(127,29,29,.45)}
body.nh-v2 .cm-o .o-top h1,body.nh-v2 .cm-o .o-top .o-kpi b{color:#fff}
body.nh-v2 .cm-o .o-top .o-lbl,body.nh-v2 .cm-o .o-top .o-muted{color:rgba(255,255,255,.72)}
body.nh-v2 .cm-o .o-top .o-pill{background:rgba(255,255,255,.2);color:#fff}
body.nh-v2 .cm-o .o-top .o-pill.frz{background:var(--buy-soft);color:var(--buy)}
body.nh-v2 .cm-o .o-top .o-revsel select{background:rgba(255,255,255,.95);color:var(--fg)!important;border-color:transparent}
body.nh-v2 .cm-o .o-top .o-btn{background:rgba(255,255,255,.14);border-color:rgba(255,255,255,.4);color:#fff}
body.nh-v2 .cm-o .o-top .o-btn:hover:not(:disabled){background:rgba(255,255,255,.26);border-color:#fff}
body.nh-v2 .cm-o .o-top .o-btn.pri{background:#fff;color:var(--accent-deep);border-color:#fff}
body.nh-v2 .cm-o .o-top .o-theme{border-color:rgba(255,255,255,.4);color:#fff}
body.nh-v2 .cm-o .o-tabs{border-bottom:2px solid var(--line)}
body.nh-v2 .cm-o .o-tabs button{color:var(--muted);border-bottom-width:3px;margin-bottom:-2px}
body.nh-v2 .cm-o .o-tabs button:hover{color:var(--accent)}
body.nh-v2 .cm-o .o-tabs button[aria-selected=true]{color:var(--accent-deep);border-bottom-color:var(--accent);font-weight:600}
body.nh-v2 .cm-o .o-panel{border-color:var(--line);box-shadow:0 2px 10px -6px rgba(15,23,42,.18)}
body.nh-v2 .cm-o .o-panel-h{background:linear-gradient(180deg,var(--accent-soft),#fff1f1);border-bottom-color:var(--line);border-radius:6px 6px 0 0}
body.nh-v2 .cm-o .o-panel-h h2{color:var(--accent-deep)}
body.nh-v2 .cm-o .o-tn[aria-current=true]{background:var(--accent-soft);box-shadow:inset 3px 0 0 var(--accent)}
body.nh-v2 .cm-o .o-subtabs{background:var(--accent-soft);border-color:var(--line)}
body.nh-v2 .cm-o .o-subtabs button[aria-selected=true]{color:var(--accent-deep);background:#fff;border-bottom-color:var(--accent);font-weight:600}
body.nh-v2 .cm-o .o-tw th{background:var(--surface2);color:var(--accent-deep);border-bottom:2px solid var(--line)}
body.nh-v2 .cm-o .o-tw tr:hover td{background:var(--surface2)}
body.nh-v2 .cm-o .o-tw tr.child td,body.nh-v2 .cm-o .o-tw tr.gen td{background:#fafbfd}
body.nh-v2 .cm-o .o-tn-head{background:var(--surface2);color:var(--accent-deep)}
body.nh-v2 .cm-o .o-btn{border-color:var(--accent);color:var(--accent-deep);background:#fff}
body.nh-v2 .cm-o .o-btn:hover:not(:disabled){background:var(--accent-soft);border-color:var(--accent-deep)}
body.nh-v2 .cm-o .o-btn.pri{background:linear-gradient(180deg,#ef4444,var(--accent));color:#fff;border-color:var(--accent-deep);box-shadow:0 2px 6px -2px rgba(127,29,29,.5)}
body.nh-v2 .cm-o .o-btn.ghost{border-color:transparent;color:var(--accent-deep)}
body.nh-v2 .cm-o .o-tools-host :is(button,.btn){border-color:var(--accent);color:var(--accent-deep);background:#fff}
body.nh-v2 .cm-o .o-tools-host :is(button,.btn):hover:not(:disabled){background:var(--accent-soft);border-color:var(--accent-deep)}
body.nh-v2 .cm-o .o-kcard{border-top:3px solid var(--accent)}
body.nh-v2 .cm-o .o-dcol h3{background:var(--surface2);color:var(--accent-deep)}
body.nh-v2 .cm-o .o-pg{background:var(--accent-soft)}
body.nh-v2 .cm-o .o-st.w{background:var(--accent-soft);color:var(--accent-deep)}
body.nh-v2 .cm-o .o-addf{background:var(--surface2)}
body.nh-v2 .cm-o .o-fld input,body.nh-v2 .cm-o .o-fld select{border-color:var(--line)}
body.nh-v2 .cm-o .o-fld input:hover,body.nh-v2 .cm-o .o-fld select:hover{border-color:var(--accent)}
body.nh-v2 .cm-o .o-fld input:focus,body.nh-v2 .cm-o .o-fld select:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
body.nh-v2 .cm-o .o-drop{border-color:var(--accent);color:var(--accent-deep);background:var(--surface2)}

/* OMZ: nella barra scura i colori buono/cattivo si schiariscono per restare leggibili */
body.nh-v2 .cm-o .o-top { --good:#a7f3d0; --bad:#fecaca; }

/* Ore e spese della commessa base (sola lettura): barre ore/spese affiancate, tabelle strette, slot vuoto tratteggiato */
body.nh-v2 .cm-o-base .months{display:grid;grid-template-columns:repeat(6,1fr);gap:10px;padding:14px 12px 10px;align-items:end;height:170px}
body.nh-v2 .cm-o-base .mcol{display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
body.nh-v2 .cm-o-base .mcol .st{width:100%;max-width:56px;display:flex;flex-direction:row;align-items:flex-end;gap:3px;flex:1}
body.nh-v2 .cm-o-base .mcol .st i{display:block;flex:1;min-width:0}
body.nh-v2 .cm-o-base .mcol .st i.h,body.nh-v2 .cm-o-base .legend i.h{background:var(--accent)}
body.nh-v2 .cm-o-base .mcol .st i.s,body.nh-v2 .cm-o-base .legend i.s{background:var(--buy)}
body.nh-v2 .cm-o-base .mcol span{font:11px var(--f-mono);color:var(--muted)}
body.nh-v2 .cm-o-base .legend{display:flex;gap:14px;padding:0 12px 12px;font-size:12px;color:var(--muted)}
body.nh-v2 .cm-o-base .legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px}
body.nh-v2 .cm-o-base .o-tw table.o-t2{min-width:0}
body.nh-v2 .cm-o .o-empty.o-slot{display:grid;place-items:center;margin:14px;padding:18px;border:1.5px dashed var(--line);border-radius:6px}
/* Elenchi lunghi: altezza limitata con scorrimento interno e intestazione ferma; tabella spese larga quanto serve */
body.nh-v2 .cm-o-base .o-tw{max-height:420px;overflow-y:auto}
body.nh-v2 .cm-o-base .o-tw th{position:sticky;top:0;background:var(--surface);z-index:1}
body.nh-v2 .cm-o-base .o-tw table.o-t2.o-t4{min-width:460px}

/* Modale Sede del cliente su schermi bassi (1366x768, 1280x720): nove righe di campi + Note + vassoio superano
   l'altezza visibile e il vassoio Salva/Annulla finiva sotto il bordo. Si stringono solo spaziature e lo spazio
   vuoto dell'area Note (resta a 3 righe): font, colori e componenti invariati, nessuno scroll interno. */
@media (max-height: 800px) {
  body.nh-v2 .editor-modal.editor-modal-floating-content:has(.customer-site-form) {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content:has(.customer-site-form) .editor-dialog .surface-head {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content:has(.customer-site-form) .editor-dialog .editor-body {
    padding-top: 14px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content .settings-form-grid.customer-site-form {
    row-gap: 10px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content .customer-site-form .dxbl-memo-edit {
    min-height: 72px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content .customer-site-form .dxbl-memo-edit textarea {
    min-height: 64px;
  }

  body.nh-v2 .editor-modal.editor-modal-floating-content .editor-dialog .customer-site-form > .modal-form-actions {
    margin-top: 6px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
}
