/* ============================================================
   ACTIONPOINTS.IT — style.css
   Design system: token del Brand Book v0.1 + layout applicativo.
   Caricato DOPO Framework/assets/css/framework.css (che scrive
   solo sui token: qui si decide come appare il prodotto).
   Regola d'oro: 80% neutro · 15% primary · 5% semantici.
   ============================================================ */

/* ── Design token (Brand Book §35) ── */
:root {
  /* Primary — Action Blue */
  --ap-primary:        #1769AA;
  --ap-primary-dark:   #0D4773;
  --ap-primary-light:  #EAF4FB;

  /* Neutrali */
  --ap-ink:            #17212B;   /* testo principale */
  --ap-text:           #344454;   /* testo secondario */
  --ap-text-soft:      #4A5A6B;   /* testo terziario (usato da framework.css) */
  --ap-muted:          #718096;   /* informazioni meno importanti */
  --ap-border:         #D9E1E8;
  --ap-surface:        #FFFFFF;   /* superficie di card e pannelli */
  --ap-bg:             #F7F9FB;   /* canvas applicativo */
  --ap-surface-alt:    #F1F5F8;   /* fasce e intestazioni tenui */
  --ap-dark:           #16232F;   /* sidebar / aree di navigazione dense */
  --ap-ink-soft:       #21323F;   /* hover su fondo scuro */

  /* Semantici — il colore ha sempre un significato */
  --ap-success:        #16845B;
  --ap-success-bg:     #E9F7F1;
  --ap-warning:        #C98200;
  --ap-warning-bg:     #FFF6E3;
  --ap-danger:         #C63D3D;
  --ap-danger-bg:      #FDECEC;
  --ap-info:           #1769AA;
  --ap-info-bg:        #EAF4FB;

  /* Tipografia */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Spacing (scala 4/8/12/16/20/24/32/40/48) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Squircle — una sola grammatica geometrica */
  --r-sm:   7px;    /* checkbox */
  --r-md:   10px;   /* input, button */
  --r-lg:   16px;   /* card */
  --r-panel:18px;   /* pannelli dashboard */
  --r-xl:   20px;   /* modal */
  --r-pill: 999px;  /* badge */

  /* Layout */
  --sidebar-w: 256px;
  --sidebar-w-mini: 62px;
  --topbar-h: 52px;
  --container-max: 1440px;

  /* Ombre — leggerissime: le card si definiscono con spazio e bordo */
  --shadow-card:  0 2px 8px rgba(20, 40, 60, .06);
  --shadow-pop:   0 6px 20px rgba(20, 40, 60, .10);
  --shadow-modal: 0 12px 32px rgba(20, 40, 60, .14);
  --focus-ring:   0 0 0 3px rgba(23, 105, 170, .18);
}

/* ── Reset base ── */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-main);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ap-ink);
  background: var(--ap-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--ap-ink); font-weight: 600; }
h1 { font-size: 32px; line-height: 38px; font-weight: 700; }
h2 { font-size: 24px; line-height: 30px; }
h3 { font-size: 18px; line-height: 24px; }
p  { margin: 0 0 var(--sp-3); }

a { color: var(--ap-primary); text-decoration: none; }
a:hover { color: var(--ap-primary-dark); text-decoration: underline; }

small, .ap-small { font-size: 12.5px; line-height: 18px; }
.ap-micro {
  font-size: 11px; line-height: 16px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ap-muted);
}
.ap-muted { color: var(--ap-muted); }
.ap-mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============================================================
   LAYOUT STRUTTURALE
   ============================================================ */

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

/* ── Sidebar laterale a scomparsa ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--ap-dark);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .28s cubic-bezier(.4, 0, .2, 1);
}

.sidebar.mini { width: var(--sidebar-w-mini); }

/* espansa via hover/JS: si sovrappone al contenuto invece di spingerlo */
.sidebar:not(.mini) { z-index: 300; }

/* ── Logo ── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 11px;
  min-height: 64px;
  flex-shrink: 0;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-logo .logo-mark {
  width: 40px; height: 40px; min-width: 40px;
  border-radius: 12px;
  background: url("../img/logo-icon.png") center/contain no-repeat;
  flex-shrink: 0;
}

.app-name {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .045em;
  line-height: 1.2;
}
/* firma visiva: ACTION ● POINTS (per i fondi chiari, es. testate di stampa) */
.app-name .point { color: #3B9BEC; }

/* Marchio della sidebar: il lettering del brand e' un'immagine, non del testo.
   Variante in negativo, perche' il lettering originale e' blu scuro e su
   --ap-dark sparirebbe. L'altezza e' fissa e la larghezza segue: cosi' il
   marchio non puo' andare a capo ne' deformarsi. */
.app-name .wordmark {
  display: block;
  height: 15px;
  width: auto;
  max-width: 100%;
}

/* Sottotitolo. Ha una classe propria: come selettore di elemento catturava
   anche <span class="point">, lo rendeva un blocco e spezzava il marchio
   su tre righe. */
.app-name .claim {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
}

/* ── Nav ── */
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-2) 0; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 2px; }

.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
  padding: 14px 16px 4px;
  white-space: nowrap; overflow: hidden;
  transition: opacity .2s;
}

