/* BeOurBest: prototipo portale retail (desktop ~1360px).
   I token vivono in ../shared/tokens.css (fonte: DESIGN.md), qui solo
   stili di superficie, tutti i colori via var(--token). */

body { background: var(--surface); }

/* ================= Layout portale (chrome prodotto) ================= */

.portal { display: flex; min-height: 100vh; }

.hq-banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  background: var(--secondary-lilla); color: #2A1C3E; font-size: 13px; font-weight: 700; }
.hq-banner .hq-select { border-radius: var(--radius-ctl); border: none; padding: 3px 8px;
  font-size: 13px; font-weight: 700; }
.hq-banner .hq-exit { margin-left: auto; color: #2A1C3E; }

.sidebar {
  width: 232px; flex: none;
  background: linear-gradient(180deg, var(--petrol-grad-start), var(--petrol-grad-end));
  color: #fff;
  border-right: none;
  padding: 24px 14px 18px;
  display: flex; flex-direction: column;
}
.sb-brand { padding: 0 10px; }
.brand-logo { width: 170px; height: auto; display: block; }
/* Brand FUORI dalla card, sullo stage petrolio: stessa impostazione dell'admin ,
   lockup bianco + ruolo in caption, e la card resta chiara col solo form. */
.auth-brand--stage { text-align: center; margin-bottom: 22px; }
.auth-brand--stage .brand-logo { width: 220px; height: auto; margin: 0 auto; }
.auth-role {
  font-size: 11px; font-weight: 800; color: var(--secondary-lilla);
  text-transform: uppercase; letter-spacing: 0.1em; margin-top: 14px;
}
.auth-trust {
  margin-top: 18px; font-size: 12px; text-align: center;
  color: rgba(255, 255, 255, 0.66);
}
/* Intestazione in lilla: richiesta esplicita del committente (feedback
   rev260824). DEBITO DI ACCESSIBILITA' ACCETTATO CONSAPEVOLMENTE: 2,86:1 sul
   petrolio in cima al gradiente (#4D7982), sotto il 4,5:1 di AA. Non e' una
   regressione di classe: il bianco al 66% che c'era prima faceva 3,06:1, gia'
   sotto soglia.
   Su questo fondo NON esiste un lilla che passi AA, e non e' questione di
   schiarirlo abbastanza: in cima al gradiente il tetto assoluto e' il bianco
   pieno, a 4,80:1, e gia' #F9F6FE, che a occhio e' bianco e non lilla, si
   ferma a 4,49:1. Il margine fra "si legge ancora come lilla" e 4,5:1 non
   esiste. L'uscita e' il fondo, non il testo: lo stesso #D5BEF4 passa AA dal
   ~52% del gradiente in giu' (6,83:1 sul #273D41 finale). Queste etichette
   stanno in cima, quindi il debito resta: dichiarato, non nascosto. */
/* Stacco logo↔intestazione: 14px, lo stesso dei tre portali. Il feedback
   rev260824 (S2) chiede il logo «piu' alto COME PER IL PORTALE HEADQUARTER»:
   il confronto e' fra le due sidebar affiancate, e qui l'etichetta partiva a
   filo (0px) contro i 14px di headquarter. */
.sb-struttura {
  font-size: 12.5px; font-weight: 700; color: var(--secondary-lilla);
  margin-top: 14px; margin-bottom: 22px;
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-ctl);
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  color: rgba(255, 255, 255, 0.78); cursor: pointer;
  border: none; background: none; text-align: left; width: 100%;
}
.nav-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.nav-item.active {
  color: var(--secondary-lilla);
  background: rgba(255, 255, 255, 0.10);
}
.nav-item.active svg { stroke: var(--secondary-lilla); }
.nav-item .badge { margin-left: auto; }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--accent); color: var(--petrol-grad-end);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
}

.portal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 28px;
  background: var(--elevated); border-bottom: 1px solid var(--hairline);
}
.tb-title { font-size: 17px; font-weight: 800; }
.tb-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 700; }
.tb-exit {
  border: none; background: none; font-family: inherit; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 6px;
}
.tb-exit:hover { color: var(--primary-strong); }

/* Colonna flex + flex:1 così il .center-fill dell'error-state di caricamento
   (tokens.css) si espande e centra il messaggio a metà dell'area contenuto.
   Nei flussi normali i figli restano full-width come in block layout. */
.portal-body {
  padding: 24px 28px 56px; width: 100%; max-width: 1128px;
  flex: 1; display: flex; flex-direction: column;
}

/* ================= Avatar ================= */

