/* Regia · grafica del 30/09/2026 sul modello di folk.app: tela bianca, fascia laterale grigio caldo,
   bordi sottili, pillole con contorno, un solo bottone nero per l'azione che chiude il compito.
   Il rosso segna solo quello che aspetta Francesco. Principi in _dev/regia/PRODUCT.md. */
:root {
  --canvas: #FFFFFF;
  --rail: #F7F6F4;
  --subtle: #F4F2EF;
  --chip: #ECE9E4;
  --hover: rgba(33, 32, 28, .045);
  --active: rgba(33, 32, 28, .085);
  --line: #E7E5E1;
  --line-2: #D6D3CE;
  --hairline: #21201C;
  --ink: #1D1C19;
  --ink-2: #3F3D38;
  --muted: #6A675F;

  --red: #D93036;
  --red-ink: #B4232A;
  --red-bg: #FDEEEE;
  --amber-ink: #7F5300;
  --amber-bg: #FFF3D1;
  --green-ink: #3B6212;
  --green-bg: #ECF6D9;
  --blue-ink: #24508C;
  --blue-bg: #E6F0FE;
  --violet-ink: #5236A8;
  --violet-bg: #EFEAFD;
  --wa: #1FA855;
  --focus: #1378D1;

  --r-s: 6px;
  --r: 10px;
  --r-l: 14px;
  --side: 232px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);

  --z-sticky: 10;
  --z-tabbar: 20;
  --z-dropdown: 30;
  --z-scrim: 40;
  --z-drawer: 41;
  --z-toast: 80;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-s); }