.nav-divider { height: 1px; background: rgba(255, 255, 255, .07); margin: var(--sp-2) 0; }

.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 16px 9px 13px;
  border-left: 3px solid transparent;
  color: rgba(255, 255, 255, .72);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background .14s, color .14s;
}
.nav-link:hover { background: var(--ap-ink-soft); color: #fff; text-decoration: none; }

/* voce attiva: fondo primary attenuato + indicatore laterale 3px */
.nav-link.active {
  background: rgba(23, 105, 170, .22);
  color: #fff;
  border-left-color: #3B9BEC;
}

.nav-link i.ti { font-size: 18px; width: 20px; flex-shrink: 0; text-align: center; }
.nav-label { flex: 1; overflow: hidden; white-space: nowrap; transition: opacity .2s; }

.nav-chevron {
  font-size: 13px; margin-left: auto; flex-shrink: 0;
  color: rgba(255, 255, 255, .38);
  transition: transform .22s;
}
.nav-link.open > .nav-chevron { transform: rotate(90deg); }

/* contatore sulla voce (es. ticket assegnati a me) */
.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--ap-danger); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
}

/* Submenu (N livelli) */
.nav-submenu { display: none; list-style: none; margin: 0; padding: 0; background: rgba(0, 0, 0, .16); }
.nav-submenu.open { display: block; }
.nav-submenu .nav-link {
  padding: 7px 16px 7px 49px;
  font-size: 13px; font-weight: 400;
  color: rgba(255, 255, 255, .58);
}
.nav-submenu .nav-link:hover { background: var(--ap-ink-soft); color: #fff; }
.nav-submenu .nav-link.active { background: rgba(23, 105, 170, .18); color: #fff; border-left-color: #3B9BEC; }
.nav-submenu .nav-submenu { background: rgba(0, 0, 0, .22); }
.nav-submenu .nav-submenu .nav-link { padding-left: 64px; font-size: 12.5px; }

/* voci non ancora implementate */
.nav-link-wip { opacity: .45; cursor: not-allowed; }
.nav-link-wip:hover { background: transparent !important; color: inherit !important; }

.sidebar-footer { flex-shrink: 0; border-top: 1px solid rgba(255, 255, 255, .07); padding: var(--sp-2) 0; }

/* ── Sidebar richiusa: restano solo le icone ── */
.sidebar.mini .app-name,
.sidebar.mini .nav-label,
.sidebar.mini .nav-chevron,
.sidebar.mini .nav-badge,
.sidebar.mini .nav-section-label { opacity: 0; pointer-events: none; }

.sidebar.mini .nav-submenu { display: none !important; }

/* etichetta a comparsa sul passaggio del mouse */
.sidebar.mini .nav-item:hover > .nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-w-mini) + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ap-ink);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  z-index: 200;
}

/* ── Main wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left .28s cubic-bezier(.4, 0, .2, 1);
}
.main-wrapper.mini { margin-left: var(--sidebar-w-mini); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--ap-surface);
  border-bottom: 1px solid var(--ap-border);
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--sp-6);
  flex-shrink: 0;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--sp-3); }

.breadcrumb { display: flex; align-items: center; gap: var(--sp-2); font-size: 13px; }
.breadcrumb a { color: var(--ap-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ap-primary); }
.breadcrumb-sep { color: var(--ap-border); }
.breadcrumb-current { color: var(--ap-ink); font-weight: 600; }

.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ap-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  cursor: default;
}

.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--ap-text);
  font-size: 18px; cursor: pointer;
  transition: background .14s, color .14s, border-color .14s;
}
.icon-btn:hover { background: var(--ap-primary-light); color: var(--ap-primary-dark); }

/* ── Campanella (B6) ── */
.notif-bell { position: relative; }
.notif-bell .icon-btn { position: relative; }
.notif-count {
  position: absolute; top: 2px; right: 1px;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--ap-danger); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--ap-surface);
}
.notif-count[hidden] { display: none; }
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  width: min(380px, calc(100vw - 32px));
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--ap-border);
}
.notif-panel-title { font-weight: 600; color: var(--ap-ink); }
.notif-panel .notif-list { max-height: min(420px, 60vh); overflow-y: auto; }
.notif-panel .notif-row { padding: var(--sp-3) var(--sp-4); grid-template-columns: 20px minmax(0, 1fr); }
.notif-panel-foot {
  display: block; padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--ap-border);
  font-size: 13px; font-weight: 600; text-align: center; text-decoration: none; color: var(--ap-primary);
}
.notif-panel-foot:hover { background: var(--ap-primary-light); }