.avatar {
  border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.md { width: 34px; height: 34px; font-size: 12.5px; }
.avatar.lg { width: 52px; height: 52px; font-size: 17px; }
.av-1 { background: var(--success-bg); color: var(--success); }
.av-2 { background: var(--info-bg);    color: var(--info); }
.av-3 { background: var(--warning-bg); color: var(--warning); }
.av-4 { background: var(--error-bg);   color: var(--error); }
/* L'avatar porta la foto quando c'e', le iniziali (col colore derivato dal nome)
   quando manca: le iniziali restano il default, non un ripiego temporaneo. */
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }

/* ================= Card / tabelle ================= */

.card {
  background: var(--elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-inner { padding: 18px 20px; }
.card-title { font-size: 14px; font-weight: 800; margin: 0 0 4px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 800;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--surface); }
.tbl .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tbl .chev { color: var(--muted); font-weight: 700; }
.row-muted { opacity: 0.6; }

.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person .nm { font-weight: 700; }

/* toolbar sopra le tabelle */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spread { margin-left: auto; }
.tbl-summary { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tbl-hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; max-width: 900px; }

/* ================= Form ================= */

.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 800;
  letter-spacing: 0.03em; color: var(--muted); margin-bottom: 5px;
}
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  background: var(--elevated); color: var(--on-surface);
  font-family: inherit; font-size: 14px;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.input[readonly] { background: var(--surface); color: var(--muted); }
.input.w-auto { width: auto; }
select.input { cursor: pointer; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.btn-outline {
  background: var(--elevated); color: var(--primary-strong);
  border: 1.5px solid var(--primary);
}

/* ================= Chip & semafori ================= */

.chip.info { color: var(--info); background: var(--info-bg); }
.chip.warn { color: var(--warning); background: var(--warning-bg); }
.chip.pref {
  color: var(--primary-strong); background: var(--elevated);
  border: 1.5px solid var(--primary);
}

.idx-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px; min-width: 176px;
}
.idx-mini { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; }
.idx-mini .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.idx-mini.ok   { color: var(--success); }
.idx-mini.attn { color: var(--warning); }
.idx-mini.off  { color: var(--error); }
/* R40: blocco in calibrazione: nessun semaforo, perché non c'è ancora nulla da
   valutare. Il grigio dice "non ancora", il verde direbbe "va bene". */
.idx-mini.neutral { color: var(--muted); }

