/* BeOurBest: prototipo portale headquarter: stili di superficie (desktop ~1360px).
   I token vivono in ../shared/tokens.css (fonte: DESIGN.md): nessun colore
   hardcoded qui: solo var(--token) (+ color-mix su token per scrim e focus). */

/* ---- Shell prodotto: sidebar + main ---- */
.portal {
  /* max-width, non width: a 1360 fissi la pagina scorre in orizzontale su
     qualunque finestra piu' stretta: e 1366 meno la scrollbar lo e' gia'.
     In demo su un portatile non massimizzato la colonna Stato finiva fuori. */
  width: 100%; max-width: 1360px; min-height: 100vh;
  margin: 0 auto; display: flex;
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  border-right: 1px solid var(--hairline);
}

.sidebar {
  width: 236px; flex: none;
  background: linear-gradient(180deg, var(--petrol-grad-start), var(--petrol-grad-end));
  color: #fff;
  border-right: none;
  padding: 22px 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.side-brand { padding: 0 10px 18px; }
.brand-logo { width: 170px; height: auto; display: block; }
/* Lockup nero DENTRO una card chiara: tenuto per eventuali landing standalone
   senza stage petrolio sopra. */
.brand-logo--auth { width: 210px; padding: 0; background: none; margin: 0 auto 6px; }
/* 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);
}
/* Lilla su petrolio: DEBITO DI ACCESSIBILITA' ACCETTATO (2,86:1). Nota
   estesa in portale-struttura/styles.css, sopra .sb-struttura. */
/* Stacco logo↔intestazione: 14px. E' il valore che il feedback rev260824 (S2)
   nomina come riferimento: retail e admin ci sono stati allineati. */
.side-org { font-size: 14px; font-weight: 800; margin-top: 14px; color: var(--secondary-lilla); }
.side-portal {
  font-size: 11.5px; font-weight: 700; color: rgba(255, 255, 255, 0.66);
  text-transform: uppercase; letter-spacing: 0.07em; margin-top: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 700; color: rgba(255, 255, 255, 0.78); cursor: pointer;
}
.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 svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; flex: none; }
.side-spacer { flex: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; flex: none;
  display: flex; align-items: center; padding: 0 32px;
  background: var(--elevated); border-bottom: 1px solid var(--hairline);
}
.tb-title { font-size: 18px; font-weight: 800; }
.tb-who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tb-meta { text-align: right; }
.tb-name { font-size: 13.5px; font-weight: 800; }
.tb-role { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tb-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; letter-spacing: 0.02em;
}
.content {
  flex: 1; min-width: 0; padding: 26px 32px 40px;
  /* Colonna flex: fa espandere davvero il .center-fill (error-state di
     caricamento, tokens.css) fino a riempire l'area contenuto. Con un solo
     figlio block (tutti gli altri stati) il layout resta identico. */
  display: flex; flex-direction: column;
}

/* ---- Schermate auth (senza sidebar) ---- */
.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 0;
}
.auth-card {
  width: 410px;
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 36px 38px 30px;
}
.auth-caption {
  font-size: 12.5px; font-weight: 700; color: var(--secondary-lilla-strong);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 2px 0 22px;
}
.auth-title { font-size: 19px; font-weight: 800; margin-bottom: 14px; }
.auth-sub { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: -6px 0 16px; }
.auth-banner { margin-bottom: 14px; }
.auth-submit { margin-top: 6px; }
.auth-links { text-align: center; margin-top: 16px; }