/* Righe di notifica (campanella e pagina Notifiche) */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: var(--sp-3);
  align-items: start; padding: var(--sp-4) var(--sp-5);
}
.notif-row + .notif-row { border-top: 1px solid var(--ap-border); }
.notif-ico { font-size: 18px; margin-top: 1px; color: var(--ap-muted); }
.notif-row.is-info    .notif-ico { color: var(--ap-primary); }
.notif-row.is-success .notif-ico { color: var(--ap-success); }
.notif-row.is-warning .notif-ico { color: var(--ap-warning); }
.notif-row.is-danger  .notif-ico { color: var(--ap-danger); }
.notif-title { font-size: 14px; font-weight: 600; color: var(--ap-ink); display: flex; align-items: baseline; gap: var(--sp-2); }
.notif-title a { color: inherit; text-decoration: none; }
.notif-title a:hover { color: var(--ap-primary); text-decoration: underline; }
.notif-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--ap-primary); transform: translateY(-1px); }
.notif-body { font-size: 13px; color: var(--ap-text); margin-top: 2px; overflow-wrap: anywhere; }
.notif-meta { font-size: 12px; color: var(--ap-muted); margin-top: 4px; }
.notif-row.is-letta .notif-title { font-weight: 500; color: var(--ap-text); }
.notif-row.is-letta .notif-ico { opacity: .6; }
.notif-empty { padding: var(--sp-5) var(--sp-4); text-align: center; font-size: 13px; color: var(--ap-muted); }
.notif-empty i.ti { font-size: 16px; vertical-align: -2px; }

/* ── Content ── */
.content { flex: 1; padding: var(--sp-6); max-width: var(--container-max); width: 100%; }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-6);
}
.page-header h1 { font-size: 24px; line-height: 30px; font-weight: 600; }
.page-header .page-sub { color: var(--ap-muted); font-size: 13.5px; margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }

/* ============================================================
   BUTTON SYSTEM (§10)
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-md);
  font-family: var(--font-main); font-size: 14px; font-weight: 500; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .14s, border-color .14s, color .14s, box-shadow .14s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn i.ti { font-size: 18px; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--ap-primary); color: #fff; }
.btn-primary:hover { background: var(--ap-primary-dark); color: #fff; }

.btn-secondary { background: var(--ap-surface); border-color: var(--ap-border); color: var(--ap-ink); }
.btn-secondary:hover { border-color: var(--ap-primary); color: var(--ap-primary-dark); }

.btn-ghost     { background: transparent; color: var(--ap-primary); }
.btn-ghost:hover { background: var(--ap-primary-light); color: var(--ap-primary-dark); }

.btn-danger    { background: var(--ap-danger); color: #fff; }
.btn-danger:hover { background: #A93131; color: #fff; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ============================================================
   FORM / INPUT SYSTEM (§11)
   ============================================================ */
.form-row   { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.form-group { margin-bottom: var(--sp-4); flex: 1 1 240px; min-width: 0; }

.form-label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ap-text);
}
.form-label .req { color: var(--ap-danger); margin-left: 2px; }

.form-control, select.form-control, textarea.form-control {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--ap-border); border-radius: var(--r-md);
  background: var(--ap-surface); color: var(--ap-ink);
  font-family: var(--font-main); font-size: 14px;
  transition: border-color .14s, box-shadow .14s;
}
textarea.form-control { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
select.form-control { padding-right: 32px; }

.form-control:focus {
  outline: none;
  border-color: var(--ap-primary);
  box-shadow: var(--focus-ring);
}
.form-control:disabled, .form-control[readonly] {
  background: #F1F4F6; color: var(--ap-muted); cursor: not-allowed;
}
.form-control.is-error { border-color: var(--ap-danger); }
.form-error { display: block; margin-top: 5px; font-size: 12.5px; color: var(--ap-danger); }
.form-hint  { display: block; margin-top: 5px; font-size: 12.5px; color: var(--ap-muted); }
.form-control[aria-invalid="true"] { border-color: var(--ap-danger); }
/* `hidden` deve vincere sui display dei componenti (.form-row e' flex, .form-hint block). */
[hidden] { display: none !important; }

/* ── Campi dinamici della tipologia (ApCampoTipo) ── */
.ap-campo-largo  { flex-basis: 100%; }
.ap-campo-scelte { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); padding-top: 2px; }
.ap-check .req   { color: var(--ap-danger); margin-left: 2px; }

/* ── Scelta a schede del richiedente (nuovo ticket) ── */
.ap-scelta { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-bottom: var(--sp-4); }

/* ── Checkbox (§12) — controllo grafico reale, testo cliccabile ── */
.ap-check, .ap-radio {
  display: inline-flex; align-items: flex-start; gap: 10px;
  cursor: pointer; user-select: none;
  font-size: 14px; color: var(--ap-ink);
}
.ap-check input, .ap-radio input { position: absolute; opacity: 0; width: 0; height: 0; }

.ap-check .box {
  width: 20px; height: 20px; min-width: 20px; margin-top: 1px;
  border: 1.5px solid #AEBAC5; border-radius: var(--r-sm);
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .14s, border-color .14s;
}
.ap-check .box::after {
  content: "\ea5e";                 /* ti-check */
  font-family: "tabler-icons";
  font-size: 13px; color: #fff;
  opacity: 0; transform: scale(.7);
  transition: opacity .12s, transform .12s;
}
.ap-check:hover .box { border-color: var(--ap-primary); }
.ap-check input:checked + .box { background: var(--ap-primary); border-color: var(--ap-primary); }
.ap-check input:checked + .box::after { opacity: 1; transform: scale(1); }
.ap-check input:focus-visible + .box { box-shadow: var(--focus-ring); }
.ap-check input:disabled + .box { background: #E9EDF1; border-color: #D2DAE1; }
.ap-check input:disabled ~ .lbl { color: var(--ap-muted); }

/* ── Radio (§13) ── */
.ap-radio .box {
  width: 20px; height: 20px; min-width: 20px; margin-top: 1px;
  border: 1.5px solid #AEBAC5; border-radius: 50%;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .14s;
}
.ap-radio .box::after {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ap-primary);
  opacity: 0; transform: scale(.5);
  transition: opacity .12s, transform .12s;
}
.ap-radio:hover .box { border-color: var(--ap-primary); }
.ap-radio input:checked + .box { border-color: var(--ap-primary); }
.ap-radio input:checked + .box::after { opacity: 1; transform: scale(1); }
.ap-radio input:focus-visible + .box { box-shadow: var(--focus-ring); }