.delta { font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.delta.up   { color: var(--success); }
.delta.down { color: var(--error); }
.delta.flat { color: var(--muted); }

/* ================= Segmented control ================= */

.seg {
  display: inline-flex; border: 1px solid var(--hairline);
  border-radius: var(--radius-full); overflow: hidden; background: var(--elevated);
}
.seg button {
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 5px 11px; border: none; background: none;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg button + button { border-left: 1px solid var(--hairline); }
.seg button.active { background: var(--primary); color: var(--on-primary); }

.filter-chip {
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  padding: 6px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--hairline); background: var(--elevated);
  color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.filter-chip .mono { font-size: 11.5px; }
.person-filter { max-width: 220px; margin-left: 8px; }

/* ================= Auth (login / invito / recupero) ================= */

.auth-stage {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--petrol-grad-start), var(--petrol-grad-end));
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 20px;
}
.auth-row {
  display: flex; gap: 20px; justify-content: center;
  align-items: flex-start; flex-wrap: wrap; width: 100%; max-width: 920px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--elevated);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 30px 30px 24px;
}
.auth-row .auth-card { flex: 1 1 340px; max-width: 440px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-sub { font-size: 13px; font-weight: 700; color: var(--secondary-lilla-strong); margin-top: 2px; }
.auth-title { font-size: 17px; font-weight: 800; margin: 0 0 4px; }
/* ===== Superficie auth: invariante fra i tre portali =====
   Stessi numeri della console admin, che è il riferimento: card 384 con padding
   26/26/20, titolo 20/800 senza margine, sottolinea 13 muted a 3/0/18, campi a
   14px con label 12,5/700, ghost a 6 di stacco.
   Il blocco è volutamente IDENTICO nei tre stylesheet: in implementazione le tre
   schermate diventano un solo componente e questo blocco un solo file. Se tocchi
   un numero qui, toccalo in tutti e tre. */
.auth-card.auth-card--std { width: 384px; max-width: 384px; padding: 26px 26px 20px; }
.auth-card.auth-card--std .auth-title { font-size: 20px; font-weight: 800; margin: 0; text-align: center; }
.auth-card.auth-card--std .auth-lead {
  font-size: 13px; font-weight: 400; color: var(--muted);
  line-height: 1.5; margin: 3px 0 18px; text-align: center;
}
.auth-card.auth-card--std .field { margin-bottom: 14px; }
.auth-card.auth-card--std .field label,
.auth-card.auth-card--std .field-label {
  display: block; font-size: 12.5px; font-weight: 700;
  color: var(--muted); margin-bottom: 6px;
}
.auth-card.auth-card--std .input,
.auth-card.auth-card--std .field input { width: 100%; font-size: 14px; padding: 10px 12px; }
.auth-card.auth-card--std .btn-primary { margin-top: 0; }
.auth-card.auth-card--std .btn + .btn { margin-top: 6px; }
.auth-desc { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.5; }
.auth-card .btn + .btn { margin-top: 8px; }

.map-note {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  text-align: center; margin-top: 16px;
}

/* ================= Monitoraggio ================= */

.mon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.mon-card {
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 14px 16px; cursor: pointer;
}
.mon-card:hover { border-color: var(--primary); }
.mon-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mon-head .nm { font-size: 14px; font-weight: 800; }
.mon-head .sub { font-size: 11.5px; color: var(--muted); }
.mon-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-top: 1px solid var(--hairline);
}
.mon-row .idx-mini { flex: 1; }
/* R37: marcatore della preferenza-blocco, che in monitoraggio sta in testa alla card. */
.mon-pref {
  font-size: 9.5px; font-weight: 800; letter-spacing: .02em;
  color: var(--primary-strong); background: var(--elevated);
  border: 1px solid var(--primary); border-radius: 999px; padding: 1px 6px;
}
.mon-row .score { font-family: var(--font-mono); font-size: 15px; }
.mon-foot { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ================= Scheda persona ================= */

.person-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.person-head .who { min-width: 0; }
.person-head .nm { font-size: 19px; font-weight: 800; }
.person-head .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.person-head .chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.person-head .actions { margin-left: auto; display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 18px; }
.tabs button {
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 9px 14px; margin-bottom: -1px;
  border: none; background: none; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.idx-card {
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.idx-card .top { display: flex; align-items: center; gap: 8px; }
.idx-card .name { font-size: 14px; font-weight: 800; }
.idx-card .sez { font-size: 11.5px; color: var(--muted); }
.idx-card .top .chip { margin-left: auto; }
.idx-card .bottom { display: flex; align-items: flex-end; gap: 12px; margin-top: 10px; }
.idx-card .score { font-family: var(--font-mono); font-size: 26px; font-weight: 500; line-height: 1; }
.idx-card .score .of { font-size: 13px; color: var(--muted); }
.idx-card .caption { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.idx-card .spark { margin-left: auto; }

.trend-row {
  display: flex; align-items: center; gap: 18px;
  padding: 13px 0; border-top: 1px solid var(--hairline);
}
.trend-row:first-child { border-top: none; }
.trend-row .lbl { width: 130px; flex: none; }
.trend-row .lbl .nm { font-size: 13.5px; font-weight: 800; }
.trend-row .lbl .sez { font-size: 11px; color: var(--muted); }
.trend-row .cmp { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.trend-row .cmp .mono { font-size: 13px; color: var(--on-surface); }

/* ================= Spark (condiviso) ================= */

.spark polyline { stroke: var(--primary); }
.spark .spark-baseline { stroke: var(--muted); stroke-dasharray: 4 3; stroke-width: 1; }
.spark-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.spark-legend .dash { width: 18px; border-top: 2px dashed var(--muted); }

/* ================= Dettaglio scostamento ================= */

.backlink {
  border: none; background: none; font-family: inherit; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--primary-strong);
  padding: 0; margin-bottom: 14px; display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start; /* .portal-body è flex column: non stirare il link */
}
.dev-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.dev-head .ttl { font-size: 17px; font-weight: 800; margin: 6px 0 4px; }
.dev-head .meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-head .state-box { margin-left: auto; text-align: right; }
.dev-head .state-box .lbl { font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.state-note { font-size: 11.5px; color: var(--muted); margin-top: 8px; max-width: 240px; }

/* Gli stadi dello scostamento, resi accanto allo stato e non in una legenda a
   parte: eredita l'allineamento a destra della .state-box. Lo stadio corrente e'
   l'unico a piena tinta; l'altro resta leggibile ma spento, cosi' si vede in
   un colpo che sono due e dove si e'. */
.stadi { margin-top: 10px; max-width: 240px; margin-left: auto; }
.stadi .chain { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.stadi .st { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.stadi .st.now { color: var(--primary-strong); font-weight: 800; }
.stadi .sep { font-size: 11.5px; color: var(--muted); }
.stadi .why { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.tl-row { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.tl-row .tl-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: none;
  background: var(--hairline); }
.tl-row.done .tl-dot { background: var(--success); }
.tl-row.pending .tl-dot { background: var(--warning); }
.tl-row .t { font-weight: 700; font-size: 13.5px; }
.tl-row .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.factor-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--hairline);
}
.factor-row:first-child { border-top: none; }
.factor-row .t { font-size: 13.5px; font-weight: 800; }
.factor-row .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.factor-row .v { margin-left: auto; font-family: var(--font-mono); font-size: 17px; white-space: nowrap; }

.rule-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl); padding: 12px 14px;
}
.rule-box .nm { font-size: 13.5px; font-weight: 800; }
.rule-box .cond { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ================= Regole & soglie ================= */

.rules-layout { display: flex; gap: 16px; align-items: flex-start; }
.rules-list { flex: 1.4; min-width: 0; }
.rules-editor { flex: 1; min-width: 300px; position: sticky; top: 16px; }
.tbl tr.selected td { background: var(--surface); }
.tbl tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.action-preview { background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl); padding: 10px 12px; }
.action-preview .ap-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--muted); margin-bottom: 4px; }
.action-preview .ap-msg { font-size: 13.5px; line-height: 1.5; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 13.5px; margin-top: 6px; }

/* ================= Chat ================= */

.chat-wrap { display: flex; height: 580px; }
.chat-list { width: 300px; flex: none; border-right: 1px solid var(--hairline); overflow-y: auto; }
.chat-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--hairline); width: 100%;
  border-left: none; border-top: none; border-right: none;
  background: none; font-family: inherit; text-align: left;
}
.chat-item:hover { background: var(--surface); }
.chat-item.active { background: var(--surface); box-shadow: inset 3px 0 0 var(--primary); }
.chat-item .who { flex: 1; min-width: 0; }
.chat-item .nm { font-size: 13.5px; font-weight: 800; }
.chat-item .preview {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}
.chat-item .side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.chat-item .when { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }

