:root {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --ink: #0F172A;
  --ink-2: #475569;
  --ink-3: #94A3B8;
  --line: #E2E8F0;
  --brand: #0F172A;
  --accent: #2563EB;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);

  /* Fasi del percorso */
  --s-ingresso: #0EA5E9; --s-ingresso-bg: #E0F2FE; --s-ingresso-ink: #075985;
  --s-dpe: #8B5CF6;      --s-dpe-bg: #EDE9FE;      --s-dpe-ink: #5B21B6;
  --s-preventivo: #F59E0B; --s-preventivo-bg: #FEF3C7; --s-preventivo-ink: #92400E;
  --s-accettato: #10B981; --s-accettato-bg: #D1FAE5; --s-accettato-ink: #065F46;
  --s-perso: #64748B;    --s-perso-bg: #E2E8F0;    --s-perso-ink: #334155;

  /* Pagamenti */
  --p-anticipato: #059669; --p-anticipato-bg: #D1FAE5;
  --p-finanziamento: #2563EB; --p-finanziamento-bg: #DBEAFE;
  --p-pagodil: #C026D3; --p-pagodil-bg: #FAE8FF;
  --p-stripe: #6366F1; --p-stripe-bg: #E0E7FF;

  --danger: #DC2626; --danger-bg: #FEE2E2;
  --warn: #D97706; --warn-bg: #FEF3C7;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1,h2,h3,h4 { margin: 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 12px 22px; background: rgba(255,255,255,.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: 8px; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; }
.brand-title { font-weight: 800; letter-spacing: .3px; }
.brand-sub { font-size: 12px; color: var(--ink-2); }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 14px; }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--ink-2); }
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: transform .08s ease, background .15s; white-space: nowrap; }
.btn:hover { background: #F8FAFC; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #1E293B; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #FECACA; background: #fff; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }

main { padding: 20px 22px 60px; max-width: 1600px; margin: 0 auto; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { border-radius: var(--radius); padding: 16px 18px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow); min-height: 104px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi .k-label { font-size: 12.5px; font-weight: 600; opacity: .9; text-transform: uppercase; letter-spacing: .4px; }
.kpi .k-value { font-size: 30px; font-weight: 800; line-height: 1.05; margin-top: 6px; }
.kpi .k-sub { font-size: 12.5px; opacity: .9; margin-top: 4px; }
.kpi .k-icon { position: absolute; right: 14px; top: 12px; font-size: 26px; opacity: .55; }
.kpi.ingresso { background: linear-gradient(135deg, #0EA5E9, #0284C7); }
.kpi.dpe { background: linear-gradient(135deg, #8B5CF6, #6D28D9); }
.kpi.preventivo { background: linear-gradient(135deg, #F59E0B, #D97706); }
.kpi.accettato { background: linear-gradient(135deg, #10B981, #059669); }
.kpi.tasso { background: linear-gradient(135deg, #0F172A, #334155); }
.kpi.anno { background: linear-gradient(135deg, #2563EB, #1D4ED8); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { flex: 1; min-width: 220px; max-width: 420px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.chip-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-2); }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(250px, 1fr)); gap: 14px; align-items: start; overflow-x: auto; padding-bottom: 10px; }
.col { border-radius: var(--radius); padding: 10px; min-height: 300px; background: var(--col-bg); border: 1.5px solid transparent; transition: border-color .15s; }
.col.drop { border-color: var(--col-accent); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 10px; }
.col-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--col-accent); box-shadow: 0 0 0 4px rgba(255,255,255,.6); }
.col-head h3 { font-size: 14.5px; font-weight: 800; color: var(--col-ink); letter-spacing: .2px; }
.col-head .count { margin-left: auto; background: #fff; color: var(--col-ink); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 700; }
.col-head .sum { font-size: 12px; color: var(--col-ink); font-weight: 700; background: rgba(255,255,255,.7); border-radius: 8px; padding: 2px 7px; }
.col-sub { font-size: 12px; color: var(--col-ink); opacity: .85; padding: 0 8px 10px; margin-top: -6px; }
.col-empty { text-align: center; color: var(--col-ink); opacity: .6; font-size: 13px; padding: 26px 10px; border: 1.5px dashed rgba(0,0,0,.12); border-radius: 14px; }

.card { background: #fff; border-radius: 14px; padding: 12px 12px 10px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; border-left: 5px solid var(--col-accent); transition: transform .1s, box-shadow .1s; position: relative; }
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(15,23,42,.10); }
.card.dragging { opacity: .5; }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-top > div:nth-child(2) { min-width: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex-shrink: 0; background: var(--col-accent); }
.card-name { font-weight: 800; font-size: 14.5px; line-height: 1.2; }
.card-meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; }
.card-amount { margin-left: auto; text-align: right; }
.card-amount .amt { font-weight: 800; font-size: 16px; color: var(--ink); white-space: nowrap; }
.card-amount .amt.empty { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #F1F5F9; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; line-height: 1.3; }
.badge.pay-anticipato { background: var(--p-anticipato-bg); color: var(--p-anticipato); }
.badge.pay-finanziamento { background: var(--p-finanziamento-bg); color: var(--p-finanziamento); }
.badge.pay-pagodil { background: var(--p-pagodil-bg); color: var(--p-pagodil); }
.badge.pay-stripe { background: var(--p-stripe-bg); color: var(--p-stripe); }
.badge.dpe-ok { background: var(--s-dpe-bg); color: var(--s-dpe-ink); }
.badge.dpe-no { background: var(--danger-bg); color: var(--danger); }
.badge.alfa { background: #ECFEFF; color: #0E7490; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.time { background: #F8FAFC; color: var(--ink-2); border: 1px solid var(--line); }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; font-size: 11.5px; color: var(--ink-3); }
.card-foot .next { color: var(--ink-2); font-weight: 600; }
.card-foot .next.overdue { color: var(--danger); }
.card-foot .days { font-weight: 600; }
.card-foot .days.hot { color: var(--danger); }
.card .quick { display: flex; gap: 6px; margin-top: 8px; }
.card .quick .btn { flex: 1; justify-content: center; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); z-index: 50; display: flex; justify-content: flex-end; }
.modal { width: min(680px, 100%); height: 100%; background: var(--bg); overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.2); animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { position: sticky; top: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); padding: 14px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; z-index: 2; }
.modal-head h2 { font-size: 18px; font-weight: 800; flex: 1; }
.modal-body { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; }
.section { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section h3 .sq { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: #F8FAFC; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #BFDBFE; border-color: #93C5FD; background: #fff; }
.field textarea { min-height: 74px; resize: vertical; }
.field.full { grid-column: 1 / -1; }
.amount-input { position: relative; }
.amount-input input { font-size: 22px; font-weight: 800; padding-left: 38px; }
.amount-input::before { content: "€"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-weight: 800; color: var(--ink-2); font-size: 18px; }

/* Stepper fasi */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.step { border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; background: #fff; cursor: pointer; transition: all .12s; }
.step .s-ico { font-size: 20px; }
.step .s-name { font-size: 12px; font-weight: 800; margin-top: 2px; }
.step .s-date { font-size: 11px; color: var(--ink-3); margin-top: 2px; min-height: 14px; }
.step.done { border-color: var(--c); background: var(--cbg); color: var(--cink); }
.step.current { border-color: var(--c); background: var(--c); color: #fff; box-shadow: 0 6px 16px -4px var(--c); }
.step.current .s-date { color: rgba(255,255,255,.85); }
.step.locked { opacity: .55; cursor: not-allowed; }
.step-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.lost-btn { border: 1.5px dashed var(--line); background: transparent; color: var(--ink-2); border-radius: 10px; padding: 8px 12px; font-weight: 600; font-size: 13px; }
.lost-btn.on { background: var(--s-perso-bg); border-style: solid; border-color: var(--s-perso); color: var(--s-perso-ink); }

/* Opzioni a bottoni (orari, pagamento) */
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 12px; background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.opt.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.opt.pay.on.anticipato { background: var(--p-anticipato); border-color: var(--p-anticipato); }
.opt.pay.on.finanziamento { background: var(--p-finanziamento); border-color: var(--p-finanziamento); }
.opt.pay.on.pagodil { background: var(--p-pagodil); border-color: var(--p-pagodil); }
.opt.pay.on.stripe { background: var(--p-stripe); border-color: var(--p-stripe); }
.opt.big { padding: 10px 16px; font-size: 14px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; align-items: baseline; }
.timeline .t-date { color: var(--ink-3); min-width: 92px; font-variant-numeric: tabular-nums; }
.timeline .t-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; position: relative; top: 2px; }

.modal-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.danger-zone { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Finanza ---------- */
.fin-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.fin-head h2 { font-size: 20px; font-weight: 800; }
.year-pick { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.year-pick button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font-weight: 700; color: var(--ink-2); }
.year-pick button.on { background: var(--ink); color: #fff; }
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.panel .sub { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { transition: opacity .12s; }
.chart .bar:hover { opacity: .8; }
.chart text { font-family: inherit; fill: var(--ink-2); font-size: 12px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .lbl { font-weight: 700; fill: var(--ink); font-size: 12px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 8px; transform: translate(-50%, -110%); white-space: nowrap; opacity: 0; transition: opacity .1s; }
.tip.show { opacity: 1; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
table.fin { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.fin th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.fin td { padding: 9px 10px; border-bottom: 1px solid #F1F5F9; font-variant-numeric: tabular-nums; }
table.fin td.num, table.fin th.num { text-align: right; }
table.fin tr.total td { font-weight: 800; border-top: 2px solid var(--line); }
.delta.up { color: #059669; font-weight: 700; } .delta.down { color: var(--danger); font-weight: 700; }
.mix { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.mix .m { border-radius: 12px; padding: 12px; }
.mix .m .ml { font-size: 12px; font-weight: 700; }
.mix .m .mv { font-size: 20px; font-weight: 800; margin-top: 2px; }
.mix .m .ms { font-size: 12px; opacity: .85; }
.m.anticipato { background: var(--p-anticipato-bg); color: var(--p-anticipato); }
.m.finanziamento { background: var(--p-finanziamento-bg); color: var(--p-finanziamento); }
.m.pagodil { background: var(--p-pagodil-bg); color: var(--p-pagodil); }
.m.stripe { background: var(--p-stripe-bg); color: var(--p-stripe); }
.m.nd { background: #F1F5F9; color: var(--ink-2); }

/* ---------- Impostazioni ---------- */
.status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 11px; font-weight: 700; font-size: 13px; }
.status-pill.ok { background: var(--s-accettato-bg); color: var(--s-accettato-ink); }
.status-pill.ko { background: var(--danger-bg); color: var(--danger); }
.status-pill.wait { background: #F1F5F9; color: var(--ink-2); }
.code { background: #0F172A; color: #E2E8F0; border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; line-height: 1.5; }
.steps-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 90vw; }
.toast.err { background: var(--danger); }
.toast.ok { background: #059669; }

.empty-state { text-align: center; padding: 40px; color: var(--ink-2); }
.demo-banner { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; border-radius: 12px; padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.demo-banner .btn { margin-left: auto; }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(5, 270px); }
}
@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand-sub { display: none; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1; justify-content: center; }
  main { padding: 14px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi { min-height: 84px; padding: 12px 12px; border-radius: 14px; }
  .kpi .k-value { font-size: 22px; }
  .kpi .k-label { font-size: 11px; }
  .kpi .k-sub { font-size: 11.5px; }
  .kpi .k-icon { font-size: 18px; right: 10px; top: 8px; }
  .board { grid-template-columns: repeat(5, 86vw); }
}

/* ---------- Messaggi WhatsApp ---------- */
.tab-badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 800; margin-left: 4px; }
.badge.wa-due { background: #DCFCE7; color: #166534; }
.badge.wa-next { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.btn.wa { background: #25D366; border-color: #25D366; color: #fff; text-decoration: none; }
.btn.wa:hover { background: #1EBE5A; }
.count-pill { background: var(--bg); color: var(--ink-2); border-radius: 999px; padding: 2px 9px; font-size: 12px; margin-left: 6px; }
.msg { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F1F5F9; }
.msg:last-child { border-bottom: 0; }
.msg.due { background: linear-gradient(90deg, #F0FDF4, transparent); margin: 0 -8px; padding: 12px 8px; border-radius: 12px; }
.msg.sent, .msg.skipped { opacity: .7; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; }
.msg-name { cursor: pointer; }
.msg-name:hover { text-decoration: underline; }
.msg-date { margin-left: auto; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.msg-text { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: 0 12px 12px 12px; padding: 9px 12px; max-width: 70ch; line-height: 1.45; }
.msg-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.wa-step { background: #F8FAFC; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
code { background: #F1F5F9; padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }

.kpi.soglia { background: linear-gradient(135deg, #DC2626, #B91C1C); }
.soglia-box { font-size: 20px; font-weight: 800; padding: 8px 0; }
.soglia-box span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* ---------- Barra pareggio sempre visibile ---------- */
.soglia-bar { position: sticky; top: 64px; z-index: 19; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 9px 22px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.soglia-bar.red { background: #DC2626; color: #fff; }
.soglia-bar.green { background: #059669; color: #fff; }
.soglia-bar.muted { background: #F8FAFC; color: var(--ink-2); font-size: 13px; }
.soglia-bar .sb-main { font-weight: 700; font-size: 16px; }
.soglia-bar .sb-main b { font-size: 20px; font-weight: 800; }
.soglia-bar .sb-sub { opacity: .9; font-size: 13px; }
.soglia-bar .sb-track { margin-left: auto; width: 220px; height: 8px; background: rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; }
.soglia-bar .sb-track i { display: block; height: 100%; background: #fff; border-radius: 999px; }
@media (max-width: 720px) { .soglia-bar { position: static; padding: 8px 14px; } .soglia-bar .sb-track { width: 100%; margin-left: 0; } }

.fatt-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px 10px; }
.amount-input.small input { font-size: 16px; font-weight: 700; padding-left: 30px; }
.amount-input.small::before { font-size: 14px; left: 11px; }
.mode-pick button.on { background: #2563EB; }
table.fin tr.cur td { background: #EFF6FF; }
@media (max-width: 1000px) { .fatt-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) { .fatt-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Categorie messaggi / scheduler / libreria ---------- */
.sch { width: min(760px, 96vw); max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: slidein .18s ease-out; }
.msg { border-left: 4px solid var(--cat, transparent); padding-left: 10px; }
.chip.tag { font-size: 12.5px; }
.lib-cat { background: #F8FAFC; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.lib-cat-h { font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.lib-tag { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }

.tag-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
mark { background: #FDE68A; color: inherit; padding: 0 2px; border-radius: 3px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2.5px var(--ink); transform: scale(1.1); }
#tag-color-custom { width: 34px; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.chip.tag { display: inline-flex; align-items: center; }
/* ---------- Campagne festività ---------- */
.camp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.camp { background: #FFF1F2; border: 1px solid #FECDD3; border-radius: 14px; padding: 12px 14px; }
.camp-h { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.camp-ico { font-size: 26px; }
.camp-text { font-size: 12.5px; color: var(--ink-2); background: #fff; border-radius: 0 10px 10px 10px; padding: 8px 10px; border: 1px solid #FECDD3; }

/* ---------- Schermata di accensione (cockpit) ---------- */
.boot { position: fixed; inset: 0; z-index: 200; background: radial-gradient(1200px 700px at 50% 30%, #13213F 0%, #0B1226 55%, #070B18 100%); color: #E2E8F0; display: flex; align-items: center; justify-content: center; overflow: hidden; transition: opacity .6s ease, visibility .6s; }
.boot[hidden] { display: none; }
.boot.off { opacity: 0; visibility: hidden; }
.boot-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(96,165,250,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(96,165,250,.07) 1px, transparent 1px); background-size: 48px 48px; mask-image: radial-gradient(circle at 50% 40%, #000 30%, transparent 75%); }
.boot-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; padding: 24px; animation: bootfade .6s ease-out; }
@keyframes bootfade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.boot-logo svg { border-radius: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06); }
.boot-title { margin-top: 14px; font-size: 30px; font-weight: 800; letter-spacing: 4px; }
.boot-title span { color: #93C5FD; font-weight: 600; }
.boot-sub { font-size: 13px; color: #94A3B8; margin-top: 4px; letter-spacing: .5px; }
.start-btn { position: relative; width: 168px; height: 168px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; margin-top: 6px; outline: none; }
.start-btn:focus-visible .start-core { box-shadow: 0 0 0 4px #93C5FD; }
.start-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(147,197,253,.35); box-shadow: 0 0 40px rgba(59,130,246,.25), inset 0 0 30px rgba(59,130,246,.15); animation: ringpulse 2.2s ease-in-out infinite; }
@keyframes ringpulse { 0%,100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.06); opacity: 1; } }
.start-core { position: absolute; inset: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 24px; letter-spacing: 3px; color: #fff; background: radial-gradient(circle at 35% 30%, #EF4444, #991B1B 70%); box-shadow: 0 10px 30px rgba(239,68,68,.35), inset 0 -8px 18px rgba(0,0,0,.35), inset 0 6px 14px rgba(255,255,255,.18); transition: transform .1s, background .3s, box-shadow .3s; }
.start-btn:hover .start-core { transform: scale(1.03); }
.start-btn:active .start-core { transform: scale(.96); }
.start-btn.on .start-core { background: radial-gradient(circle at 35% 30%, #34D399, #047857 70%); box-shadow: 0 0 50px rgba(16,185,129,.55), inset 0 -8px 18px rgba(0,0,0,.35), inset 0 6px 14px rgba(255,255,255,.18); }
.start-btn.on .start-ring { border-color: rgba(52,211,153,.7); box-shadow: 0 0 70px rgba(16,185,129,.45); animation: none; }
.boot-hint { font-size: 13px; color: #94A3B8; letter-spacing: 1px; text-transform: uppercase; }
.boot-check { list-style: none; margin: 0; padding: 0; width: min(440px, 90vw); text-align: left; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; }
.boot-check li { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px solid rgba(148,163,184,.12); opacity: 0; transform: translateX(-8px); animation: chk .35s ease-out forwards; }
@keyframes chk { to { opacity: 1; transform: none; } }
.boot-check .led { width: 11px; height: 11px; border-radius: 50%; background: #F59E0B; box-shadow: 0 0 10px #F59E0B; flex-shrink: 0; transition: background .25s, box-shadow .25s; }
.boot-check li.ok .led { background: #22C55E; box-shadow: 0 0 12px #22C55E; }
.boot-check li.warn .led { background: #F59E0B; }
.boot-check li.ko .led { background: #EF4444; box-shadow: 0 0 12px #EF4444; }
.boot-check .lbl { flex: 1; color: #CBD5E1; }
.boot-check .val { color: #F8FAFC; font-weight: 700; }
.boot-bar { width: min(440px, 90vw); height: 6px; border-radius: 999px; background: rgba(148,163,184,.2); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #0EA5E9, #8B5CF6, #10B981); transition: width .4s ease; }
.boot-skip { background: transparent; border: 1px solid rgba(148,163,184,.3); color: #94A3B8; border-radius: 999px; padding: 5px 12px; font-size: 12px; }
.boot-foot { position: absolute; bottom: 16px; left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 22px; font-size: 12px; color: #64748B; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .start-ring { animation: none; } .boot-inner { animation: none; } }
/* accensione dei quadri dopo lo START */
.kpis.power-on .kpi { animation: poweron .55s cubic-bezier(.2,.8,.2,1) both; }
@keyframes poweron { 0% { opacity: 0; transform: translateY(10px) scale(.97); filter: brightness(1.6); } 60% { filter: brightness(1.15); } 100% { opacity: 1; transform: none; filter: none; } }
.kpis.power-on .kpi:nth-child(1) { animation-delay: .05s } .kpis.power-on .kpi:nth-child(2) { animation-delay: .15s } .kpis.power-on .kpi:nth-child(3) { animation-delay: .25s } .kpis.power-on .kpi:nth-child(4) { animation-delay: .35s } .kpis.power-on .kpi:nth-child(5) { animation-delay: .45s } .kpis.power-on .kpi:nth-child(6) { animation-delay: .55s }

/* ---------- Cockpit: scenografia ---------- */
.boot-stars { position: absolute; inset: 0; background-image: radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,255,255,.55) 50%, transparent 51%), radial-gradient(1px 1px at 30% 70%, rgba(255,255,255,.4) 50%, transparent 51%), radial-gradient(1.5px 1.5px at 55% 12%, rgba(255,255,255,.5) 50%, transparent 51%), radial-gradient(1px 1px at 72% 40%, rgba(255,255,255,.45) 50%, transparent 51%), radial-gradient(1.5px 1.5px at 86% 78%, rgba(255,255,255,.5) 50%, transparent 51%), radial-gradient(1px 1px at 40% 88%, rgba(255,255,255,.35) 50%, transparent 51%), radial-gradient(1px 1px at 64% 62%, rgba(255,255,255,.4) 50%, transparent 51%), radial-gradient(1.5px 1.5px at 8% 55%, rgba(255,255,255,.4) 50%, transparent 51%), radial-gradient(1px 1px at 92% 22%, rgba(255,255,255,.45) 50%, transparent 51%); animation: twinkle 4s ease-in-out infinite alternate; pointer-events: none; }
@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }
.boot-horizon { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; background: linear-gradient(to top, rgba(37,99,235,.18), transparent); pointer-events: none; }
.boot-horizon::before { content: ""; position: absolute; left: 10%; right: 10%; top: 0; height: 2px; background: linear-gradient(90deg, transparent, rgba(147,197,253,.7), transparent); box-shadow: 0 0 24px rgba(59,130,246,.6); }
.boot-scan { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, transparent, rgba(52,211,153,.9), transparent); box-shadow: 0 0 18px rgba(52,211,153,.8); animation: scan 2.4s linear infinite; pointer-events: none; }
.boot-scan[hidden] { display: none; }
@keyframes scan { from { transform: translateY(0); } to { transform: translateY(100vh); } }
.boot.armed .boot-grid { animation: gridpulse 1.2s ease-in-out infinite alternate; }
@keyframes gridpulse { from { opacity: .7; } to { opacity: 1.2; } }
.boot.armed .boot-title { text-shadow: 0 0 18px rgba(147,197,253,.8), 0 0 40px rgba(59,130,246,.5); transition: text-shadow .6s; }
.gauges { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.gauges[hidden] { display: none; }
.gauge { width: 170px; text-align: center; animation: gaugein .5s ease-out both; }
.gauge:nth-child(2) { animation-delay: .12s } .gauge:nth-child(3) { animation-delay: .24s }
@keyframes gaugein { from { opacity: 0; transform: translateY(14px) scale(.95); } to { opacity: 1; transform: none; } }
.gauge svg { width: 170px; height: 102px; overflow: visible; }
.g-track { fill: none; stroke: rgba(148,163,184,.18); stroke-width: 12; stroke-linecap: round; }
.g-arc { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 251.3; stroke-dashoffset: 251.3; transition: stroke-dashoffset 1.6s cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 0 8px rgba(96,165,250,.5)); }
.g-ticks line { stroke: rgba(226,232,240,.55); stroke-width: 2; }
.g-needle { stroke: #F8FAFC; stroke-width: 3; stroke-linecap: round; transform-origin: 100px 110px; transform: rotate(-90deg); transition: transform 1.7s cubic-bezier(.3,1.4,.4,1); filter: drop-shadow(0 0 6px rgba(255,255,255,.7)); }
.g-hub { fill: #F8FAFC; }
.g-val { font-size: 26px; font-weight: 800; margin-top: -6px; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.g-lbl { font-size: 11px; color: #94A3B8; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; }
.boot-ready { font-size: 20px; font-weight: 800; letter-spacing: 3px; color: #34D399; text-shadow: 0 0 20px rgba(52,211,153,.7); animation: readyin .5s ease-out; }
@keyframes readyin { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.boot.off .boot-inner { transform: scale(1.04); opacity: 0; transition: transform .7s ease, opacity .6s; }
@media (prefers-reduced-motion: reduce) { .boot-scan, .boot-stars, .boot.armed .boot-grid { animation: none; } .g-needle, .g-arc { transition: none; } }

/* ---------- Cloud badge, login, vista Oggi ---------- */
.cloud-badge { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 5px 10px; background: #F1F5F9; color: var(--ink-2); white-space: nowrap; }
.cloud-badge.on { background: #DCFCE7; color: #166534; } .cloud-badge.sync { background: #DBEAFE; color: #1E40AF; } .cloud-badge.err { background: var(--danger-bg); color: var(--danger); }
.login { position: fixed; inset: 0; z-index: 300; background: rgba(7,11,24,.78); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login[hidden] { display: none; }
.login-card { background: #fff; border-radius: 22px; padding: 28px 26px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.45); text-align: center; }
.login-card svg { margin: 0 auto; border-radius: 18px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.login-card h2 { font-size: 22px; font-weight: 800; }
.login-card label { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.login-card input { padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: #F8FAFC; font-size: 15px; }
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; font-weight: 600; }
.today-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.today-head h2 { font-size: 20px; font-weight: 800; text-transform: capitalize; }
.today-kpis .kpi { cursor: pointer; }
.today-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #F1F5F9; }
.today-item:last-child { border-bottom: 0; }
.ti-main { flex: 1; min-width: 0; }
.ti-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.ti-head b { cursor: pointer; } .ti-head b:hover { text-decoration: underline; }
.ti-right { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.ti-body { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.ti-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ti-actions .btn { padding: 9px 13px; font-size: 14px; }
@media (max-width: 720px) { .ti-actions .btn { flex: 1; justify-content: center; } .cloud-badge { display: none; } }
@media (max-width: 720px) { .tabs { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; } .tab { padding: 8px 11px; font-size: 14px; white-space: nowrap; } .topbar-actions .btn { font-size: 14px; } }
/* ---------- Blocco PIN ---------- */
.lock-input { text-align: center; font-size: 26px; letter-spacing: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: #F8FAFC; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0; }
.keypad .key { font-size: 20px; font-weight: 700; padding: 12px 0; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.keypad .key:active { background: #F1F5F9; }
.keypad .key.ok { background: var(--ink); color: #fff; border-color: var(--ink); }
.keypad .key.muted { color: var(--ink-2); }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.login-remember { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px; font-size: 13.5px !important; font-weight: 600 !important; color: var(--ink-2); cursor: pointer; }
.login-remember input { width: 18px; height: 18px; accent-color: #0F172A; }
/* ---------- Ricerca globale ---------- */
.gsearch { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.gsearch input { width: 100%; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: #F8FAFC; font-size: 14px; }
.gsearch input:focus { outline: 2px solid #BFDBFE; border-color: #93C5FD; background: #fff; }
.gsearch-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 40px rgba(15,23,42,.18); z-index: 60; max-height: 420px; overflow-y: auto; padding: 6px; }
.gsearch-results[hidden] { display: none; }
.gs-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.gs-item:hover, .gs-item.active { background: #F1F5F9; }
.gs-item .avatar { width: 30px; height: 30px; font-size: 11px; }
.gs-name { font-weight: 700; font-size: 14px; }
.gs-meta { font-size: 12px; color: var(--ink-2); }
.gs-stage { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.gs-empty { padding: 12px; font-size: 13px; color: var(--ink-2); text-align: center; }
.gs-item mark { background: #FDE68A; border-radius: 3px; padding: 0 1px; }
@media (max-width: 720px) { .gsearch { max-width: none; width: 100%; order: 5; } }
/* ---------- Obiettivi ---------- */
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.goal { background: #F8FAFC; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.goal.big { grid-column: 1 / -1; background: linear-gradient(135deg, #F5F3FF, #EEF2FF); border-color: #DDD6FE; }
.goal-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; margin-bottom: 8px; }
.goal-h b { font-size: 16px; font-variant-numeric: tabular-nums; }
.goal-track { height: 12px; border-radius: 999px; background: #E2E8F0; overflow: hidden; }
.goal-track i { display: block; height: 100%; border-radius: 999px; transition: width .6s ease; }
.goal-pct { font-size: 12px; font-weight: 800; color: var(--ink-2); margin: 4px 0 2px; }
@media (max-width: 720px) { .goals { grid-template-columns: 1fr; } }