/* ── Toggle (§14) — solo impostazioni ON/OFF ── */
.ap-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.ap-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ap-toggle .track {
  width: 40px; height: 22px; border-radius: var(--r-pill);
  background: #C4CFD8; position: relative; transition: background .16s;
}
.ap-toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(20, 40, 60, .2);
  transition: transform .16s;
}
.ap-toggle input:checked + .track { background: var(--ap-primary); }
.ap-toggle input:checked + .track::after { transform: translateX(18px); }
.ap-toggle input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* ============================================================
   BADGE (§15) — testo + icona + fondo tenue, mai pillole enormi
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.badge i.ti { font-size: 13px; }

.badge-neutral { background: var(--ap-surface-alt); color: var(--ap-text); }
.badge-info    { background: var(--ap-info-bg);    color: var(--ap-primary-dark); }
.badge-success { background: var(--ap-success-bg); color: var(--ap-success); }
.badge-warning { background: var(--ap-warning-bg); color: var(--ap-warning); }
.badge-danger  { background: var(--ap-danger-bg);  color: var(--ap-danger); }

/* Stati ticket */
.badge-stato-aperto       { background: var(--ap-info-bg);     color: var(--ap-primary-dark); }
.badge-stato-lavorazione  { background: #EAF0F6;               color: var(--ap-primary-dark); }
.badge-stato-attesa       { background: var(--ap-warning-bg);  color: var(--ap-warning); }
.badge-stato-risolto      { background: var(--ap-success-bg);  color: var(--ap-success); }
.badge-stato-chiuso       { background: var(--ap-surface-alt); color: var(--ap-muted); }

/* Priorita' — colore + icona + testo, mai il solo pallino */
.badge-prio-bassa   { background: var(--ap-surface-alt); color: var(--ap-muted); }
.badge-prio-normale { background: var(--ap-surface-alt); color: var(--ap-text); }
.badge-prio-alta    { background: var(--ap-warning-bg);  color: var(--ap-warning); }
.badge-prio-urgente { background: var(--ap-danger-bg);   color: var(--ap-danger); }

/* ============================================================
   CARD / PANNELLI
   ============================================================ */
.card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--ap-border);
}
.card-title  { font-size: 15px; font-weight: 600; color: var(--ap-ink); }
.card-body   { padding: var(--sp-5); }
.card-footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--ap-border); }

.panel { background: var(--ap-surface); border: 1px solid var(--ap-border); border-radius: var(--r-panel); padding: var(--sp-5); }

/* ── KPI (§19) ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); }
.kpi {
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--r-panel); padding: var(--sp-4) var(--sp-5);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
}
.kpi-value { font-size: 30px; line-height: 1.1; font-weight: 700; color: var(--ap-ink); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12.5px; color: var(--ap-muted); margin-top: 3px; }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-delta.up   { color: var(--ap-danger); }
.kpi-delta.down { color: var(--ap-success); }
.kpi-icon { font-size: 20px; color: var(--ap-muted); opacity: .6; }
.kpi.is-danger  .kpi-value { color: var(--ap-danger); }
.kpi.is-warning .kpi-value { color: var(--ap-warning); }
.kpi.is-success .kpi-value { color: var(--ap-success); }

/* ── Ticket card (§16) ── */
.ticket-card {
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
  display: block; text-decoration: none; color: inherit;
  transition: border-color .14s, box-shadow .14s;
}
.ticket-card:hover { border-color: #BFCEDA; box-shadow: var(--shadow-card); text-decoration: none; }
.ticket-card-top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.ticket-code { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--ap-muted); }
.ticket-date { margin-left: auto; font-size: 12px; color: var(--ap-muted); text-transform: uppercase; letter-spacing: .04em; }
.ticket-title { font-size: 15.5px; font-weight: 600; color: var(--ap-ink); margin-bottom: var(--sp-3); }
.ticket-people { display: flex; flex-wrap: wrap; gap: var(--sp-5); font-size: 12.5px; color: var(--ap-muted); margin-bottom: var(--sp-3); }
.ticket-people b { color: var(--ap-text); font-weight: 500; }
.ticket-card-bottom { display: flex; align-items: center; gap: var(--sp-3); }

