/* ==========================================================================
   Revalior — Componenti della dashboard operativa
   ========================================================================== */

/* ---------- Riquadri della Home --------------------------------------- */

.tile-group + .tile-group { margin-top: 36px; }
.tile-group__label {
  margin-bottom: 14px;
  font-family: var(--font-display);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile {
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 6px;
  min-height: 176px;
  padding: 22px;
  border: 1px solid transparent;
  border-top: 4px solid var(--rv-salvia);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.tile:hover { border-top-color: var(--rv-verde); box-shadow: var(--shadow-md); }
@media (prefers-reduced-motion: no-preference) { .tile:hover { transform: translateY(-2px); } }
.tile__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--rv-salvia);
  color: var(--rv-verde);
}
.tile__icon .icon { width: 20px; height: 20px; }
.tile__title { margin-top: 6px; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); color: var(--rv-profondo); }
.tile__desc { font-size: var(--fs-sm); line-height: 1.45; color: var(--color-muted); }
.tile__num { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.tile__num b { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 700; color: var(--rv-profondo); font-variant-numeric: tabular-nums; line-height: 1; }
.tile__num small { font-size: var(--fs-xs); color: var(--color-muted); }
.tile--human { border-top-color: #EAD9B8; }
.tile--human .tile__icon { background: var(--rv-ambra-bg); color: var(--rv-ambra); }
.tile--human:hover { border-top-color: var(--rv-ambra); }
.tile--attn { border-top-color: var(--rv-ambra); }
.tile__chip {
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--rv-rosso-bg);
  color: var(--rv-rosso);
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* ---------- Stati e fasi ----------------------------------------------- */

.badge--stop { background: var(--rv-rosso-bg); color: var(--rv-rosso); }
.stat__value--warn { color: var(--rv-ambra); }
.legend-note { font-size: var(--fs-xs); color: var(--color-muted); }
.stack { display: grid; gap: 16px; }
.stack--sm { display: grid; gap: 10px; }
.mt { margin-top: 20px; }
.mt-sm { margin-top: 10px; }
.w-full { width: 100%; }
.row--end { align-items: flex-end; }
fieldset.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.row--end .field { flex: 0 1 300px; }

.phasebar { display: flex; gap: 3px; margin: 6px 0 4px; }
.phasebar span { width: 14px; height: 8px; border-radius: 2px; background: var(--rv-linea); }
.phasebar span.is-human { border-radius: 8px; }
.phasebar .is-done { background: var(--rv-verde); }
.phasebar .is-run { background: var(--rv-profondo); box-shadow: 0 0 0 2px #CFE7DE; }
.phasebar .is-wait { background: #C98A1E; box-shadow: 0 0 0 2px var(--rv-ambra-bg); }
.phasebar .is-stop { background: var(--rv-rosso); box-shadow: 0 0 0 2px var(--rv-rosso-bg); }
.phasebar .is-closed { background: var(--rv-linea-forte); }
.phasebar .is-final { background: var(--rv-verde); }

.fase { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-weight: 700; font-size: var(--fs-sm); }
.fase--agent { background: #E3F1EC; color: var(--rv-profondo); }
.fase--human { background: var(--rv-ambra-bg); color: #6B4510; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--rv-salvia);
  color: var(--rv-profondo);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.tag--new { background: var(--rv-verde); color: #fff; }
.tag--pro { background: var(--rv-profondo); color: var(--color-on-dark); }
.tag--warn { background: var(--rv-ambra-bg); color: var(--rv-ambra); }

/* ---------- Tabelle di lavoro ----------------------------------------- */

.table--work td { padding: 12px 14px; }
.table--work th { padding: 12px 14px; font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase; }
.table--work tbody tr:nth-child(even) td { background: transparent; }
.table--work tbody tr:hover td { background: #F3F8F5; }
.table--work tr.is-new td:first-child { box-shadow: inset 3px 0 0 var(--rv-verde); }
.cell-sub { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--color-muted); }
span.cell-note { display: block; max-width: 280px; margin-top: 4px; font-size: var(--fs-xs); color: var(--color-muted); white-space: normal; }
/* Testo piccolo in una cella intera: resta una cella di tabella (display: block la farebbe uscire dalla griglia) */
td.cell-small { min-width: 200px; font-size: var(--fs-xs); color: var(--color-muted); white-space: normal; }
.cell-actions { text-align: right; white-space: nowrap; }
.table-empty { padding: 32px 16px !important; text-align: center; color: var(--color-muted); }

/* ---------- Filtri ------------------------------------------------------ */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.filters .search { position: relative; flex: 1 1 280px; }
.filters .search .icon { position: absolute; top: 50%; left: 12px; width: 18px; height: 18px; transform: translateY(-50%); color: var(--color-muted); }
.filters .search .input { padding-left: 40px; }
.filters .select { width: auto; min-width: 170px; }
.filters__count { margin-left: auto; font-size: var(--fs-sm); font-weight: 700; color: var(--rv-grafite); }

/* ---------- Layout con pannello laterale -------------------------------- */

.workgrid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.side-stack { display: grid; gap: 16px; }
.mini-list { display: grid; margin: 0; padding: 0; list-style: none; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--color-line); }
.mini-list li:first-child { border-top: 0; padding-top: 0; }
.mini-list b { display: block; font-size: var(--fs-sm); color: var(--rv-profondo); }
.mini-list small { display: block; font-size: var(--fs-xs); color: var(--color-muted); }

/* ---------- Fascicolo pratica ----------------------------------------- */

.facts { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 16px; }
.facts div { display: grid; gap: 2px; }
.facts span { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--color-muted); }
.facts b { color: var(--rv-profondo); }

.phase-track { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 0; list-style: none; }
.phase-track li { display: grid; gap: 8px; font-size: 11px; line-height: 1.3; color: var(--color-muted); }
.phase-track li::before { content: ""; height: 8px; border-radius: 2px; background: var(--rv-linea); }
.phase-track li.is-human::before { border-radius: 8px; }
.phase-track li.is-done::before { background: var(--rv-verde); }
.phase-track li.is-done { color: var(--rv-grafite); }
.phase-track li.is-current { color: var(--rv-profondo); font-weight: 700; }
.phase-track li.is-current::before { background: var(--rv-profondo); }
.phase-track li.is-current.is-wait::before { background: #C98A1E; }
.phase-track li.is-current.is-stop::before { background: var(--rv-rosso); }
.phase-track li.is-current.is-closed::before { background: var(--rv-linea-forte); }

.action-panel { border-top: 4px solid var(--rv-ambra); }
.action-panel--done { border-top-color: var(--rv-verde); }

.tabs { display: flex; gap: 4px; margin-bottom: -1px; overflow-x: auto; }
.tab {
  padding: 10px 16px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--rv-profondo); }
.tab[aria-selected="true"] { border-color: var(--color-line); background: var(--color-surface); color: var(--rv-profondo); box-shadow: inset 0 3px 0 var(--rv-verde); }
.tab-panel { padding: 24px; border: 1px solid var(--color-line); border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm); background: var(--color-surface); }

.timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 0 0 18px; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; top: 28px; bottom: 2px; left: 13px; width: 2px; background: var(--color-line); }
.timeline__dot { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--rv-salvia); color: var(--rv-verde); }
.timeline__dot .icon { width: 15px; height: 15px; }
.timeline .k-persona .timeline__dot { background: var(--rv-ambra-bg); color: var(--rv-ambra); }
.timeline .k-cliente .timeline__dot { background: var(--rv-profondo); color: var(--rv-menta); }
.timeline b { color: var(--rv-profondo); font-size: var(--fs-sm); }
.timeline small { display: block; font-size: var(--fs-xs); color: var(--color-muted); }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 24px; margin: 0; }
.kv dt { font-size: var(--fs-sm); color: var(--color-muted); }
.kv dd { margin: 0; color: var(--rv-profondo); }

.mail-preview { border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: #fff; }
.mail-preview__head { display: grid; grid-template-columns: 70px 1fr; gap: 6px 12px; padding: 14px 18px; border-bottom: 1px solid var(--color-line); font-size: var(--fs-sm); }
.mail-preview__head span:nth-child(odd) { color: var(--color-muted); }
.mail-preview__body { padding: 18px; white-space: pre-wrap; max-width: 72ch; }
textarea.input { min-height: 260px; padding: 12px 14px; line-height: 1.6; resize: vertical; font-family: var(--font-body); }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--rv-salvia); color: var(--rv-profondo); font-size: var(--fs-sm); }
.notice .icon { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--rv-verde); }
.notice--warn { background: var(--rv-ambra-bg); color: #5A3A0C; }
.notice--warn .icon { color: var(--rv-ambra); }
.notice--stop { background: var(--rv-rosso-bg); color: #6E1F12; }
.notice--stop .icon { color: var(--rv-rosso); }

/* ---------- Matrice priorità ------------------------------------------- */

.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: var(--fs-xs); color: var(--color-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; vertical-align: -1px; }

/* ---------- Agenti ------------------------------------------------------ */

.agent-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.agent-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--rv-grafite);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
}
.agent-tab__n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--rv-salvia); color: var(--rv-verde); font-family: var(--font-display); }
.agent-tab[aria-pressed="true"] { border-color: var(--rv-profondo); background: var(--rv-profondo); color: var(--color-on-dark); }
.agent-tab[aria-pressed="true"] .agent-tab__n { background: var(--rv-menta); color: var(--rv-profondo); }