.chat-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.thread-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--hairline);
}
.thread-head .nm { font-size: 14px; font-weight: 800; }
.live-pill {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700;
  color: var(--success); background: var(--success-bg);
  border-radius: var(--radius-full); padding: 3px 10px;
}
.live-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: proto-pulse 1.6s infinite; }
@keyframes proto-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 62%; padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; }
.msg .when { display: block; font-family: var(--font-mono); font-size: 10px; margin-top: 4px; opacity: 0.75; }
.msg.op { align-self: flex-end; background: var(--primary); color: var(--on-primary); border-bottom-right-radius: 4px; }
.msg.p  { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline); border-bottom-left-radius: 4px; }
.msg-trigger { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.msg.op .msg-trigger { color: var(--on-primary); }

.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--hairline); }
.composer .input { flex: 1; }

/* ================= Operatori / profilo ================= */

.invite-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.invite-row .field { margin-bottom: 0; }
.invite-row .grow { flex: 1; min-width: 220px; }
.action-link {
  border: none; background: none; font-family: inherit; cursor: pointer;
  font-size: 12.5px; font-weight: 700; color: var(--primary-strong); padding: 2px 4px;
}
.action-link.danger { color: var(--error); }
.action-note { font-size: 11.5px; color: var(--success); font-weight: 700; margin-top: 3px; }

.profile-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.qr-panel { text-align: center; padding: 6px 0 2px; }
.qr-box {
  display: inline-block; padding: 12px;
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl);
}
.qr-code {
  font-family: var(--font-mono); font-size: 21px; letter-spacing: 0.12em;
  margin: 12px 0 2px;
}
.qr-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

/* ---- BOB Index e badge di affidabilità (spec §8.2) ------------------------ */
.mon-head .mon-bob { margin-left: auto; text-align: right; line-height: 1; }
.mon-head .mon-bob .mono { font-size: 22px; font-weight: 500; }
.mon-head .mon-bob .lbl {
  display: block; font-size: 9.5px; font-weight: 800; letter-spacing: 0.08em;
  color: var(--muted); margin-top: 2px;
}
.mon-bob.ok .mono   { color: var(--success); }
.mon-bob.attn .mono { color: var(--warning); }
.mon-bob.off .mono  { color: var(--error); }
.mon-bob.empty .mono { color: var(--muted); }
.mon-badge { margin: -4px 0 8px; }