/* ── SLA (§21) — informazione operativa, non decorazione ── */
.sla { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--ap-text); }
.sla .ap-mono { font-weight: 600; }
.sla.is-ok       { color: var(--ap-success); }
.sla.is-warning  { color: var(--ap-warning); }
.sla.is-danger   { color: var(--ap-danger); }
.sla.is-superato { color: var(--ap-danger); font-weight: 600; }

/* ============================================================
   TABELLA TICKET (§17) — linee sottili, hover leggero, riga cliccabile
   ============================================================ */
.ap-table-wrap {
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--r-lg); overflow: hidden;
}
.ap-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ap-table thead th {
  padding: 11px var(--sp-4);
  background: var(--ap-surface-alt);
  border-bottom: 1px solid var(--ap-border);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ap-muted); text-align: left; white-space: nowrap;
}
.ap-table tbody td { padding: 11px var(--sp-4); border-bottom: 1px solid #EDF1F4; color: var(--ap-text); vertical-align: middle; }
.ap-table tbody tr:last-child td { border-bottom: none; }
.ap-table tbody tr.is-clickable { cursor: pointer; }
.ap-table tbody tr:hover td { background: #FAFCFD; }
.ap-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.ap-table .cell-strong { color: var(--ap-ink); font-weight: 600; }

/* ── Toolbar filtri ── */
.toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.toolbar .form-control { height: 38px; width: auto; min-width: 180px; }
.search-box { position: relative; flex: 1 1 280px; max-width: 420px; }
.search-box i.ti { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ap-muted); font-size: 17px; }
.search-box .form-control { height: 38px; padding-left: 36px; }

/* ── Riepilogo dei filtri attivi ──
   Un elenco filtrato che non dice di esserlo fa sembrare vuoto il database.
   Ogni chip nomina il filtro e si toglie da sola. */
.filter-chips { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--sp-2) 0 var(--sp-3);
  border: 1px solid var(--ap-border); border-radius: var(--r-pill);
  background: var(--ap-surface); font-size: 12px; color: var(--ap-text);
}
.chip b { font-weight: 600; color: var(--ap-ink); }
.chip a { display: inline-flex; color: var(--ap-muted); text-decoration: none; }
.chip a:hover { color: var(--ap-danger); }

/* ── Riga di conteggio sopra la tabella ── */
.list-meta {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap; margin-bottom: var(--sp-2);
  font-size: 12.5px; color: var(--ap-muted);
}
.list-meta b { color: var(--ap-ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Paginatore ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-4); }
.pagination .page-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 34px; height: 34px; padding: 0 var(--sp-3);
  border: 1px solid var(--ap-border); border-radius: var(--r-sm);
  background: var(--ap-surface); color: var(--ap-text);
  font-size: 13px; text-decoration: none; font-variant-numeric: tabular-nums;
}
.pagination .page-link:hover { border-color: #BFCEDA; background: var(--ap-surface-alt); text-decoration: none; }
.pagination .page-link.is-current { background: var(--ap-primary); border-color: var(--ap-primary); color: #FFF; font-weight: 600; }
.pagination .page-link.is-disabled { color: #C3CFD9; pointer-events: none; }
.pagination .page-gap { color: var(--ap-muted); padding: 0 2px; }

/* ============================================================
   TIMELINE DEL TICKET (§22)
   ============================================================ */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--ap-border);
}
.tl-item { position: relative; padding-bottom: var(--sp-5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ap-surface); border: 2px solid var(--ap-primary);
}
.tl-item.is-success::before { border-color: var(--ap-success); }
.tl-item.is-warning::before { border-color: var(--ap-warning); }
.tl-item.is-danger::before  { border-color: var(--ap-danger); }
.tl-item.is-muted::before   { border-color: var(--ap-border); }
.tl-time   { font-size: 12px; color: var(--ap-muted); font-variant-numeric: tabular-nums; }
.tl-title  { font-size: 14px; font-weight: 600; color: var(--ap-ink); margin-top: 1px; }
.tl-meta   { font-size: 12.5px; color: var(--ap-muted); }
.tl-detail { font-size: 13px; color: var(--ap-text); margin-top: 4px; }

/* ── Commenti (§23) — pubblico vs interno distinguibili senza il colore ── */
.comment {
  border: 1px solid var(--ap-border); border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-3);
  background: var(--ap-surface);
}
.comment-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.comment-author { font-size: 13.5px; font-weight: 600; color: var(--ap-ink); }
.comment-time { font-size: 12px; color: var(--ap-muted); margin-left: auto; }
.comment-body { font-size: 14px; color: var(--ap-text); white-space: pre-wrap; }
.comment.is-interna { background: var(--ap-warning-bg); border-color: #F0DFB6; border-left: 3px solid var(--ap-warning); }

/* ============================================================
   EMPTY STATE (§24) — spiega cosa succede e cosa fare
   ============================================================ */
.empty-state { text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--ap-muted); }
.empty-state i.ti { font-size: 40px; color: #C3CFD9; }
.empty-state h3 { margin: var(--sp-4) 0 var(--sp-2); font-size: 16px; color: var(--ap-ink); }
.empty-state p { max-width: 420px; margin: 0 auto var(--sp-4); font-size: 13.5px; }

/* ============================================================
   MODAL (§25)
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(23, 33, 43, .42);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
}
.modal {
  width: 100%; max-width: 520px;
  background: var(--ap-surface); border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--ap-border);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--ap-ink); }
.modal-close { border: none; background: transparent; color: var(--ap-muted); font-size: 19px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--ap-ink); }
.modal-body { padding: var(--sp-5); font-size: 14px; color: var(--ap-text); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--ap-border); }

/* ============================================================
   NOTIFICHE / TOAST (§26)
   ============================================================ */
#toastContainer {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 1100;
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 380px;
  padding: 12px 14px;
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-left: 3px solid var(--ap-primary);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.toast i.ti { font-size: 18px; margin-top: 1px; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--ap-ink); }
.toast-msg { font-size: 13px; color: var(--ap-text); }
.toast-success { border-left-color: var(--ap-success); } .toast-success > i.ti { color: var(--ap-success); }
.toast-warning { border-left-color: var(--ap-warning); } .toast-warning > i.ti { color: var(--ap-warning); }
.toast-danger  { border-left-color: var(--ap-danger);  } .toast-danger  > i.ti { color: var(--ap-danger); }
.toast-info    { border-left-color: var(--ap-info);    } .toast-info    > i.ti { color: var(--ap-info); }