.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: end; height: 170px; }
.bar-day { display: grid; grid-template-rows: 1fr auto auto; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: center; }
.bar-day__stack { display: flex; flex-direction: column-reverse; align-self: end; overflow: hidden; border-radius: 3px 3px 0 0; }
.bar-day__stack span { display: block; }
.bar-day .ok { background: var(--rv-verde); }
.bar-day .warn { background: #C98A1E; }
.bar-day .stop { background: var(--rv-rosso); }
.bar-day__n { margin-top: 6px; font-family: var(--font-display); font-weight: 700; color: var(--rv-profondo); }
.bar-day__d { font-size: 11px; color: var(--color-muted); }
.bar-day[aria-pressed="true"] .bar-day__d { color: var(--rv-profondo); font-weight: 700; }
.bar-day[aria-pressed="true"] .bar-day__stack { box-shadow: 0 0 0 2px var(--rv-ambra); }

/* ---------- Processo / RACI ------------------------------------------- */

.raci-cell { text-align: center; }
.raci { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-sm); font-weight: 800; font-size: var(--fs-xs); }
.raci--R { background: #E3F1EC; color: var(--rv-profondo); }
.raci--A { background: var(--rv-profondo); color: #fff; }
.raci--C { background: var(--rv-ambra-bg); color: var(--rv-ambra); }
.raci--I { background: var(--rv-nebbia); color: var(--color-muted); border: 1px solid var(--color-line); }

/* ---------- Dialog e notifiche ---------------------------------------- */

.dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-top: 4px solid var(--rv-verde);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 30px 60px -20px rgba(6, 46, 40, .45);
}
.dialog::backdrop { background: rgba(6, 46, 40, .5); }
.dialog--danger { border-top-color: var(--rv-rosso); }
.dialog__form { display: grid; gap: 18px; padding: 26px; }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-size: var(--fs-xs); font-family: ui-monospace, Consolas, monospace; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--rv-profondo);
  color: var(--color-on-dark);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-md);
  animation: rv-enter .25s var(--ease);
}
.toast .icon { flex: none; width: 18px; height: 18px; color: var(--rv-menta); }
.toast--error { background: var(--rv-rosso); }
.toast--error .icon { color: #fff; }

.loading { display: grid; place-items: center; min-height: 240px; color: var(--color-muted); }
.loading::before {
  content: "";
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  border: 3px solid var(--rv-salvia);
  border-top-color: var(--rv-verde);
  border-radius: 50%;
  animation: rv-spin .8s linear infinite;
}
@keyframes rv-spin { to { transform: rotate(360deg); } }

.nav-link .count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--rv-ambra);   /* bianco su #C98A1E non arriva a 4,5:1 */
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}
button.nav-link { width: 100%; border: 0; background: none; font: inherit; font-size: var(--fs-sm); font-weight: 600; text-align: left; cursor: pointer; }
.role-chip { display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--rv-salvia); color: var(--rv-profondo); font-size: 11px; font-weight: 700; }

