:root {
  --bg: #F4F5FA; --card: #fff; --ink: #18181F; --ink-2: #3F4150; --muted: #5B6070; --faint: #A3A6B2;
  --line: #F0F1F5; --line-2: #E4E6EC; --track: #EEF0F4;
  --piano: #4F46E5; --piano-ink: #3730A3; --piano-tint: #EEF0FF;
  --ok: #15803D; --ok-bg: #E6F6EC; --ok-ink: #14532D;
  --ko: #B91C1C; --ko-bg: #FDECEC; --ko-ink: #991B1B;
  --wip-bg: #FFF5D6; --wip-ink: #854D0E;
  --side: #14151B; --side-2: #1E2029; --side-line: #2A2C36; --side-hover: #22242E; --side-ink: #E4E5EA;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.05);
  --shadow-up: 0 2px 4px rgba(16,24,40,.05), 0 14px 32px rgba(16,24,40,.09);
  --r: 20px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.main:focus { outline: none; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
::selection { background: var(--piano); color: #fff; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--piano); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* livelli */
.lv-piano { font-weight: 800; color: var(--piano); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.lv-par { font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.lv-obj { font-weight: 600; letter-spacing: -0.01em; }
.lv-tap { font-weight: 500; color: var(--muted); }
.dot { display: inline-block; border-radius: 50%; flex: none; }

/* struttura */
.app { min-height: 100vh; display: flex; gap: 16px; padding: 16px; align-items: flex-start; }
.side { position: sticky; top: 16px; width: 248px; flex: none; min-height: calc(100vh - 32px); border-radius: 24px; padding: 22px 16px;
  background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; gap: 20px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 6px; text-decoration: none; }
.logo-ico { width: 36px; height: 36px; border-radius: 11px; background: var(--piano); display: flex; align-items: center; justify-content: center; flex: none; }
.logo b { font-size: 18px; font-weight: 700; color: #fff; }
.side-piano { display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.side-piano label { font-size: 12px; font-weight: 500; color: var(--faint); }
.side-piano .riga { display: flex; gap: 6px; }
.side select { flex: 1; min-width: 0; height: 40px; border-radius: 10px; border: 1px solid var(--side-line); background: var(--side-2); color: var(--side-ink); padding: 0 8px; font-weight: 600; font-size: 13px; }
.side .ico-btn { width: 40px; height: 40px; flex: none; border-radius: 10px; border: 1px solid var(--side-line); background: var(--side-2); color: var(--side-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.side .ico-btn:hover { background: var(--side-hover); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: 12px; text-decoration: none; font-size: 14px; font-weight: 500; color: var(--side-ink); transition: background .2s; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.on { background: var(--piano); color: #fff; }
.nav a .cnt { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--faint); }
.nav a.on .cnt { color: #fff; }
.nav svg { flex: none; }
.chat-hint { margin-top: auto; border-radius: 18px; padding: 16px; background: var(--piano); color: #fff; display: flex; flex-direction: column; gap: 8px; }
.chat-hint b { font-size: 14.5px; }
.chat-hint span { font-size: 12.5px; line-height: 1.45; color: #E0E3FF; }
.utente { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #FFE4D5; color: #9A3412; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }
.utente .chi { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.utente .chi b { font-size: 14px; font-weight: 600; }
.utente .chi small { font-size: 12px; color: var(--faint); }
.esci { background: none; border: 0; color: var(--faint); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 8px; border-radius: 8px; }
.esci:hover { color: #fff; background: var(--side-hover); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; padding: 6px 4px 40px; }
.demo-banner { border-radius: 14px; background: var(--wip-bg); color: var(--wip-ink); padding: 10px 14px; font-size: 13.5px; font-weight: 600; }

/* elementi */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 22px; }
.pad-l { padding: 24px; }
.hov { transition: transform .2s, box-shadow .2s; text-decoration: none; color: inherit; }
.hov:hover { transform: translateY(-2px); box-shadow: var(--shadow-up); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; border: 0; white-space: nowrap; transition: background .2s, transform .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2E2F38; }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px #D9DCE3; }
.btn-ghost:hover { background: #F7F8FB; }
.btn-soft { background: #F0F1F5; color: var(--ink); min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn-soft:hover { background: var(--line-2); }
.btn-danger { background: var(--ko-bg); color: var(--ko-ink); }
.btn-danger:hover { background: #FAD9D9; }
.link { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.wip { background: var(--wip-bg); color: var(--wip-ink); }
.pill.zero { background: #EEF0F4; color: var(--ink-2); }
.pill.done { background: var(--ok-bg); color: var(--ok-ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.ko { background: var(--ko-bg); color: var(--ko-ink); }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 8px; color: #fff; font-size: 11px; }
.track { display: block; background: var(--track); border-radius: 999px; overflow: hidden; }
.track > i { display: block; height: 100%; border-radius: 999px; transition: width .35s; }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sec-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.sec-head .sub { font-size: 13px; color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { font-size: 14px; color: var(--muted); }
.page-head .azioni { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font-size: 14px; }
.crumbs a { text-decoration: none; }
.crumbs .sep { color: var(--faint); }
.avviso { border-radius: 14px; background: var(--wip-bg); color: var(--wip-ink); padding: 12px 14px; font-size: 13.5px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.vuoto { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 300px)), 1fr)); }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .big { flex: 2 1 520px; min-width: 0; }
.split > .small { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.riga-sep { border-top: 1px solid var(--line); }

/* form */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lab { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 44px; border: 1px solid #D9DCE3; border-radius: 12px; padding: 0 12px; font-size: 15px; font-weight: 500; background: #fff; min-width: 0; width: 100%; font-variant-numeric: tabular-nums; }
.field textarea { padding: 10px 12px; min-height: 80px; resize: vertical; line-height: 1.45; }
.field .aiuto { font-size: 12.5px; color: var(--muted); }
.campi { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.seg { display: inline-flex; flex-wrap: wrap; padding: 4px; border-radius: 14px; background: #EEF0F4; gap: 4px; }
.seg button { border: 0; background: none; min-height: 38px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button { border: 0; min-height: 38px; padding: 0 14px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px #E4E6EC; font-weight: 600; font-size: 13.5px; cursor: pointer; color: var(--ink-2); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.cerca { position: relative; display: flex; align-items: center; }
.cerca svg { position: absolute; left: 14px; pointer-events: none; }
.cerca input { width: 230px; max-width: 100%; height: 44px; border: 0; border-radius: 12px; background: #fff; padding: 0 14px 0 40px; font-weight: 500; font-size: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.05); }

/* dashboard */
.kpi { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.kpi a { border-radius: 20px; padding: 18px; display: flex; align-items: center; gap: 14px; text-decoration: none; }
.kpi .ico { width: 48px; height: 48px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; display: block; line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--ink-2); }
.gp-bar { position: relative; height: 26px; }
.gp-bar .t { position: absolute; left: 0; right: 0; top: 5px; height: 16px; border-radius: 8px; background: var(--track); }
.gp-bar .f { position: absolute; left: 0; top: 5px; height: 16px; border-radius: 8px; background: var(--piano); }
.gp-bar .k { position: absolute; top: 0; height: 26px; width: 3px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.anni { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.par-card { overflow: hidden; display: flex; flex-direction: column; }
.par-top { display: flex; flex-direction: column; gap: 12px; padding: 20px 20px 16px; text-decoration: none; color: inherit; border-top: 5px solid; }
.par-bar { position: relative; display: block; height: 18px; }
.par-bar .t { position: absolute; left: 0; right: 0; top: 4px; height: 10px; border-radius: 5px; background: rgba(255,255,255,.85); }
.par-bar .f { position: absolute; left: 0; top: 4px; height: 10px; border-radius: 5px; }
.par-bar .k { position: absolute; top: 0; height: 18px; width: 3px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.par-body { flex: 1; padding: 4px 20px 12px; display: flex; flex-direction: column; }
.ob-mini { display: grid; grid-template-columns: minmax(0, 1fr) 88px 46px; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; color: inherit; }
.ob-mini .n { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-mini .d { font-size: 12px; }
.ob-mini .p { text-align: right; font-size: 13.5px; font-weight: 700; }
.corso-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; border-left: 5px solid; }
.agg-riga { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; padding: 12px 0; }
.frase-card { border-radius: 20px; padding: 24px; background: var(--ink); color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; }
.frase-card blockquote { margin: 0; font-size: 19px; line-height: 1.45; font-weight: 600; }

/* obiettivi */
.area-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.area-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.area-tile { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; flex: none; }
.tabella { overflow-x: auto; min-width: 0; max-width: 100%; }
.main > *, #lista > *, .area-card > *, .split > * { min-width: 0; }
.tabella .inner { min-width: 820px; }
.tr { display: grid; grid-template-columns: minmax(220px, 2.2fr) 110px 128px 64px minmax(150px, 1.4fr) 96px; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.tr.head { border-top: 0; padding-top: 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tr .nm { display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; }
.tr .nm b { font-weight: 600; }
.tr .nm small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* scheda */
.big-pct { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.tappe-row { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tappe-row .linea { position: absolute; left: 8.33%; right: 8.33%; top: 15px; height: 2px; background: var(--line-2); }
.tappe-row .linea-f { position: absolute; left: 8.33%; top: 15px; height: 2px; }
.tappa-btn { position: relative; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 6px 2px 8px; border-radius: 12px; min-width: 0; }
.tappa-btn:hover { background: #F7F8FB; }
.tappa-list { display: flex; flex-direction: column; }
.tappa-li { display: grid; grid-template-columns: 22px 108px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px 8px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 12px; width: 100%; }
.tappa-li:hover { background: #F7F8FB; }
.tappa-li .tn { font-size: 13.5px; font-weight: 600; }
.tappa-li .tt { font-size: 14px; color: var(--ink-2); }
.storia-li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding: 12px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 14px; padding: 12px 16px; font-size: 14px; font-weight: 600; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow-up); z-index: 60; max-width: calc(100vw - 32px); }
.toast button { background: none; border: 0; color: #A5B4FC; font-weight: 700; cursor: pointer; padding: 6px; }

/* nuovo */
.start-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.start-chips button { border: 0; min-height: 40px; padding: 0 14px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; background: #F4F5FA; color: var(--ink-2); }
.start-chips button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* andamento */
.legenda { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--ink-2); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }

/* vision */
.collage { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.foto { margin: 0; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.foto img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--track); }
.foto figcaption { padding: 12px 14px; font-size: 14px; font-weight: 600; min-height: 46px; }
.foto .azioni { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.foto .azioni button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.92); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.upload { min-height: 220px; border: 2px dashed #D0D3DC; border-radius: 20px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.upload:hover { background: #fff; }

/* modale */
.velo { position: fixed; inset: 0; background: rgba(20,21,27,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; }
.finestra { background: #fff; border-radius: 22px; width: min(560px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-up); }
.finestra h2 { font-size: 20px; font-weight: 700; }
.finestra .spiega { font-size: 14px; color: var(--muted); }
.finestra .azioni { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.finestra .azioni .sx { margin-right: auto; }
.bil-riga { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 12px; align-items: center; padding: 6px 0; }
.bil-riga input { min-height: 40px; border: 1px solid #D9DCE3; border-radius: 10px; padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums; width: 100%; }
.bil-tot { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--ko-bg); color: var(--ko-ink); font-weight: 700; }
.bil-tot.ok { background: var(--ok-bg); color: var(--ok-ink); }
.colori { display: flex; flex-wrap: wrap; gap: 10px; }
.colori button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #D9DCE3; cursor: pointer; }
.colori button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }

/* login */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gate form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.gate .err { color: var(--ko-ink); font-weight: 600; font-size: 14px; min-height: 0; }
.gate .err:empty { display: none; }

/* computer: tutto un po' più compatto */
@media (min-width: 901px) {
  body { zoom: .86; }
  .app { min-height: calc(100vh / .86); }
  .side { min-height: calc(100vh / .86 - 32px); }
}

/* telefono */
@media (max-width: 900px) {
  .app { flex-direction: column; padding: 0; gap: 0; align-items: stretch; }
  .side { position: static; width: 100%; min-height: 0; border-radius: 0 0 20px 20px; padding: 12px 16px; gap: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .logo { padding: 0; }
  .side .side-piano { order: 2; flex: 1 1 160px; padding: 0; }
  .side .side-piano label { display: none; }
  .nav { order: 3; flex-direction: row; width: 100%; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { height: 38px; padding: 0 12px; flex: none; font-size: 13.5px; }
  .nav a .cnt { margin-left: 4px; }
  .chat-hint { display: none; }
  .utente { order: 1; margin-left: auto; padding: 0; }
  .utente .chi { display: none; }
  .main { padding: 16px 16px 40px; }
  .cerca input { width: 100%; }
  .page-head .azioni { width: 100%; }
  .page-head .azioni > * { flex: 1 1 auto; }
  .tappa-li { grid-template-columns: 22px minmax(0, 1fr); }
  .tappa-li .tt { grid-column: 2; }
  .tappe-row .tn-lab { font-size: 11.5px !important; }
}