/* ── Alert inline ── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid transparent; font-size: 13.5px;
  margin-bottom: var(--sp-4);
}
.alert i.ti { font-size: 18px; margin-top: 1px; }
.alert-info    { background: var(--ap-info-bg);    border-color: #CDE3F2; color: var(--ap-primary-dark); }
.alert-success { background: var(--ap-success-bg); border-color: #C6E7D9; color: var(--ap-success); }
.alert-warning { background: var(--ap-warning-bg); border-color: #F0DFB6; color: #96620A; }
.alert-danger  { background: var(--ap-danger-bg);  border-color: #F3CFCF; color: var(--ap-danger); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ap-bg); padding: var(--sp-5);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--ap-surface); border: 1px solid var(--ap-border);
  border-radius: var(--r-xl); box-shadow: var(--shadow-card);
  padding: var(--sp-8);
}
.login-logo { display: block; width: 240px; max-width: 100%; margin: 0 auto var(--sp-5); }
.login-payoff {
  text-align: center; color: var(--ap-muted);
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  margin-bottom: var(--sp-6);
}

/* ============================================================
   DETTAGLIO TICKET (A5)
   ============================================================ */
.tk-header { flex-wrap: wrap; }
.tk-header-main { min-width: 0; flex: 1 1 420px; }
.tk-code-line { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.tk-header h1 { overflow-wrap: anywhere; }
.tk-actions { flex-wrap: wrap; flex-shrink: 1; justify-content: flex-end; }
.tk-no-actions { display: inline-flex; align-items: center; gap: 6px; }
.tl-title i.ti { font-size: 15px; color: var(--ap-muted); }
.tl-meta i.ti { font-size: 13px; }

/* Testo scritto da persone: gli a capo del richiedente sono informazione. */
.tk-prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Coppie etichetta/valore del pannello laterale e dei campi della tipologia */
.meta-list { margin: 0; display: grid; gap: var(--sp-3); }
.meta-list-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.meta-list dt { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ap-muted); }
.meta-list dd { margin: 2px 0 0; font-size: 13.5px; color: var(--ap-ink); overflow-wrap: anywhere; }
.meta-list dd .sla { margin-left: 4px; }

.form-control.form-control-sm, select.form-control.form-control-sm { height: 34px; font-size: 13px; }

/* Filtro segmentato (Tutto / Conversazione / Eventi) */
.seg { display: inline-flex; border: 1px solid var(--ap-border); border-radius: var(--r-md); overflow: hidden; }
.seg-btn {
  height: 30px; padding: 0 12px; border: 0; background: var(--ap-surface);
  font: 500 12.5px var(--font-main); color: var(--ap-text); cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--ap-border); }
.seg-btn:hover { background: var(--ap-surface-alt); }
.seg-btn.is-active { background: var(--ap-primary-light); color: var(--ap-primary-dark); font-weight: 600; }
a.seg-btn { display: inline-flex; align-items: center; text-decoration: none; }
.seg-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Nella timeline il commento sta al posto della riga d'evento */
.timeline .comment { margin: 0; }

/* Composer: pubblico e interno si distinguono per etichetta e bordo, non solo per colore */
.composer { display: block; }
.composer-vis { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-bottom: var(--sp-3); }
.composer-vis .lbl i.ti { font-size: 15px; vertical-align: -2px; }
.composer.is-interna textarea { background: var(--ap-warning-bg); border-color: #F0DFB6; border-left: 3px solid var(--ap-warning); }

/* Sezioni ripiegabili del pannello (riassegna, nuovo promemoria) */
.tk-details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ap-primary); list-style: none; }
.tk-details summary::-webkit-details-marker { display: none; }
.tk-details summary::before { content: "\ea61"; font-family: "tabler-icons"; margin-right: 6px; display: inline-block; transition: transform .16s; }
.tk-details[open] summary::before { transform: rotate(90deg); }

