/* =============================================================
   Gestionale Gali Web Factory - design system
   Stile: Apple / "liquid glass". Tema scuro predefinito, tema chiaro opzionale.
   CSS scritto a mano, un solo file, nessun build step (vedi nota.md, RC).
   ============================================================= */

:root {
  /* Brand */
  --navy:        #050A28;
  --blue:        #3FA2F6;
  --white:       #FFFFFF;

  /* Superfici tema scuro (predefinito) */
  --bg:          #050A28;
  --bg-glow:     #0b1540;
  --surface:     rgba(255, 255, 255, 0.055);
  --surface-2:   rgba(255, 255, 255, 0.085);
  --border:      rgba(255, 255, 255, 0.12);
  --border-soft: rgba(255, 255, 255, 0.07);

  --text:        #EAEEF9;
  --text-soft:   #9AA6C4;
  --text-dim:    #6B7280;

  --accent:      #3FA2F6;
  --accent-ink:  #05132b;
  --ok:          #34D399;
  --warn:        #FBBF24;
  --danger:      #F87171;

  --radius:      20px;
  --radius-sm:   12px;
  --radius-pill: 999px;

  --shadow:      0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-sm:   0 6px 20px rgba(0, 0, 0, 0.25);
  --blur:        saturate(180%) blur(20px);

  --sidebar-w:   250px;
  --ease:        cubic-bezier(0.22, 1, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-title: "Garnet Capitals Bold", var(--font);
}

html[data-tema="chiaro"] {
  --bg:          #F4F7FC;
  --bg-glow:     #e5edfa;
  --surface:     rgba(255, 255, 255, 0.75);
  --surface-2:   rgba(255, 255, 255, 0.9);
  --border:      rgba(5, 10, 40, 0.1);
  --border-soft: rgba(5, 10, 40, 0.06);
  --text:        #0b1220;
  --text-soft:   #4b5563;
  --text-dim:    #9aa3b2;
  --accent-ink:  #ffffff;
  --shadow:      0 12px 40px rgba(5, 10, 40, 0.12);
  --shadow-sm:   0 6px 20px rgba(5, 10, 40, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow-x: hidden; }  /* rete di sicurezza: nessun elemento deve far scorrere la pagina di lato */
body { width: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px 500px at 12% -5%, var(--bg-glow), transparent 70%),
    radial-gradient(800px 600px at 100% 0%, rgba(63, 162, 246, 0.16), transparent 65%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
.muted { color: var(--text-soft); font-size: 0.9rem; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }

/* ---------- Vetro ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Layout app ---------- */
body.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 12px auto 12px 12px;
  width: var(--sidebar-w);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-radius: var(--radius);
  z-index: 20;
}
.brand { padding: 4px 8px 10px; }
.brand-logo { height: 30px; width: auto; }

/* Logo: bianco su tema scuro, navy su tema chiaro */
.logo-chiaro { display: none; }
html[data-tema="chiaro"] .logo-scuro { display: none; }
html[data-tema="chiaro"] .logo-chiaro { display: inline-block; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-secondaria { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active {
  background: linear-gradient(180deg, rgba(63,162,246,0.22), rgba(63,162,246,0.12));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(63,162,246,0.35);
}
.ico { width: 19px; height: 19px; flex: none; }

.main {
  flex: 1;
  margin-left: calc(var(--sidebar-w) + 24px);
  padding: 12px 24px 60px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  margin-bottom: 22px;
}
.topbar-title { font-size: 1.15rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user { font-size: 0.9rem; color: var(--text-soft); padding-left: 6px; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.18s, transform 0.18s var(--ease);
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }
.badge-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: var(--danger); color: #fff;
  font-size: 0.68rem; font-weight: 700;
  border-radius: var(--radius-pill);
  display: flex; align-items: center; justify-content: center;
}

.content { display: flex; flex-direction: column; gap: 22px; }

/* ---------- Card / griglie ---------- */
.card { padding: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 0.82rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi-hint { font-size: 0.78rem; color: var(--text-dim); }

.fondo-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fondo-row > div { display: flex; flex-direction: column; gap: 4px; }
.fondo-row strong { font-size: 1.15rem; }

/* ---------- Pill / badge ---------- */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.pill-ok   { background: rgba(52, 211, 153, 0.16); color: var(--ok); }
.pill-warn { background: rgba(248, 113, 113, 0.16); color: var(--danger); }
.pill-info { background: rgba(63, 162, 246, 0.16); color: var(--accent); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Progress / barchart ---------- */
.progress { height: 10px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; margin: 4px 0 10px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), #7cc4ff); border-radius: inherit; }

.barchart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 34px;
  background: linear-gradient(180deg, #7cc4ff, var(--accent));
  border-radius: 8px 8px 4px 4px;
  transition: height 0.5s var(--ease);
}
.bar-label { font-size: 0.72rem; color: var(--text-dim); }

/* ---------- Liste ---------- */
.lista { list-style: none; display: flex; flex-direction: column; }
.lista li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.9rem;
}
.lista li:last-child { border-bottom: 0; }
.lista-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-meta { color: var(--text-soft); font-size: 0.82rem; white-space: nowrap; }

/* ---------- Toolbar / form ---------- */
.toolbar { display: flex; justify-content: flex-end; }
.inline-form, .form { display: flex; flex-direction: column; gap: 14px; }
.inline-form { flex-direction: row; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--text-soft); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field input, .field select, .field textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 162, 246, 0.25);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600;
  padding: 11px 20px;
  border: 0; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #57b0f8, var(--accent));
  color: var(--accent-ink);
  cursor: pointer;
  transition: transform 0.16s var(--ease), box-shadow 0.16s, opacity 0.16s;
  box-shadow: 0 6px 18px rgba(63, 162, 246, 0.3);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: 0.9; }
.btn-block { width: 100%; }
.btn-ghost {
  background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.9rem; border: 1px solid var(--border); }
.flash-ok     { background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.4); }
.flash-errore { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.4); }
.flash-info   { background: rgba(63, 162, 246, 0.14); border-color: rgba(63, 162, 246, 0.4); }

/* ---------- Stub ---------- */
.stub { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.stub .lista { width: 100%; }

/* ---------- Schermata di accesso ---------- */
.auth-body { display: flex; min-height: 100vh; }
.auth-shell { margin: auto; width: 100%; max-width: 380px; padding: 24px; }
.login-card { padding: 34px 30px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { height: 34px; width: auto; align-self: flex-start; }
.login-sub { color: var(--text-soft); font-size: 0.9rem; margin-top: -8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .grid-2, .kpi-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Componenti moduli (Fase 2+)
   ============================================================ */

.pagina-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pagina-head h2 { font-size: 1.2rem; }

.torna { display: inline-block; color: var(--text-soft); font-size: 0.85rem; margin-bottom: 4px; }
.torna:hover { color: var(--text); }

/* Sotto-schede */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.subtab { padding: 8px 14px; border-radius: 9px; font-size: 0.88rem; color: var(--text-soft); font-weight: 500; }
.subtab:hover { background: var(--surface-2); color: var(--text); }
.subtab.is-active { background: rgba(63,162,246,0.2); color: var(--text); box-shadow: inset 0 0 0 1px rgba(63,162,246,0.35); }

/* Tabelle */
.tabella-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.tabella { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.tabella th, .tabella td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.tabella th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); font-weight: 600; }
.tabella tbody tr { transition: background 0.14s; }
.tabella tbody tr:hover { background: var(--surface); }
.tabella td.num, .tabella th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabella a.riga-link { font-weight: 600; }

/* Form */
.form-largo { max-width: 720px; }
.form-riga { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-azioni { display: flex; gap: 10px; margin-top: 6px; }
.field em.req { color: var(--accent); font-style: normal; }
.field .aiuto, small.aiuto { color: var(--text-dim); font-size: 0.76rem; font-weight: 400; }
.check { display: inline-flex; align-items: center; }
.check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.color-wrap { display: flex; align-items: center; gap: 10px; }
.color-wrap input[type="color"] { width: 44px; height: 34px; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.color-wrap code { color: var(--text-soft); font-size: 0.82rem; }

.btn-danger { background: linear-gradient(180deg, #fb8f8f, var(--danger)); color: #2a0808; box-shadow: 0 6px 18px rgba(248,113,113,0.3); }
.inline { display: inline; }
form.inline { display: inline-block; }

.pill-neutra { background: var(--surface-2); color: var(--text-soft); }

/* Badge cliente */
.badge-cli { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px; border: 1px solid; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 600; }

/* Dettaglio (scheda cliente / progetto) */
.dett-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.dett-lista { list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 0.9rem; }
.dett-lista li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; }
.dett-lista li span:first-child { color: var(--text-soft); }
.link-rapidi { display: flex; flex-wrap: wrap; gap: 8px; }
.link-rapidi a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.84rem; }
.link-rapidi a:hover { border-color: var(--accent); }

/* Filtri a chip */
.filtri { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: 0.82rem; color: var(--text-soft); cursor: pointer; user-select: none; }
.chip:hover { color: var(--text); }
.chip.is-on { background: rgba(63,162,246,0.16); color: var(--text); border-color: rgba(63,162,246,0.4); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.kanban-col h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); display: flex; justify-content: space-between; }
.kanban-card { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 11px 12px; font-size: 0.86rem; display: flex; flex-direction: column; gap: 6px; }
.kanban-card:hover { border-color: var(--accent); }
.kanban-card .meta { display: flex; gap: 8px; align-items: center; font-size: 0.76rem; color: var(--text-soft); flex-wrap: wrap; }
.prio { font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.prio-super-high { background: rgba(248,113,113,0.2); color: var(--danger); }
.prio-high { background: rgba(251,191,36,0.2); color: var(--warn); }
.prio-medium { background: rgba(63,162,246,0.18); color: var(--accent); }
.prio-low { background: var(--surface-2); color: var(--text-dim); }

/* Calendario */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); text-align: center; padding: 4px 0; }
.cal-cell { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.fuori { opacity: 0.4; }
.cal-cell.oggi { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(63,162,246,0.4); }
.cal-cell .giorno { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.cal-ev { font-size: 0.72rem; padding: 2px 6px; border-radius: 6px; background: rgba(63,162,246,0.18); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--accent); }
.cal-ev.cat-fisco { background: rgba(248,113,113,0.16); border-color: var(--danger); }
.cal-ev.cat-task { background: rgba(52,211,153,0.14); border-color: var(--ok); }
.cal-ev.cat-spesa { background: rgba(251,191,36,0.16); border-color: var(--warn); }

.agenda li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 0.88rem; }
.agenda .quando { color: var(--text-soft); min-width: 120px; }

/* Calendario - griglia oraria (giorno / 3 giorni / settimana) */
.cal-tg-wrap { padding: 16px 16px 20px; overflow-x: auto; }
.cal-tg-head {
  display: grid; grid-template-columns: 56px repeat(var(--cal-cols), minmax(120px, 1fr));
  border-bottom: 1px solid var(--border-soft); padding-bottom: 8px; margin-bottom: 4px;
}
.cal-tg-corner { }
.cal-tg-daycol-head { text-align: center; padding: 4px 0; border-radius: 10px; }
.cal-tg-daycol-head.oggi { background: rgba(63,162,246,0.14); }
.cal-tg-dow { display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); }
.cal-tg-daynum { display: block; font-size: 1.05rem; font-weight: 700; }
.cal-tg-daycol-head.oggi .cal-tg-daynum { color: var(--accent); }

.cal-tg-allday {
  display: grid; grid-template-columns: 56px repeat(var(--cal-cols), minmax(120px, 1fr));
  gap: 4px; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px dashed var(--border-soft);
  min-height: 20px; align-items: start;
}
.cal-tg-allday .cal-tg-daycol { display: flex; flex-direction: column; gap: 3px; }

.cal-tg-body { display: grid; grid-template-columns: 56px repeat(var(--cal-cols), minmax(120px, 1fr)); position: relative; }
.cal-tg-ore { display: flex; flex-direction: column; }
.cal-tg-ora { height: var(--cal-riga); font-size: 0.68rem; color: var(--text-dim); text-align: right; padding-right: 8px; transform: translateY(-6px); }
.cal-tg-daycol.cal-tg-slots {
  position: relative; border-left: 1px solid var(--border-soft);
  height: calc(var(--cal-ore) * var(--cal-riga));
}
.cal-tg-daycol.cal-tg-slots.oggi { background: rgba(63,162,246,0.05); }
.cal-tg-slot { display: block; border-bottom: 1px solid var(--border-soft); }
.cal-tg-slot:hover { background: rgba(63,162,246,0.08); }
.cal-tg-event {
  position: absolute; z-index: 2; overflow: hidden;
  border-left: 3px solid var(--accent); border-radius: 6px;
  padding: 3px 7px; font-size: 0.74rem; line-height: 1.25;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.cal-tg-event strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-tg-autore { display: block; font-size: 0.68rem; color: var(--text-soft); }

/* Notifiche */
.notif { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.notif.non-letta { border-left: 3px solid var(--accent); padding-left: 12px; }
.notif .n-corpo { flex: 1; }
.notif .n-quando { color: var(--text-dim); font-size: 0.78rem; }

/* Statistiche riquadri piccoli */
.mini-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.mini-kpi > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.mini-kpi .v { font-size: 1.25rem; font-weight: 700; }
.mini-kpi .l { font-size: 0.78rem; color: var(--text-soft); }

/* Chat interna */
.chat-shell { display: flex; gap: 14px; height: calc(100vh - 150px); min-height: 480px; }

.chat-canali { width: 220px; flex: none; padding: 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.chat-canali-head { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-soft); padding: 0 8px; }
.chat-canali-lista { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.chat-canale-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-soft); font-size: 0.88rem; }
.chat-canale-link:hover { background: var(--surface-2); color: var(--text); }
.chat-canale-link.is-active { background: rgba(63,162,246,0.18); color: var(--text); box-shadow: inset 0 0 0 1px rgba(63,162,246,0.35); }
.chat-canale-link .ico { width: 16px; height: 16px; }
.chat-nuovo-canale { margin-top: auto; font-size: 0.84rem; color: var(--text-soft); }
.chat-nuovo-canale summary { cursor: pointer; padding: 6px 8px; }
.chat-nuovo-canale form { padding: 8px; }
.chat-nuovo-canale input[type="text"] { width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }

.chat-main, .chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-main { flex: 1; }
.chat-thread { width: 340px; flex: none; }
.chat-main-head, .chat-thread-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.chat-main-head h3, .chat-thread-head h3 { font-size: 1rem; }

.chat-messaggi { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.chat-thread-sep { border: 0; border-top: 1px dashed var(--border-soft); margin: 4px 0 10px; }

.chat-msg { display: flex; gap: 10px; }
.chat-msg-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #7cc4ff, var(--accent)); color: var(--accent-ink);
  font-weight: 700; font-size: 0.82rem;
}
.chat-msg.mio .chat-msg-avatar { background: linear-gradient(160deg, #a78bfa, #8b5cf6); }
.chat-msg-corpo { flex: 1; min-width: 0; }
.chat-msg-meta { display: flex; align-items: baseline; gap: 8px; font-size: 0.86rem; margin-bottom: 2px; }
.chat-msg-meta .muted { font-size: 0.72rem; }
.chat-msg-testo { font-size: 0.9rem; line-height: 1.45; word-wrap: break-word; }
.chat-msg-allegato { display: inline-block; margin-top: 6px; font-size: 0.82rem; padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.chat-msg-azioni { display: flex; gap: 12px; margin-top: 4px; font-size: 0.76rem; }
.chat-msg-azioni a { color: var(--accent); }
.chat-elimina { background: none; border: 0; padding: 0; color: var(--text-dim); font-size: 0.76rem; cursor: pointer; font-family: inherit; }
.chat-elimina:hover { color: var(--danger); }

.chat-composer { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.chat-composer textarea {
  flex: 1; resize: none; max-height: 120px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none;
}
.chat-composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,162,246,0.25); }
.chat-allegato-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 1.1rem; }
.chat-composer .btn { height: 40px; padding: 0 16px; }

@media (max-width: 1100px) {
  .chat-thread { position: fixed; inset: 12px; z-index: 40; width: auto; }
}
@media (max-width: 900px) {
  .dett-grid { grid-template-columns: 1fr; }
  .form-riga { grid-template-columns: 1fr; }
  .cal-cell { min-height: 64px; }
  .chat-shell { flex-direction: column; height: auto; }
  .chat-canali { width: auto; flex-direction: row; overflow-x: auto; }
  .chat-canali-lista { flex-direction: row; }
  .chat-messaggi { max-height: 50vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ============================================================
   Form ridisegnati, persone, profili, mobile  (2026-09-19)
   ============================================================ */

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

/* ---- Form ---- */
.form-card { padding: 26px; max-width: 780px; }
.form-card h3 { margin-bottom: 4px; }
.form-largo { gap: 18px; max-width: none; }
.field > span:first-child { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.01em; color: var(--text-soft); }
.field input, .field select, .field textarea {
  min-height: 46px; font-size: 16px; padding: 11px 14px; border-radius: 14px; width: 100%;
}
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA6C4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.field input[type="file"] { padding: 10px 12px; font-size: 14px; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-dim); }

.form-sezione {
  margin-top: 6px; padding-top: 18px; border-top: 1px solid var(--border-soft);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); font-weight: 700;
}

.form-azioni-sticky { margin-top: 8px; }
.btn { min-height: 44px; }
.btn-small { min-height: 34px; padding: 6px 14px; font-size: 0.82rem; border-radius: 10px; }

/* Interruttore (sostituisce la casella di spunta) */
.field-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 0.92rem; }
.field-toggle .toggle { position: relative; flex: none; width: 46px; height: 28px; }
.field-toggle .toggle input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.field-toggle .toggle i { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: background 0.18s var(--ease); }
.field-toggle .toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.3); transition: transform 0.18s var(--ease); }
.field-toggle .toggle input:checked + i { background: var(--accent); border-color: var(--accent); }
.field-toggle .toggle input:checked + i::after { transform: translateX(18px); }
.toggle-testo small.aiuto { display: block; margin-top: 2px; }
.installa-passi { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 14px 0 4px; }
.installa-passi ol { margin: 8px 0 0; padding-left: 20px; color: var(--text-soft); font-size: 0.9rem; line-height: 1.55; }
.installa-passi b { color: var(--text); }
.field-toggle + .btn-block, .field-toggle + button { margin-top: 16px; }

/* Scelta a pulsanti affiancati */
.segmentato { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; max-width: 100%; }
.segmentato label { cursor: pointer; position: relative; }
.segmentato input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmentato label span { display: block; padding: 9px 14px; border-radius: 10px; font-size: 0.86rem; font-weight: 500; color: var(--text-soft); transition: background 0.16s, color 0.16s; }
.segmentato label:hover span { color: var(--text); }
.segmentato input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 4px 12px rgba(63,162,246,0.3); }
.segmentato input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmentato-mini label span { padding: 6px 12px; font-size: 0.8rem; }