/* ===== 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; }


/* ---- Form ---- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  font-family: var(--font-sans); font-size: 14.5px;
  background: var(--elevated); color: var(--on-surface);
}
.field select:disabled { opacity: 0.6; }
.field input:focus, .field select:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.field input:disabled { opacity: 0.6; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.link { color: var(--primary-strong); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-xs { display: inline-block; width: auto; padding: 6px 12px; font-size: 12.5px; }
.btn-ghost-danger { color: var(--error); background: none; }
.btn-danger-solid { background: var(--error); color: var(--on-primary); }
.btn-outline-danger {
  display: inline-block; width: auto; padding: 8px 16px; font-size: 13.5px;
  color: var(--error); background: var(--elevated);
  border: 1px solid var(--error); border-radius: var(--radius-btn);
}
.btn-outline {
  background: var(--elevated); color: var(--primary-strong);
  border: 1.5px solid var(--primary);
}
.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.sem-bar { display: flex; width: 88px; height: 9px; border-radius: var(--radius-full); overflow: hidden; background: var(--hairline); }
.sem-seg.ok { background: var(--success); }
.sem-seg.attn { background: var(--warning); }
.sem-seg.off { background: var(--error); }
.cell-muted { color: var(--muted); font-size: 12.5px; }
.banner-warning {
  display: flex; align-items: center; gap: 10px;
  background: var(--warning-bg); color: var(--warning);
  border-radius: var(--radius-ctl); padding: 12px 14px;
  font-size: 14px; font-weight: 600;
}

/* ---- Stat tiles (conteggi aggregati) ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stats-2 { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.stat {
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 16px 20px;
}
.stat .st-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; line-height: 1.1; }
.stat .st-label {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.02em; margin-top: 6px;
}
.stat .st-cap { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; }

/* ---- Toolbar lista ---- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar .search { flex: 1; max-width: 340px; }
.toolbar .search input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  font-family: var(--font-sans); font-size: 14px;
  background: var(--elevated); color: var(--on-surface);
}
.toolbar .search input:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.toolbar .spacer { flex: 1; }

/* ---- Tabella ---- */
.table-card {
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  overflow: hidden; overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 12px 16px;
  font-size: 11.5px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--surface); border-bottom: 1px solid var(--hairline);
}
.table th.num-h { text-align: right; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--hairline); font-size: 14px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.rowlink { cursor: pointer; }
.table tbody tr.rowlink:hover { background: var(--surface); }
.table .num { text-align: right; font-family: var(--font-mono); font-size: 13.5px; }
/* Colonne aggregati (PS25): numeriche compatte, padding orizzontale ridotto
   perché il contenuto è breve (2-3 cifre): evita di far traboccare la
   tabella rete quando si aggiungono più colonne di sintesi. */
.table th.col-tight, .table td.col-tight { padding-left: 10px; padding-right: 10px; }
.cell-main { font-weight: 700; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cell-actions { text-align: right; white-space: nowrap; }
/* Due azioni di riga (consultazione + disattiva): impilate invece che
   affiancate, altrimenti la label esplicita "Consultazione dettagli utenti"
   (PS25 review) da sola sfonda la larghezza della tabella rete. */
.cell-actions-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; white-space: normal; }
.btn-consult-compact {
  width: 116px; white-space: normal; text-align: center; line-height: 1.3;
  padding: 6px 8px; font-size: 12px;
}
.sk-row { height: 52px; margin: 10px 16px; }

/* ---- Card e key-value ---- */
.card {
  background: var(--elevated); border: 1px solid var(--hairline);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 20px 24px;
}
.card-head { display: flex; align-items: center; margin-bottom: 10px; }
.card-title { font-size: 15px; font-weight: 800; }
.card-head .btn { margin-left: auto; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.mt { margin-top: 20px; }

.kv {
  display: grid; grid-template-columns: 170px 1fr; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--hairline);
  font-size: 14px; align-items: baseline;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); font-weight: 600; font-size: 13px; }
.kv .v { font-weight: 600; }

/* ---- Pagina dettaglio ---- */
.crumb { display: inline-block; font-size: 13px; font-weight: 700; color: var(--primary-strong); cursor: pointer; margin-bottom: 12px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-title { font-size: 22px; font-weight: 800; }
.page-head .spacer { flex: 1; }

/* ---- 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: 460px;
  background: var(--elevated); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 24px 26px;
}
.dialog-title { font-size: 17px; font-weight: 800; margin-bottom: 8px; }
.dialog-body { font-size: 14px; line-height: 1.55; }
.dialog-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.preview {
  border: 1px solid var(--hairline); border-radius: var(--radius-ctl);
  background: var(--surface); padding: 12px 14px; margin-top: 12px;
}

/* ---- Empty state (azioni affiancate) ---- */
.es-actions { display: flex; gap: 10px; justify-content: center; }

/* ---- Catalogo regole (R48): riga selezionata + anteprima messaggio ------- */
.table tbody tr.rowlink.selected { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.table tbody tr.rowlink.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

/* ---- Finalità ingaggio/premio (PS30) -------------------------------------- */
.chip--finalita { font-size: 11px; font-weight: 700; }
.finalita-ingaggio { background: var(--info-bg); color: var(--info); }
.finalita-premio { background: var(--success-bg); color: var(--success); }
.btn-ghost.active { background: var(--primary); color: var(--on-primary); }