/* Remind del ticket */
.remind-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.remind-item { border: 1px solid var(--ap-border); border-radius: var(--r-md); padding: var(--sp-3); }
.remind-item.is-scaduto { border-left: 3px solid var(--ap-danger); }
.remind-title { font-size: 13.5px; font-weight: 600; color: var(--ap-ink); margin-top: 2px; }
.remind-actions { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); margin-left: -12px; }

/* ── Agenda dei remind (Site/Remind, B5) ── */
.agenda-sez      { margin-bottom: var(--sp-6); }
.agenda-sez-head { display: flex; align-items: baseline; gap: var(--sp-3); margin: 0 0 var(--sp-3); }
.agenda-sez-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ap-ink); }
.agenda-sez-head .ap-muted { font-size: 13px; }
.agenda-list { list-style: none; margin: 0; padding: 0; }
.agenda-row {
  display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; gap: var(--sp-4);
  align-items: start; padding: var(--sp-4) var(--sp-5);
}
.agenda-row + .agenda-row { border-top: 1px solid var(--ap-border); }
.agenda-row.is-scaduto { box-shadow: inset 3px 0 0 var(--ap-danger); }
.agenda-when { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--ap-text); padding-top: 2px; }
.agenda-when small { display: block; font-family: var(--font-main); font-weight: 500; color: var(--ap-muted); margin-top: 2px; }
.agenda-when.is-scaduto, .agenda-when.is-scaduto small { color: var(--ap-danger); }
.agenda-title { font-size: 14px; font-weight: 600; color: var(--ap-ink); margin: 2px 0 4px; }
.agenda-meta  { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); font-size: 12.5px; color: var(--ap-muted); }
.agenda-meta a { font-family: var(--font-mono); font-weight: 600; }
.agenda-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-1); }
.agenda-note { font-size: 12.5px; color: var(--ap-muted); margin-top: var(--sp-2); }
@media (max-width: 760px) {
  .agenda-row { grid-template-columns: minmax(0, 1fr); gap: var(--sp-2); }
  .agenda-actions { justify-content: flex-start; margin-left: -12px; }
}

/* Allegati */
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.file-list li { display: flex; gap: var(--sp-2); align-items: flex-start; }
.file-list i.ti { font-size: 18px; color: var(--ap-muted); margin-top: 1px; }
.file-name { font-size: 13.5px; color: var(--ap-ink); overflow-wrap: anywhere; }
a.file-name { color: var(--ap-primary); text-decoration: none; }
a.file-name:hover { text-decoration: underline; }
.file-info { flex: 1; min-width: 0; }
.file-list .btn { flex-shrink: 0; margin-top: -4px; }
.file-list .btn i.ti { color: inherit; margin-top: 0; }
.comment-files { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--ap-border); gap: var(--sp-2); }
.composer-files { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.composer-files .ap-muted { overflow-wrap: anywhere; min-width: 0; flex: 1; }
/* L'input file resta nel DOM (e raggiungibile da tastiera) ma lo rappresenta la label-bottone. */
.composer-files input[type=file]:focus-visible + .ap-muted { outline: 2px solid var(--ap-primary); outline-offset: 2px; }

/* ============================================================
   FLUSSI DI LAVORO (Site/Config/flussi_scheda.php, C4)
   ============================================================ */
/* Schema della catena (G10, C-42): nodi = Cliente e stazioni, fra due nodi le
   frecce di escalation (sopra) e di chiusura (sotto). La direzione e' detta a
   parole e con l'icona, non solo con il colore. */
.chain-editor { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--sp-2); list-style: none; margin: 0; padding: 0; }
.chain-node { display: flex; flex-direction: column; gap: 4px; min-width: 170px; max-width: 240px; padding: 10px 12px;
  border: 1px solid var(--ap-border); border-radius: var(--r-md); background: var(--ap-surface); }
.chain-node.is-virtuale { border-style: dashed; background: var(--ap-surface-alt); }
.chain-node.is-warning  { border-color: #F0DFB6; background: var(--ap-warning-bg); }
.chain-n     { font-family: var(--font-mono); font-size: 12px; color: var(--ap-muted); }
.chain-nome  { font-weight: 600; color: var(--ap-ink); }
.chain-meta  { font-size: 12.5px; color: var(--ap-muted); }
.chain-membri { font-size: 12.5px; color: var(--ap-ink); }
.chain-cmd   { display: flex; gap: 2px; margin-top: auto; padding-top: 4px; }
.chain-cmd form { display: inline; }
.chain-link  { display: flex; flex-direction: column; justify-content: center; gap: var(--sp-2); min-width: 150px; max-width: 220px; }
.chain-arrow { font-size: 12.5px; padding: 6px 8px; border-radius: var(--r-md); border: 1px solid var(--ap-border); }
.chain-arrow.is-fwd  { border-left: 3px solid var(--ap-primary); }
.chain-arrow.is-back { border-right: 3px solid var(--ap-success); text-align: right; }
.chain-dir  { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ap-muted); }
.chain-tr   { font-weight: 600; color: var(--ap-ink); }
.is-missing { color: var(--ap-warning); }

@media (max-width: 700px) {
  .chain-editor { flex-direction: column; }
  .chain-node, .chain-link { max-width: none; }
}