/* ---- Persone ---- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%; font-size: 0.72rem; font-weight: 700; color: #04122b;
  box-shadow: 0 0 0 2px var(--bg);
}
.avatar-pila { display: inline-flex; }
.avatar-pila .avatar + .avatar { margin-left: -8px; }
.persone-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.persona-chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 5px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 0.86rem; color: var(--text-soft);
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}
.persona-chip input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.persona-chip .avatar { box-shadow: none; }
.persona-chip:hover { color: var(--text); }
.persona-chip:has(input:checked) { background: rgba(63,162,246,0.18); border-color: rgba(63,162,246,0.55); color: var(--text); font-weight: 600; }
.persona-chip input:checked ~ span:last-child::after { content: " ✓"; color: var(--accent); }
.persone-filtro { align-items: center; }
.persone-filtro .chip .avatar { width: 20px; height: 20px; font-size: 0.62rem; box-shadow: none; }

.pill-lav { background: rgba(251,191,36,0.18); color: var(--warn); }

/* ---- Liste con ricerca ---- */
.toolbar-lista { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 14px 0 18px; }
.cerca-wrap { flex: 1; min-width: 200px; max-width: 420px; }
.cerca-wrap input {
  width: 100%; min-height: 44px; padding: 10px 14px 10px 40px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239AA6C4' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
  border: 1px solid var(--border); border-radius: 14px; outline: none;
}
.cerca-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63,162,246,0.25); }

/* ---- Profili per cliente ---- */
.gruppo { margin-bottom: 26px; }
.gruppo-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.gruppo-link { margin-left: auto; font-size: 0.8rem; color: var(--accent); }
.profili-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.profilo-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  transition: transform 0.18s var(--ease), border-color 0.18s;
}
.profilo-card:hover { transform: translateY(-2px); border-color: rgba(63,162,246,0.45); }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-head strong { font-size: 1.02rem; }
.pc-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.86rem; }
.pc-user code { background: var(--surface-2); padding: 3px 8px; border-radius: 8px; word-break: break-all; }
.pc-note { font-size: 0.82rem; margin: 0; }
.pc-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border-soft); }
.pc-chi { margin-left: auto; }
.copia { font: inherit; font-size: 0.74rem; color: var(--accent); background: none; border: 1px solid rgba(63,162,246,0.4); border-radius: 8px; padding: 2px 9px; cursor: pointer; }
.copia:hover { background: rgba(63,162,246,0.12); }
.copia.ok { color: var(--ok); border-color: var(--ok); }
[hidden] { display: none !important; }