.qr { display: grid; place-items: center; width: 200px; padding: 8px; margin: 4px auto; background: #fff; border: 1px solid var(--color-line); border-radius: var(--radius-sm); }
.qr svg { width: 100%; height: auto; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); letter-spacing: .08em; word-break: break-all; text-align: center; }
.code-input { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: .4em; text-align: center; }

/* ---------- Utilità aggiunte --------------------------------------------- */

.spacer { flex: 1 1 auto; }
[aria-busy="true"] { cursor: progress; }
.row--between { justify-content: space-between; align-items: center; }
.mono, textarea.input.mono { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-xs); }
.cell-wide { min-width: 240px; white-space: normal; }
.is-late { color: var(--rv-rosso); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.case-top { margin-bottom: 16px; }
.newgrid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 20px; align-items: start; }
.table tr.is-chosen td { background: #E6F3EE; }
.table tr.clk { cursor: pointer; }
.table tr.is-sel td { background: var(--rv-salvia); }
details summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 700; color: var(--rv-verde); }
details[open] summary { margin-bottom: 8px; }
pre { margin: 0; max-height: 360px; overflow: auto; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--rv-profondo); color: #DCEFE7; font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-xs); line-height: 1.55; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }

.tab__state { margin-left: 4px; padding: 1px 6px; border-radius: var(--radius-pill); background: #E3F1EC; color: var(--rv-verde); font-size: 11px; font-weight: 800; }
.tab__state.is-wait { background: var(--rv-nebbia); color: var(--color-muted); }

/* Passaggi dell'agente 1 */
.psteps { display: grid; margin: 0; padding: 0; list-style: none; border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: var(--color-surface); }
.pstep { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; padding: 12px 16px; border-top: 1px solid var(--color-line); border-left: 4px solid transparent; }
.pstep:first-child { border-top: 0; }
.pstep p { margin-top: 4px; font-size: var(--fs-sm); }
.pstep.st-warn { border-left-color: #C98A1E; }
.pstep.st-stop { border-left-color: var(--rv-rosso); }
.pstep.st-skip { opacity: .6; }
.pstep__n { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-xs); }
.n-ok { background: #DCF1E9; color: #06614F; }
.n-warn { background: var(--rv-ambra-bg); color: var(--rv-ambra); }
.n-stop { background: var(--rv-rosso-bg); color: var(--rv-rosso); }
.n-skip { background: var(--rv-nebbia); color: var(--color-muted); }

/* Mail */
.mail-preview mark { padding: 0 3px; border-radius: 3px; background: #E3F1EC; color: inherit; }
.mail-preview mark.j { background: var(--rv-ambra-bg); }
.mail-preview .input { min-height: 36px; }
.mail-preview textarea.input { min-height: 340px; border: 0; padding: 0; box-shadow: none; }
.caut-range { flex: 1 1 280px; }
.caut-range input[type="range"] { width: 100%; accent-color: var(--rv-verde); }
.checks { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
.checks li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; }
.checks .icon { width: 18px; height: 18px; margin-top: 2px; }
.checks .y .icon { color: var(--rv-verde); }
.checks .n .icon { color: var(--rv-rosso); }
.thread { display: grid; gap: 6px; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--color-line); list-style: none; font-size: var(--fs-sm); }
.thread li { display: grid; gap: 1px; }
.thread .mono { color: var(--color-muted); }

/* Matrice priorità */
.mx { width: 100%; height: auto; }
.mx text { font-family: var(--font-body); font-size: 10.5px; fill: var(--color-muted); }
.mx .grid-line { stroke: var(--rv-linea); stroke-dasharray: 2 4; }
.mx .axis { stroke: var(--rv-linea-forte); }
.mx .soglia { stroke: var(--rv-ambra); stroke-dasharray: 5 4; stroke-width: 1.2; }
.mx .soglia-t { fill: var(--rv-ambra); }
.mx g { cursor: pointer; }
.mx .seg { stroke-width: 6; stroke-linecap: round; }
.mx .dot { stroke: #fff; stroke-width: 2; }
.mx .lbl { fill: var(--rv-profondo); font-weight: 700; pointer-events: none; }
.mx g.is-selected .seg { stroke-width: 10; }
.mx g:focus { outline: none; }
.mx g:focus-visible .dot { stroke: var(--rv-ambra); stroke-width: 3; }
.mx .p-none .seg { stroke: #7D8B87; } .mx .p-none .dot { fill: #7D8B87; }
.mx .p-alta .seg { stroke: var(--rv-profondo); } .mx .p-alta .dot { fill: var(--rv-profondo); }
.mx .p-media .seg { stroke: var(--rv-verde); } .mx .p-media .dot { fill: var(--rv-verde); }
.mx .p-bassa .seg { stroke: #C98A1E; } .mx .p-bassa .dot { fill: #C98A1E; }
.mx .p-scartata { opacity: .4; } .mx .p-scartata .seg { stroke: var(--rv-linea-forte); } .mx .p-scartata .dot { fill: var(--rv-linea-forte); }
.legend .lg { width: 18px; height: 5px; border-radius: 3px; }
.legend .lg.p-none { background: #7D8B87; } .legend .lg.p-alta { background: var(--rv-profondo); }
.legend .lg.p-media { background: var(--rv-verde); } .legend .lg.p-bassa { background: #C98A1E; } .legend .lg.p-scartata { background: var(--rv-linea-forte); }

/* Agenti */
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day { display: grid; place-items: center; min-width: 70px; height: 52px; padding: 0 10px; border: 1px solid var(--color-line-strong); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--rv-grafite); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.day b { font-family: var(--font-display); font-size: var(--fs-md); color: var(--rv-profondo); }
.day[aria-pressed="true"] { border-color: var(--rv-profondo); background: var(--rv-profondo); color: var(--color-on-dark); }
.day[aria-pressed="true"] b { color: var(--rv-menta); }
.io { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; flex: 1 1 520px; margin: 0; }
.io dt { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--color-muted); }
.io dd { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--rv-profondo); }
.chart { width: 100%; height: auto; }
.chart text { font-family: var(--font-body); font-size: 10px; fill: var(--color-muted); }
.chart .grid-line { stroke: var(--rv-linea); }
.chart .bar { fill: var(--rv-verde); }
.chart .bar-now { fill: var(--rv-profondo); }
.agrow { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.agrow:hover b { color: var(--rv-verde); }
.agrow__v { text-align: right; }
.agrow__v b { font-family: var(--font-display); font-size: var(--fs-md); }

/* Flusso */
.flow-wrap { overflow-x: auto; }
.flowsvg { display: block; width: 100%; min-width: 980px; height: auto; }
.flowsvg .bx { fill: #fff; stroke: var(--rv-linea-forte); stroke-width: 1.2; }
.flowsvg .ag { fill: #E3F1EC; stroke: var(--rv-verde); stroke-width: 1.4; }
.flowsvg .hu { fill: var(--rv-ambra-bg); stroke: var(--rv-ambra); stroke-width: 1.4; }
.flowsvg text { fill: var(--rv-profondo); font-family: var(--font-body); font-size: 12px; }
.flowsvg .t1 { font-family: var(--font-display); font-weight: 700; font-size: 12.5px; }
.flowsvg .t2 { fill: var(--color-muted); font-size: 11px; }
.flowsvg .ln { fill: none; stroke: #8A9A94; stroke-width: 1.4; }
.flowsvg .ah { fill: #8A9A94; }
.flowsvg .nb { fill: var(--rv-profondo); }
.flowsvg .nt { fill: var(--rv-menta); font-weight: 800; font-size: 11.5px; }

/* ---------- Presentazione per l'azienda ------------------------------------ */

.device { overflow: hidden; border: 1px solid var(--color-line); border-radius: var(--radius-md); background: #fff; }
.device__bar { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-bottom: 1px solid var(--color-line); background: var(--rv-nebbia);
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--color-muted); }
.device__bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--rv-linea-forte); }
.device__body { padding: clamp(14px, 3vw, 36px); }

.pres { display: grid; gap: 18px; }
.pres h2 { font-size: clamp(1.25rem, 2.6vw, 1.625rem); line-height: 1.25; }
.pres-intro { display: grid; gap: 8px; }
.pres-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.pres-stats div { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: #fff; }
.pres-stats b { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--rv-profondo); font-variant-numeric: tabular-nums; }
.pres-stats span { font-size: var(--fs-xs); color: var(--color-muted); }
.pres-area { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 18px; border: 1px solid var(--color-line); border-top: 4px solid var(--rv-verde);
  border-radius: var(--radius-sm); background: #fff; }
.pres-area__n { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--rv-salvia);
  font-family: var(--font-display); font-weight: 700; color: var(--rv-verde); }
.pres-area__body { display: grid; gap: 10px; min-width: 0; }
.pres-area__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: baseline; }
.pres-area__est { font-family: var(--font-display); font-weight: 700; color: var(--rv-profondo); font-variant-numeric: tabular-nums; }
.pres-area__ev { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 14px; align-items: center; }
.pres-area__ev p + p { margin-top: 6px; font-size: var(--fs-sm); }
.spark { width: 100%; height: auto; }
.spark rect { fill: var(--rv-linea); }
.spark rect.on { fill: var(--rv-verde); }
.spark text { font-family: var(--font-body); font-size: 9.5px; fill: var(--color-muted); }
.spark text.na { font-style: italic; opacity: .8; }
.pres-q { display: grid; gap: 8px; padding-top: 10px; border-top: 1px dashed var(--color-line-strong); }
.pres-q.is-missing { padding: 12px; border: 1px solid #EDB5A8; border-radius: var(--radius-sm); background: var(--rv-rosso-bg); }
.seg3 { display: flex; flex-wrap: wrap; gap: 6px; }
.seg3 button { min-height: 38px; padding: 0 14px; border: 1px solid var(--color-line-strong); border-radius: var(--radius-sm); background: #fff;
  color: var(--rv-profondo); font-size: var(--fs-sm); font-weight: 700; cursor: pointer; }
.seg3 button:hover { border-color: var(--rv-verde); }
.seg3 button:disabled { cursor: progress; opacity: .6; }
.seg3 button[aria-pressed="true"] { border-color: var(--rv-verde); background: var(--rv-verde); color: #fff; }
.seg3 button.ns[aria-pressed="true"] { border-color: var(--rv-ardesia); background: var(--rv-ardesia); }
.qfx { font-size: var(--fs-xs); color: var(--color-muted); }
.dett { display: grid; gap: 10px; padding: 8px 0 4px 14px; border-left: 3px solid var(--rv-verde); }
.dett label { display: grid; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--rv-profondo); }
.dett .input { max-width: 140px; }
.dsn { display: grid; gap: 6px; } .dsn p { font-size: var(--fs-sm); font-weight: 600; color: var(--rv-profondo); }
.pres-sticky { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-top: 1px solid var(--color-line); background: rgba(252, 253, 252, .96); }
.pres-big { display: grid; justify-items: center; gap: 6px; text-align: center; }
.pres-range { font-family: var(--font-display); font-weight: 700; font-size: clamp(2rem, 5vw, 2.875rem); line-height: 1.1; color: var(--rv-profondo); font-variant-numeric: tabular-nums; }
.pres-bar { width: 100%; max-width: 620px; height: auto; }
.pres-bar .track { fill: var(--rv-salvia); } .pres-bar .fill { fill: var(--rv-verde); }
.pres-bar text { font-family: var(--font-body); font-size: 11px; fill: var(--color-muted); }
.pres-brk { display: grid; gap: 8px; width: 100%; max-width: 620px; margin: 0 auto; }
.pres-brow { display: grid; grid-template-columns: minmax(0, 200px) 1fr 120px; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.pres-brow b { text-align: right; font-variant-numeric: tabular-nums; }
.pres-track { position: relative; height: 10px; border-radius: 5px; background: var(--rv-salvia); }
.pres-track span { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--rv-verde); }
.pres-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pres-form, .pres-ok { width: 100%; max-width: 620px; margin: 0 auto; padding: 16px; border: 1px solid var(--color-line); border-radius: var(--radius-sm); background: #fff; }
.pres-form { display: grid; gap: 14px; }
.pres-ok { background: var(--rv-salvia); color: var(--rv-profondo); }
.pres-promise { text-align: center; font-weight: 600; color: var(--rv-profondo); }

/* Pagina pubblica del link di lettura */
body.lettura { background: var(--rv-nebbia); }
.lettura__bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 18px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--color-line); background: var(--color-surface); }
.lettura__logo { font-size: 33px; }   /* logo ≥ 120 px (brand book, slide 20) */
.lettura__main { max-width: 920px; margin: 0 auto; padding: 28px 16px 64px; }
.lettura__foot { padding: 20px; text-align: center; font-size: var(--fs-xs); color: var(--color-muted); }

/* ---------- Responsive ------------------------------------------------- */

@media (max-width: 1280px) {
  .workgrid { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .grid--5, .grid--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .newgrid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phase-track { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 14px; }
}
@media (max-width: 640px) {
  .grid--5, .grid--6, .pres-stats, .io { grid-template-columns: 1fr 1fr; }
  .pres-area { grid-template-columns: 1fr; }
  .pres-area__ev { grid-template-columns: 1fr; }
  .pres-brow { grid-template-columns: 1fr; gap: 4px; }
  .pres-brow b { text-align: left; }
  .tiles { grid-template-columns: 1fr; }
  .filters .select { flex: 1 1 140px; min-width: 0; }
  .filters__count { margin-left: 0; }
  /* Fasi su telefono: due colonne, così le etichette lunghe non invadono la vicina */
  .phase-track { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
  .phase-track li { overflow-wrap: anywhere; }
  .tab-panel { padding: 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* ---------- Carica i bilanci ---------- */
.dropzone { position: relative; display: grid; justify-items: center; gap: 6px; padding: 28px 16px; text-align: center;
  border: 2px dashed var(--rv-linea-forte); border-radius: 12px; background: var(--rv-nebbia); color: var(--rv-profondo); cursor: pointer; }
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--rv-verde); background: var(--rv-salvia); }
.dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .icon { width: 28px; height: 28px; color: var(--rv-verde); }
.field--inline { max-width: 320px; }
.row--right { justify-content: flex-end; flex-wrap: nowrap; }
.review { border-left: 4px solid var(--rv-verde); }
.table--review caption { caption-side: top; text-align: left; font-weight: 700; color: var(--rv-profondo); padding: 0 0 8px; }
.table--review tbody th[scope="row"] { background: transparent; color: var(--rv-profondo); font-weight: 500; text-align: left;
  text-transform: none; letter-spacing: normal; font-size: var(--fs-sm); }
.table--review .input--num { max-width: 180px; text-align: right; font-variant-numeric: tabular-nums; }
.table--review tr.is-changed td, .table--review tr.is-changed th { background: var(--rv-ambra-bg); }
.checks .w .icon { color: var(--rv-ambra); }
@media (max-width: 640px) {
  .row--right { flex-wrap: wrap; justify-content: flex-start; }
  .table--review .input--num { max-width: 100%; }
}

/* ---------- Avanzamento del lavoro automatico ---------- */
.avanz { display: grid; gap: 10px; }
.avanz__barra { height: 10px; border-radius: 999px; background: var(--rv-salvia); overflow: hidden; }
.avanz__barra span { display: block; width: 0; height: 100%; background: var(--rv-verde); border-radius: inherit; transition: width .6s ease; }
.avanz.is-fermo .avanz__barra span { background: var(--rv-rosso); }
.avanz__passi { display: grid; gap: 8px; margin: 4px 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
.avanz__passi li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; color: var(--color-muted); }
.avanz__passi li b { color: var(--rv-profondo); font-weight: 600; }
.avanz__ico { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--rv-linea-forte); }
.avanz__ico .icon { width: 13px; height: 13px; }
.avanz__passi .is-fatto .avanz__ico { background: var(--rv-verde); border-color: var(--rv-verde); color: #fff; }
.avanz__passi .is-lavora .avanz__ico { border-color: var(--rv-verde); color: var(--rv-verde); }
.avanz__passi .is-lavora .avanz__ico .icon { animation: avanz-giro 1.4s linear infinite; }
.avanz__passi .is-lavora { color: var(--rv-grafite); }
.avanz__passi .is-coda .avanz__ico { border-color: var(--rv-ambra); color: var(--rv-ambra); }
.avanz__passi .is-fermo .avanz__ico { border-color: var(--rv-rosso); color: var(--rv-rosso); }
.avanz__passi .is-umano { padding-top: 6px; border-top: 1px dashed var(--rv-linea); }
.avanz__passi .is-umano .avanz__ico { border-color: var(--rv-profondo); color: var(--rv-profondo); }
.avanz__det { display: inline-block; margin-top: 2px; }
@keyframes avanz-giro { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) { .avanz__passi .is-lavora .avanz__ico .icon { animation: none; } .avanz__barra span { transition: none; } }

/* ---------- Priorità: classifica delle pratiche ---------- */
.riepilogo { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.riepilogo > div { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 12px; background: var(--color-surface); border: 1px solid var(--rv-linea); }
.riepilogo b { font-size: 1.75rem; line-height: 1; color: var(--rv-profondo); font-variant-numeric: tabular-nums; }
.riepilogo span { font-size: var(--fs-sm); color: var(--color-muted); }
.riepilogo > div:first-child { border-color: var(--rv-verde); background: var(--rv-salvia); }
.clas { --cols: minmax(130px, 1.2fr) 84px minmax(200px, 2.8fr) 100px 112px; display: grid; gap: 2px; }
.clas__testa, .clas__riga { display: grid; grid-template-columns: var(--cols); gap: 14px; align-items: center; }
.clas__testa { padding: 0 10px 10px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-muted); }
.clas__scala { position: relative; height: 30px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.clas__scala i { position: absolute; bottom: 0; transform: translateX(-50%); font-style: normal; font-variant-numeric: tabular-nums; }
.clas__scala i:first-child { transform: none; }
.clas__soglia-t { position: absolute; top: 0; transform: translateX(-50%); color: var(--rv-ambra); font-weight: 700; white-space: nowrap; }
.clas__riga { padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.clas__riga:hover { background: var(--rv-nebbia); }
.clas__riga:focus-visible { outline: 2px solid var(--rv-ambra); outline-offset: 1px; }
.clas__riga.is-sel { background: var(--rv-salvia); border-color: var(--rv-verde); }
.clas__nome strong { display: block; color: var(--rv-profondo); line-height: 1.25; }
.clas__pot { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; }
.clas__pot b { color: var(--rv-profondo); font-variant-numeric: tabular-nums; text-align: right; }
.clas__potbar { height: 6px; border-radius: 3px; background: var(--rv-salvia); overflow: hidden; }
.clas__potbar i { display: block; width: 0; height: 100%; background: var(--rv-profondo); border-radius: inherit; }
.clas__track { position: relative; height: 14px; border-radius: 7px; background: var(--rv-nebbia); }
.clas__soglia { position: absolute; top: -6px; bottom: -6px; width: 0; border-left: 2px dashed var(--rv-ambra); }
.clas__range { position: absolute; top: 2px; bottom: 2px; width: 0; border-radius: 5px; background: #7D8B87; }
.clas__val { font-size: var(--fs-sm); color: var(--rv-profondo); text-align: right; white-space: nowrap; }
.clas__riga.p-alta .clas__range { background: var(--rv-profondo); }
.clas__riga.p-media .clas__range { background: var(--rv-verde); }
.clas__riga.p-bassa .clas__range { background: #C98A1E; }
.clas__riga.p-none .clas__range { background: var(--rv-verde); }
.clas__riga.is-sotto .clas__range, .clas__riga.p-scartata .clas__range { background: var(--rv-linea-forte); }
.clas__riga.is-sotto .clas__nome strong, .clas__riga.p-scartata .clas__nome strong { color: var(--color-muted); }
.clas__riga.is-sotto .clas__potbar i, .clas__riga.p-scartata .clas__potbar i { background: var(--rv-linea-forte); }
@media (max-width: 1100px) {
  .clas { --cols: minmax(140px, 1fr) 80px minmax(160px, 2fr) 104px; }
  .clas__testa > :last-child, .clas__stato { display: none; }
}
@media (max-width: 720px) {
  .riepilogo { grid-template-columns: 1fr; }
  .clas__testa { display: none; }
  .clas__riga { grid-template-columns: 1fr auto; grid-template-areas: "nome val" "track track" "pot pot"; row-gap: 8px; }
  .clas__nome { grid-area: nome; } .clas__val { grid-area: val; } .clas__track { grid-area: track; } .clas__pot { grid-area: pot; }
}

.workgrid--classifica { grid-template-columns: minmax(0, 1fr) 300px; }
@media (max-width: 1100px) { .workgrid--classifica { grid-template-columns: 1fr; } }
.workgrid--classifica [data-selected] .btn { width: 100%; max-width: 100%; white-space: normal; text-align: center; }
.clas__stato .badge { white-space: normal; line-height: 1.25; }

/* Ricerca dell'azienda nel Registro Imprese: menu a tendina sotto il campo */
.cerca { position: relative; }
.cerca__lista { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--color-surface); border: 1px solid var(--color-line-strong);
  border-radius: 10px; box-shadow: var(--shadow-md); }
.cerca__lista li { padding: 8px 10px; border-radius: 8px; color: var(--color-ink); }
.cerca__lista [role="option"] { cursor: pointer; }
.cerca__lista [role="option"]:hover, .cerca__lista [aria-selected="true"] { background: var(--rv-salvia); }
.cerca__vuoto { color: var(--color-muted); font-size: var(--fs-sm, .875rem); }
.dialog:has(.cerca__esito) { width: min(720px, calc(100vw - 32px)); }
.form-grid--cerca { grid-template-columns: 1fr 140px; }
@media (max-width: 560px) { .form-grid--cerca { grid-template-columns: 1fr; } }
.cerca__esito { display: grid; gap: 8px; max-height: min(52vh, 460px); overflow-y: auto; }
.cerca__esito details summary { cursor: pointer; color: var(--color-muted); font-size: var(--fs-sm, .875rem); padding: 6px 0; }
.cerca__risultati { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.cerca__voce { display: grid; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--color-ink); font: inherit; text-align: left; cursor: pointer; }
.cerca__voce:hover, .cerca__voce:focus-visible { background: var(--rv-salvia); }
.registro { display: grid; gap: 8px; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--color-line); border-radius: 12px; background: var(--rv-nebbia); }