/* Mappa: per ogni stato, i pulsanti che l'operatore vedra' e dove portano. */
.flow-map { display: grid; gap: var(--sp-3); }
.flow-row { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); gap: var(--sp-3);
  align-items: start; padding-bottom: var(--sp-3); border-bottom: 1px solid var(--ap-border); }
.flow-row:last-child { border-bottom: 0; padding-bottom: 0; }
.flow-state { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flow-exits { display: flex; flex-direction: column; gap: 6px; }
.flow-exit  { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13.5px; }
.flow-exit.is-off { opacity: .55; }

/* Controlli di coerenza: livello = icona + testo, mai solo colore. */
.flow-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.flow-checks li { display: flex; gap: var(--sp-2); align-items: flex-start; font-size: 13.5px; }
.flow-checks li > i.ti { font-size: 18px; margin-top: 1px; flex-shrink: 0; }
.flow-checks .is-danger  > i.ti { color: var(--ap-danger); }
.flow-checks .is-warning > i.ti { color: var(--ap-warning); }
.flow-checks .is-info    > i.ti { color: var(--ap-primary); }
.flow-checks .is-ok      > i.ti { color: var(--ap-success); }

/* Frase di un automatismo: "quando … se … allora … dopo …". */
.flow-sentence b { color: var(--ap-ink); font-weight: 600; }

/* Blocco del form che vale solo per un certo tipo di azione / movimento. */
.flow-explain { padding: var(--sp-3); border: 1px dashed var(--ap-border); border-radius: var(--r-md);
  background: var(--ap-surface-alt); font-size: 13.5px; }

@media (max-width: 700px) {
  .flow-row { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   UTILITY
   ============================================================ */
.u-flex    { display: flex; }
.u-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.u-gap-2 { gap: var(--sp-2); } .u-gap-3 { gap: var(--sp-3); } .u-gap-4 { gap: var(--sp-4); }
.u-mt-4 { margin-top: var(--sp-4); } .u-mt-6 { margin-top: var(--sp-6); }
.u-mb-4 { margin-bottom: var(--sp-4); } .u-mb-6 { margin-bottom: var(--sp-6); }
.u-right { text-align: right; } .u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }
.u-hidden { display: none !important; }
.u-visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--sp-4); }
.grid-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-5); align-items: start; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-w-mini); }
  .main-wrapper { margin-left: var(--sidebar-w-mini); }
  .content { padding: var(--sp-4); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   PORTALE CLIENTE — il Capolinea (Portal/, C-43)
   Niente sidebar: una barra con le due cose che il cliente fa qui.
   L'unica azione che il cliente deve fare (confermare la chiusura)
   ha il suo riquadro, in testa a elenco e dettaglio.
   ============================================================ */
.portal-body { margin: 0; min-height: 100vh; background: var(--ap-bg); }
.portal-top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--sp-6); flex-wrap: wrap;
  min-height: var(--topbar-h); padding: 0 var(--sp-6);
  background: var(--ap-surface); border-bottom: 1px solid var(--ap-border);
}
.portal-logo img { height: 26px; display: block; }
.portal-nav { display: flex; gap: var(--sp-2); flex: 1; }
.portal-link {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--ap-text); font-weight: 500; text-decoration: none;
}
.portal-link:hover { background: var(--ap-surface-alt); text-decoration: none; }
.portal-link.is-active { background: var(--ap-primary-light); color: var(--ap-primary-dark); font-weight: 600; }
.portal-user { display: flex; align-items: center; gap: var(--sp-3); }
.portal-chi { display: flex; flex-direction: column; text-align: right; line-height: 1.25; }
.portal-nome { font-weight: 600; color: var(--ap-ink); font-size: 13.5px; }
.portal-azienda { font-size: 12px; color: var(--ap-muted); }
.portal-content { max-width: 960px; margin: 0 auto; padding: var(--sp-6); }

.portal-list { display: flex; flex-direction: column; }
.portal-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--ap-border); color: inherit; text-decoration: none;
}
.portal-row:last-child { border-bottom: 0; }
.portal-row:hover { text-decoration: none; }
.portal-row:hover .portal-row-ogg { color: var(--ap-primary); }
.portal-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.portal-row-ogg { font-weight: 600; color: var(--ap-ink); overflow-wrap: anywhere; }
.portal-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* Il riquadro della conferma: bordo e icona, non il solo colore (§6). */
.portal-attesa, .portal-conferma { border-left: 3px solid var(--ap-success); }
.portal-azioni { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.portal-form .card-footer { display: flex; }
/* Gruppi di radio del portale (priorita', valutazione E6): voto o livello con la sua
   parola, mai il solo colore. Si toglie solo la cornice del fieldset: il margine
   sotto resta quello di .form-group. */
.portal-voti { border: 0; padding: 0; margin-left: 0; margin-right: 0; min-width: 0; }

@media (max-width: 700px) {
  .portal-top { padding: var(--sp-2) var(--sp-4); gap: var(--sp-3); }
  .portal-nav { order: 3; flex-basis: 100%; }
  .portal-chi { display: none; }
  .portal-content { padding: var(--sp-4); }
  .portal-row { flex-direction: column; align-items: flex-start; }
  .portal-row-side { align-items: flex-start; flex-direction: row; }
}