/* ---- Menu mobile (cassetto) ---- */
.menu-btn { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(2,5,20,0.6); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.nav-aperta .nav-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); margin: 0; z-index: 60;
    border-radius: 0 var(--radius) var(--radius) 0; overflow-y: auto;
    transform: translateX(-108%); transition: transform 0.26s var(--ease);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch;
    padding-top: max(22px, env(safe-area-inset-top));
  }
  body.nav-aperta .sidebar { transform: none; }
  body.nav-aperta { overflow: hidden; }
  .nav { flex-direction: column; flex-wrap: nowrap; }
  .nav-secondaria { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border-soft); }
  .nav-link { padding: 13px 14px; font-size: 1rem; }
  .nav-link span { display: inline; }

  .main { margin-left: 0; padding: 6px 10px calc(36px + env(safe-area-inset-bottom)); }
  .topbar { top: 6px; padding: 9px 12px; margin-bottom: 12px; gap: 10px; }
  .topbar-title { font-size: 1.02rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-user { display: none; }
  .content { gap: 16px; }
  .card { padding: 16px; }
  .form-card { padding: 18px 16px; }
  .kpi-value { font-size: 1.4rem; }
  .pagina-head h2 { font-size: 1.1rem; }
  .pagina-head .btn { flex: none; }

  /* barra azioni del form sempre a portata di pollice */
  .form-azioni-sticky {
    position: sticky; bottom: 0; z-index: 5; margin: 8px -16px -18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface-2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  }
  .form-azioni-sticky .btn { flex: 1; }
  .segmentato { display: flex; width: 100%; }
  .segmentato label { flex: 1 1 auto; text-align: center; }
  .segmentato label span { padding: 10px 8px; }

  .kanban { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .kanban-col { scroll-snap-align: start; }
  .profili-cards { grid-template-columns: 1fr; }
  .cal-head { gap: 8px; }
  .cal-head h3 { font-size: 0.98rem; }
  .cal-tg-wrap { padding: 10px 8px 14px; }
  .chat-shell { height: calc(100dvh - 150px); }
  .toolbar-lista { margin-top: 10px; }
  .filtri { gap: 6px; }
}

/* ---- Tabelle a schede su telefono ---- */
@media (max-width: 700px) {
  .tabella-wrap { overflow: visible; }
  .tabella, .tabella tbody, .tabella tr, .tabella td { display: block; width: 100%; }
  .tabella thead { display: none; }
  .tabella tr { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 16px; padding: 8px 14px; margin-bottom: 10px; }
  .tabella tbody tr:hover { background: var(--surface); }
  .tabella td { white-space: normal; border: 0; padding: 7px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
  .tabella td::before { content: attr(data-label); flex: none; text-align: left; color: var(--text-soft); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
  .tabella td[data-label=""]::before { display: none; }
  .tabella td:first-child { font-weight: 600; font-size: 1rem; }
  .tabella td[colspan] { justify-content: center; }
  .tabella td[colspan]::before { display: none; }

  /* mese: solo pallini colorati */
  .cal-cell { min-height: 52px; padding: 4px; }
  .cal-cell .cal-ev { font-size: 0; width: 7px; height: 7px; padding: 0; border-radius: 50%; border-left: 0; background: var(--accent); display: inline-block; }
  .cal-cell .cal-ev.cat-fisco { background: var(--danger); } .cal-cell .cal-ev.cat-task { background: var(--ok); } .cal-cell .cal-ev.cat-spesa { background: var(--warn); }
  .cal-cell { flex-direction: row; flex-wrap: wrap; align-content: flex-start; gap: 3px; }
  .cal-cell .giorno { width: 100%; }
}


/* ============================================================
   Colori stati, avvisi popup, password, spaziatura pulsanti (2026-09-19)
   ============================================================ */

/* ---- Stati colorati ---- */
.pill-c { display: inline-flex; align-items: center; gap: 7px; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip .dot { margin-right: 2px; }

.segmentato.colorato label span { display: flex; align-items: center; gap: 8px; }
.segmentato.colorato label span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.segmentato.colorato input:checked + span { background: var(--c); color: var(--ct, #fff); box-shadow: 0 4px 14px rgba(0,0,0,0.28); }
.segmentato.colorato input:checked + span::before { background: var(--ct, #fff); }

.select-stato {
  appearance: none; -webkit-appearance: none; width: 100%; min-height: 36px; font: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 7px 30px 7px 12px; border-radius: 999px; cursor: pointer; color: var(--text);
  border: 1px solid var(--c, var(--border)); background-color: var(--surface);
  background-color: color-mix(in srgb, var(--c, #94A3B8) 16%, transparent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA6C4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select-stato option { background: #0b1540; color: #eaeef9; }
html[data-tema="chiaro"] .select-stato option { background: #fff; color: #0b1220; }

.kanban-col { border-top: 3px solid var(--c, var(--border)); }
.kanban-card { border-left: 3px solid var(--c, transparent); }
.kanban-card .select-stato { margin-top: 6px; }

/* ---- Avvisi (popup) ---- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; position: relative; display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 40px 18px 14px; border-radius: 18px; cursor: pointer;
  background: rgba(14, 22, 64, 0.94); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: var(--shadow);
  animation: toast-entra 0.3s var(--ease);
}
html[data-tema="chiaro"] .toast { background: rgba(255, 255, 255, 0.97); }
.toast-promemoria { border-left-color: #FBBF24; } .toast-evento { border-left-color: #A78BFA; } .toast-assegnazione { border-left-color: #34D399; }
.toast-ico { font-size: 1.3rem; line-height: 1.2; flex: none; }
.toast-corpo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast-corpo strong { font-size: 0.92rem; }
.toast-corpo span { font-size: 0.84rem; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toast-x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: none; color: var(--text-dim); cursor: pointer; }
.toast-x:hover { background: var(--surface-2); color: var(--text); }
.toast-barra { position: absolute; left: 14px; right: 14px; bottom: 7px; height: 3px; border-radius: 2px; background: currentColor; color: var(--accent); opacity: 0.6; transform-origin: left; animation: toast-barra 9s linear forwards; }
.toast.esce { animation: toast-esce 0.26s var(--ease) forwards; }
@keyframes toast-entra { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-esce { to { opacity: 0; transform: translateX(24px); } }
@keyframes toast-barra { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.avvisi-opzioni { display: flex; flex-direction: column; gap: 16px; margin: 16px 0 20px; }
@media (max-width: 700px) {
  .toasts { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: 16px; right: 16px; width: auto; flex-direction: column-reverse; }
}

/* ---- Password nei profili ---- */
.pw-input { display: flex; gap: 8px; align-items: stretch; }
.pw-input input { flex: 1; min-width: 0; }
.pw-input .btn { flex: none; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; margin-left: 8px; }
.pc-titolo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-titolo .muted { font-size: 0.78rem; }
.pc-apri { width: 100%; justify-content: center; }
.pc-dati { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 2px 0 0; align-items: center; }
.pc-dati dt { color: var(--text-soft); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; }
.pc-dati dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.pc-chi { display: flex; align-items: center; gap: 8px; }
.pc-azioni { display: flex; gap: 14px; margin-left: auto; }
.pw-valore { letter-spacing: 0.05em; }
.tabella td .copia { margin-left: 8px; }

/* ---- Spaziatura pulsanti: niente piu' elementi attaccati ---- */
.torna { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.pagina-head { gap: 14px; margin-bottom: 4px; }
.form-azioni { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-azioni form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.form-azioni input[type="date"] { min-height: 44px; }
.azioni { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.zona-pericolo { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card > .btn, .card > a.btn { margin-top: 14px; }
.card > h3 + p, .card > h3 + .flash { margin-top: 8px; }
.card > * + .form, .card > * + form.form { margin-top: 16px; }
.card-head { gap: 14px; flex-wrap: wrap; }
.dett-lista + .link-rapidi, .dett-lista + .form-azioni, .dett-lista + p { margin-top: 18px; }
details > summary { padding: 4px 0; }
details[open] > summary + * { margin-top: 14px; }
.filtri { row-gap: 8px; }
.filtri + .glass, .filtri + .card, .filtri + .kanban { margin-top: 4px; }
.riga-link + form.inline, form.inline + .riga-link { margin-left: 4px; }
.kanban-card .meta { row-gap: 6px; }
.chat-composer > * { flex: none; }
.chat-composer textarea { flex: 1; }
@media (max-width: 900px) {
  .pagina-head { align-items: stretch; }
  .pagina-head > .btn, .pagina-head > .form-azioni { align-self: flex-start; }
  .zona-pericolo { justify-content: flex-start; }
  .pc-azioni { margin-left: 0; width: 100%; }
}


/* ============================================================
   Selezioni piu' belle: caselle, permessi, testata utente (2026-09-19)
   ============================================================ */

/* le caselle/radio dentro un .field non devono ereditare le misure dei campi di testo */
.field input[type="checkbox"], .field input[type="radio"] { width: auto; min-height: 0; padding: 0; }

/* caselle di spunta dentro i chip: niente casella grezza del browser */
label.chip > input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0;
  border: 1.5px solid var(--text-dim); border-radius: 6px; background: transparent; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
label.chip > input[type="checkbox"]:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2305132b' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat;
  border-color: var(--accent);
}
label.chip { gap: 8px; }

/* permessi per modulo: carte con interruttore */
.permessi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.permesso-card {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface);
  transition: border-color 0.16s, background 0.16s, transform 0.16s var(--ease);
}
.permesso-card:hover { transform: translateY(-1px); border-color: rgba(63,162,246,0.4); }
.permesso-card input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.perm-ico { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--surface-2); color: var(--text-soft); transition: background 0.16s, color 0.16s; }
.perm-ico .ico { width: 18px; height: 18px; }
.perm-nome { flex: 1; min-width: 0; font-size: 0.9rem; font-weight: 500; line-height: 1.25; }
.perm-switch { position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); transition: background 0.16s, border-color 0.16s; }
.perm-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.3); transition: transform 0.16s var(--ease); }
.permesso-card:has(input:checked) { border-color: rgba(63,162,246,0.55); background: rgba(63,162,246,0.12); }
.permesso-card input:checked ~ .perm-ico { background: rgba(63,162,246,0.22); color: var(--accent); }
.permesso-card input:checked ~ .perm-switch { background: var(--accent); border-color: var(--accent); }
.permesso-card input:checked ~ .perm-switch::after { transform: translateX(16px); }
.permesso-card input:focus-visible ~ .perm-switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* testata della scheda utente */
.utente-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 16px; }
.utente-info { flex: 1; min-width: 200px; }
.utente-info h2 { font-size: 1.25rem; }
.pillole { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.azioni-utente { display: flex; gap: 10px; flex-wrap: wrap; }
.avatar-lg { width: 52px; height: 52px; font-size: 1.2rem; box-shadow: none; }
.dett-lista { margin-bottom: 18px; }


/* ============================================================
   Calendario: etichetta cliente, legenda tipi, form rapido (2026-09-19)
   ============================================================ */
.cli-tag {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; margin-top: 3px;
  padding: 1px 8px 1px 6px; border-radius: 999px; font-size: 0.68rem; font-weight: 600; line-height: 1.5;
  background: rgba(255,255,255,0.12); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
html[data-tema="chiaro"] .cli-tag { background: rgba(5,10,40,0.08); }
.cli-tag .dot { width: 7px; height: 7px; flex: none; }
.cli-logo { width: 14px; height: 14px; border-radius: 50%; object-fit: cover; flex: none; background: #fff; }
.cli-tag-mini { margin: 0 0 0 5px; padding: 0 6px 0 5px; font-size: 0.62rem; vertical-align: middle; }
.cal-tg-event .cli-tag { display: flex; width: fit-content; }
.cal-tg-event { padding-bottom: 4px; }

.legenda-tipi { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: -6px 0 14px; font-size: 0.78rem; }
.legenda-tipi .leg { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }

.chip-rapidi { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
button.chip { font: inherit; background: none; cursor: pointer; }
.riepilogo-fine { font-size: 0.84rem; color: var(--accent); min-height: 1.2em; margin-top: -6px; }
.durata-scelta { width: 100%; }


/* ============================================================
   Selezione multipla, cestino, barra "Annulla" (2026-09-19)
   ============================================================ */
.filtri-fine { margin-left: auto; }
.azioni-testata { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sel-attiva [data-sel] { cursor: pointer; position: relative; transition: background 0.12s, box-shadow 0.12s; }
.sel-attiva [data-sel] :is(a, button, select, input, textarea, label, summary) { pointer-events: none; }
.sel-attiva [data-sel].sel-scelto { background: rgba(63, 162, 246, 0.14); box-shadow: inset 0 0 0 2px rgba(63, 162, 246, 0.6); }
.sel-attiva tr[data-sel].sel-scelto { box-shadow: none; }
.sel-attiva tr[data-sel].sel-scelto td { background: rgba(63, 162, 246, 0.14); }
.sel-attiva .profilo-card, .sel-attiva .kanban-card { padding-left: 44px; }
.sel-check { position: absolute; top: 12px; left: 12px; z-index: 3; line-height: 0; }
.sel-cella, .sel-cella-th { width: 44px; padding-right: 0 !important; }
.sel-cb {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; padding: 0; min-height: 0;
  border: 1.5px solid var(--text-dim); border-radius: 7px; background: var(--surface); cursor: pointer; flex: none;
  transition: background 0.14s, border-color 0.14s;
}
.sel-cb:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2305132b' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 13px no-repeat;
  border-color: var(--accent);
}
.sel-bar {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 150;
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-radius: 22px;
  background: rgba(14, 22, 64, 0.96); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); animation: toast-entra 0.25s var(--ease);
}
html[data-tema="chiaro"] .sel-bar { background: rgba(255, 255, 255, 0.97); }
.sel-conta { font-size: 0.9rem; margin-right: 6px; white-space: nowrap; }
.sel-conta b { font-size: 1.05rem; }
.sel-bar .btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.sel-cambia-stato { min-height: 38px; font-size: 0.84rem; max-width: 170px; }
.sel-cambia-stato:disabled { opacity: 0.45; }
body.sel-modalita .main { padding-bottom: 110px; }
@media (max-width: 700px) {
  .sel-bar { left: 12px; right: 12px; transform: none; flex-wrap: wrap; justify-content: space-between; }
  .sel-conta { width: 100%; }
  .sel-bar .btn { flex: 1; }
  .sel-cambia-stato { flex: 1 1 100%; max-width: none; order: 2; }
  .sel-check { top: 10px; left: 10px; }
}

/* barra "Annulla" dopo un'eliminazione */
.flash-undo { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.flash-undo > span { flex: 1; min-width: 180px; }

/* pagina Cestino */
.cestino-riga { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.cestino-riga:last-child { border-bottom: 0; }
.cestino-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 220px; }
.cestino-meta { flex-basis: 100%; font-size: 0.78rem; }
.cestino-azioni { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-testo-danger { color: var(--danger); }
.cestino-vuoto { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px 20px; text-align: center; }
.cestino-ico { width: 54px; height: 54px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-soft); margin-bottom: 6px; }
.cestino-ico .ico { width: 26px; height: 26px; }


/* ---- Impostazioni > Avvisi ---- */
.push-dispositivi { margin-top: 14px; }
.push-cron { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--border-soft); }
.push-cron h4 { font-size: 0.95rem; margin-bottom: 6px; }
.passi-lista { margin: 10px 0 12px; padding-left: 22px; color: var(--text-soft); font-size: 0.9rem; line-height: 1.6; }
.passi-lista code, .push-cron code { background: var(--surface-2); padding: 1px 7px; border-radius: 7px; }
.banner-push { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(63,162,246,0.22), rgba(63,162,246,0.10)); border: 1px solid rgba(63,162,246,0.4); }
.banner-push .banner-ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: rgba(63,162,246,0.25); color: var(--accent); }
.banner-push .banner-testo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 0.9rem; }
.banner-push .banner-testo small { color: var(--text-soft); font-size: 0.78rem; line-height: 1.35; }
.banner-push .btn { flex: none; }
.banner-push .banner-x { flex: none; width: 32px; height: 32px; border: 0; border-radius: 10px; background: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; }
.banner-push.fatto { background: rgba(52,211,153,0.16); border-color: rgba(52,211,153,0.45); }
#form-avvisi { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.volume-riga { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.volume-riga input[type="range"] { flex: 1; min-width: 160px; accent-color: var(--accent); height: 28px; }
.volume-valore { min-width: 44px; text-align: right; font-weight: 600; }
.avvisi-tabella { display: flex; flex-direction: column; margin-top: 8px; }
.avviso-riga { display: grid; grid-template-columns: minmax(180px, 1.3fr) auto auto minmax(220px, 1.4fr); gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.avviso-riga:last-child { border-bottom: 0; }
.avviso-tono { display: flex; gap: 8px; align-items: center; }
.avviso-tono select { flex: 1; min-width: 0; min-height: 40px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.avvisi-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
@media (max-width: 800px) {
  .avviso-riga { grid-template-columns: 1fr 1fr; }
  .avviso-nome, .avviso-tono { grid-column: 1 / -1; }
}


/* ---- Backup ---- */
.backup-testata { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.backup-stato .dett-lista { margin: 14px 0 18px; }
.codice-copia { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin-top: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.codice-copia code { flex: 1; min-width: 200px; font-size: 0.82rem; word-break: break-all; }


/* ---- Tipi di progetto (icone) ---- */
.ptipo { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 26px; height: 26px; margin-right: 8px; vertical-align: middle;
  border-radius: 9px; color: var(--c); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.10); }
html[data-tema="chiaro"] .ptipo { background: rgba(5,10,40,0.06); border-color: rgba(5,10,40,0.08); }
.ptipo .ico { width: 15px; height: 15px; }
.ptipo-badge { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 8px; border-radius: 999px; border: 1px solid var(--c); color: var(--c); font-size: 0.78rem; font-weight: 600; margin-left: 6px; vertical-align: middle; }
.ptipo-badge .ico { width: 15px; height: 15px; }
.chip .ptipo { width: 20px; height: 20px; margin: 0 6px 0 0; border-radius: 7px; }
.chip .ptipo .ico { width: 12px; height: 12px; }
.segmentato.icone label span { display: flex; align-items: center; gap: 8px; }
.segmentato.icone label span .ico { width: 16px; height: 16px; color: var(--c); flex: none; }
.segmentato.icone input:checked + span { background: var(--c); color: var(--ct, #fff); box-shadow: 0 4px 14px rgba(0,0,0,0.28); }
.segmentato.icone input:checked + span .ico { color: var(--ct, #fff); }
.kanban-card > .ptipo { position: absolute; top: 11px; right: 11px; margin: 0; }

.kanban-card { position: relative; }
.kanban-card > .ptipo + .riga-link { padding-right: 34px; }


/* ============================================================
   Calendario: colori per categoria + menu a cassetto sotto i 1100px (2026-09-19)
   ============================================================ */
@media (max-width: 700px) {
  .cal-cell .cal-ev { background: var(--c, var(--accent)) !important; border-left: 0 !important; }
}

/* su finestre strette (portatili con la finestra ridotta) il menu laterale diventa un cassetto */
@media (max-width: 1100px) {
  .menu-btn { display: inline-flex; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(2,5,20,0.6); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.nav-aperta .nav-backdrop { opacity: 1; pointer-events: auto; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, 300px); margin: 0; z-index: 60;
    border-radius: 0 var(--radius) var(--radius) 0; overflow-y: auto;
    transform: translateX(-108%); transition: transform 0.26s var(--ease);
  }
  body.nav-aperta .sidebar { transform: none; }
  body.nav-aperta { overflow: hidden; }
  .main { margin-left: 0; padding: 8px 18px 60px; }
  .topbar-title { flex: 1; min-width: 0; }
}

/* filtri del calendario piu' compatti */
.cal-filtri { padding: 12px 14px !important; }
.cal-filtri .filtri { gap: 6px; }
.cal-filtri label.chip { padding: 5px 12px 5px 10px; font-size: 0.82rem; }


/* ============================================================
   Testate di pagina: titolo/filtri a sinistra, azione principale a destra
   ============================================================ */
.pagina-head { row-gap: 12px; column-gap: 16px; margin-bottom: 6px; }
.pagina-head > :last-child:not(:first-child) { margin-left: auto; }
.pagina-head > .btn, .pagina-head .azioni-testata > .btn:not(.btn-ghost) { min-height: 42px; padding: 9px 20px; font-size: 0.92rem; white-space: nowrap; }
.pagina-head .azioni-testata { margin-left: auto; }
.content > .pagina-head + .glass, .content > .pagina-head + .filtri { margin-top: 6px; }
@media (max-width: 700px) {
  .pagina-head > :last-child:not(:first-child) { margin-left: 0; }
  .pagina-head > .btn { width: 100%; }
  .pagina-head .azioni-testata { width: 100%; margin-left: 0; }
  .pagina-head .azioni-testata > .btn:not(.btn-ghost) { flex: 1; text-align: center; justify-content: center; }
}


/* ============================================================
   APP DA TELEFONO (2026-09-19 v10): barra in basso, foglio "Altro", Home "Oggi",
   calendario, chat a tutto schermo, board a chip, caricamento
   ============================================================ */
:root { --bar-bg: rgba(6, 12, 44, 0.86); --sheet-bg: #0c1646; --tabbar-h: 62px; }
html[data-tema="chiaro"] { --bar-bg: rgba(255, 255, 255, 0.9); --sheet-bg: #ffffff; }

/* elementi solo-telefono: invisibili altrove */
.tabbar, .sheet, .sheet-backdrop, .kanban-nav, .chat-back, .cal-giorno { display: none; }

/* barra di caricamento in alto + pulsanti che "girano" dopo l'invio */
.carica-barra { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 300; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, var(--accent), #9bd0ff); transform: scaleX(0); transform-origin: left; }
.carica-barra.vai { opacity: 1; animation: carica 8s cubic-bezier(0.1, 0.6, 0.2, 1) forwards; }
@keyframes carica { from { transform: scaleX(0.05); } to { transform: scaleX(0.92); } }
.btn.is-loading { opacity: 0.75; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira 0.7s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.content { animation: pagina-entra 0.22s var(--ease); }
@keyframes pagina-entra { from { opacity: 0; } to { opacity: 1; } }

/* Home: "Oggi" */
.oggi-card { display: flex; flex-direction: column; gap: 14px; }
.oggi-testa h2 { font-size: 1.4rem; }
.azioni-rapide { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-azione { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; min-height: 42px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: 0.88rem; font-weight: 600; transition: transform 0.15s var(--ease), border-color 0.15s; }
.chip-azione:hover { border-color: rgba(63, 162, 246, 0.5); transform: translateY(-1px); }
.chip-azione .ico { width: 17px; height: 17px; color: var(--accent); }
.oggi-sotto { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-top: 6px; }
.oggi-lista { display: flex; flex-direction: column; gap: 8px; }
.oggi-riga { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-soft); border-left: 4px solid var(--c, var(--accent)); }
.oggi-ora { flex: none; min-width: 56px; white-space: nowrap; font-size: 0.8rem; font-weight: 700; color: var(--text-soft); line-height: 1.2; font-variant-numeric: tabular-nums; }
.oggi-corpo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.oggi-corpo strong { font-size: 0.94rem; font-weight: 600; }

/* Calendario: linea "adesso", elenco del giorno */
.cal-adesso { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.cal-adesso::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cal-giorno-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cal-giorno-riga { display: block; padding: 11px 13px; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--c, var(--accent)); font-size: 0.92rem; line-height: 1.35; }

/* Chat: righe dei canali (sul computer restano compatte) */
.chat-canale-link .cc-ico { display: inline-flex; flex: none; }
.chat-canale-link .cc-ico .ico { width: 16px; height: 16px; }
.cc-testo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cc-testo strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-testo small, .cc-meta time { display: none; }
.cc-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.cc-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.chat-canale-link.ha-non-lette .cc-testo strong { color: var(--text); font-weight: 700; }

/* ------------------------------------------------------------ SOLO TELEFONO / TABLET STRETTO */
@media (max-width: 900px) {
  html { scroll-padding-top: 72px; }
  body { -webkit-tap-highlight-color: transparent; }
  a, button, label, summary, select, input, textarea { touch-action: manipulation; }
  body.app { display: block; }

  /* il menu laterale lascia il posto alla barra in basso */
  .sidebar, .nav-backdrop, .menu-btn, .topbar-user, .topbar .js-tema { display: none !important; }
  .main { margin-left: 0; padding: 0 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 96px); }

  /* barra del titolo: piatta, a tutta larghezza, sotto la barra di stato */
  .topbar.glass {
    position: sticky; top: 0; z-index: 40; margin: 0 -12px 14px; min-height: 0;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    border-radius: 0; border: 0; border-bottom: 1px solid var(--border-soft); box-shadow: none; background: var(--bar-bg);
  }
  .topbar-title { font-size: 1.15rem; font-weight: 700; }
  .icon-btn { width: 40px; height: 40px; }

  /* barra in basso */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--bar-bg); border-top: 1px solid var(--border);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  }
  .tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 50px; padding: 2px 0; color: var(--text-soft); background: none; border: 0; font: inherit; cursor: pointer;
  }
  .tab-ico { position: relative; display: flex; align-items: center; justify-content: center; padding: 4px 18px; border-radius: 999px; transition: background 0.2s var(--ease); }
  .tab .ico { width: 24px; height: 24px; }
  .tab-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; }
  .tab.is-active { color: var(--accent); }
  .tab.is-active .tab-ico { background: rgba(63, 162, 246, 0.2); }
  .tab:active .tab-ico { transform: scale(0.92); }
  .tab-badge { position: absolute; top: -1px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
    font-size: 0.66rem; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg); }

  /* foglio "Altro" */
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(2, 5, 20, 0.62); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  body.sheet-aperto .sheet-backdrop { opacity: 1; pointer-events: auto; }
  body.sheet-aperto { overflow: hidden; }
  .sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 8px 16px calc(22px + env(safe-area-inset-bottom)); background: var(--sheet-bg);
    border: 1px solid var(--border); border-bottom: 0; border-radius: 28px 28px 0 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
    transform: translateY(105%); transition: transform 0.32s var(--ease); visibility: hidden;
  }
  body.sheet-aperto .sheet { transform: none; visibility: visible; }
  .sheet-maniglia { width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 16px; }
  .sheet-utente { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
  .sheet-utente .avatar-lg { width: 46px; height: 46px; font-size: 1.05rem; }
  .sheet-utente strong { display: block; font-size: 1.05rem; }
  .sheet-utente small { color: var(--text-soft); font-size: 0.8rem; }
  .sheet-griglia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
  .sheet-tile { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 14px 6px 12px; border-radius: 20px; background: var(--surface);
    border: 1px solid var(--border-soft); font-size: 0.8rem; font-weight: 600; text-align: center; line-height: 1.2; }
  .sheet-tile:active { transform: scale(0.96); }
  .sheet-tile .tile-ico { width: 46px; height: 46px; border-radius: 15px; display: flex; align-items: center; justify-content: center; background: rgba(63, 162, 246, 0.16); color: var(--accent); }
  .sheet-tile .tile-ico .ico { width: 23px; height: 23px; }
  .sheet-tile.is-active { border-color: rgba(63, 162, 246, 0.6); background: rgba(63, 162, 246, 0.14); }
  .sheet-lista { display: flex; flex-direction: column; border-top: 1px solid var(--border-soft); padding-top: 6px; }
  .sheet-riga { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 6px; font: inherit; font-size: 1rem; color: var(--text); background: none; border: 0; text-align: left; cursor: pointer; border-radius: 12px; }
  .sheet-riga > span { flex: 1; }
  .sheet-riga .ico:first-child { width: 22px; height: 22px; color: var(--text-soft); }
  .sheet-riga .ico:last-child:not(:first-child) { width: 16px; height: 16px; color: var(--text-dim); }
  .sheet-riga:active { background: var(--surface-2); }
  .sheet-esci, .sheet-esci .ico:first-child { color: var(--danger); }

  /* le schermate "di lavoro" (moduli con l'invio in basso) e la chat aperta usano tutto lo schermo */
  body.app:has(.form-azioni-sticky) .tabbar { display: none; }
  body.app:has(.form-azioni-sticky) .main { padding-bottom: 28px; }

  /* pulsante flottante per "+ Nuovo ..." (l'azione principale della pagina) */
  .pagina-head a.btn[href*="form=new"]:not(.btn-ghost) {
    position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 45;
    width: auto; min-height: 54px; padding: 0 22px; border-radius: 27px; font-size: 0.98rem; white-space: nowrap;
    box-shadow: 0 12px 32px rgba(63, 162, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
  .pagina-head a.btn[href*="form=new"]:active { transform: scale(0.96); }
  .sel-bar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); z-index: 60; }
  body.sel-modalita .pagina-head a.btn[href*="form=new"] { display: none; }

  /* avvisi: come i banner di iPhone, in alto */
  .toasts { top: calc(8px + env(safe-area-inset-top)); bottom: auto; left: 10px; right: 10px; width: auto; flex-direction: column; }
  .toast { border-radius: 20px; }

  /* pulsanti e campi comodi da toccare */
  .btn { min-height: 46px; }
  .btn-small { min-height: 38px; }
  .chip { min-height: 36px; padding: 7px 14px; }
  .flash { border-radius: 14px; }
  .glass { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); }
  .card { padding: 16px; }
  .content { gap: 14px; }

  /* filtri e schede: una sola riga scorrevole, non tre righe che vanno a capo */
  .pagina-head > .filtri, .persone-filtro, .subtabs, .cal-filtri .filtri, .kanban-nav {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%;
  }
  .pagina-head > .filtri::-webkit-scrollbar, .persone-filtro::-webkit-scrollbar, .subtabs::-webkit-scrollbar, .cal-filtri .filtri::-webkit-scrollbar, .kanban-nav::-webkit-scrollbar { display: none; }
  .pagina-head > .filtri { flex: 1 1 100%; min-width: 0; }
  .chip, .subtab { flex: none; white-space: nowrap; }
  .solo-desktop, .pagina-head > .titolo-pagina { display: none !important; }
  .cal-filtri.glass { margin: 8px 0 !important; padding: 0 !important; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .cal-filtri label.chip { min-height: 34px; padding: 5px 12px 5px 10px; font-size: 0.8rem; }
  .persone-filtro > .muted { display: none; }
  .persone-filtro { margin: 0 0 8px !important; }

  /* Home */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi.card { padding: 14px; gap: 4px; }
  .kpi-label { font-size: 0.66rem; }
  .kpi-value { font-size: 1.2rem; }
  .kpi-hint { display: none; }
  .fondo-row { grid-template-columns: 1fr; gap: 8px; }
  .fondo-row > div { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .barchart { height: 140px; gap: 4px; }
  .bar-label { font-size: 0.58rem; }
  .oggi-testa h2 { font-size: 1.3rem; }
  .azioni-rapide { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chip-azione { flex: none; }

  /* Board: chip degli stati + colonne a pagina intera */
  .kanban-nav { display: flex; gap: 8px; padding: 2px 0 12px; }
  .kanban-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; min-height: 40px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-soft); font: inherit; font-size: 0.86rem; font-weight: 600; cursor: pointer; }
  .kanban-chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c, #94A3B8); }
  .kanban-chip.is-on { color: var(--text); border-color: var(--c, var(--accent)); background: rgba(255, 255, 255, 0.1); background: color-mix(in srgb, var(--c, #3FA2F6) 20%, transparent); }
  .kanban { grid-auto-columns: 92%; gap: 10px; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .kanban::-webkit-scrollbar { display: none; }
  .kanban-col h4 { display: none; }
  .kanban-col { padding: 10px; border-top-width: 3px; }
  .kanban-card { padding: 13px 14px; font-size: 0.95rem; border-radius: 14px; }
  .kanban-card .riga-link { font-size: 1rem; }

  /* Calendario */
  .cal-head { margin: 10px 0 10px; }
  .cal-head h3 { font-size: 1.12rem; }
  .cal-nav { gap: 6px; }
  .cal-nav .btn { min-height: 40px; min-width: 42px; padding: 0 13px; border-radius: 12px; }
  .cal-tg-wrap { padding: 10px 6px 14px; border-radius: 20px; }
  .cal-tg-head, .cal-tg-allday, .cal-tg-body { grid-template-columns: 40px repeat(var(--cal-cols), minmax(88px, 1fr)); }
  .cal-tg-ora { font-size: 0.62rem; padding-right: 5px; }
  .cal-tg-daynum { font-size: 1.15rem; }
  .cal-tg-event { font-size: 0.74rem; }
  .cal-grid { gap: 4px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-cell { min-height: 58px; padding: 6px 3px 4px; border-radius: 12px; cursor: pointer; flex-direction: row; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 4px; }
  .cal-cell .giorno { flex: 0 0 100%; text-align: center; font-size: 0.92rem; color: var(--text); }
  .cal-cell.oggi .giorno { color: var(--accent); font-weight: 800; }
  .cal-cell.sel { background: rgba(63, 162, 246, 0.16); border-color: var(--accent); }
  .cal-cell .cal-ev { font-size: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; border-left: 0; background: var(--c, var(--accent)) !important; display: inline-block; overflow: hidden; }
  .cal-tg-allday .cal-ev { font-size: 0.74rem; padding: 3px 8px; border-radius: 7px; }
  .cal-cell .cal-ev:nth-child(n+7) { display: none; }
  .cal-giorno { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
  .agenda li { flex-direction: column; gap: 3px; }
  .agenda .quando { min-width: 0; font-weight: 700; color: var(--text); }
  .cal-dow { font-size: 0.66rem; }

  /* Chat: prima l'elenco dei canali, poi la conversazione a tutto schermo */
  .chat-shell { display: block; height: auto; min-height: 0; }
  body.chat-lista .chat-main, body.chat-lista .chat-thread { display: none; }
  .chat-canali { width: auto; padding: 6px; flex-direction: column; overflow: visible; gap: 6px; }
  .chat-canali-head { display: none; }
  .chat-canali-lista { flex-direction: column; gap: 2px; overflow: visible; }
  .chat-canale-link { gap: 13px; padding: 11px 10px; border-radius: 16px; }
  .chat-canale-link .cc-ico { width: 48px; height: 48px; border-radius: 16px; background: rgba(63, 162, 246, 0.16); color: var(--accent); align-items: center; justify-content: center; }
  .chat-canale-link .cc-ico .ico { width: 22px; height: 22px; }
  .cc-testo { gap: 2px; }
  .cc-testo strong { font-size: 1.02rem; font-weight: 600; color: var(--text); }
  .cc-testo small { display: block; color: var(--text-soft); font-size: 0.84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cc-meta { flex-direction: column; align-items: flex-end; gap: 6px; }
  .cc-meta time { display: block; font-size: 0.7rem; color: var(--text-dim); white-space: nowrap; }
  .chat-canale-link.is-active { background: transparent; box-shadow: none; }
  .chat-nuovo-canale { margin: 4px 6px 6px; }

  body.chat-conv .tabbar, body.chat-conv .topbar, body.chat-conv .banner-push { display: none; }
  body.chat-conv .main { padding: 0; }
  body.chat-conv .chat-canali { display: none; }
  body.chat-conv .chat-shell {
    position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column;
    height: 100vh; height: var(--vvh, 100dvh); background: var(--bg);
  }
  body.chat-conv .chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; border-radius: 0; border: 0; box-shadow: none; background: transparent; }
  .chat-main-head { justify-content: flex-start; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px 8px; background: var(--bar-bg); border-bottom: 1px solid var(--border-soft); }
  .chat-main-head h3 { font-size: 1.05rem; }
  .chat-main-head .muted { display: none; }
  .chat-back { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 12px; color: var(--accent); }
  .chat-back .ico { width: 26px; height: 26px; }
  .chat-messaggi { flex: 1; min-height: 0; max-height: none; padding: 12px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .chat-msg-testo { font-size: 0.97rem; }
  .chat-composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--bar-bg); border-top: 1px solid var(--border-soft); align-items: flex-end; gap: 8px; }
  .chat-composer textarea { border-radius: 21px; padding: 10px 15px; min-height: 42px; max-height: 130px; font-size: 16px; line-height: 1.35; }
  .chat-allegato-btn { width: 42px; height: 42px; border-radius: 50%; flex: none; }
  .chat-composer .btn { width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%; flex: none; }
  .chat-composer .btn .ico { width: 19px; height: 19px; }
  .chat-thread { position: fixed; inset: 0; z-index: 120; width: auto; height: 100vh; height: var(--vvh, 100dvh); border-radius: 0; border: 0; background: var(--bg); }
  .chat-thread-head { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--bar-bg); }

  /* accesso */
  .auth-shell { padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); }
}

/* dispositivi con il dito: niente "sollevamenti" al passaggio, feedback al tocco */
@media (hover: none) {
  .btn:hover, .icon-btn:hover, .profilo-card:hover, .permesso-card:hover, .chip-azione:hover { transform: none; }
  .btn:active, .chip:active, .chip-azione:active, .oggi-riga:active, .cal-giorno-riga:active { transform: scale(0.97); opacity: 0.92; }
}


/* ---- Promemoria (form evento e preset) ---- */
.reminder-box { display: flex; flex-direction: column; gap: 12px; }
.reminder-extra { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reminder-extra input, .reminder-extra select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 12px; min-height: 42px; outline: none;
}
.reminder-extra input { width: 92px; }
.reminder-extra select { appearance: none; -webkit-appearance: none; padding-right: 28px; }
.reminder-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.reminder-info .link-btn { margin-left: 0; font-size: 0.84rem; }
.preset-lista { display: flex; flex-direction: column; margin-top: 8px; }
.preset-riga { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.preset-riga:last-child { border-bottom: 0; }
.preset-nome { display: flex; align-items: center; gap: 10px; }
.preset-nome .dot { width: 12px; height: 12px; }



/* ============================================================
   CALENDARIO v2: barra strumenti, mese piu' grande, griglia oraria leggibile, agenda per giorni
   ============================================================ */
:root { --tint: rgba(255, 255, 255, 0.03); --linea-mezza: rgba(255, 255, 255, 0.05); }
html[data-tema="chiaro"] { --tint: rgba(5, 10, 40, 0.035); --linea-mezza: rgba(5, 10, 40, 0.06); }

.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-toolbar-sx { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.cal-toolbar-dx { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cal-titolo { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .btn { min-height: 40px; padding: 0 15px; border-radius: 12px; }
.cal-viste { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; }
.cal-vista { padding: 8px 15px; border-radius: 10px; font-size: 0.86rem; font-weight: 600; color: var(--text-soft); white-space: nowrap; transition: background 0.15s, color 0.15s; }
.cal-vista:hover { color: var(--text); }
.cal-vista.is-on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgba(63, 162, 246, 0.3); }
.cal-vai { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-dim); }
.cal-vai input { font: inherit; font-size: 0.86rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 7px 10px; min-height: 40px; color-scheme: dark; outline: none; }
html[data-tema="chiaro"] .cal-vai input { color-scheme: light; }
.cal-filtri-barra { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-filtri .chip.is-on[style*="--c"] { border-color: var(--c); background: rgba(255, 255, 255, 0.08); background: color-mix(in srgb, var(--c) 16%, transparent); }
.cal-tasti { margin-top: 16px; font-size: 0.76rem; text-align: center; }
.cal-tasti kbd { font: inherit; font-size: 0.7rem; padding: 1px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }

/* Agenda: raggruppata per giorno */
.agenda-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.agenda-giorno { display: grid; grid-template-columns: 88px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border-soft); }
.agenda-giorno:first-of-type { border-top: 0; }
.agenda-data { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 16px; align-self: start; text-align: center; }
.agenda-data b { font-size: 1.8rem; line-height: 1; font-weight: 800; }
.agenda-data span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-soft); }
.agenda-data em { font-style: normal; font-size: 0.72rem; font-weight: 700; color: var(--accent); }
.agenda-giorno.oggi .agenda-data { background: rgba(63, 162, 246, 0.14); box-shadow: inset 0 0 0 1px rgba(63, 162, 246, 0.4); }
.agenda-voci { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.agenda-voce { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 15px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-soft); border-left: 4px solid var(--c, var(--accent)); }
.ag-ora { flex: none; width: 66px; display: flex; flex-direction: column; font-size: 0.92rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.ag-ora small { font-size: 0.72rem; font-weight: 500; color: var(--text-dim); }
.ag-corpo { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.ag-titolo { font-weight: 600; }
.ag-titolo:hover { color: var(--accent); }
.sel-attiva .agenda-voce { padding-left: 46px; }

/* Griglia oraria (giorno / 3 giorni / settimana) */
.cal-tg-daycol-head { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px 8px; border-radius: 12px; text-align: center; transition: background 0.15s; }
.cal-tg-daycol-head:hover { background: var(--surface-2); }
.cal-tg-daycol-head.oggi { background: transparent; }
.cal-tg-daycol-head.weekend .cal-tg-dow { color: var(--text-dim); }
.cal-tg-daynum { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 1.3rem; font-weight: 800; line-height: 1; }
.cal-tg-daycol-head.oggi .cal-tg-daynum { background: var(--accent); color: var(--accent-ink); }
.cal-tg-count { font-size: 0.66rem; color: var(--text-dim); }
.cal-tg-slots.weekend { background: var(--tint); }
.cal-tg-daycol.cal-tg-slots.oggi { background: rgba(63, 162, 246, 0.07); }
.cal-tg-slot { position: relative; border-bottom: 1px dashed var(--linea-mezza); }
.cal-tg-slot.ora-piena { border-bottom: 1px solid var(--border-soft); }
.cal-tg-slot:hover { background: rgba(63, 162, 246, 0.11); }
.cal-tg-slot:hover::after { content: attr(data-ora); position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 0.68rem; font-weight: 700; color: var(--accent); pointer-events: none; }
.cal-tg-body { padding-top: 10px; }
.cal-tg-ora { font-size: 0.7rem; }
.cal-tg-event {
  display: flex; flex-direction: column; gap: 1px; padding: 4px 8px; border-radius: 9px; border-left: 4px solid var(--c, var(--accent));
  font-size: 0.78rem; line-height: 1.25; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: box-shadow 0.15s, transform 0.15s var(--ease);
}
.cal-tg-event:hover { z-index: 20 !important; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); transform: translateY(-1px); }
.cal-tg-event .ev-ora { font-size: 0.68rem; font-weight: 700; opacity: 0.85; white-space: nowrap; }
.cal-tg-event strong { font-size: 0.84rem; font-weight: 600; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-tg-event > * { flex: none; max-width: 100%; }
.cal-tg-event.bassa .cal-tg-autore { display: none; }
.cal-tg-event.corta { flex-direction: row; align-items: center; padding-top: 1px; padding-bottom: 1px; }
.cal-tg-event.corta strong { display: block; white-space: nowrap; text-overflow: ellipsis; font-size: 0.78rem; }
.cal-tg-allday .cal-ev { display: block; font-size: 0.76rem; padding: 3px 8px; border-radius: 7px; border-left-width: 3px; }

/* Mese: piu' grande e leggibile (solo computer) */
.cal-cell-nuovo { display: none; }
.cal-ev-extra, .cal-piu { display: none; }
@media (min-width: 901px) {
  .cal-tg-wrap { padding: 0 0 14px; overflow: visible; }
  .cal-tg-top { position: sticky; top: 92px; z-index: 12; padding: 12px 16px 0; background: var(--sheet-bg);
    border-bottom: 1px solid var(--border-soft); border-radius: var(--radius) var(--radius) 0 0; }
  .cal-tg-top .cal-tg-allday { border-bottom: 0; margin-bottom: 0; padding-bottom: 8px; }
  .cal-tg-body { padding: 10px 16px 4px; }

  .cal-filtri.glass { margin: 0 !important; padding: 8px 12px; border-radius: 16px; box-shadow: none; }
  .cal-filtri-barra .persone-filtro { margin: 0 !important; }

  .cal-grid { gap: 8px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .cal-dow { padding: 6px 0 2px; font-weight: 700; }
  .cal-cell { position: relative; min-height: 150px; padding: 8px; gap: 4px; border-radius: 14px; transition: border-color 0.15s, background 0.15s; }
  .cal-cell:hover { border-color: rgba(63, 162, 246, 0.45); background: var(--surface-2); }
  .cal-cell.weekend { background: var(--tint); }
  .cal-cell.fuori { opacity: 0.42; }
  .cal-cell.oggi { border-color: var(--accent); background: rgba(63, 162, 246, 0.08); box-shadow: inset 0 0 0 1px rgba(63, 162, 246, 0.5); }
  .cal-cell-nuovo { display: block; position: absolute; inset: 0; z-index: 0; border-radius: inherit; }
  .cal-cell .giorno, .cal-cell .cal-ev, .cal-cell .cal-piu { position: relative; z-index: 1; }
  .cal-cell .giorno { align-self: flex-start; min-width: 28px; height: 28px; padding: 0 7px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 0.9rem; font-weight: 700; color: var(--text); }
  .cal-cell .giorno:hover { background: var(--surface-2); }
  .cal-cell.oggi .giorno { background: var(--accent); color: var(--accent-ink); }
  .cal-cell .cal-ev { display: block; font-size: 0.78rem; padding: 3px 8px; border-radius: 8px; border-left-width: 3px; line-height: 1.35; transition: filter 0.15s; }
  .cal-cell .cal-ev:hover { filter: brightness(1.2); }
  .cal-cell .cal-ev.cal-ev-extra { display: none; }
  .cal-cell .cal-ev .ev-ora { font-weight: 700; opacity: 0.85; }
  .cal-piu { display: inline-block; align-self: flex-start; font-size: 0.76rem; font-weight: 700; color: var(--accent); padding: 1px 8px; border-radius: 8px; }
  .cal-piu:hover { background: rgba(63, 162, 246, 0.14); }
}

@media (max-width: 900px) {
  .cal-tasti, .cal-vai { display: none; }
  .cal-toolbar { flex-direction: column; align-items: stretch; gap: 10px; margin: 8px 0 8px; }
  .cal-toolbar-sx { flex-wrap: nowrap; justify-content: space-between; gap: 10px; }
  .cal-titolo { order: 1; flex: 1; min-width: 0; font-size: 1.2rem; }
  .cal-nav { order: 2; }
  .cal-toolbar-dx { flex-wrap: nowrap; gap: 0; }
  .cal-viste { display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .cal-vista { flex: 1; text-align: center; padding: 9px 8px; }
  .cal-toolbar a.btn[href*="form=new"]:not(.btn-ghost) {
    position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 45;
    width: auto; min-height: 54px; padding: 0 22px; border-radius: 27px; font-size: 0.98rem; white-space: nowrap;
    box-shadow: 0 12px 32px rgba(63, 162, 246, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  }
  .cal-filtri-barra { flex-direction: column; align-items: stretch; gap: 0; margin-bottom: 8px; }
  .cal-ev-extra { display: inline-block; }
  .cal-piu { display: none; }
  .cal-tg-top { padding: 0; }
  .cal-tg-body { padding: 8px 0 0; }
  .cal-tg-daynum { width: 34px; height: 34px; font-size: 1.1rem; }
  .cal-tg-count { display: none; }
  .agenda-card { padding: 14px; }
  .agenda-giorno { grid-template-columns: 58px 1fr; gap: 10px; }
  .agenda-data b { font-size: 1.4rem; }
  .agenda-voce { padding: 10px 12px; gap: 10px; }
  .ag-ora { width: 52px; font-size: 0.85rem; }
}


/* ============================================================
   Persone assegnate + tag cliente in evidenza + ripetizione su giorni scelti
   ============================================================ */
.avatar-xs { width: 21px; height: 21px; font-size: 0.6rem; }
.avatar-pila .avatar-xs + .avatar-xs { margin-left: -6px; }
.cal-persone { display: inline-flex; align-items: center; gap: 7px; flex: none; }
.cal-persone small { font-size: 0.76rem; }

/* tag cliente: colore del cliente, logo e nome, sempre leggibile */
.cli-tag { margin-top: 0; padding: 2px 9px 2px 5px; border: 1px solid; font-size: 0.72rem; font-weight: 700; line-height: 1.4; gap: 6px; max-width: 100%; }
.cli-tag .cli-nome { overflow: hidden; text-overflow: ellipsis; }
.cli-tag .dot { width: 8px; height: 8px; margin-left: 2px; }
.cli-logo { width: 16px; height: 16px; }
.cli-tag-mini { margin: 0; padding: 1px 8px 1px 5px; font-size: 0.68rem; }

/* pillola evento (mese / tutto il giorno / elenco del giorno): riga titolo + persone, poi il cliente */
.cal-ev { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; white-space: normal; }
.cal-ev .ev-riga { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
.cal-ev .ev-titolo { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev .ev-ora { flex: none; font-weight: 700; opacity: 0.85; }
.cal-ev .cli-tag { max-width: 100%; }
.cal-ev .ev-piede { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
.cal-ev .ev-piede .cli-tag { flex: 0 1 auto; min-width: 0; margin: 0; }
.cal-ev .ev-piede .cal-persone { margin-left: auto; }

/* blocchi della griglia oraria */
.cal-tg-event .ev-riga { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; }
.cal-tg-event .ev-riga strong { flex: 1; min-width: 0; }
.cal-tg-event .ev-piede { display: flex; align-items: center; gap: 6px; margin-top: 2px; min-width: 0; }
.cal-tg-event .ev-piede .cli-tag { flex: 0 1 auto; min-width: 0; margin: 0; }
.cal-tg-event .ev-piede .cal-persone { margin-left: auto; }
.cal-tg-event.bassa strong { -webkit-line-clamp: 1; }
.cal-tg-event.corta .cli-tag { max-width: 40%; flex: 0 1 auto; }

/* agenda e "Oggi" */
.ag-corpo .cal-persone { margin-left: auto; }
.oggi-corpo .ev-piede { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.cal-giorno-riga .cal-ev { display: block; }

@media (min-width: 901px) {
  .cal-cell .cal-ev { display: flex; flex-direction: column; gap: 3px; white-space: normal; padding: 4px 8px 5px; }
  .cal-tg-allday .cal-ev { display: flex; }
}

/* ripetizione: giorni scelti */
.ricorrenza-blocco { display: flex; flex-direction: column; gap: 12px; padding: 14px; margin: 4px 0 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-soft); }
.ricorrenza-titolo { font-size: 0.8rem; font-weight: 600; color: var(--text-soft); }
.giorni-mese { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 440px; }
.giorni-mese label { position: relative; cursor: pointer; }
.giorni-mese input { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.giorni-mese span { display: flex; align-items: center; justify-content: center; height: 42px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 0.92rem; font-weight: 600; color: var(--text-soft); transition: background 0.14s, color 0.14s, border-color 0.14s; }
.giorni-mese label:hover span { color: var(--text); border-color: rgba(63, 162, 246, 0.5); }
.giorni-mese input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgba(63, 162, 246, 0.3); }
.giorni-mese input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-ricorrenza-box] { display: flex; flex-direction: column; gap: 12px; }
.cal-giorno-riga .ev-riga { display: flex; align-items: center; gap: 6px; }
.cal-giorno-riga .ev-titolo { flex: 1; min-width: 0; font-weight: 600; }
.cal-giorno-riga .ev-piede { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cal-giorno-riga .ev-piede .cal-persone { margin-left: auto; }


/* ============================================================
   Eventi del calendario: blocchi piu' leggibili + scheda al passaggio del mouse
   ============================================================ */
/* i blocchi orari prendono il colore dal tipo (variabile --c): sfumatura leggera, barra a sinistra piu' marcata */
.cal-tg-event {
  background: rgba(255, 255, 255, 0.08);
  background: linear-gradient(100deg, color-mix(in srgb, var(--c) 34%, transparent), color-mix(in srgb, var(--c) 18%, transparent));
  border-left-width: 5px; border-radius: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent);
}
html[data-tema="chiaro"] .cal-tg-event { background: linear-gradient(100deg, color-mix(in srgb, var(--c) 30%, white), color-mix(in srgb, var(--c) 16%, white)); }
.cal-tg-event .ev-ora { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.01em; opacity: 0.95; }
.cal-tg-event strong { font-size: 0.86rem; }

/* eventi corti (30 minuti o meno): una riga chiara e leggibile, il resto nella scheda */
.cal-tg-event.corta { container-type: inline-size; padding: 0 8px; align-items: center; justify-content: center; }
.cal-tg-event.corta .ev-riga { flex-wrap: nowrap; }
.cal-tg-event.corta strong { font-size: 0.82rem; font-weight: 700; }
.cal-tg-event.corta .ev-ora { font-weight: 600; opacity: 0.85; margin-right: 3px; }
.cal-tg-event.corta .cli-tag { display: none; }
.cal-tg-event.corta .avatar-xs { width: 18px; height: 18px; font-size: 0.55rem; }
.cli-punto { flex: none; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2); }
@container (max-width: 150px) {
  .cal-tg-event.corta .ev-ora { display: none; }
  .cal-tg-event.corta .avatar-pila .avatar:nth-child(n+2) { display: none; }
}
@container (min-width: 200px) {
  .cal-tg-event.corta .cli-tag { display: inline-flex; }
  .cal-tg-event.corta .cli-punto { display: none; }
}

/* scheda al passaggio del mouse */
.cal-pop {
  position: fixed; z-index: 400; width: 300px; padding: 14px 16px 16px; border-radius: 18px; pointer-events: none;
  background: var(--sheet-bg); border: 1px solid var(--border); border-top: 4px solid var(--c, var(--accent));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), 0 2px 10px rgba(0, 0, 0, 0.3);
  display: flex; flex-direction: column; gap: 10px;
  opacity: 0; transform: scale(0.96) translateY(4px); transform-origin: left top; transition: opacity 0.14s, transform 0.16s var(--ease);
}
.cal-pop.on { opacity: 1; transform: none; }
.cal-pop .pop-tipo { display: inline-flex; align-items: center; gap: 7px; align-self: flex-start; padding: 2px 10px 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; color: var(--text-soft); }
.cal-pop .pop-tipo i { width: 8px; height: 8px; border-radius: 50%; }
.cal-pop .pop-titolo { font-size: 1.05rem; line-height: 1.25; font-weight: 700; }
.cal-pop .pop-riga { display: flex; align-items: flex-start; gap: 11px; }
.cal-pop .pop-riga > .ico { width: 18px; height: 18px; margin-top: 2px; color: var(--text-dim); flex: none; }
.cal-pop .pop-riga > span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-pop .pop-riga b { font-size: 0.98rem; font-weight: 700; }
.cal-pop .pop-riga small { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.cal-pop .cli-tag { align-self: flex-start; font-size: 0.82rem; padding: 3px 12px 3px 7px; }
.cal-pop .cli-logo { width: 20px; height: 20px; }
.cal-pop .pop-persone { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.cal-pop .pop-persona { display: flex; flex-direction: row; align-items: center; gap: 9px; font-size: 0.92rem; font-weight: 600; }
.cal-pop .pop-persona .avatar { width: 26px; height: 26px; box-shadow: none; }
@media (hover: none), (max-width: 900px) { .cal-pop { display: none; } }


/* ============================================================
   Processi interni
   ============================================================ */
.processi-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.processo-card { display: flex; flex-direction: column; gap: 12px; transition: transform 0.18s var(--ease), border-color 0.18s; }
.processo-card:hover { transform: translateY(-2px); border-color: rgba(63, 162, 246, 0.45); }
.processo-card.spento { opacity: 0.6; }
.processo-card-testa { display: flex; align-items: center; gap: 12px; }
.processo-card-testa strong { font-size: 1.05rem; }
.processo-card-testa .ptipo { width: 34px; height: 34px; border-radius: 12px; margin: 0; }
.processo-card-testa .ptipo .ico { width: 18px; height: 18px; }
.processo-card-fasi { display: flex; flex-wrap: wrap; gap: 6px; }
.fase-mini { padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.72rem; color: var(--text-soft); }
.processo-testata { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.processo-titolo { display: flex; align-items: flex-start; gap: 14px; }
.processo-titolo .ptipo { width: 40px; height: 40px; border-radius: 14px; margin: 2px 0 0; }
.processo-titolo .ptipo .ico { width: 21px; height: 21px; }
.processo-titolo h2 { font-size: 1.35rem; }
.processo { display: flex; flex-direction: column; gap: 22px; }
.processo-fase { display: flex; flex-direction: column; gap: 10px; }
.fase-titolo { display: flex; align-items: center; gap: 12px; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-soft); }
.fase-num { width: 26px; height: 26px; border-radius: 50%; background: rgba(63, 162, 246, 0.2); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; letter-spacing: 0; }
.passo { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border-radius: 18px; }
.passo-num { flex: none; width: 30px; height: 30px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.86rem; color: var(--text-soft); }
.passo-corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.passo-titolo { font-size: 1rem; }
.passo-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 0.82rem; }
.chip-giorni { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.chip-giorni .ico { width: 15px; height: 15px; }
.passo-chi { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); }
.passo-chi .avatar { width: 22px; height: 22px; font-size: 0.6rem; box-shadow: none; }
.passo-link { color: var(--accent); }
.passo-come summary { cursor: pointer; color: var(--accent); font-size: 0.84rem; font-weight: 600; }
.passo-istr { margin-top: 8px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-soft); font-size: 0.92rem; line-height: 1.55; color: var(--text-soft); }
.passo-azioni { display: flex; gap: 6px; flex: none; }
.passo-azioni form { display: inline-flex; }
.passo-azioni .icon-btn { width: 34px; height: 34px; font-size: 1rem; }
.fase-tag { display: inline-block; margin-left: 8px; padding: 1px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); font-size: 0.68rem; font-weight: 600; vertical-align: middle; }
.processo-anteprima { margin-top: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border-soft); }
.processo-anteprima ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.processo-anteprima li small { display: block; color: var(--text-dim); font-size: 0.74rem; }
.processo-applica { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border-soft); }
.processo-applica select { font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; min-height: 40px; max-width: 100%; }
@media (max-width: 900px) {
  .passo { padding: 12px; gap: 10px; }
  .passo-azioni { flex-direction: column; }
}


/* ============================================================
   Filtri sotto un'icona, con selezione multipla
   ============================================================ */
.barra-filtri, .cal-filtri-barra { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 14px; }
.filtri-menu { position: relative; display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filtri-btn { gap: 8px; min-height: 42px; padding: 0 16px; }
.filtri-btn .ico { width: 18px; height: 18px; }
.filtri-conta { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; display: inline-flex; align-items: center; justify-content: center; }
.filtri-riepilogo { font-size: 0.82rem; color: var(--text-soft); }
.filtri-pannello {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 70; width: min(460px, 92vw); max-height: 72vh; overflow-y: auto;
  padding: 16px 18px; border-radius: 20px; background: var(--sheet-bg); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.filtri-fondo { position: fixed; inset: 0; z-index: 65; background: transparent; }
.filtri-testa { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.filtri-gruppo { border: 0; margin: 0; padding: 12px 0 8px; border-top: 1px solid var(--border-soft); min-width: 0; }
.filtri-testa + .filtri-gruppo { border-top: 0; }
.filtri-gruppo legend { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; margin-bottom: 10px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; color: var(--text-dim); }
.filtri-rapidi button { background: none; border: 0; padding: 0; margin-left: 12px; font: inherit; font-size: 0.78rem; text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--accent); cursor: pointer; }
.filtri-voci { display: flex; flex-wrap: wrap; gap: 8px; }
.filtri-voci .chip { gap: 8px; }
.filtri-azioni { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
@media (max-width: 900px) {
  .filtri-fondo { background: rgba(2, 5, 20, 0.6); z-index: 95; }
  .filtri-pannello { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 100; width: auto; max-height: 86vh; max-height: 86dvh;
    border-radius: 26px 26px 0 0; border-bottom: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45); }
  .barra-filtri, .cal-filtri-barra { margin: 8px 0 10px; }
  .filtri-azioni .btn { flex: 1; }
}



/* ---- Modifica rapida di stato/priorità/scadenza dentro la tabella del progetto ---- */
.riga-rapida { display: inline-block; }
.riga-rapida .select-stato { min-height: 34px; padding: 5px 26px 5px 10px; font-size: 0.78rem; }
.input-rapido {
  font: inherit; font-size: 0.82rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 8px; min-height: 34px; outline: none; color-scheme: dark; max-width: 132px;
}
html[data-tema="chiaro"] .input-rapido { color-scheme: light; }
.input-rapido:focus { border-color: var(--accent); }
@media (max-width: 700px) {
  .riga-rapida { display: block; }
  .input-rapido { max-width: none; width: 100%; }
}


/* ============================================================
   Ricerca globale (Ctrl/Cmd+K)
   ============================================================ */
.ricerca-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(2, 5, 20, 0.6); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.ricerca-box { width: min(600px, 100%); max-height: 74vh; display: flex; flex-direction: column; background: var(--sheet-bg); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,0.5); overflow: hidden; }
.ricerca-campo { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.ricerca-campo .ico { width: 20px; height: 20px; color: var(--text-dim); flex: none; }
.ricerca-campo input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font: inherit; font-size: 1rem; color: var(--text); }
.ricerca-chiudi { flex: none; width: 30px; height: 30px; border-radius: 9px; border: 0; background: var(--surface-2); color: var(--text-soft); cursor: pointer; }
.ricerca-risultati { overflow-y: auto; padding: 8px; }
.ricerca-vuoto { padding: 20px 14px; text-align: center; }
.ricerca-gruppo { margin-bottom: 6px; }
.ricerca-gruppo-nome { display: block; padding: 8px 10px 4px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim); font-weight: 700; }
.ricerca-voce { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; }
.ricerca-voce:hover, .ricerca-voce.is-attiva { background: var(--surface-2); }
.ricerca-voce-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); color: var(--c, var(--accent)); }
.ricerca-voce-ico .ico { width: 17px; height: 17px; }
.ricerca-voce-testo { min-width: 0; display: flex; flex-direction: column; }
.ricerca-voce-testo strong { font-size: 0.92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ricerca-voce-testo small { color: var(--text-soft); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) {
  .ricerca-overlay { padding: 0; align-items: flex-end; }
  .ricerca-box { width: 100%; max-height: 88vh; max-height: 88dvh; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .ricerca-campo { padding: calc(12px + env(safe-area-inset-top)) 14px 12px; }
  .ricerca-campo input { font-size: 16px; }
}


/* ============================================================
   Rinnovi dei clienti
   ============================================================ */
.warn-txt { color: var(--warn); }
.rinnovi-blocco { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.rinnovi-titolo-blocco { font-size: 0.95rem; }
.rinnovo-riga { display: flex; align-items: center; gap: 14px; padding: 13px 15px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-soft); border-left: 4px solid var(--c, var(--accent)); }
.rinnovo-riga.urgente { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.35); }
.rinnovo-riga.scaduto { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.4); }
.rinnovo-tipo-ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--c); }
.rinnovo-corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rinnovo-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 0.84rem; }
.rinnovo-dx { display: flex; align-items: center; gap: 14px; flex: none; }
.rinnovo-urgenza { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.9rem; font-weight: 700; white-space: nowrap; }
.rinnovo-urgenza small { font-weight: 500; font-size: 0.74rem; color: var(--text-dim); }
.rinnovo-azioni { display: flex; align-items: center; gap: 6px; }
@media (max-width: 700px) {
  .rinnovo-riga { flex-wrap: wrap; }
  .rinnovo-dx { width: 100%; justify-content: space-between; padding-top: 8px; border-top: 1px dashed var(--border-soft); }
  .rinnovo-urgenza { align-items: flex-start; }
}


/* ============================================================
   Preventivi: editor delle voci, riepilogo, elenco
   ============================================================ */
.prev-listino-rapido { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.prev-select-listino { flex: 1; min-width: 220px; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-height: 44px; }
.prev-tabella-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border-soft); }
.prev-tabella { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.prev-tabella th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); padding: 10px 10px; background: var(--surface); }
.prev-tabella td { padding: 8px 10px; border-top: 1px solid var(--border-soft); vertical-align: top; }
.prev-tabella th:nth-child(2), .prev-tabella td:nth-child(2) { width: 64px; }
.prev-tabella th:nth-child(3), .prev-tabella td:nth-child(3) { width: 110px; }
.prev-tabella th:nth-child(4), .prev-tabella td:nth-child(4) { width: 110px; }
.prev-tabella th:nth-child(5), .prev-tabella td:nth-child(5) { width: 100px; }
.prev-tabella th:last-child, .prev-tabella td:last-child { width: 36px; }
.prev-input { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; min-height: 38px; outline: none; }
.prev-input:focus { border-color: var(--accent); }
.prev-descr { resize: vertical; min-height: 38px; line-height: 1.35; }
.prev-num { text-align: right; }
.prev-riga-totale { text-align: right; font-weight: 700; white-space: nowrap; padding-top: 14px !important; }
.prev-rimuovi { width: 32px; height: 32px; margin-top: 3px; color: var(--text-dim); }
.prev-rimuovi:hover { color: var(--danger); }
.prev-piede { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-soft); }
.prev-sconto { flex-direction: row !important; align-items: center; gap: 8px; }
.prev-input-sconto { width: 72px; min-height: 38px; text-align: right; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; }
.prev-totali { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 0.88rem; color: var(--text-soft); text-align: right; }
.prev-totali b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 8px; }
.prev-tot-finale { font-size: 1.1rem; color: var(--text); margin-top: 2px; }
.prev-tot-finale b { color: var(--accent); font-size: 1.2rem; }
.prev-riepilogo-dett { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 20px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); font-size: 0.92rem; color: var(--text-soft); }
.prev-riepilogo-dett b { color: var(--text); margin-left: 6px; }
.prev-riepilogo-tot { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.prev-riepilogo-tot b { color: var(--accent); }
.listino-spento { opacity: 0.55; }

/* ---- Assistente AI: layout chat + bozza affiancate ---- */
.prev-ai-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.prev-chat { display: flex; flex-direction: column; height: calc(100vh - 160px); min-height: 460px; position: sticky; top: 12px; }
.prev-chat-testa { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.prev-chat-testa h3 { font-size: 1rem; }
.prev-chat .chat-messaggi { flex: 1; }
.prev-chat-attesa { display: flex; align-items: center; gap: 8px; padding: 6px 18px; font-size: 0.82rem; color: var(--text-soft); }
.prev-puntini { display: inline-flex; gap: 3px; }
.prev-puntini i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-dim); animation: prev-puntino 1.1s infinite ease-in-out; }
.prev-puntini i:nth-child(2) { animation-delay: 0.15s; } .prev-puntini i:nth-child(3) { animation-delay: 0.3s; }
@keyframes prev-puntino { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.prev-bozza { padding: 18px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 1100px) {
  .prev-ai-shell { grid-template-columns: 1fr; }
  .prev-chat { height: 60vh; min-height: 380px; position: static; }
  .prev-bozza { position: static; max-height: none; }
}
@media (max-width: 700px) {
  .prev-tabella th, .prev-tabella td { padding: 7px 6px; }
  .prev-piede { flex-direction: column; align-items: stretch; }
  .prev-totali { align-items: flex-start; text-align: left; }
}


/* ============================================================
   v2026.09.23 — Modifica rapida, card cliente, pannello Profili, menu scorrevole
   ============================================================ */
[hidden] { display: none !important; }

/* ---- Menu laterale (desktop): scorre se gli elementi non stanno nell'altezza dello schermo ---- */
.sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 6px; }
html[data-tema="chiaro"] .sidebar { scrollbar-color: rgba(10,20,60,0.25) transparent; }
html[data-tema="chiaro"] .sidebar::-webkit-scrollbar-thumb { background: rgba(10,20,60,0.25); }
.sidebar .brand { flex: none; }
.sidebar .nav, .sidebar .nav-secondaria { flex: none; }
@media (max-height: 820px) and (min-width: 1101px) {
  .sidebar { gap: 14px; padding: 16px 12px; }
  .nav-link { padding: 8px 12px; }
}

/* ---- Icona tonda del cliente (logo oppure iniziale) ---- */
.cli-avatar {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: rgba(63, 162, 246, 0.2); background: color-mix(in srgb, var(--c, #3FA2F6) 22%, transparent);
  color: var(--c, #3FA2F6); font-size: 1.05rem; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 2px rgba(63, 162, 246, 0.4); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, #3FA2F6) 45%, transparent);
}
.cli-avatar b { font-weight: 800; display: inline-flex; }
.cli-avatar b .ico { width: 55%; height: 55%; }
.cli-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #fff; }
.cli-avatar-sm { width: 28px; height: 28px; font-size: 0.8rem; box-shadow: none; }
.cli-avatar-lg { width: 60px; height: 60px; font-size: 1.4rem; }
.cli-avatar-xl { width: 76px; height: 76px; font-size: 1.8rem; }
.riga-cliente { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }
.pagina-head h2 .cli-avatar { vertical-align: middle; margin-right: 6px; }
.cli-testata { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cli-testata div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cli-testata strong { font-size: 1.05rem; }
.flash-errore { border-color: rgba(248, 113, 113, 0.5); color: var(--danger); }

/* ---- Card dei clienti ---- */
.cli-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.cli-card {
  position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left;
  color: inherit; font: inherit; cursor: pointer; border-radius: var(--radius);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
button.cli-card { appearance: none; -webkit-appearance: none; width: 100%; }
.cli-card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(63, 162, 246, 0.5); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28), 0 0 0 1px color-mix(in srgb, var(--c) 55%, transparent); }
.cli-card-banda { display: block; height: 66px; background: linear-gradient(135deg, rgba(63, 162, 246, 0.5), rgba(63, 162, 246, 0.1)); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 55%, transparent), color-mix(in srgb, var(--c) 10%, transparent)); }
.cli-card-corpo { position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; margin-top: -40px; padding: 0 18px 18px; text-align: center; }
.cli-card-corpo .cli-avatar { box-shadow: 0 0 0 4px var(--bg); }
.cli-card-nome { font-size: 1.05rem; font-weight: 700; line-height: 1.25; margin-top: 4px; }
.cli-card-sotto { font-size: 0.82rem; min-height: 1.2em; overflow-wrap: anywhere; }
.cli-card-stato { margin: 2px 0; }
.cli-card-num { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 0.8rem; color: var(--text-soft); margin: 4px 0 2px; padding: 0; }
.cli-card-num b { color: var(--text); }
.cli-card-servizi { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.cli-card-piede { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border-soft); width: 100%; font-size: 0.78rem; }
.cli-card-link { position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.cli-card .rapido, .cli-card-piede { position: relative; z-index: 2; }
.sel-attiva .cli-card { padding-left: 0; }
.sel-attiva .cli-card.sel-scelto { box-shadow: 0 0 0 3px var(--accent); }
.sel-attiva .cli-card .sel-check { top: 10px; left: 10px; background: var(--bg); border-radius: 9px; padding: 3px; }

/* ---- Pannello dei profili di un cliente ---- */
.profili-pannello { position: fixed; inset: 0; z-index: 180; display: flex; justify-content: flex-end; }
.profili-pannello-velo { position: absolute; inset: 0; background: rgba(2, 5, 20, 0.55); backdrop-filter: blur(2px); }
.profili-pannello-corpo {
  position: relative; width: min(580px, 100%); height: 100%; display: flex; flex-direction: column;
  background: #0c1646; border-left: 1px solid var(--border); box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
  animation: pannello-entra 0.24s var(--ease);
}
html[data-tema="chiaro"] .profili-pannello-corpo { background: #f4f7fd; }
@keyframes pannello-entra { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.profili-pannello-testa { display: flex; align-items: center; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.profili-pannello-titolo { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.profili-pannello-titolo strong { font-size: 1.15rem; }
.profili-pannello-lista.profili-cards { display: flex; flex-direction: column; gap: 14px; flex: 1; overflow-y: auto; padding: 18px 22px; }
.profili-pannello-piede { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-soft); }
body.profili-aperto { overflow: hidden; }
.profilo-evidenzia { animation: profilo-lampo 2.2s ease-out; }
@keyframes profilo-lampo { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 700px) {
  .profili-pannello-corpo { width: 100%; border-left: 0; }
  .profili-pannello-testa, .profili-pannello-piede { padding-left: 16px; padding-right: 16px; }
  .profili-pannello-lista.profili-cards { padding: 14px 16px; }
}

/* ---- Modifica rapida: pulsanti nelle liste ---- */
.rapido {
  appearance: none; -webkit-appearance: none; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-pill);
  transition: opacity 0.14s, box-shadow 0.14s, background 0.14s, filter 0.14s;
}
.rapido:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rapido-attesa { opacity: 0.5; pointer-events: none; }
.rapido-aperto { box-shadow: 0 0 0 3px rgba(63, 162, 246, 0.45); }
.rapido-pill:hover { filter: brightness(1.18); }
.rapido-freccia { width: 6px; height: 6px; margin: -3px 2px 0 -4px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: rotate(45deg); opacity: 0.35; transition: opacity 0.14s; flex: none; }
.rapido-pill:hover .rapido-freccia, .rapido-aperto .rapido-freccia { opacity: 0.9; }
.rapido-pill .pill { margin-right: 0; }
.rapido-data { padding: 4px 9px; border-radius: 9px; border: 1px dashed transparent; white-space: nowrap; }
.rapido-data:hover { border-color: var(--border); background: var(--surface); }
.rapido-vuoto { color: var(--text-dim); font-size: 0.82rem; }
.rapido-persone { padding: 2px; }
.rapido-persone:hover { background: var(--surface-2); }
.avatar-vuoto { background: transparent; border: 1.5px dashed var(--text-dim); color: var(--text-dim); box-shadow: none; font-size: 0.9rem; }
.kanban-card .meta .rapido-data { padding: 2px 7px; font-size: 0.78rem; }
.dett-lista .rapido { justify-content: flex-end; }

/* ---- Modifica rapida: il menu che si apre ---- */
.rapido-velo { position: fixed; inset: 0; z-index: 240; }
.rapido-pop {
  position: fixed; z-index: 250; min-width: 220px; max-width: min(330px, calc(100vw - 16px)); max-height: min(72vh, 440px); overflow-y: auto;
  padding: 8px; border-radius: 16px; background: rgba(12, 22, 70, 0.98); border: 1px solid var(--border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45); animation: rapido-in 0.13s ease-out;
}
html[data-tema="chiaro"] .rapido-pop { background: #fff; box-shadow: 0 18px 48px rgba(10, 20, 60, 0.22); }
@keyframes rapido-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
.rapido-titolo { padding: 6px 10px 8px; font-size: 0.7rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; }
.rapido-lista { display: flex; flex-direction: column; gap: 2px; }
.rapido-voce { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 11px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 0.9rem; text-align: left; cursor: pointer; }
.rapido-voce:hover, .rapido-voce:focus-visible { background: var(--surface-2); outline: none; }
.rapido-voce .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.rapido-voce-testo { flex: 1; }
.rapido-spunta { opacity: 0; color: var(--accent); font-weight: 800; }
.rapido-voce.is-on { font-weight: 600; }
.rapido-voce.is-on .rapido-spunta { opacity: 1; }
.rapido-data-box, .rapido-data { display: flex; flex-direction: column; gap: 10px; }
.rapido-pop .rapido-data { padding: 4px; border: 0; }
.rapido-input-data { width: 100%; min-height: 42px; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.rapido-rapide { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rapido-rapide button { padding: 9px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 0.82rem; cursor: pointer; }
.rapido-rapide button:hover { background: var(--surface-2); }
.rapido-rapide .rapido-togli { grid-column: 1 / -1; color: var(--text-soft); }
.rapido-persone-lista { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px; }
.rapido-persona { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-size: 0.9rem; }
.rapido-persona:hover { background: var(--surface-2); }
.rapido-persona input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); flex: none; }
.rapido-persona .avatar { box-shadow: none; }
.rapido-modi { margin: 0 4px 8px; }
.rapido-applica { width: calc(100% - 8px); margin: 0 4px 4px; justify-content: center; }
.toast-rapido { padding: 10px 14px; }
.toast-rapido .toast-ico { font-size: 1rem; color: var(--ok); }
.toast-errore { border-left-color: var(--danger); }
.toast-errore .toast-ico { color: var(--danger); }
@media (max-width: 700px) {
  .rapido-velo { background: rgba(2, 5, 20, 0.55); }
  .rapido-pop { left: 0; right: 0; bottom: 0; top: auto; max-width: none; max-height: 78vh; border-radius: 22px 22px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); animation: rapido-su 0.2s var(--ease); }
  .rapido-voce { padding: 14px 12px; font-size: 1rem; }
  .rapido-persona { padding: 12px 10px; font-size: 1rem; }
}
@keyframes rapido-su { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* barra della selezione multipla: tante azioni, va a capo */
.sel-bar { flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); row-gap: 8px; }
.sel-bar .sel-azione { white-space: nowrap; }


/* ============================================================
   Uniformità (2026-09-23): stessa griglia di spazi e stesse testate in tutte le pagine
   Ritmo unico: 20px tra i blocchi di una pagina (16px su telefono), 22px dentro le card (16px su telefono).
   Le vecchie regole sparse più sopra restano come base: questo strato le porta tutte allo stesso passo.
   ============================================================ */
:root { --sp-pagina: 20px; --sp-card: 22px; --sp-piccolo: 12px; }
.content { gap: var(--sp-pagina); }
.card { padding: var(--sp-card); }
@media (max-width: 700px) {
  :root { --sp-pagina: 14px; --sp-card: 14px; --sp-piccolo: 10px; }
}

/* contenitori di piu' blocchi (liste di card, board): stesso passo dei blocchi di pagina */
[data-selezione]:not(.kanban):not(.cli-grid):not(.glass):not(.card):not(.profili-cards):not(#profili-wrap) { display: flex; flex-direction: column; gap: var(--sp-pagina); }
#profili-wrap { display: flex; flex-direction: column; gap: var(--sp-pagina); }
#profili-wrap .gruppo, .gruppo { margin-bottom: 0; }
.gruppo-head { margin-bottom: var(--sp-piccolo); }

/* testate di pagina: stesso titolo, stesso sottotitolo, stessa altezza */
.pagina-head { min-height: 44px; margin: 0; row-gap: var(--sp-piccolo); }
@media (max-width: 700px) { .pagina-head { min-height: 0; } }
.pagina-head h2, .titolo-pagina { font-size: 1.3rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.015em; }
.pagina-head > div > .muted, .pagina-sottotitolo { margin-top: 4px; font-size: 0.88rem; }
@media (max-width: 700px) { .pagina-head h2, .titolo-pagina { font-size: 1.15rem; } }

/* barre sotto la testata (filtri, viste, ricerca): nessun margine proprio, ci pensa il passo di pagina */
.barra-filtri, .toolbar-lista, .cal-filtri-barra, .filtri, .mini-kpi { margin: 0; }
.toolbar-lista { row-gap: var(--sp-piccolo); }
.content > .pagina-head + .glass, .content > .pagina-head + .filtri { margin-top: 0; }
.filtri + .glass, .filtri + .card, .filtri + .kanban { margin-top: 0; }
.subtabs { align-self: flex-start; max-width: 100%; }
.torna { margin-bottom: 0; align-self: flex-start; }
.content > .torna + .pagina-head, .content > .torna + .glass { margin-top: calc(var(--sp-piccolo) * -0.5); }

/* card: testata interna sempre uguale */
.card-head { margin-bottom: 16px; min-height: 30px; }
.card-head h3 { font-size: 1.02rem; }
.card > .card-head:last-child { margin-bottom: 0; }
.card .tabella-wrap + .azioni, .card .lista + .azioni { margin-top: 16px; }
.dett-grid, .grid-2, .kpi-grid, .kanban { gap: var(--sp-pagina); }
.dett-grid > .content { gap: var(--sp-pagina); }


/* form: stessa larghezza e stesso passo tra i campi */
.form-card { max-width: 780px; padding: 26px; }
@media (max-width: 700px) { .form-card { padding: 18px 16px; } }
.form-largo { gap: 18px; }
.form-riga { gap: 16px; }
.form-sezione { margin-top: 6px; }

/* riga d'azioni sotto una tabella o una lista */
.azioni { margin-top: 16px; gap: 10px; }
.zona-pericolo { margin-top: 24px; }
.pc-azioni .riga-link { font-size: 0.84rem; }


/* ============================================================
   Onboarding e playbook: percorso del cliente, avanzamento, flusso nei Processi
   ============================================================ */
.avanz { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.avanz-barra { display: inline-block; width: 74px; height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.avanz-barra i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--ok)); }
.avanz-testo { font-size: 0.78rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.percorso-passi { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.percorso-fase { position: relative; display: flex; gap: 14px; padding-bottom: 20px; }
.percorso-fase:last-child { padding-bottom: 0; }
.percorso-fase:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); border-radius: 2px; }
.percorso-nodo { flex: none; width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; background: var(--surface-2); border: 2px solid var(--accent); color: var(--text); }
.percorso-nodo.fatto { background: var(--ok); border-color: var(--ok); color: #05261b; }
.percorso-corpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.percorso-titolo { font-weight: 700; font-size: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.percorso-titolo .muted { font-weight: 400; font-size: 0.8rem; }
.percorso-riga { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--surface); }
.percorso-riga .riga-link { font-weight: 600; }
.percorso-riga .avanz { margin-left: auto; }
.percorso-avvia { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.percorso-avvia form { margin: 0; }
.chip-playbook { appearance: none; cursor: pointer; font: inherit; font-size: 0.82rem; border-color: rgba(255, 255, 255, 0.14); border-color: color-mix(in srgb, var(--c) 45%, transparent); color: var(--text); background: rgba(255, 255, 255, 0.04); background: color-mix(in srgb, var(--c) 12%, transparent); }
.chip-playbook .ico { width: 15px; height: 15px; color: var(--c); }
.chip-playbook:hover { background: color-mix(in srgb, var(--c) 24%, transparent); }

/* Processi: sezioni e flusso */
.processi-sezione { display: flex; flex-direction: column; gap: var(--sp-piccolo, 12px); }
.sezione-titolo { font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.sezione-titolo .muted { font-weight: 400; font-size: 0.82rem; }
.flusso { display: flex; align-items: stretch; gap: 14px; flex-wrap: wrap; }
.flusso-passo { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--surface); min-width: 170px; flex: 1; }
.flusso-passo.flusso-largo { flex: 2.4; }
.flusso-passo small { color: var(--text-soft); font-size: 0.78rem; }
.flusso-nodo { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem; background: var(--surface-2); border: 2px solid var(--c, var(--accent)); margin-bottom: 4px; }
.flusso-freccia { align-self: center; color: var(--text-dim); font-size: 1.3rem; }
.flusso-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
@media (max-width: 900px) { .flusso-freccia { display: none; } .flusso-passo, .flusso-passo.flusso-largo { flex: 1 1 100%; } }


/* ============================================================
   v2026.09.25 — colonne allineate e ordinabili, task a elenco, trascinamento, Profili compatti
   ============================================================ */

/* ---- Tabelle: intestazioni ordinabili e colonne dritte ---- */
.th-ord { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; cursor: pointer; border-radius: 6px; padding: 2px 4px; margin: -2px -4px; }
.th-ord:hover { color: var(--text); background: var(--surface-2); }
.th-ord-attivo .th-ord { color: var(--accent); }
.th-freccia { width: 8px; height: 10px; position: relative; flex: none; opacity: 0.45; }
.th-freccia::before, .th-freccia::after { content: ""; position: absolute; left: 0; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.th-freccia::before { top: 0; border-bottom: 4.5px solid currentColor; }
.th-freccia::after { bottom: 0; border-top: 4.5px solid currentColor; }
.th-freccia.su::after, .th-freccia.giu::before { opacity: 0.15; }
.th-ord-attivo .th-freccia { opacity: 1; }
@media (min-width: 701px) {
  .tabella-fissa { table-layout: fixed; width: 100%; min-width: 900px; }
  .tabella-fissa th, .tabella-fissa td { overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
  .tabella-fissa td { white-space: nowrap; }
  .tabella-fissa td .riga-link { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
  .tabella-fissa td .rapido-persone, .tabella-fissa td .rapido-data { max-width: 100%; }
}
.mini-piu { margin-left: 8px; font-size: 0.72rem; color: var(--text-dim); border: 1px dashed var(--border); border-radius: 999px; padding: 1px 8px; }
.mini-piu:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Task dentro un progetto: elenco semplice ---- */
.task-veloce { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 14px; }
.task-veloce textarea { flex: 1 1 260px; min-height: 44px; max-height: 160px; resize: none; font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; outline: none; line-height: 1.35; }
.task-veloce textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(63, 162, 246, 0.2); }
.task-veloce select, .task-veloce input[type="date"] { min-height: 44px; font: inherit; font-size: 0.85rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 0 10px; }
.task-veloce .btn { min-height: 44px; }
.task-lista { display: flex; flex-direction: column; }
.task-riga { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.task-riga:last-child { border-bottom: 0; }
.task-spunta { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--text-dim); background: transparent; color: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.task-spunta .ico { width: 14px; height: 14px; }
.task-spunta:hover { border-color: var(--ok); color: var(--ok); }
.task-riga.fatta .task-spunta { background: var(--ok); border-color: var(--ok); color: #05261b; }
.task-corpo { flex: 1 1 220px; min-width: 0; }
.task-nome { color: var(--text); font-weight: 600; font-size: 0.95rem; }
.task-nome:hover { color: var(--accent); }
.task-riga.fatta .task-nome { text-decoration: line-through; color: var(--text-dim); font-weight: 500; }
.task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-left: auto; }
.task-fatte { margin-top: 12px; }
.task-fatte > summary { cursor: pointer; color: var(--text-soft); font-size: 0.85rem; font-weight: 600; padding: 6px 0; }
@media (max-width: 700px) { .task-meta { margin-left: 38px; width: 100%; } }

/* ---- Trascinamento ---- */
.kanban[data-dnd] .kanban-card { cursor: grab; }
.kanban-card.trascinato { opacity: 0.4; transform: scale(0.98); }
.kanban.dnd-attivo .kanban-col { outline: 2px dashed transparent; transition: outline-color 0.12s, background 0.12s; }
.kanban.dnd-attivo .kanban-col.drop-ok { outline-color: var(--c, var(--accent)); background: rgba(63, 162, 246, 0.08); }
[data-drag-ev] { cursor: grab; }
.cal-trascinato { opacity: 0.35; }
.cal-cell.drop-ok, .cal-tg-tuttogiorno.drop-ok { background: rgba(63, 162, 246, 0.16); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-drop-linea { position: absolute; left: 3px; right: 3px; z-index: 30; border-radius: 8px; background: rgba(63, 162, 246, 0.28); border: 2px solid var(--accent); color: var(--text); font-size: 0.72rem; font-weight: 700; padding: 2px 8px; pointer-events: none; box-sizing: border-box; }

/* ---- Profili: card cliente pulite e pannello compatto ---- */
.cli-card-num { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; font-size: 0.85rem; color: var(--text-soft); margin: 2px 0 0; }
.cli-card-num b { color: var(--text); }
.profili-pannello-cerca { padding: 12px 22px 0; }
.profili-pannello-cerca input { width: 100%; min-height: 42px; font: inherit; font-size: 0.92rem; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; outline: none; }
.profili-pannello-cerca input:focus { border-color: var(--accent); }
.profilo-card.compatta { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.pc-riga-testa { display: flex; align-items: center; gap: 12px; }
.pc-riga-testa .pc-titolo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pc-riga-testa .pc-titolo strong { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-riga-testa .pc-titolo .muted { font-size: 0.78rem; }
.pc-icona { flex: none; width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--c); background: rgba(63, 162, 246, 0.16); background: color-mix(in srgb, var(--c) 18%, transparent); }
.pc-apri-mini { flex: none; }
.pc-righe { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.pc-riga { display: flex; align-items: center; gap: 10px; min-height: 30px; }
.pc-etichetta { flex: none; width: 74px; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.pc-riga code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-riga .copia { margin-left: 0; flex: none; }
.profilo-card.compatta .pc-foot { padding-top: 8px; border-top: 1px solid var(--border-soft); }
@media (min-width: 701px) {
  .tabella-fissa td .ptipo + .riga-link { max-width: calc(100% - 44px); }
}