.ic-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--muted);
}
.ic-badge .ic-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ic-badge.ic-oro     { color: #8A6B2A; background: #F7EFDC; border-color: #E6D4AC; }
.ic-badge.ic-argento { color: #5E6A72; background: #EDF1F3; border-color: #D3DBE0; }
.ic-badge.ic-bronzo  { color: #8A5A3C; background: #F5E9E2; border-color: #E0C9BC; }

.bob-summary { display: flex; align-items: center; gap: 16px; }
.bob-num { flex: none; line-height: 1; }
.bob-num .mono { font-size: 34px; font-weight: 500; }
.bob-num .of { font-size: 14px; color: var(--muted); }
.bob-num.ok .mono   { color: var(--success); }
.bob-num.attn .mono { color: var(--warning); }
.bob-num.off .mono  { color: var(--error); }
/* BOB Index in costruzione (R41): trattino grigio, mai uno zero rosso. */
.bob-num.empty .mono { color: var(--muted); }
.bob-copy { flex: 1; }
.bob-summary .ic-badge { flex: none; }

/* ---- Barra del consenso ai parametri grezzi (R47) ------------------------- */
.consent-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl);
}
.consent-bar .consent-note { flex: 1; font-size: 12px; color: var(--muted); min-width: 240px; }

/* ---- Dialog (conferme, es. pausa segnalazioni PS23) ----------------------- */
.dialog-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--on-surface) 45%, transparent);
  display: flex; align-items: center; justify-content: center;
}
.dialog {
  width: 420px; max-width: calc(100% - 32px);
  background: var(--elevated); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 22px 24px;
}
.dialog-title { font-size: 16.5px; font-weight: 800; margin-bottom: 6px; }
.dialog-text { font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---- Chat flottante (chrome, R22/PS4: resta aperta durante la navigazione)
   z-index 30: sopra il contenuto normale della pagina, ma SOTTO qualsiasi scrim
   modale (.dialog-overlay è 40): un dialog deve bloccare tutto, dock inclusa. */
.chat-dock-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: var(--on-primary); font-size: 22px;
  box-shadow: 0 6px 18px rgba(28, 52, 54, 0.28);
}
.chat-dock-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px;
  border-radius: var(--radius-full); background: var(--accent); color: var(--petrol-grad-end);
  font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 5px;
}
.chat-dock {
  position: fixed; right: 22px; bottom: 22px; z-index: 30;
  width: 336px; max-height: 460px; display: flex; flex-direction: column;
  background: var(--elevated); border: 1px solid var(--hairline); border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(28, 52, 54, 0.22); overflow: hidden;
}
.chat-dock-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: linear-gradient(150deg, var(--petrol-grad-start), var(--petrol-grad-end)); color: var(--on-primary);
}
.chat-dock-select {
  flex: 1; background: rgba(255, 255, 255, 0.14); color: var(--on-primary); border: none;
  border-radius: var(--radius-ctl); padding: 6px 8px; font: inherit; font-size: 13px;
}
.chat-dock-close { background: none; border: none; color: var(--on-primary); font-size: 20px; cursor: pointer; line-height: 1; }
.chat-dock-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-dock-msg { max-width: 82%; padding: 8px 11px; border-radius: var(--radius-md); font-size: 13.5px; }
.chat-dock-vuota { margin: auto 0; text-align: center; font-size: 12.5px; color: var(--muted); padding: 0 8px; }
.chat-dock-msg.in { background: var(--surface); align-self: flex-start; }
.chat-dock-msg.out { background: var(--primary); color: var(--on-primary); align-self: flex-end; }
.chat-dock-msg.out .msg-trigger, .chat-dock-msg.out .chat-dock-time { color: var(--on-primary); }
.chat-dock-time { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.chat-dock-foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--hairline); }
.chat-dock-foot .input { flex: 1; }

/* ---- Parametri grezzi: sintesi robuste e voci del Diario ----
   Stessa impostazione di "I tuoi valori" nell'app (R47: stessa resa). */
.card-unit { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.par-sintesi { display: flex; gap: 10px; margin: 10px 0 14px; }
.ps-box { flex: 0 0 auto; min-width: 190px; background: var(--surface); border-radius: var(--radius-md); padding: 9px 12px; }
.ps-lab { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.ps-val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.par-voci { margin: 10px 0 4px; }
.par-voce {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--hairline);
}
.par-voce:last-child { border-bottom: none; }
.pv-data { font-size: 13px; color: var(--muted); }
.pv-val { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.pv-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--hairline); border-radius: 999px; padding: 2px 7px;
}
.card-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 10px; }
