/* Permessi granulari [PACCHETTO D]: l'albero delle spunte (Utenti e permessi, scheda degli agenti) e i ruoli. */
.pt { display: grid; gap: .7rem; min-width: 0; }
.pt-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.pt-search { flex: 1 1 16rem; display: flex; align-items: center; gap: .45rem; min-width: 0; padding: 0 .7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.pt-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.pt-search svg { width: var(--ic-sm); height: var(--ic-sm); color: var(--muted); flex: none; }
.pt-search input { border: 0; background: transparent; box-shadow: none; padding: .55rem 0; min-width: 0; width: 100%; outline: none; }
.pt-bar-acts { display: flex; gap: .35rem; flex-wrap: wrap; }
.pt-bar-acts button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.pt-sum { display: flex; align-items: flex-start; gap: .65rem; padding: .7rem .85rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); }
.pt-sum p { margin: 0; flex: 1; min-width: 0; font-size: var(--fs-base); line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
.pt-sum strong { color: var(--ink); }
.pt-sum-txt { flex: 1; min-width: 0; display: grid; gap: .2rem; font-size: var(--fs-sm); line-height: 1.45; color: var(--ink-2);
  max-height: 12rem; overflow-y: auto; overscroll-behavior: contain; padding-right: .2rem; }
.pt-sum-txt > strong { font-size: var(--fs-sm); letter-spacing: .03em; text-transform: uppercase; color: var(--accent); }
.pt-sa { display: block; overflow-wrap: anywhere; }
.pt-sa b { font-weight: 600; color: var(--ink); }
.pt-sa b::after { content: ":"; }
.pt-sum-ico { flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink, #fff); }
.pt-sum-ico.none { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pt-sum-ico svg { width: var(--ic-xs); height: var(--ic-xs); }
.pt-count { flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; padding-top: .15rem; }

.pt-groups { display: grid; gap: .9rem; }
.pt-group { display: grid; gap: .35rem; }
.pt-gh { display: flex; align-items: center; gap: .45rem; margin: 0 0 .1rem; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); }
.pt-gh svg { width: var(--ic-xs); height: var(--ic-xs); }
.pt-area { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s; min-width: 0; }
.pt-area.some { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.pt-area.open { box-shadow: var(--shadow); }
.pt-ah { display: flex; align-items: stretch; min-width: 0; }
.pt-acheck { display: grid; place-items: center; padding: 0 .35rem 0 .75rem; cursor: pointer; flex: none; }
.pt-acheck input, .pt-act input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); cursor: pointer; flex: none; }
.pt-atoggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; justify-content: space-between; text-align: left;
  border: 0; background: transparent; padding: .6rem .75rem .6rem .45rem; min-height: 3rem; color: var(--ink); border-radius: 0 var(--radius) var(--radius) 0; }
.pt-atoggle:hover { background: var(--surface-2); }
.pt-atxt { display: grid; min-width: 0; gap: .05rem; }
.pt-atxt strong { font-size: var(--fs-md); font-weight: 600; }
.pt-ameta { font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
.pt-chip { flex: none; margin-left: auto; font-size: var(--fs-2xs); padding: .12rem .55rem; border-radius: var(--radius); color: var(--muted);
  border: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt-chip.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.pt-atoggle > svg { width: var(--ic-sm); height: var(--ic-sm); color: var(--muted); flex: none; transition: transform .18s; }
.pt-area.open .pt-atoggle > svg { transform: rotate(180deg); }
.pt-acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .1rem .6rem; padding: .25rem .75rem .7rem 2.35rem;
  border-top: 1px solid var(--line); }
.pt-acts[hidden] { display: none; }
.pt-act { display: flex; align-items: center; gap: .6rem; min-height: 2.5rem; padding: .3rem .4rem; border-radius: var(--radius); cursor: pointer; min-width: 0; }
.pt-act:hover { background: var(--surface-2); }
.pt-act.off { opacity: .5; cursor: not-allowed; }
.pt-act.hidden { display: none; }
.pt-al { flex: 1; min-width: 0; font-size: var(--fs-base); color: var(--ink); line-height: 1.3; }
.pt-al::first-letter { text-transform: uppercase; }
.pt-base { font-size: var(--fs-2xs); font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 .35rem; margin-left: .2rem; vertical-align: 1px; }
.pt-kind { flex: none; font-size: var(--fs-2xs); font-weight: 600; padding: .05rem .4rem; border-radius: var(--radius); letter-spacing: .02em; }
.pt-kind.v { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.pt-kind.e { color: var(--accent); background: var(--accent-soft); }
.pt-empty { margin: 0; color: var(--muted); font-size: var(--fs-base); text-align: center; padding: 1rem; }
.pt .hidden { display: none !important; }

/* ruoli pronti e personalizzati (Utenti e permessi) */
.pr-roles { display: flex; flex-wrap: wrap; gap: .4rem; }
.pr-role { display: inline-flex; align-items: center; gap: .1rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.pr-role > button { border: 0; background: transparent; min-height: 2.2rem; padding: .3rem .8rem; font-size: var(--fs-sm); color: var(--ink); border-radius: var(--radius); }
.pr-role > button:hover { color: var(--accent); }
.pr-role.custom { border-style: dashed; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pr-role .pr-del { min-height: 2.2rem; min-width: 2rem; padding: 0 .55rem 0 .1rem; color: var(--muted); }
.pr-role .pr-del svg { width: var(--ic-xs); height: var(--ic-xs); }
.pr-role.on { border-color: var(--accent); background: var(--accent-soft); }
.pr-role.on > button { color: var(--accent); font-weight: 600; }
.pr-save { margin-left: auto; }
.pr-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 1.2rem 0 .5rem; }
.pr-head h4 { margin: 0; font-size: var(--fs-md); }
.pr-head .meta { font-weight: 400; }
.us-sum { margin: .2rem 0 0; font-size: var(--fs-sm); color: var(--ink-2); overflow-wrap: anywhere; }

/* scheda dell'agente: l'albero dentro il modulo */
.ar-powers .pt { margin-top: .4rem; }
.ar-powers .pt-acts { grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }

@media (max-width: 700px) {
  .pt-bar-acts { width: 100%; }
  .pt-bar-acts button { flex: 1; }
  .pt-acts { grid-template-columns: minmax(0, 1fr); padding: .2rem .5rem .6rem .5rem; }
  .pt-act { min-height: 2.75rem; }
  .pt-ameta { display: none; }
  .pt-sum { flex-wrap: wrap; }
  .pt-count { order: 3; margin-left: 2.25rem; padding-top: 0; }
  .pr-save { margin-left: 0; width: 100%; }
}