::placeholder { color: var(--muted); opacity: 1; }
.msg, .caso .lead-msg, .caso .prima, .dlg .citazione, .trova, .drawer { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
kbd { font: 500 11px/1 var(--font); color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 5px; background: var(--canvas); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ guscio */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--rail); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 6px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--hairline); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; right: -3px; top: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--rail); }
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-gruppo { font-size: 12px; font-weight: 500; color: var(--muted); padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 450; transition: background .15s var(--ease); }
.nav a svg { width: 17px; height: 17px; color: var(--muted); }
.nav a:hover { background: var(--hover); }
.nav a.on { background: var(--active); color: var(--ink); font-weight: 550; }
.nav a.on svg { color: var(--ink); }
.nav a .n { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 10px 2px; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.side-foot .riga { display: flex; align-items: center; gap: 8px; }
.pallino { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex: none; }
.pallino.ok { background: #3DA35D; }
.pallino.ko { background: var(--red); }
.pallino.att { background: #E0A100; }

.main { min-width: 0; outline: none; }
.topbar { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 32px; background: var(--canvas); border-bottom: 1px solid transparent; transition: border-color .15s; }
.topbar.ombra { border-bottom-color: var(--line); }
.topbar-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search { position: relative; display: flex; align-items: center; gap: 8px; height: 36px; width: 300px; padding: 0 10px 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--canvas); color: var(--muted); transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--hairline); }
.search svg { width: 16px; height: 16px; }
.search input { border: 0; background: transparent; outline: none; width: 100%; min-width: 0; color: var(--ink); height: 100%; }
.search input::-webkit-search-cancel-button { display: none; }
.topbar .cerca-btn, .topbar .cerca-chiudi { display: none; }
.trova { position: absolute; top: calc(100% + 6px); right: 0; width: 420px; max-width: calc(100vw - 32px); background: var(--canvas); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: 0 6px 8px -4px rgba(33, 32, 28, .12); padding: 4px; z-index: var(--z-dropdown); color: var(--ink); animation: cala .14s var(--ease); }
.trova .vuoto { padding: 12px; font-size: 13px; }
.trova-r { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.trova-r.sel, .trova-r:hover { background: var(--hover); }
.trova-r .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trova-r .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes cala { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); flex: none; }
.sync.ok { background: #3DA35D; }
.sync.ko { background: var(--red); }
.sync.lavora { background: #E0A100; }

.view { padding: 4px 32px 120px; max-width: 1160px; }
.view.stretta { max-width: 920px; }

.carico { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; max-width: 760px; }
.carico i { display: block; height: 96px; border-radius: var(--r-l); background: var(--subtle); animation: pulsa 1.4s ease-in-out infinite; }
.carico i:nth-child(2) { animation-delay: .15s; }
.carico i:nth-child(3) { animation-delay: .3s; }
@keyframes pulsa { 50% { opacity: .55; } }

/* ------------------------------------------------ mattoni */
.pagina-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.pagina-sub b { color: var(--ink); font-weight: 600; }
.sezione { margin-top: 28px; }
.sezione:first-child { margin-top: 6px; }
.sez-t { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin: 0 0 10px; letter-spacing: -.005em; }
.sez-t .c { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.sez-t .dx { margin-left: auto; font-weight: 450; font-size: 13px; }
.vuoto { color: var(--muted); padding: 20px 0; font-size: 14px; }
.vuoto-grande { border: 1px dashed var(--line-2); border-radius: var(--r-l); padding: 28px 24px; color: var(--muted); font-size: 14px; }
.vuoto-grande b { display: block; color: var(--ink); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
p.nota { color: var(--muted); font-size: 13px; margin: 8px 0 0; max-width: 70ch; }

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1; }
.pill svg { width: 12px; height: 12px; }
.pill.contorno { background: transparent; border: 1px solid var(--line-2); }
.pill.rosso { background: var(--red-bg); color: var(--red-ink); }
.pill.ambra { background: var(--amber-bg); color: var(--amber-ink); }
.pill.verde { background: var(--green-bg); color: var(--green-ink); }
.pill.blu { background: var(--blue-bg); color: var(--blue-ink); }
.pill.viola { background: var(--violet-bg); color: var(--violet-ink); }
.pill.nero { background: var(--hairline); color: #fff; }
.pill.f-nuovo { background: var(--amber-bg); color: var(--amber-ink); }
.pill.f-interessato { background: var(--blue-bg); color: var(--blue-ink); }
.pill.f-call_fissata { background: var(--green-bg); color: var(--green-ink); }
.pill.f-dopo_call { background: var(--violet-bg); color: var(--violet-ink); }
.pill.f-cliente { background: var(--hairline); color: #fff; }
.pill.f-pausa { background: var(--chip); color: var(--ink-2); }
.pill.f-no { background: transparent; border: 1px solid var(--line-2); color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); flex: none; display: inline-block; }
.aspetta { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--red-ink); white-space: nowrap; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; letter-spacing: .01em; flex: none; color: var(--ink); background: var(--chip); }
.avatar.a0 { background: #DCE9FF; }
.avatar.a1 { background: #E6DDFD; }
.avatar.a2 { background: #FFE9B3; }
.avatar.a3 { background: #DDF2B6; }
.avatar.a4 { background: #F7DDE9; }
.avatar.a5 { background: #D8EDEA; }
.avatar.g { width: 44px; height: 44px; font-size: 15px; }
.avatar.p { width: 26px; height: 26px; font-size: 10.5px; }

/* bottoni: pillola, un solo nero per schermata di lavoro */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--canvas); color: var(--ink); font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.btn:hover { background: var(--subtle); }
.btn:active { background: var(--active); }
.btn svg { width: 16px; height: 16px; }
.btn.primario { background: var(--hairline); border-color: var(--hairline); color: #fff; }
.btn.primario:hover { background: var(--canvas); color: var(--ink); }
.btn.primario:active { background: var(--subtle); }
.btn.primario .wa { color: #4ADE80; }
.btn.primario:hover .wa { color: var(--wa); }
.btn.piccolo { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.testo { border-color: transparent; background: transparent; color: var(--muted); padding: 0 10px; }
.btn.testo:hover { color: var(--ink); background: var(--hover); }
.btn.tondo { width: 34px; padding: 0; }
.btn.fatta { border-color: transparent; background: var(--green-bg); color: var(--green-ink); }
.btn.fatta:hover { background: #E0F0C4; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .wa-v { color: var(--wa); }

.azioni { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.azioni .spinta { margin-left: auto; }

.filtri { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 16px; }
.filtri button { height: 30px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--canvas); font-size: 13px; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; transition: background .15s var(--ease); }
.filtri button .c { color: var(--muted); font-variant-numeric: tabular-nums; }
.filtri button:hover { background: var(--subtle); }
.filtri button.on { background: var(--hairline); border-color: var(--hairline); color: #fff; }
.filtri button.on .c { color: rgba(255, 255, 255, .7); }
.filtri select.filtro-sel { width: auto; height: 30px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink-2); padding-left: 12px; max-width: 280px; }

.inp, select.inp, textarea.inp { width: 100%; border: 1px solid var(--line-2); background: var(--canvas); border-radius: 8px; padding: 8px 11px; outline: none; font-size: 14px; transition: border-color .15s; }
select.inp { height: 36px; padding: 0 30px 0 10px; appearance: none; background: var(--canvas) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236A675F' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center / 16px; }
input.inp { height: 36px; }
textarea.inp { min-height: 76px; max-height: 45vh; resize: vertical; line-height: 1.5; field-sizing: content; }
.inp:hover { border-color: #C4C0BA; }
.inp:focus { border-color: var(--hairline); }
.campo { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; min-width: 0; }
.campo:first-child { margin-top: 0; }
.campo label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.due-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tre-col { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr; gap: 8px; }
.coppia { display: flex; gap: 6px; }
.due-col > .campo, .tre-col > .campo { margin-top: 0; }
.azioni select.inp { width: auto; height: 34px; }

.avviso { display: flex; gap: 10px; align-items: center; background: var(--red-bg); color: var(--red-ink); padding: 10px 12px; border-radius: var(--r); font-size: 13.5px; }
.avviso svg { width: 16px; height: 16px; }
.avviso.ambra { background: var(--amber-bg); color: var(--amber-ink); }
.avviso.verde { background: var(--green-bg); color: var(--green-ink); }
.avviso .x { margin-left: auto; color: inherit; }

.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 2px; gap: 2px; background: var(--canvas); }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 0 12px; height: 26px; font-size: 12.5px; font-weight: 500; color: var(--muted); transition: background .15s var(--ease), color .15s; }
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--hairline); color: #fff; }

/* ------------------------------------------------ Da fare */
.oggi { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; align-items: start; }
.oggi-aside { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 22px; }
.aside-t { font-size: 13px; font-weight: 600; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.aside-t a { margin-left: auto; font-weight: 450; color: var(--muted); text-decoration: none; font-size: 12.5px; }
.aside-t a:hover { color: var(--ink); }
.prossima { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 8px; margin: 0 -8px; border-radius: 8px; cursor: pointer; }
.prossima:hover { background: var(--hover); }
.prossima .o { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.prossima .g { font-size: 11.5px; color: var(--muted); }
.prossima .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.prossima.rc .o { color: var(--amber-ink); }
.prossima .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lavori { display: flex; flex-direction: column; gap: 10px; }
.lavoro { border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px 16px; background: var(--canvas); transition: border-color .15s; }
.lavoro:hover { border-color: var(--line-2); }
.lavoro-testa { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.lavoro-testa .chi { min-width: 0; flex: 1; }
.lavoro-testa .nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lavoro-testa .dove { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; }
.lavoro-testa .dove svg { width: 14px; height: 14px; }
.lavoro-testa .quando { color: var(--muted); font-size: 12.5px; white-space: nowrap; align-self: flex-start; padding-top: 2px; }
.rc-riga { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.motivi { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.motivi .pill { white-space: normal; height: auto; min-height: 22px; padding: 4px 9px; line-height: 1.35; }

.msg { margin-top: 12px; background: var(--subtle); border-radius: 4px var(--r-l) var(--r-l) var(--r-l); padding: 10px 13px 11px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 13.5em; overflow: auto; }
.msg .chi { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 3px; white-space: normal; }

.bozza { margin-top: 10px; border: 1px solid var(--hairline); border-radius: var(--r-l) 4px var(--r-l) var(--r-l); padding: 9px 13px 10px; background: var(--canvas); }
.bozza:focus-within { box-shadow: 0 0 0 3px rgba(33, 32, 28, .08); }
.bozza .intesta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; flex-wrap: wrap; }
.bozza .intesta svg { width: 14px; height: 14px; }
.bozza textarea { display: block; width: 100%; border: 0; outline: none; resize: none; min-height: 3.2em; max-height: 22em; background: transparent; font-size: 14.5px; line-height: 1.55; padding: 0; field-sizing: content; }
.perche { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.perche svg { width: 14px; height: 14px; margin-top: 2px; }
.perche.forte { color: var(--amber-ink); }

/* ------------------------------------------------ elenchi (Interessati, Dopo la call, Archivio) */
.tabella { border-top: 1px solid var(--line); }
.riga { display: grid; grid-template-columns: 32px minmax(0, 1fr) 120px 110px 124px; gap: 14px; align-items: center; padding: 11px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; text-decoration: none; }
.riga:hover { background: var(--hover); }
.riga.intesta { cursor: default; padding-top: 8px; padding-bottom: 8px; font-size: 12px; color: var(--muted); font-weight: 500; background: transparent; }
.riga.intesta > :first-child { grid-column: 1 / 3; }
.riga-nome { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 550; }
.riga-nome .t { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riga-nome .citta { flex: 1 1 0; min-width: 0; color: var(--muted); font-weight: 400; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riga-ant { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.riga-can { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.riga-can svg { width: 15px; height: 15px; color: var(--muted); }
.riga-quando { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.riga-stato { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.riga.altro-r { grid-template-columns: 24px minmax(0, 1fr) auto 18px; color: var(--ink); }
.riga.altro-r .ico { display: flex; color: var(--muted); }
.riga.altro-r > svg { color: var(--muted); width: 16px; height: 16px; }
.oggi-main { min-width: 0; }

/* ------------------------------------------------ call */
.giorno { margin-top: 26px; }
.giorno:first-child { margin-top: 6px; }
.giorno-t { font-weight: 600; font-size: 14px; margin: 0 0 4px; display: flex; gap: 8px; align-items: baseline; }
.giorno-t .muted { font-weight: 450; font-size: 13px; }
.call-riga { display: grid; grid-template-columns: 56px 32px minmax(0, 1fr) minmax(0, max-content); gap: 12px; align-items: center; padding: 12px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .12s; }
.call-riga:hover { background: var(--hover); }
.call-riga .ora { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.call-riga .chi { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-riga .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-riga .sub svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; }
.call-riga .prom { max-width: 340px; }
.prom { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.call-riga.rc .ora { color: var(--amber-ink); }
.call-riga.rc .chi { font-weight: 500; }

/* ------------------------------------------------ clienti */
.clienti { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cliente { border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; cursor: pointer; transition: border-color .15s; }
.cliente:hover { border-color: var(--line-2); }
.cliente .testa { display: flex; gap: 10px; align-items: center; }
.cliente .nome { font-weight: 600; }
.cliente .sub { font-size: 12.5px; color: var(--muted); }
.cliente .prossimo { margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.cliente .prossimo span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }

/* ------------------------------------------------ scheda del lead (pannello a destra, come folk) */
.drawer-scrim { position: fixed; inset: 0; background: rgba(29, 28, 25, .16); z-index: var(--z-scrim); animation: appare .18s var(--ease); }
@keyframes appare { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--canvas); z-index: var(--z-drawer); border-left: 1px solid var(--line-2); transform: translateX(100%); visibility: hidden; transition: transform .24s var(--ease), visibility 0s .24s; overflow-y: auto; overscroll-behavior: contain; }
.drawer.aperto { transform: none; visibility: visible; transition: transform .24s var(--ease), visibility 0s 0s; }
.d-head { position: sticky; top: 0; background: var(--canvas); padding: 18px 22px 14px; border-bottom: 1px solid var(--line); z-index: 2; }
.d-head .riga1 { display: flex; align-items: center; gap: 12px; }
.d-head .id { min-width: 0; flex: 1; }
.d-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
.d-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.d-head .chiudi { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--canvas); display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: flex-start; }
.d-head .chiudi:hover { background: var(--subtle); }
.d-head .contatti { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.d-head .punto { margin-top: 12px; font-size: 13.5px; color: var(--ink-2); }
.d-body { padding: 4px 22px 60px; }
.d-sez { padding: 18px 0; border-bottom: 1px solid var(--line); }
.d-sez:last-child { border-bottom: 0; }
.d-sez > .t { font-size: 14px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.d-sez > .t .c { color: var(--muted); font-weight: 500; }
.d-sez > .t .dx { margin-left: auto; }
.callcard { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: center; }
.callcard .qd { font-size: 15px; font-weight: 600; }
.callcard .tp { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.callcard .prom { grid-column: 1 / -1; justify-content: flex-start; margin-top: 6px; }
.callcard .ico { grid-row: 1 / 3; width: 38px; height: 38px; border-radius: 10px; background: var(--subtle); display: flex; align-items: center; justify-content: center; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.bolla { max-width: 86%; padding: 9px 12px 10px; border-radius: var(--r-l); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.bolla.in { align-self: flex-start; background: var(--subtle); border-top-left-radius: 4px; }
.bolla.out { align-self: flex-end; background: var(--canvas); border: 1px solid var(--line-2); border-top-right-radius: 4px; }
.bolla.campagna { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); cursor: pointer; max-width: 100%; align-self: stretch; display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 8px 12px; }
.bolla.campagna:hover { background: var(--hover); }
.bolla.auto { opacity: .6; }
.bolla.taglia { max-height: 19em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
.btn.lungo { align-self: flex-start; margin-top: -6px; }
.btn.lungo.out { align-self: flex-end; }
.bolla .testa { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; font-weight: 500; white-space: normal; }
.bolla .testa svg { width: 12px; height: 12px; }
.storia { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.storia li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; }
.storia li:last-child { border-bottom: 0; }
.storia li .q { flex: none; width: 96px; font-variant-numeric: tabular-nums; }
details.apri > summary { list-style: none; cursor: pointer; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
details.apri > summary::-webkit-details-marker { display: none; }
details.apri > summary svg { width: 15px; height: 15px; color: var(--muted); transition: transform .15s var(--ease); }
details.apri[open] > summary svg { transform: rotate(90deg); }
.crm { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ------------------------------------------------ palestra */
.progresso { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.progresso .conti { font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.progresso .conti b { font-weight: 600; }
.barra { flex: 1; min-width: 160px; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; display: flex; }
.barra i { display: block; height: 100%; background: var(--hairline); }
.barra i.r { background: #E0A100; }
.barra i.g { background: var(--line-2); }
.caso { border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.caso .etich { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.caso .sit { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.caso .sit b { color: var(--ink); font-weight: 600; font-size: 14px; }
.caso .sit svg { width: 14px; height: 14px; }
.caso .prima { background: var(--canvas); border: 1px solid var(--line-2); border-radius: var(--r-l); border-top-right-radius: 4px; padding: 8px 12px; font-size: 13px; color: var(--ink-2); white-space: pre-wrap; max-height: 9em; overflow: auto; margin-bottom: 8px; }
.caso .lead-msg { background: var(--subtle); border-radius: 4px var(--r-l) var(--r-l) var(--r-l); padding: 10px 13px; white-space: pre-wrap; font-size: 14px; overflow-wrap: anywhere; max-height: 16em; overflow: auto; }
.caso .bozza-pal { border: 1px solid var(--hairline); border-radius: var(--r-l) 4px var(--r-l) var(--r-l); padding: 10px 13px; white-space: pre-wrap; font-size: 14px; min-height: 60px; overflow-wrap: anywhere; }
.caso .bozza-pal.attesa { border-style: dashed; border-color: var(--line-2); color: var(--muted); }
.caso .vera { margin-top: 10px; font-size: 13.5px; background: var(--green-bg); border-radius: var(--r); padding: 9px 12px; white-space: pre-wrap; color: var(--green-ink); }
.caso .vera .t { font-weight: 600; font-size: 12px; display: block; margin-bottom: 3px; }
.caso .vera.tua { background: var(--amber-bg); color: var(--amber-ink); }
.caso textarea.inp { margin-top: 10px; field-sizing: content; min-height: 110px; }

/* ------------------------------------------------ regole */
.gruppo { border: 1px solid var(--line); border-radius: var(--r-l); padding: 4px 16px; }
.gruppo.pieno { padding: 16px; }
.regola { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.regola:last-child { border-bottom: 0; }
.regola .n { font-weight: 500; }
.regola .d { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.stato-griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 20px; font-size: 13.5px; }
.stato-griglia div { display: flex; flex-direction: column; gap: 2px; }
.stato-griglia span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------ dialogo, toast, barra del telefono */
dialog.dlg { border: 1px solid var(--line-2); border-radius: var(--r-l); padding: 0; width: min(480px, calc(100vw - 32px)); color: var(--ink); background: var(--canvas); box-shadow: 0 8px 8px -6px rgba(33, 32, 28, .18); }
dialog.dlg::backdrop { background: rgba(29, 28, 25, .28); }
dialog.dlg[open] { animation: sale .18s var(--ease); }
@keyframes sale { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dlg form { padding: 20px; }
.dlg h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.dlg .corpo { font-size: 13.5px; color: var(--muted); }
.dlg .citazione { margin: 12px 0 4px; border: 1px solid var(--hairline); border-radius: var(--r); padding: 10px 12px; white-space: pre-wrap; color: var(--ink); font-size: 14px; max-height: 40vh; overflow: auto; }
.dlg textarea.inp { margin-top: 12px; }
.dlg .spunta { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.dlg .spunta input { width: 17px; height: 17px; accent-color: var(--hairline); }
.dlg .azioni { justify-content: flex-end; margin-top: 18px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px); background: var(--hairline); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); z-index: var(--z-toast); max-width: min(92vw, 520px); text-align: center; }
.toast.su { opacity: 1; transform: translate(-50%, 0); }
.tabbar { display: none; }

@media (max-width: 1180px) {
  .oggi { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .oggi-aside { position: static; order: -1; margin-bottom: 20px; }
  .oggi-aside .prossima:nth-of-type(n+3) { display: none; }
  .oggi-aside .stato-motore { display: none; }
}

@media (max-width: 860px) {
  html, body { font-size: 15px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { height: auto; min-height: 54px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; gap: 8px; }
  .topbar-title { font-size: 18px; }
  .search { display: none; }
  .topbar .cerca-btn { display: inline-flex; }
  .kbd-cerca { display: none; }
  .topbar.cercando .topbar-title, .topbar.cercando .sync { display: none; }
  .topbar.cercando .topbar-right { margin-left: 0; flex: 1; }
  .topbar.cercando .search { display: flex; flex: 1; width: auto; height: 40px; }
  .topbar.cercando .cerca-chiudi { display: inline-flex; }
  .topbar.cercando .cerca-btn { display: none; }
  .trova { width: auto; max-width: none; position: fixed; top: calc(58px + env(safe-area-inset-top)); left: 12px; right: 12px; max-height: 60vh; overflow: auto; }
  .trova-r { padding: 10px 8px; }
  .view, .view.stretta { padding: 4px 16px calc(100px + env(safe-area-inset-bottom)); }
  .btn { height: 40px; padding: 0 16px; font-size: 14px; }
  .btn.piccolo { height: 36px; padding: 0 13px; font-size: 13.5px; }
  .btn.tondo { width: 40px; }
  .filtri { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px; scrollbar-width: none; }
  .filtri::-webkit-scrollbar { display: none; }
  .filtri button { height: 34px; flex: none; }
  .filtri select.filtro-sel { height: 34px; flex: none; font-size: 14px; }
  .inp, select.inp, textarea.inp, .bozza textarea { font-size: 16px; }
  input.inp, select.inp { height: 42px; }
  .azioni select.inp { height: 40px; }
  .lavoro { padding: 12px 13px 14px; border-radius: var(--r); }
  .azioni .spinta { margin-left: 0; }
  .riga { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; padding: 12px 16px; margin: 0 -16px; }
  .riga.intesta { display: none; }
  .riga-can { display: none; }
  .riga-quando { grid-column: 3; grid-row: 1; align-self: start; font-size: 12px; }
  .riga-stato { grid-column: 2 / 4; justify-content: flex-start; }
  .riga-stato:empty { display: none; }
  .call-riga { grid-template-columns: 50px minmax(0, 1fr); padding: 12px 16px; margin: 0 -16px; }
  .call-riga .avatar { display: none; }
  .call-riga .prom { grid-column: 2; justify-content: flex-start; }
  .caso { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 13px; }
  .drawer { width: 100vw; border-left: 0; }
  .d-head { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .d-head .contatti { flex-wrap: nowrap; overflow-x: auto; margin: 12px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
  .d-head .contatti::-webkit-scrollbar { display: none; }
  .d-head .contatti .btn { flex: none; }
  .d-body { padding: 0 16px calc(80px + env(safe-area-inset-bottom)); }
  .due-col, .tre-col { grid-template-columns: minmax(0, 1fr); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar); background: var(--canvas); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 50px; justify-content: center; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; position: relative; border-radius: 10px; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--ink); }
  .tabbar a.on svg { stroke-width: 2; }
  .tabbar a .badge { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 18px; height: 18px; font-size: 10.5px; padding: 0 5px; margin: 0; border: 2px solid var(--canvas); box-sizing: content-box; }
}

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