/* ============================================================
   Boardroom — Business Plan digitale (CFO/CEO). UX/UI di riferimento: Product & Sales
   → Clienti (pattern .cli-*). Prefix .brd-*, palette teal. Nessun colore hardcoded
   fuori da qui (§1.2). Empty state card (§1.6.1), overlay sync (§1.3).
   ============================================================ */
:root {
  --brd-primary: #0f766e;
  --brd-primary-dark: #115e59;
  --brd-primary-light: #eefaf8;
  --brd-accent: #16a34a;
  --brd-warn: #b45309;
  --brd-danger: #dc2626;
}
/* Header: titolo a sinistra, azioni (es. select scenario) SEMPRE in alto a destra. Niente wrap del blocco
   azioni: il sottotitolo, anche lungo, va a capo DENTRO la colonna titolo (min-width:0) e non spinge la select
   a capo → la posizione della select resta identica navigando fra tab/sezioni (desktop). Su mobile si impila. */
.brd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: nowrap; margin-bottom: 1rem; }
.brd-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.brd-head h1 { margin: 0 0 .25rem; }
.brd-head .subtitle { margin: 0; }
.brd-head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; flex-shrink: 0; }

.brd-btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: #f8fafc; color: #334155; border-radius: 8px; padding: .5rem .9rem; font-size: .82rem; font-weight: 600; cursor: pointer; transition: filter .12s; }
.brd-btn:hover:not(:disabled) { filter: brightness(.96); }
.brd-btn:disabled { opacity: .55; cursor: wait; }
.brd-btn-primary { background: var(--brd-primary); border-color: var(--brd-primary); color: #fff; }
.brd-btn-primary:hover:not(:disabled) { background: var(--brd-primary-dark); }
.brd-btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--brd-danger); }
.brd-btn-danger:hover:not(:disabled) { background: #fee2e2; }
.brd-btn svg { flex-shrink: 0; }

/* modale riusabile (conferme + drill-down) */
.brd-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 4100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.brd-modal { background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(15,23,42,.28); width: 100%; max-width: 560px; max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.brd-modal.brd-modal-wide { max-width: 940px; width: 94vw; }
.brd-modal-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.brd-modal-head h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--text); }
.brd-modal-x { border: none; background: #f1f5f9; color: #475569; width: 30px; height: 30px; border-radius: 8px; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.brd-modal-x:hover { background: #e2e8f0; }
.brd-modal-body { padding: 1.1rem 1.25rem; overflow-y: auto; }
.brd-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: #fafbfc; }

.brd-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1.1rem; }
.brd-kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1.1rem; }
.brd-kpi-val { font-size: 1.7rem; font-weight: 700; color: var(--text); letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.brd-kpi-val.good { color: var(--brd-accent); }
.brd-kpi-val.warn { color: var(--brd-warn); }
.brd-kpi-val.bad { color: var(--brd-danger); }
.brd-kpi-val.brand { color: var(--brd-primary); }
.brd-kpi-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: .3rem; }
.brd-kpi-hint { font-size: .72rem; color: var(--muted); margin-top: .2rem; }

.brd-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .7rem; }
.brd-segment { display: inline-flex; background: #eef1f6; border-radius: 8px; padding: 3px; }
.brd-seg { border: none; background: #eef1f6; color: #475569; font-size: .78rem; font-weight: 600; padding: .35rem .8rem; border-radius: 6px; cursor: pointer; }
.brd-seg.active { background: #fff; color: var(--brd-primary); box-shadow: 0 1px 2px rgba(15,23,42,.08); }
/* Ledger — filtri a cascata (Stato → Tipo → Anno → Mese) */
.brd-ledger-filtercard { padding: .7rem .9rem; margin-bottom: .7rem; display: flex; flex-direction: column; gap: .5rem; }
.brd-ledger-frow { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.brd-ledger-frow > .brd-segment { flex-wrap: wrap; gap: .3rem; }
/* Dettaglio fattura — modale */
.brd-inv-detail { display: flex; flex-direction: column; gap: 1rem; }
.brd-inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--border, #e2e8f0); }
.brd-inv-cp { font-size: 1.05rem; font-weight: 700; color: var(--text, #0f172a); }
.brd-inv-amts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.brd-inv-amt { background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: .7rem .8rem; text-align: center; }
.brd-inv-amt-v { font-size: 1.15rem; font-weight: 700; color: var(--text, #0f172a); font-variant-numeric: tabular-nums; }
.brd-inv-grid { margin: 0; display: flex; flex-direction: column; gap: 0; }
.brd-inv-row { display: flex; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border, #e2e8f0); }
.brd-inv-row:last-child { border-bottom: none; }
.brd-inv-row > dt { flex: 0 0 40%; margin: 0; color: var(--muted, #64748b); font-size: .82rem; }
.brd-inv-row > dd { flex: 1; margin: 0; color: var(--text, #0f172a); font-size: .88rem; word-break: break-word; }
.brd-inv-uid { font-size: .78rem; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; }
@media (max-width: 560px) { .brd-inv-amts { grid-template-columns: 1fr; } .brd-inv-row { flex-direction: column; gap: .15rem; } .brd-inv-row > dt { flex-basis: auto; } }
.brd-select { border: 1px solid var(--border); background: #fff; color: #334155; border-radius: 8px; padding: .45rem .7rem; font-size: .8rem; }
.brd-search { flex: 1; min-width: 180px; max-width: 340px; }
.brd-search input { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: .45rem .8rem; font-size: .8rem; box-sizing: border-box; }

.brd-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.brd-card-head { display: flex; justify-content: space-between; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: .7rem; }
.brd-card-title { font-size: .95rem; font-weight: 700; color: var(--text); margin: 0; display: flex; align-items: center; gap: .5rem; }
.brd-card-title svg { color: var(--brd-primary); }
.brd-card-desc { font-size: .78rem; color: var(--muted); margin: -.4rem 0 .8rem; }
.brd-evidence { font-size: .72rem; color: var(--muted); margin-top: .5rem; }

.brd-table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; margin-bottom: 1rem; }
.brd-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.brd-table thead th { text-align: left; padding: .7rem .9rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfc; }
.brd-table thead th.num, .brd-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.brd-table tbody td { padding: .6rem .9rem; border-bottom: 1px solid #f0f2f5; vertical-align: middle; color: var(--text); max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.brd-table tbody tr:hover { background: var(--brd-primary-light); }
.brd-table tbody tr:last-child td { border-bottom: none; }
.brd-cellsub { font-size: .72rem; color: var(--muted); margin-top: .15rem; }
.brd-count { font-size: .78rem; color: var(--muted); margin: .4rem 0 1.2rem; }

.brd-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; background: #f1f5f9; color: #475569; }
.brd-badge-rev { background: #dcfce7; color: #166534; }
.brd-badge-cost { background: #fee2e2; color: #991b1b; }
.brd-badge-neutral { background: #f1f5f9; color: #475569; }
.brd-badge-hired { background: #dbeafe; color: #1d4ed8; }   /* Assunto oggi (blu) — persona con anagrafica */
.brd-badge-new { background: #dcfce7; color: #166534; }     /* Nuovo inserimento (verde) — assunzione da piano */
.brd-badge-actual { background: #dbeafe; color: #1d4ed8; }  /* Scenario Consuntivo (Actual) — blu */
.brd-badge-plan { background: #fef3c7; color: #92400e; }    /* Scenario Business Plan di riferimento — ambra */
.brd-badge-locked { background: #f1f5f9; color: #475569; }  /* Scenario bloccato (freeze BP) — grigio */
/* Linea di prodotto ricavi (#7) — §1.4.1: colore distinto per ogni valore discreto */
.brd-pl-vmp        { background: #e0e7ff; color: #3730a3; }  /* VMP — indaco */
.brd-pl-workforce  { background: #ccfbf1; color: #0f766e; }  /* Workforce — teal */
.brd-pl-tfconnect  { background: #fae8ff; color: #86198f; }  /* TF Connect — fucsia */
.brd-pl-otherwl    { background: #fef9c3; color: #854d0e; }  /* Other WL — giallo */
.brd-pl-altri      { background: #f1f5f9; color: #475569; }  /* Altri — grigio */
/* Tipo fornitore (anagrafica) — §1.4.1: colore distinto per valore */
.brd-sup-cont { background: #e0e7ff; color: #3730a3; }  /* Collaboratore continuativo — indaco */
.brd-sup-est  { background: #ccfbf1; color: #0f766e; }  /* Collaboratore esterno — teal */
.brd-sup-az   { background: #f1f5f9; color: #475569; }  /* Azienda — grigio */
/* Anagrafica fornitori — selezione multipla + modifica massiva */
.brd-sup-bulkbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .4rem .2rem .7rem; }
.brd-sup-bulkbar-on { background: #ecfeff; border: 1px solid #bae6fd; border-radius: 8px; padding: .5rem .7rem; margin-bottom: .4rem; }
.brd-sup-chkcol { text-align: center; width: 40px; }
.brd-sup-chk { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brd-primary, #0f766e); }
/* Errore inline modale (§1.1: errori form inline con role=alert, non toast) */
.brd-form-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: .5rem .7rem; font-size: .8rem; margin: .2rem 0 .7rem; }
/* Badge per-prospetto Rettifiche (§1.4.1: colore distinto per ciascun valore discreto) */
.brd-mod-pnl         { background: #e1f5ee; color: #0f6e56; }
.brd-mod-cashflow    { background: #e6f1fb; color: #0c447c; }
.brd-mod-staff       { background: #e0e7ff; color: #3730a3; }
.brd-mod-costi       { background: #fee2e2; color: #991b1b; }
.brd-mod-capex       { background: #faeeda; color: #854f0b; }
.brd-mod-mrr         { background: #eaf3de; color: #3b6d11; }
.brd-mod-whitelabel  { background: #ccfbf1; color: #115e59; }
.brd-mod-marketplace { background: #fae8ff; color: #86198f; }
.brd-mod-cdarev      { background: #eeedfe; color: #3c3489; }
.brd-mod-debito      { background: #f1f5f9; color: #334155; }
.brd-mod-investors   { background: #fbeaf0; color: #99355a; }
/* Anteprima live cella Rettifiche: Calcolato → Ufficiale = Δ → Risultato */
.brd-rt-preview { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .9rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; margin: .2rem 0 .8rem; }
.brd-rt-pv-cell { display: flex; flex-direction: column; gap: .1rem; }
.brd-rt-pv-lbl { font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.brd-rt-pv-val { font-size: 1.05rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.brd-rt-pv-val.good { color: #0f766e; }
.brd-rt-pv-val.bad { color: #b91c1c; }
.brd-rt-pv-val.brand { color: var(--brd-primary); }
.brd-rt-pv-arr { color: var(--muted); font-size: 1.1rem; align-self: center; }
.brd-rt-pv-warn { flex-basis: 100%; font-size: .74rem; color: #854d0e; background: #fef9c3; border-radius: 6px; padding: .3rem .5rem; }
/* Chip motivo (template) */
.brd-rt-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 3px 0 6px; }
.brd-chip { border: 1px solid var(--border); background: #f8fafc; color: #334155; border-radius: 999px; padding: 3px 11px; font-size: .74rem; cursor: pointer; }
.brd-chip:hover { background: var(--brd-primary-light); color: var(--brd-primary); }
/* ── Bilancino (fascia L): switch modalità + quadratura incolla-da-Excel ── */
.brd-rett-seg { display: inline-flex; gap: 2px; background: #eef2f6; border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin: 0 0 .6rem; }
.brd-seg-btn { border: 0; background: #eef2f6; color: #475569; font-weight: 600; font-size: .8rem; padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.brd-seg-btn:hover:not(.active) { background: #e2e8f0; }
.brd-seg-btn.active { background: var(--brd-primary); color: #ffffff; cursor: default; }
.brd-rb-paste { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.5; white-space: pre; }
.brd-rb-kpi { margin: .2rem 0 .8rem; }
.brd-rb-tblwrap { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.brd-rb-tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }
.brd-rb-tbl thead th { position: sticky; top: 0; background: #f8fafc; z-index: 1; text-align: left; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.brd-rb-tbl td { padding: .5rem .6rem; border-bottom: 1px solid #eef2f6; vertical-align: top; color: var(--text); }
.brd-rb-tbl td.num, .brd-rb-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.brd-rb-voce { font-weight: 600; color: var(--text); margin-bottom: 3px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brd-rb-line { width: 100%; max-width: 320px; font-size: .78rem; padding: 3px 6px; }
.brd-rb-conf { font-size: .68rem; color: var(--muted); margin-top: 3px; }
.brd-rb-blocked { background: #fbfbfc; opacity: .72; }
.brd-recon-delta-ok { color: #0f766e; font-weight: 700; }
.brd-recon-delta-bad { color: #b91c1c; font-weight: 700; }
/* badge distinti per valore (§1.4.1) */
.brd-conf-alta { background: #dcfce7; color: #166534; }
.brd-conf-media { background: #fef3c7; color: #92400e; }
.brd-conf-bassa { background: #ffedd5; color: #9a3412; }
.brd-conf-none { background: #f1f5f9; color: #64748b; }
.brd-recon-ok { background: #dbeafe; color: #1d4ed8; }
.brd-recon-warn { background: #f1f5f9; color: #475569; }
.brd-recon-bad { background: #fee2e2; color: #991b1b; }
.brd-rb-applybar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .8rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.brd-rett-empty { background: #ffffff; border: 1px solid var(--border); border-radius: 10px; padding: 1.6rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; margin-top: .6rem; }
.brd-recon-receipt { background: #ffffff; border: 1px solid var(--border); border-radius: 12px; padding: 1.2rem; margin-top: .6rem; }
.brd-recon-receipt-h { font-size: 1rem; font-weight: 700; color: #166534; margin-bottom: .6rem; }
.brd-recon-skip { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: .6rem .8rem; }
.brd-recon-skip-h { font-size: .78rem; font-weight: 700; color: #991b1b; text-transform: uppercase; letter-spacing: .03em; margin-bottom: .4rem; }
.brd-recon-skip-row { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; font-size: .8rem; color: var(--text); border-top: 1px dashed #fecaca; }
.brd-recon-skip-row:first-of-type { border-top: 0; }
/* ── Combobox riga (ricerca + autocomplete, dropdown dentro la modale) ── */
.brd-combo { position: relative; }
.brd-combo-inp { width: 100%; }
.brd-combo-pop { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 3px); max-height: 260px; overflow-y: auto; background: #ffffff; border: 1px solid var(--border); border-radius: 9px; box-shadow: 0 10px 28px rgba(15,23,42,.14); }
.brd-combo-opt { padding: 8px 11px; font-size: .84rem; color: var(--text); cursor: pointer; border-bottom: 1px solid #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brd-combo-opt:last-child { border-bottom: 0; }
.brd-combo-opt:hover, .brd-combo-opt.active { background: var(--brd-primary-light); color: var(--brd-primary); }
.brd-combo-opt mark { background: transparent; color: inherit; font-weight: 700; }
.brd-combo-empty { padding: 12px; font-size: .82rem; color: var(--muted); text-align: center; }
/* ── Multi-periodo (più mesi) ── */
.brd-rt-multi { margin: .1rem 0 .7rem; }
.brd-rt-multi-tog { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--text); cursor: pointer; }
.brd-rt-multi-body { margin-top: .5rem; padding: .6rem .7rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 9px; }
.brd-rt-months { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.brd-rt-mchip { display: inline-flex; align-items: center; gap: 4px; background: #ffffff; border: 1px solid var(--border); border-radius: 7px; padding: 3px 8px; font-size: .76rem; color: var(--text); cursor: pointer; }
.brd-rt-split { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .6rem; font-size: .8rem; color: var(--text); }
.brd-rt-split label { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
/* ── Dedup + impatto sui totali + cronologia ── */
.brd-rt-dup { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 9px; padding: .55rem .7rem; margin: 0 0 .6rem; font-size: .82rem; }
.brd-rt-impact { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 9px; padding: .6rem .7rem; margin: 0 0 .6rem; }
.brd-rt-impact-note { font-size: .8rem; color: #1e40af; margin-bottom: .35rem; }
.brd-rt-impact-chk { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--text); cursor: pointer; }
.brd-rt-history { margin: 0 0 .6rem; }
.brd-rt-history summary { font-size: .8rem; color: var(--brd-primary); cursor: pointer; font-weight: 600; }
.brd-rt-hist-list { margin-top: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.brd-rt-hist-row { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--text); padding: .3rem .5rem; background: #f8fafc; border-radius: 7px; }
.brd-rt-hist-row > span:first-child { font-weight: 600; white-space: nowrap; }
.brd-rt-hist-row > .brd-cellsub { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ── Chip filtro anno + stato attivo generico dei chip ── */
.brd-rett-yearchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 .8rem; }
.brd-chip.active { background: var(--brd-primary); color: #ffffff; border-color: var(--brd-primary); }
/* ── Competenza per-fattura (v255): chip in tabella + editor con anteprima ripartizione ── */
.brd-comp-chip { border: 1px solid var(--border); border-radius: 7px; padding: 2px 9px; font-size: .74rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.brd-comp-doc { background: #f1f5f9; color: #64748b; }
.brd-comp-single { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.brd-comp-spread { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
/* Contratti Firmati — badge distinti per linea P&L e stato (§1.4.1) */
.brd-sc-wl    { background: #ecfeff; color: #0e7490; }
.brd-sc-mp    { background: #eef2ff; color: #4338ca; }
.brd-sc-wlsu  { background: #f0fdfa; color: #0f766e; }
.brd-sc-tf    { background: #fef3c7; color: #92400e; }
.brd-sc-cr    { background: #fce7f3; color: #9d174d; }
.brd-sc-signed { background: #dbeafe; color: #1d4ed8; }
.brd-sc-active { background: #dcfce7; color: #166534; }
.brd-sc-closed { background: #f1f5f9; color: #475569; }
/* Dettaglio sola lettura (Dati storici): chip leggibili al posto di array/CSV nudi, sotto-tabelle annidate */
.brd-ro-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.brd-ro-chip { display: inline-flex; align-items: baseline; gap: 5px; background: #f1f5f9; color: #334155; border: 1px solid var(--border, #e2e8f0); border-radius: 999px; padding: 2px 9px; font-size: .78rem; white-space: nowrap; }
.brd-ro-chip b { color: var(--muted, #64748b); font-weight: 600; font-size: .72rem; }
.brd-ro-mon .brd-ro-chip { font-variant-numeric: tabular-nums; }
.brd-ro-sub { width: 100%; font-size: .8rem; }
.brd-ro-sub td { padding: 3px 6px; border-bottom: 1px dashed #eef2f6; }
.brd-ro-sub thead th { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 3px 6px; }
/* RIC-3 — card editor Linee/Fatturato CDA (colori spostati dal render JS al CSS, §1.2) */
.brd-cr-card { margin: 0 0 .9rem; padding: .7rem .9rem; background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; }
.brd-cr-billedcard { margin: 1.1rem 0 .3rem; padding: .7rem .9rem; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 10px; }
/* Avviso inline su campo (valore fuori dominio / segno errato) */
.brd-fld-warn { font-size: .74rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 2px 7px; margin-top: 3px; }
.brd-plan-catsel { font-size: .76rem; padding: 2px 6px; margin-top: 3px; max-width: 260px; }
.brd-iu-suf { font-size: .78rem; color: var(--muted); margin-left: 4px; }
/* Alert affidabilità Proiezioni (forecast off + contratti firmati nel futuro) */
.brd-affid-alert { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 10px; padding: .7rem .9rem; margin-bottom: 1rem; font-size: .84rem; line-height: 1.5; }
.brd-affid-alert strong { color: #78350f; }
button.brd-comp-chip:hover { filter: brightness(.97); }
.brd-comp-modes { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .2rem 0 .6rem; }
.brd-comp-modes label { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; color: var(--text); cursor: pointer; }
.brd-comp-preview { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin: .3rem 0 .7rem; }
.brd-comp-pv-note { font-size: .8rem; color: var(--muted); }
.brd-comp-pv-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; font-size: .78rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .4rem; }
.brd-comp-pv-q { font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: none; letter-spacing: 0; font-size: .78rem; }
.brd-comp-pv-q.ok { background: #dcfce7; color: #166534; }
.brd-comp-pv-q.bad { background: #fee2e2; color: #991b1b; }
.brd-comp-pv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 3px 10px; max-height: 180px; overflow-y: auto; }
.brd-comp-pv-row { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text); padding: 2px 0; border-bottom: 1px dashed #eef2f6; }
/* Tipo scenario (§1.4.1: colore distinto per ogni valore discreto) */
.brd-kind-interno { background: #dbeafe; color: #1d4ed8; }
.brd-kind-aucap { background: #fef3c7; color: #92400e; }
.brd-kind-acquirer { background: #ede9fe; color: #6d28d9; }
.brd-kind-simulazione { background: #ecfeff; color: #0e7490; }

.brd-empty-state { background: #ffffff; border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 2.5rem 1.5rem; text-align: center; color: var(--text, #0f172a); }
.brd-es-icon { width: 48px; height: 48px; margin: 0 auto .75rem; color: var(--muted, #64748b); }
.brd-es-title { font-size: 1rem; font-weight: 600; margin: 0 0 .375rem; }
.brd-es-desc { font-size: .875rem; color: var(--muted, #64748b); margin: 0 0 1rem; max-width: 560px; margin-left: auto; margin-right: auto; }

.brd-skel { background: linear-gradient(90deg, #f1f5f9 25%, #e8edf3 50%, #f1f5f9 75%); background-size: 200% 100%; animation: brd-shimmer 1.2s infinite; border-radius: 8px; min-height: 90px; margin-bottom: .8rem; }
@keyframes brd-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .brd-skel { animation: none; } }

.brd-sync-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 4000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; }
.brd-sync-spinner { width: 46px; height: 46px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: brd-spin .8s linear infinite; }
@keyframes brd-spin { to { transform: rotate(360deg); } }
.brd-sync-label { color: #fff; font-size: 1rem; font-weight: 700; }
.brd-sync-sublabel { color: #cbd5e1; font-size: .82rem; }

.brd-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }

/* accordion + drill-down (Proiezioni) */
.brd-acc-section > td:first-child { font-weight: 700; }
.brd-acc-toggle { display: inline-block; width: 1.1em; color: var(--brd-primary); cursor: pointer; font-size: .8rem; user-select: none; }
.brd-acc-total > td { font-weight: 700; background: #f7fafc; }
.brd-acc-detail > td:first-child { color: var(--muted); }
.brd-acc-indent { padding-left: 1.3rem; display: inline-block; }
.brd-cell-clic { cursor: pointer; }
.brd-cell-clic:hover { background: var(--brd-primary-light); outline: 1px solid var(--brd-primary); outline-offset: -1px; }
.brd-table tfoot td { border-top: 2px solid var(--border); font-variant-numeric: tabular-nums; }

/* modifica inline nome/tipo scenario (doppio click) */
.brd-inline-edit { border: 1px solid var(--brd-primary); background: #fff; color: var(--text); border-radius: 6px; padding: .3rem .5rem; font-size: .85rem; font-weight: 600; min-width: 160px; }

/* drill-down ricorsivo (modale Proiezioni) */
.brd-drill-crumbs { font-size: .78rem; margin-bottom: .6rem; color: var(--muted); line-height: 1.6; }
.brd-crumb { color: var(--brd-primary); cursor: pointer; font-weight: 600; }
.brd-crumb:hover { text-decoration: underline; }
.brd-crumb-cur { color: var(--text); font-weight: 700; }
.brd-crumb-sep { color: var(--muted); margin: 0 .1rem; }
tr.brd-drill-clic { cursor: pointer; }
tr.brd-drill-clic:hover { background: var(--brd-primary-light); }
.brd-drill-caret { color: var(--brd-primary); font-weight: 700; margin-left: .3rem; }

/* delta confronto scenari (Proiezioni) */
.brd-delta { font-size: .72rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: .1rem; }
.brd-delta.up { color: var(--brd-accent); }
.brd-delta.down { color: var(--brd-danger); }

/* tab modulo + sotto-tab gruppo (Configuratore) */
.brd-tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.brd-tab { border: none; background: #f8fafc; color: #475569; font-size: .82rem; font-weight: 600; padding: .5rem .9rem; border-radius: 8px 8px 0 0; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.brd-tab:hover { background: #eef1f6; }
.brd-tab.active { background: #fff; color: var(--brd-primary); border-bottom-color: var(--brd-primary); }
.brd-subtabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; }
.brd-subtab { border: 1px solid var(--border); background: #f8fafc; color: #475569; font-size: .76rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; cursor: pointer; }
.brd-subtab:hover { background: #eef1f6; }
.brd-subtab.active { background: var(--brd-primary-light); color: var(--brd-primary); border-color: var(--brd-primary); }
/* 2ª riga di sotto-tab (modulo → gruppo): più compatta e secondaria */
.brd-subtabs-2 { margin-top: -.35rem; }
.brd-subtabs-2 .brd-subtab { font-size: .72rem; padding: .25rem .6rem; }
/* Driver in sola lettura (tab "Dati importati"): campi non-editabili ma dettaglio consultabile
   → gli INPUT sono inerti (niente typing), i BOTTONI restano attivi (es. "Gestisci periodi" apre la modale in lettura). */
.brd-imported input, .brd-imported textarea, .brd-imported select { pointer-events: none; background: #f1f5f9; color: #64748b; }
/* azioni per-riga (icone) sempre su una sola riga */
.brd-row-actions { display: inline-flex; gap: .3rem; align-items: center; flex-wrap: nowrap; }
/* editor a segmenti su asse ANNO (dal … al … → valore) */
/* riga segmento-anno: tutto su UNA riga (niente wrap del cestino), input a larghezza fissa */
.brd-yseg-row { display: flex; align-items: center; gap: .45rem; margin-bottom: .45rem; flex-wrap: nowrap; }
.brd-yseg-row > span { flex: none; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.brd-yseg-yr { width: 66px; text-align: center; flex: none; }
.brd-yseg-val { width: 92px; flex: none; }
.brd-yseg-row .brd-iu { flex: none; max-width: none; }
.brd-yseg-row .brd-iu input { width: 82px; min-width: 0; }
.brd-yseg-row .brd-btn { flex: none; }
.brd-yseg-row .brd-btn-danger { margin-left: .15rem; }
.brd-yseg > .brd-btn { margin-top: .1rem; }
.brd-yseg-dim { margin-bottom: .8rem; }
.brd-yseg-dimhd { font-size: .74rem; font-weight: 700; color: var(--brd-primary); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 .35rem; padding: .25rem .5rem; background: var(--brd-primary-light); border-radius: 6px; display: inline-block; }
.brd-yseg-hint { margin-top: .4rem; }
/* Organico: KPI + grafico cliccabili, anagrafica ad accordion per funzione */
.brd-kpi-clic { cursor: pointer; transition: box-shadow .12s, transform .06s; }
.brd-kpi-clic:hover { box-shadow: 0 3px 12px rgba(15,23,42,.1); transform: translateY(-1px); }
.brd-org-clic { cursor: pointer; }
.brd-org-clic:hover .brd-org-bar { outline: 2px solid var(--brd-primary); outline-offset: 1px; border-radius: 4px; }
.brd-org-acc { border: 1px solid var(--border); border-radius: 10px; margin-bottom: .7rem; background: #fff; overflow: hidden; }
.brd-org-acchd { cursor: pointer; padding: .7rem 1rem; font-size: .92rem; list-style: none; display: flex; align-items: center; gap: .5rem; }
.brd-org-acchd::-webkit-details-marker { display: none; }
.brd-org-acchd::before { content: '\25B8'; color: var(--muted); font-size: .8rem; transition: transform .12s; }
.brd-org-acc[open] > .brd-org-acchd::before { transform: rotate(90deg); }
.brd-org-accdot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }
.brd-org-acc > .brd-table-wrap { border-top: 1px solid var(--border); }
.brd-org-acctbl { margin: 0; }
.brd-adv-details { margin-top: .7rem; border-top: 1px solid var(--border); padding-top: .6rem; }
.brd-adv-details > summary { cursor: pointer; font-size: .82rem; color: var(--brd-primary); font-weight: 600; margin-bottom: .5rem; }
/* Editor "Compenso nel tempo" (costPlan): importi assoluti per intervallo di date */
.brd-comp-sec { margin-top: .7rem; padding: .7rem .8rem; background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; }
.brd-comp-head, .brd-comp-row { display: grid; grid-template-columns: 1fr 1fr 1.25fr 30px; gap: .4rem; align-items: center; }
.brd-comp-head { font-size: .68rem; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .25rem; padding: 0 .1rem; }
.brd-comp-row { margin-bottom: .35rem; }
.brd-comp-row > input { min-width: 0; }
.brd-comp-row > .brd-btn { padding: 0; justify-content: center; }
.brd-comp-actions { display: flex; gap: .4rem; margin-top: .45rem; flex-wrap: wrap; }
.brd-comp-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; font-weight: 600; color: #0e7490; background: #ecfeff; border-radius: 5px; padding: .05rem .3rem; }
/* Configuratore: parametri con tabella lunga → riga full-width (titolo/descrizione sopra, tabella, Salva sotto) */
.brd-cfg-bigrow > td, .brd-cfg-inforow > td { padding: 1rem 1.1rem 1.15rem !important; vertical-align: top; }
.brd-cfg-bighdr { margin-bottom: .75rem; }
.brd-cfg-bighdr > strong { font-size: .98rem; }
.brd-cfg-bighdr .brd-cellsub { margin-top: .2rem; }
.brd-cfg-bigactions { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--border, #e2e8f0); display: flex; gap: .5rem; flex-wrap: wrap; }
.brd-cfg-inforow > td { background: #f8fafc; }
.brd-cfg-bigrow > td > .brd-wcell { max-width: 100%; overflow-x: auto; }
/* tag categoria P&L (read-only) sotto il nome voce nel piano costi */
.brd-plan-cat { display: inline-block; margin-top: .2rem; font-size: .68rem; font-weight: 600; color: #475569; background: #f1f5f9; border-radius: 5px; padding: .05rem .35rem; }
/* su viewport stretti la riga può scorrere orizzontalmente invece di spezzarsi */
@media (max-width: 900px) { .brd-yseg { overflow-x: auto; } .brd-yseg-row { min-width: max-content; } }

/* editor driver strutturato (Configuratore) */
.brd-dinp { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: .35rem .5rem; font-size: .8rem; box-sizing: border-box; width: 100%; max-width: 160px; }
.brd-dinp:focus { outline: 2px solid var(--brd-primary); outline-offset: -1px; border-color: var(--brd-primary); }
textarea.brd-dinp { max-width: none; font-family: monospace; font-size: .72rem; }
.brd-dgrid { display: flex; flex-wrap: wrap; gap: .5rem; }
.brd-dcell { display: inline-flex; flex-direction: column; gap: .15rem; }
.brd-dcell > span { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.brd-dcell .brd-dinp { max-width: 92px; }
.brd-dobj { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: flex-end; }
.brd-dsub { width: 100%; }
.brd-dsub > .brd-cellsub { margin-bottom: .2rem; font-weight: 600; }
.brd-dtable { width: 100%; border-collapse: collapse; font-size: .78rem; }
.brd-dtable th { text-align: left; padding: .3rem .5rem; font-size: .66rem; font-weight: 700; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.brd-dtable td { padding: .25rem .5rem; border-bottom: 1px solid #f0f2f5; }
.brd-dtable .brd-dtidx { color: var(--muted); font-variant-numeric: tabular-nums; }
.brd-dtable .brd-dinp { max-width: 120px; }
.brd-dadv { margin: 0; }
.brd-dadv > summary { cursor: pointer; font-size: .74rem; color: var(--brd-primary); font-weight: 600; }
.brd-dadv > textarea { margin-top: .4rem; }

/* ====== Tabella generica brdSmartTable (sort + filtri + paginazione) ====== */
.brd-tbl-toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.brd-table thead th.brd-th-sort { cursor: pointer; user-select: none; }
.brd-table thead th.brd-th-sort:hover { color: var(--brd-primary); background: var(--brd-primary-light); }
.brd-sort-ind { font-size: .7rem; color: var(--brd-primary); }
.brd-filter-row th { padding: .3rem .5rem !important; background: #fff !important; border-bottom: 1px solid var(--border); }
.brd-tbl-ftext, .brd-tbl-fsel { width: 100%; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: .3rem .5rem; font-size: .74rem; box-sizing: border-box; color: var(--text); }
.brd-tbl-ftext:focus, .brd-tbl-fsel:focus { outline: none; border-color: var(--brd-primary); }
.brd-pager { display: flex; align-items: center; justify-content: flex-end; gap: .7rem; margin: .3rem 0 1rem; font-size: .78rem; color: var(--muted); }
.brd-pgbtn { background: #f8fafc; border: 1px solid var(--border); border-radius: 7px; padding: .35rem .7rem; font-size: .78rem; color: var(--text); cursor: pointer; }
.brd-pgbtn:hover:not(:disabled) { background: var(--brd-primary-light); border-color: var(--brd-primary); color: var(--brd-primary); }
.brd-pgbtn:disabled { opacity: .45; cursor: default; }
.brd-pginfo { tabular-nums: true; }
.brd-drill-total { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--text); background: var(--brd-primary-light); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .8rem; margin-bottom: .6rem; font-size: .9rem; }
/* editor a matrice (dimensione × periodo) per driver nested */
.brd-mx { font-size: .8rem; }
.brd-mx thead th { position: sticky; top: 0; background: #fafbfc; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .4rem .5rem; text-align: right; white-space: nowrap; }
.brd-mx thead th:first-child { text-align: left; }
.brd-mx-dim { font-weight: 600; color: var(--text); white-space: nowrap; padding: .35rem .6rem; position: sticky; left: 0; background: #fff; }
.brd-mx td { padding: .2rem .3rem; }
.brd-mx td .brd-dinp { width: 84px; text-align: right; }
/* matrice 3D raggruppata (macro → sub → periodo) */
.brd-mx-group { margin-bottom: .9rem; }
.brd-mx-group:last-child { margin-bottom: 0; }
.brd-mx-grouphd { font-size: .74rem; font-weight: 700; color: var(--brd-primary); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 .3rem; padding: .25rem .4rem; background: var(--brd-primary-light); border-radius: 6px; display: inline-block; }
/* Seed storico Actual 2022 — matrice fascia × mese (Fornitori / Clienti), colonna/righe Totale */
.brd-mx-cap { font-size: .74rem; color: var(--muted); margin: 0 0 .5rem; max-width: 78ch; }
.brd-mx-seed .brd-mx-grouprow td { background: var(--brd-primary-light); color: var(--brd-primary); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .3rem .6rem; position: sticky; left: 0; }
.brd-mx-seed thead th:last-child { border-left: 1px solid var(--border); }
.brd-mx-seed .brd-mx-total { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); background: #fafbfc; border-left: 1px solid var(--border); }
.brd-mx-seed .brd-mx-subtot td { font-weight: 700; background: #f8fafc; }
.brd-mx-seed .brd-mx-subtot .brd-mx-dim { color: var(--text); background: #f8fafc; }
.brd-mx-seed .brd-mx-grand td { border-top: 2px solid var(--border); }
/* piano forward tabellare (righe voce + colonne periodo) e master-detail */
.brd-plan td .brd-dinp, .brd-md td .brd-dinp { width: 90px; text-align: right; }
.brd-plan td:first-child .brd-dinp, .brd-md td:first-child .brd-dinp { text-align: left; width: 130px; }
.brd-plan thead th.num, .brd-md thead th.num { text-align: right; }
.brd-plan-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.brd-btn-xs { padding: .18rem .5rem; font-size: .72rem; line-height: 1.1; }
.brd-md-detrow > td { background: #fafbfc; padding: .1rem .5rem .5rem 1.4rem; }
.brd-md-det { border-left: 2px solid var(--brd-primary-light); padding-left: .7rem; }
.brd-md-det .brd-cellsub { margin: .2rem 0 .3rem; font-weight: 600; }
.brd-md-dtbl { width: auto; }
.brd-md-dtbl td .brd-dinp { width: 100px; }
.brd-wcell { min-width: 220px; }
/* input unità-aware (prefisso € / suffisso %/mesi/anni / helper %) — valore RAW invariato */
.brd-iu { display: inline-flex; align-items: center; border: 1px solid var(--border); background: #fff; border-radius: 6px; overflow: hidden; max-width: 170px; }
.brd-iu:focus-within { outline: 2px solid var(--brd-primary); outline-offset: -1px; border-color: var(--brd-primary); }
.brd-iu input { border: 0; outline: 0; padding: .35rem .45rem; font-size: .8rem; width: 100%; min-width: 60px; text-align: right; background: transparent; box-sizing: border-box; }
.brd-iu-a { flex: none; padding: 0 .45rem; font-size: .74rem; font-weight: 600; color: var(--muted); background: #f8fafc; align-self: stretch; display: flex; align-items: center; }
.brd-iu-pre .brd-iu-a { border-right: 1px solid var(--border); }
.brd-iu-suf .brd-iu-a { border-left: 1px solid var(--border); }
.brd-iu-pct { max-width: 200px; }
.brd-iu-pcthint { flex: none; padding: 0 .5rem; font-size: .72rem; color: var(--brd-primary); white-space: nowrap; background: var(--brd-primary-light); align-self: stretch; display: flex; align-items: center; }
/* toggle Sì/No */
.brd-toggle { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: #f1f5f9; border-radius: 999px; padding: .18rem .5rem .18rem .22rem; cursor: pointer; font-size: .76rem; font-weight: 600; color: var(--muted); }
.brd-toggle-dot { width: 14px; height: 14px; border-radius: 50%; background: #cbd5e1; transition: background .15s, transform .15s; }
.brd-toggle.on { background: var(--brd-primary-light); border-color: var(--brd-primary); color: var(--brd-primary); }
.brd-toggle.on .brd-toggle-dot { background: var(--brd-primary); transform: translateX(2px); }
.brd-toggle:focus-visible { outline: 2px solid var(--brd-primary); outline-offset: 1px; }
/* lista serie temporali (una riga per serie) + editor a segmenti */
.brd-seg-list td { vertical-align: middle; }
.brd-seg-name { min-width: 180px; }
.brd-seg-sum { color: var(--text); }
.brd-seg-badge { display: inline-block; background: var(--brd-primary-light); color: var(--brd-primary); font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.brd-seg-tbl th.num, .brd-seg-tbl td { white-space: nowrap; }
.brd-seg-tbl td { vertical-align: middle; }
.brd-seg-kind { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; padding: 1px 7px; border-radius: 4px; }
.brd-seg-kind.const { background: #dcfce7; color: #166534; }
.brd-seg-kind.var { background: #fef3c7; color: #92400e; }
.brd-seg-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; margin-top: .7rem; padding: .8rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.brd-seg-add-f { display: flex; flex-direction: column; gap: .25rem; }
.brd-seg-add-f > label { font-size: .72rem; font-weight: 600; color: var(--muted); }
.brd-seg-add-f input[type=month] { border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; font-size: .8rem; }
.brd-seg-detrow > td { background: #fafbfc; padding: .5rem .8rem; }
.brd-seg-det { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.brd-seg-det .brd-dcell { min-width: 0; }
.brd-seg-det .brd-iu { max-width: none; }
/* layout a form raggruppato per dimensione (sostituisce le matrici-tabella annuali) */
.brd-agrid { display: flex; flex-direction: column; gap: .5rem; }
.brd-agrow { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; padding: .5rem .7rem; background: #fafbfc; border: 1px solid var(--border); border-radius: 8px; }
.brd-agrow-lab { font-weight: 600; color: var(--text); flex: 0 0 160px; min-width: 130px; font-size: .82rem; }
.brd-agrow-cells { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1; }
.brd-agrow-cells .brd-dcell { min-width: 82px; }
.brd-inp-empty { border-color: #fca5a5; background: #fff7f7; }
.brd-inp-empty::placeholder { color: #ef4444; opacity: .7; }
/* Organico — grafico piano teste per ruolo/mese (barre impilate CSS) */
.brd-org-legend { display: flex; flex-wrap: wrap; gap: .9rem; margin: 0 0 .7rem; }
.brd-org-lg { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: var(--muted); }
.brd-org-lg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.brd-org-chart { overflow-x: auto; }
.brd-org-bars { display: flex; gap: .5rem; align-items: flex-end; min-width: 480px; padding-top: .6rem; }
.brd-org-barcol { flex: 1; min-width: 30px; display: flex; flex-direction: column; align-items: center; }
.brd-org-bartot { font-size: .68rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; min-height: 1rem; text-align: center; line-height: 1.1; }
.brd-org-flow { display: block; font-size: .6rem; color: #64748b; font-weight: 600; }
.brd-sec-lbl { font-size: .8rem; font-weight: 700; color: var(--muted, #64748b); text-transform: uppercase; letter-spacing: .04em; margin: .2rem 0 .5rem; }
.brd-sup-sel { font-size: .82rem; }
.brd-org-bar { width: 60%; min-width: 20px; display: flex; flex-direction: column-reverse; justify-content: flex-start; border-radius: 4px 4px 0 0; overflow: hidden; background: #f1f5f9; }
.brd-org-bar.is-fut { outline: 1px dashed #cbd5e1; outline-offset: 1px; opacity: .82; }
.brd-org-seg { width: 100%; transition: height .2s; }
.brd-org-monthlab { font-size: .68rem; color: var(--muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .02em; }
/* cutoff actual/forecast */
.brd-cutoff { display: inline-flex; align-items: center; gap: .4rem; background: var(--brd-primary-light); border: 1px solid var(--border); border-radius: 8px; padding: .2rem .5rem; }
.brd-cutoff-lbl { font-size: .72rem; font-weight: 600; color: var(--brd-primary); white-space: nowrap; }
.brd-cutoff-inp { width: 130px; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .5rem; font-size: .78rem; }
.brd-cutoff-badge { font-size: .74rem; color: var(--brd-primary); background: var(--brd-primary-light); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .6rem; }
/* form modale tipizzato */
.brd-form { display: flex; flex-direction: column; gap: .7rem; }
.brd-form-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.brd-fld { display: flex; flex-direction: column; gap: .25rem; flex: 1; min-width: 160px; }
.brd-fld > span { font-size: .72rem; font-weight: 600; color: var(--muted); }
.brd-fld .brd-select, .brd-fld input[type=text], .brd-fld input[type=number], .brd-fld input[type=month] { width: 100%; box-sizing: border-box; }

/* Proiezione futura (forecast dinamico) */
.brd-fc-row { display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap; }
.brd-fc-grid { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.brd-fc-enable { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.brd-fc-enable input { width: 15px; height: 15px; }
.brd-fld-chk { flex-direction: row; align-items: center; gap: .5rem; min-width: 220px; }
.brd-fld-chk > span { font-size: .8rem; font-weight: 500; color: var(--text); }
.brd-fld-chk input { width: 15px; height: 15px; flex: 0 0 auto; }
.brd-inp-unit { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .8rem; font-weight: 600; }
.brd-dinp-sm { max-width: 84px !important; }
.brd-dtable td .brd-inp-unit .brd-dinp { max-width: 84px; }
.brd-fc-presets { display: flex; gap: .7rem; flex-wrap: wrap; }
.brd-fc-preset { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; text-align: left; padding: .7rem .9rem; min-width: 190px; height: auto; line-height: 1.3; }
.brd-fc-preset strong { font-size: .82rem; color: var(--text); }
.brd-fc-deals-toolbar { display: flex; gap: .5rem; flex-wrap: wrap; }
/* Costi "Per voce": gruppi natura espandibili */
.brd-cost-leaves { display: flex; flex-direction: column; gap: .5rem; }
.brd-cost-natgrp { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.brd-cost-nathead { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; background: #f8fafc; border: none; padding: .6rem .8rem; cursor: pointer; font-size: .85rem; color: var(--text); }
.brd-cost-nathead:hover { background: #eef1f6; }
.brd-cost-nathead strong { font-weight: 600; }
.brd-cost-caret { color: var(--brd-primary); font-size: .8rem; width: 14px; display: inline-block; }
.brd-cost-natbody { padding: .3rem .6rem .6rem; }
.brd-cost-natbody .brd-dtable th { font-size: .68rem; }
/* Previsione costi — cella nome (label statica + doppio clic per modifica) + chip categoria + conteggio gruppo */
.brd-plan-name { display: flex; flex-direction: column; gap: .15rem; min-width: 180px; }
.brd-plan-namelab { font-weight: 600; color: var(--text); border-radius: 5px; padding: .1rem .3rem; margin: -.1rem -.3rem; }
.brd-plan-namelab[role="button"] { cursor: text; }
.brd-plan-namelab[role="button"]:hover { background: #f1f5f9; }
.brd-plan-namelab:focus-visible { outline: 2px solid var(--brd-primary); outline-offset: 1px; }
.brd-plan-name-empty { color: #ef4444; }
.brd-plan-nminp { min-width: 200px; }
.brd-plan-cat { display: inline-block; align-self: flex-start; font-size: .68rem; color: #64748b; background: #f1f5f9; border-radius: 4px; padding: .05rem .35rem; }
.brd-plan-actions { margin-top: .5rem; }
.brd-plan-grpcount { margin-left: auto; font-size: .72rem; font-weight: 600; color: #475569; background: #eef2f7; border-radius: 999px; padding: .1rem .55rem; }
.brd-cost-natbody > .brd-table-wrap { margin: 0; }
.brd-step-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; margin-bottom: .35rem; font-size: .82rem; }
/* Editor smart per-anno dei driver */
.brd-annual-fill { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.brd-dcell-fut span { color: var(--brd-primary); }
.brd-dcell-fut input { border-style: dashed; background: #f8fafc; }

@media (max-width: 768px) {
  .brd-head { flex-direction: column; }
  .brd-table thead { display: none; }
  .brd-table tbody td { display: block; max-width: none; border-bottom: none; padding: .3rem .9rem; }
  .brd-table tbody td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; color: var(--muted); font-size: .72rem; text-transform: uppercase; }
  .brd-table tbody tr { display: block; border-bottom: 1px solid var(--border); padding: .5rem 0; }
}

/* ── Reporting — meta + rendering markdown del report azionisti ── */
.brd-rep-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: 0 0 1rem; font-size: .8rem; color: var(--muted, #64748b); }
.brd-rep-meta span { background: var(--surface, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 6px; padding: .2rem .55rem; }
.brd-report-md { color: var(--text, #0f172a); line-height: 1.6; font-size: .95rem; }
.brd-report-md .brd-md-h { color: var(--text, #0f172a); font-weight: 700; line-height: 1.3; margin: 1.3rem 0 .5rem; }
.brd-report-md h2.brd-md-h { font-size: 1.15rem; border-bottom: 2px solid var(--border, #e2e8f0); padding-bottom: .3rem; }
.brd-report-md h3.brd-md-h { font-size: 1.02rem; }
.brd-report-md h4.brd-md-h { font-size: .94rem; }
.brd-report-md .brd-md-h:first-child { margin-top: 0; }
.brd-report-md .brd-md-p { margin: .55rem 0; }
.brd-report-md .brd-md-ul, .brd-report-md .brd-md-ol { margin: .4rem 0 .85rem 1.3rem; }
.brd-report-md .brd-md-ul li, .brd-report-md .brd-md-ol li { margin: .25rem 0; }
.brd-report-md .brd-md-hr { border: 0; border-top: 1px solid var(--border, #e2e8f0); margin: 1.2rem 0; }
.brd-report-md .brd-md-table td { font-variant-numeric: tabular-nums; }
.brd-report-md code { background: var(--surface, #f1f5f9); padding: .05rem .3rem; border-radius: 4px; font-size: .85em; }
/* Variazioni colorate (segno ECONOMICO, non aritmetico): il prompt marca le celle Δ con {{good:…}}/{{bad:…}} */
.brd-report-md .brd-delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.brd-report-md .brd-delta-pos { color: #15803d; }
.brd-report-md .brd-delta-neg { color: #b91c1c; }
/* dettaglio serie a richiesta nella modale sola lettura */
.brd-ro-det > summary { cursor: pointer; font-size: .76rem; color: var(--brd-primary); background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 6px; padding: 2px 8px; display: inline-block; list-style: none; }
.brd-ro-det > summary::-webkit-details-marker { display: none; }
.brd-ro-det[open] > summary { margin-bottom: 5px; }
.brd-pct-bad { color: #991b1b; background: #fee2e2; border-radius: 5px; padding: 1px 6px; font-weight: 600; }
.brd-deal-off { opacity: .62; background: #fbfbfc; }
/* intestazione dati fattura nella modale di classificazione */
.brd-inv-mini { background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: .55rem .7rem; margin-bottom: .7rem; font-size: .86rem; }

/* ── Schedulazione report automatici (v259) ── */
/* §1.4.1 — stato del job in coda: un colore distinto per ogni valore, palette coerente con i badge audit */
.brd-jst-pending { background: #dbeafe; color: #1d4ed8; }   /* In coda — blu */
.brd-jst-claimed { background: #fef3c7; color: #92400e; }   /* In lavorazione — ambra */
.brd-jst-done    { background: #dcfce7; color: #166534; }   /* Completato — verde */
.brd-jst-error   { background: #fee2e2; color: #991b1b; }   /* Errore — rosso */
.brd-jst-skipped { background: #f1f5f9; color: #475569; }   /* Saltato — grigio */
/* Errore di validazione inline (§1.1: mai in toast) */
.brd-inline-err { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; border-radius: 8px; padding: .5rem .7rem; font-size: .85rem; }

/* ── Editor visuale del report (v263): si scrive sul documento formattato ── */
.brd-wys-tb { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .5rem .6rem; margin-bottom: .8rem;
  background: #f8fafc; border: 1px solid var(--border, #e2e8f0); border-radius: 10px; position: sticky; top: 0; z-index: 5; }
/* §1.2 — nessun bottone trasparente: sfondo pieno sempre */
.brd-wys-b { background: #ffffff; border: 1px solid var(--border, #e2e8f0); color: var(--text, #0f172a);
  border-radius: 7px; padding: .3rem .6rem; font-size: .82rem; line-height: 1.2; cursor: pointer; font-family: inherit; }
.brd-wys-b:hover { background: #eef2f7; }
.brd-wys-b:active { background: #e2e8f0; }
.brd-wys-b:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: 1px; }
.brd-wys-sep { width: 1px; height: 20px; background: var(--border, #e2e8f0); margin: 0 .2rem; }
.brd-wys { min-height: 58vh; padding: 1.1rem 1.2rem; border: 1px solid var(--border, #e2e8f0); border-radius: 10px;
  background: #fff; overflow-y: auto; }
.brd-wys:focus { outline: 2px solid var(--primary, #2563eb); outline-offset: 1px; }
/* le celle restano visibili come area editabile mentre si lavora */
.brd-wys table td:hover, .brd-wys table th:hover { background: #f8fafc; }
@media (prefers-reduced-motion: reduce) { .brd-wys-b { transition: none; } }
