:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e3e7ee;
  --nav: #16263d;
  --nav-ink: #c9d3e1;
  --accent: #2563eb;
  --pos: #0f7a3d;
  --neg: #c0262d;
  --c: #dbeafe;   /* consuntivo (azzurro, come nei file del cliente) */
  --p: #dcfce7;   /* previsionale (verde) */
  --a: #fef3c7;   /* anno precedente (giallo) */
  --d: #fde7e1;   /* differenze (rosso chiaro) */
  --sub: #eef2f7;
  --warn-bg: #fff7e6;
  --warn: #9a5b00;
  --err-bg: #fdecec;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
  display: grid; grid-template-columns: 224px minmax(0, 1fr); grid-template-rows: 56px 1fr; min-height: 100vh;
}
body.senza-menu { grid-template-columns: minmax(0, 1fr); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- barra superiore --- */
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 50; height: 56px; background: var(--nav); color: #fff;
  display: flex; align-items: center; gap: 18px; padding: 0 18px; box-shadow: 0 1px 0 rgba(255,255,255,.06); }
.topbar .brand { color: #fff; display: flex; flex-direction: column; line-height: 1.1; min-width: 190px; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand b { font-size: 16px; letter-spacing: .3px; }
.topbar .brand span { font-size: 11px; opacity: .7; }
.topbar details { position: relative; }
.topbar summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 7px 12px;
  border-radius: 8px; color: var(--nav-ink); font-weight: 550; }
.topbar summary::-webkit-details-marker { display: none; }
.topbar summary:hover, .topbar details[open] summary { background: rgba(255,255,255,.08); color: #fff; }
.topbar .caret { font-size: 11px; opacity: .7; }
.topbar .menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 300px; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 40px rgba(15,23,42,.18); padding: 6px; z-index: 60; }
.topbar .menu.right { left: auto; right: 0; min-width: 200px; }
.topbar .menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--ink); }
.topbar .menu a:hover { background: #f1f5f9; text-decoration: none; }
.topbar .menu a.on { background: #e8f0fe; color: #1d4ed8; font-weight: 600; }
.topbar .menu a.voce-home { color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); border-radius: 7px 7px 0 0; margin-bottom: 4px; }
.topbar .menu i.badge { font-style: normal; margin-left: 4px; }
.usermenu summary { padding: 4px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #2563eb; color: #fff; display: grid; place-items: center; font-weight: 700; }
.who { display: flex; flex-direction: column; line-height: 1.15; }
.who b { color: #fff; font-size: 13px; } .who small { font-size: 11px; opacity: .75; }
@media (max-width: 900px) { .who { display: none; } .topbar .brand { min-width: 0; } }

/* --- menu laterale unico (strumenti abilitati) --- */
nav.side { background: #fff; border-right: 1px solid var(--line); padding: 12px 0 24px; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto; }
nav.side a.voce { display: flex; align-items: center; gap: 8px; color: #334155; padding: 7px 18px 7px 42px; font-size: 13.5px;
  border-left: 3px solid transparent; }
nav.side a.voce:hover { background: #f8fafc; text-decoration: none; }
nav.side a.voce.on { background: #eef4ff; border-left-color: var(--accent); color: #1d4ed8; font-weight: 600; }
nav.side a.voce.home { padding-left: 18px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
nav.side a.voce.home svg { color: #64748b; }
nav.side .sezione { padding: 10px 0 6px; border-top: 1px solid var(--line); }
nav.side .sez-titolo { display: flex; align-items: center; gap: 8px; padding: 2px 18px 6px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: #64748b; }
nav.side .sez-titolo svg { flex: none; }
nav.side .sez-titolo span { flex: 1; }
nav.side .sez-titolo i.badge { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 10.5px; }
nav.side .sezione.corrente .sez-titolo { color: #1d4ed8; }
nav.side .sezione.admin .sez-titolo { color: #4338ca; }
nav.side .vuoto { padding: 12px 18px; color: var(--muted); font-size: 13px; }

/* --- home a riquadri --- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  color: var(--ink); transition: box-shadow .15s, transform .15s, border-color .15s; min-height: 170px; }
a.tile:hover { text-decoration: none; border-color: #bcd0f7; box-shadow: 0 8px 24px rgba(37,99,235,.12); transform: translateY(-2px); }
.tile .ico { width: 42px; height: 42px; border-radius: 10px; background: #eef4ff; color: #1d4ed8; display: grid; place-items: center; }
.tile h3 { margin: 0; font-size: 16px; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; flex: 1; }
.tile .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.tile.off { opacity: .6; background: #f8fafc; }
.tile.off .ico { background: #f1f5f9; color: #64748b; }
.area { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

/* --- login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #16263d 0%, #23426b 100%); padding: 16px; }
.login-box { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 30px 60px rgba(0,0,0,.25); }
.login-box h1 { margin-bottom: 2px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.login-box input { width: 100%; }
.login-box button { width: 100%; justify-content: center; margin-top: 20px; min-height: 40px; }

main { padding: 22px 28px 60px; min-width: 0; }
header.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.sub { color: var(--muted); font-size: 13px; }

.filtri { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filtri label, .campo { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; text-transform: uppercase; letter-spacing: .4px; }
select, input[type=text], input[type=password], input[type=email], input[type=number], input[type=month], input[type=file] {
  font: inherit; font-size: 14px; padding: 6px 9px; border: 1px solid #cfd6e0; border-radius: 7px; background: #fff; color: var(--ink); min-height: 34px;
}
button, .btn {
  font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; white-space: nowrap;
}
.btn.sec, button.sec { background: #fff; color: var(--accent); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn:hover { text-decoration: none; filter: brightness(1.05); }
button.small, .btn.small { padding: 3px 9px; font-size: 12px; min-height: 26px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1100px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* --- KPI --- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .t { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi .v { font-size: 24px; font-weight: 650; margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.kpi .r { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding-top: 3px; }
.kpi .r b { font-variant-numeric: tabular-nums; }

/* --- tabelle --- */
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { font-size: 11.5px; font-weight: 650; color: #374151; text-transform: uppercase; letter-spacing: .3px; background: #f8fafc; position: sticky; top: 0; z-index: 1; }
td.l, th.l { text-align: left; }
tr.sub td { background: var(--sub); font-weight: 650; }
tr.sub.big td { background: #dfe7f2; }
th.c, td.c { background: var(--c); } th.p, td.p { background: var(--p); } th.a, td.a { background: var(--a); } th.d, td.d { background: var(--d); }
tr.sub td.c, tr.sub td.p, tr.sub td.a, tr.sub td.d { filter: brightness(.96); }
td.inc { color: var(--muted); font-size: 12px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
td.click { cursor: pointer; }
td.click:hover { text-decoration: underline; }
tr.det td { font-size: 12.5px; color: #4b5563; background: #fbfcfe; }
tr.det td.l { padding-left: 28px; }
table.compact td, table.compact th { padding: 4px 7px; font-size: 12.5px; }
tr.hl td { background: #fff8e1; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
td.wrap { white-space: normal; text-align: left; max-width: 420px; }

/* --- badge e avvisi --- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2f7; color: #374151; white-space: nowrap; }
.badge.ok { background: #e6f6ec; color: var(--pos); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--neg); }
.badge.info { background: #e8f0fe; color: #1d4ed8; }
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; line-height: 1.45; }
.alert.warn { background: var(--warn-bg); color: #6b4200; border: 1px solid #f5d9a6; }
.alert.err { background: var(--err-bg); color: #8a1c21; border: 1px solid #f3c2c4; }
.alert.info { background: #eef4ff; color: #1e3a8a; border: 1px solid #c9dafc; }
.alert.ok { background: #e9f7ef; color: #14532d; border: 1px solid #bfe5cd; }
ul.avvisi { list-style: none; padding: 0; margin: 0; }
ul.avvisi li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
ul.avvisi li:last-child { border: 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; border: 1px solid rgba(0,0,0,.08); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; padding: 8px 0 8px 36px; position: relative; border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 7px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.check { color: var(--pos); font-weight: 700; } .cross { color: var(--neg); font-weight: 700; }

dialog { border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 520px; width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(15,23,42,.35); }
dialog .row { display: flex; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
dialog .row > * { flex: 1; }

/* griglia del budget (Jspreadsheet CE, MIT) */
#griglia { width: 100%; overflow-x: auto; }
#griglia .jexcel { font-size: 12.5px; color: #111; }
#griglia .jexcel > thead > tr > td { background: #f3f4f6; color: #222; font-weight: 600; padding: 4px 6px; white-space: nowrap; }
#griglia .jexcel > tbody > tr > td { padding: 3px 6px; height: 23px; background: #fff; }
#griglia .jexcel > tbody > tr > td.readonly { color: #777; }
#griglia .jexcel > tbody > tr > td.gSub { background: var(--sub); font-weight: 650; }
#griglia .jexcel > tbody > tr > td.gTot { background: #f1f5f9; font-weight: 600; }
#griglia .jexcel > tbody > tr > td.gAp { color: var(--muted); background: #fffbeb; }
#griglia .jexcel > tbody > tr > td.highlight { background-color: rgba(37, 99, 235, .08); }
/* prima colonna (voce) sempre visibile scorrendo in orizzontale */
#griglia .jexcel > thead > tr > td:nth-child(2), #griglia .jexcel > tbody > tr > td:nth-child(2) { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 #ccc; }
#griglia .jexcel > thead > tr > td:nth-child(2) { z-index: 3; }
.salvato { font-size: 12px; color: var(--pos); }

/* --- checklist caricamenti --- */
table.checklist td.ck-cell { text-align: center; padding: 6px 2px; }
.ck { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font-size: 13px; font-weight: 700; text-decoration: none; }
a.ck:hover { text-decoration: none; filter: brightness(.95); }
.ck.ok { background: #dcfce7; color: var(--pos); }
.ck.ok.warn { box-shadow: inset 0 0 0 2px #f5c26b; }
.ck.coperto { background: #eef2f7; color: #64748b; }
.ck.da_caricare { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px #f5d9a6; }
.ck.mancante { background: var(--err-bg); color: var(--neg); }
.ck.futuro { color: #cbd5e1; }
.legend i.ck { width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }

/* --- menu su smartphone / tablet --- */
.hamburger { display: none; background: transparent; border: 0; color: #fff; padding: 6px; min-height: 0; margin-left: -6px; }
.velo { display: none; }
@media (max-width: 860px) {
  body.con-menu { grid-template-columns: minmax(0, 1fr); }
  .hamburger { display: inline-flex; }
  .topbar { gap: 10px; padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .topbar .brand { min-width: 0; }
  .topbar .who small { display: none; }
  nav.side { position: fixed; top: calc(56px + env(safe-area-inset-top)); left: 0; bottom: 0; height: auto; width: 270px; z-index: 45;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 10px 40px rgba(15,23,42,.25); }
  body.menu-aperto nav.side { transform: none; }
  body.menu-aperto .velo { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 44; }
  main { padding: 16px 16px 60px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) { .topbar .who { display: none; } }

/* --- visite punti vendita --- */
:root { --visual: #7c3aed; --visual-bg: #f3edff; --am: #0f766e; --am-bg: #e3f6f3; --stella: #e0a800; }
.badge.cat-visual { background: var(--visual-bg); color: var(--visual); }
.badge.cat-am { background: var(--am-bg); color: var(--am); }
.badge.st-pianificata { background: #e8f0fe; color: #1d4ed8; }
.badge.st-completata { background: #e6f6ec; color: var(--pos); }
.badge.st-annullata { background: #eef2f7; color: #64748b; text-decoration: line-through; }
.badge.st-da_chiudere { background: var(--warn-bg); color: var(--warn); }
.stelle { color: var(--stella); letter-spacing: 1px; white-space: nowrap; }
.stelle .off { color: #d8dde5; }
.voto { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.voto input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.voto label { font-size: 30px; line-height: 1; color: #d8dde5; cursor: pointer; padding: 0 1px; text-transform: none; letter-spacing: 0; }
.voto label:hover, .voto label:hover ~ label, .voto input:checked ~ label { color: var(--stella); }
.voto input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.voci-voto { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 14px; align-items: center; }
.voci-voto .azzera { font-size: 12px; color: var(--muted); background: none; border: 0; padding: 0; min-height: 0; cursor: pointer; }
@media (max-width: 520px) { .voci-voto { grid-template-columns: 1fr auto; } .voci-voto .azzera { grid-column: 2; justify-self: end; } }
textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 7px; width: 100%; min-height: 90px; resize: vertical; color: var(--ink); }
input[type=date], input[type=time] { font: inherit; font-size: 14px; padding: 6px 9px; border: 1px solid #cfd6e0; border-radius: 7px; background: #fff; min-height: 34px; color: var(--ink); }
.campo-l { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.campo-l > span { text-transform: uppercase; letter-spacing: .4px; font-size: 11px; }
.riga-campi { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0 12px; }
.occupati { font-size: 12.5px; margin: -4px 0 12px; }
.occupati li { margin: 2px 0; }
.occupati .lib { color: var(--pos); }
.dlg-err { margin-bottom: 12px; }
dialog.largo { max-width: 620px; }
dialog form h2 { margin-top: 0; }

.lista-visite { display: flex; flex-direction: column; gap: 10px; }
a.visita-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line);
  border-left: 4px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
a.visita-card:hover { text-decoration: none; border-color: #bcd0f7; box-shadow: 0 4px 14px rgba(37,99,235,.08); }
a.visita-card.cat-visual { border-left-color: var(--visual); }
a.visita-card.cat-am { border-left-color: var(--am); }
.visita-card .data { text-align: center; line-height: 1.1; }
.visita-card .data b { display: block; font-size: 20px; }
.visita-card .data small { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.visita-card .cosa b { display: block; }
.visita-card .cosa span { color: var(--muted); font-size: 13px; }
.visita-card .cosa p { margin: 3px 0 0; font-size: 13px; color: #374151; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media (max-width: 520px) { a.visita-card { grid-template-columns: 52px 1fr; } a.visita-card > .badge { grid-column: 2; justify-self: start; } }
.scheda dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.scheda dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding-top: 2px; }
.scheda dd { margin: 0; }
.testo { white-space: pre-wrap; line-height: 1.5; }
@media (max-width: 520px) { .scheda dl { grid-template-columns: 1fr; gap: 2px; } .scheda dd { margin-bottom: 8px; } }
td.allerta { background: #fff7e6; }

/* FullCalendar adattato allo stile del portale */
#calendario { --fc-border-color: var(--line); --fc-today-bg-color: #f5f8ff; --fc-page-bg-color: #fff; --fc-neutral-bg-color: #f8fafc;
  --fc-button-bg-color: #fff; --fc-button-text-color: var(--accent); --fc-button-border-color: #cfd6e0;
  --fc-button-hover-bg-color: #eef4ff; --fc-button-hover-border-color: #bcd0f7;
  --fc-button-active-bg-color: var(--accent); --fc-button-active-border-color: var(--accent); --fc-event-border-color: transparent;
  font-size: 13px; }
#calendario .fc-button { font-size: 13px; padding: 5px 10px; box-shadow: none !important; text-transform: none; }
#calendario .fc-button-active { color: #fff; }
#calendario .fc-toolbar-title { font-size: 17px; font-weight: 650; text-transform: capitalize; }
#calendario .fc-event { cursor: pointer; border-radius: 6px; font-size: 12px; }
#calendario .fc-timegrid-event .fc-event-main { padding: 2px 4px; }
/* le regole generali delle tabelle del portale non devono toccare le tabelle interne del calendario */
#calendario th, #calendario td { text-align: left; white-space: normal; padding: 0; position: static; text-transform: none; letter-spacing: 0; }
#calendario th { background: #f8fafc; font-size: 12px; }
#calendario .fc-col-header-cell-cushion { padding: 6px 4px; }
#calendario .fc-timegrid-slot { height: 2.1em; }
#calendario .fc-timegrid-slot-label-cushion, #calendario .fc-timegrid-axis-cushion { padding: 0 6px; font-size: 12px; color: var(--muted); }
#calendario .fc-list-event td { padding: 8px 10px; }
#calendario .fc-list-day-cushion { padding: 6px 10px; }
#calendario .fc-list-event-time { white-space: nowrap; color: var(--muted); }
#calendario .fc-list-event-title { width: 100%; }
#calendario .fc-list-event-title .muted { font-size: 12px; }
#calendario .fc-timegrid-event.cat-visual, #calendario .fc-daygrid-block-event.cat-visual { background: var(--visual); }
#calendario .fc-timegrid-event.cat-am, #calendario .fc-daygrid-block-event.cat-am { background: var(--am); }
#calendario .fc-list-event.st-completata { opacity: .65; }
#calendario .fc-list-event.st-da_chiudere .fc-list-event-time { color: var(--warn); font-weight: 600; }
#calendario .fc-daygrid-event.cat-visual .fc-daygrid-event-dot { border-color: var(--visual); }
#calendario .fc-daygrid-event.cat-am .fc-daygrid-event-dot { border-color: var(--am); }
#calendario .fc-list-event.cat-visual .fc-list-event-dot { border-color: var(--visual); }
#calendario .fc-list-event.cat-am .fc-list-event-dot { border-color: var(--am); }
#calendario .fc-timegrid-event.st-completata, #calendario .fc-daygrid-block-event.st-completata { opacity: .55; }
#calendario .fc-timegrid-event.st-da_chiudere { box-shadow: inset 0 0 0 2px #f59e0b; }
#calendario .fc-timegrid-event.st-annullata { background: #94a3b8; text-decoration: line-through; opacity: .6; }
#calendario .fc-timegrid-event.mia { box-shadow: inset 3px 0 0 #fff; }
#calendario .fc-list-event:hover td { background: #f8fafc; }
@media (max-width: 860px) {
  #calendario .fc-header-toolbar { flex-wrap: wrap; gap: 8px; }
  #calendario .fc-list-event-graphic { display: none; }
  #calendario .fc-list-event td { padding: 8px 6px; }
  .grid2.dett { grid-template-columns: 1fr !important; }
  #filtri-cal label, #filtri-cal select { width: 100%; }
  #filtri-cal label:nth-child(-n+3) { flex: 1 1 140px; }
  #calendario .fc-toolbar-title { font-size: 15px; }
}

/* --- contatori "Le mie visite" --- */
.contatori { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; max-width: 560px; }
.contatori a { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--ink); display: flex; flex-direction: column; }
.contatori a:hover { text-decoration: none; border-color: #bcd0f7; }
.contatori b { font-size: 22px; line-height: 1.1; }
.contatori span { font-size: 12px; color: var(--muted); }
.contatori a.warn { background: var(--warn-bg); border-color: #f5d9a6; }
.contatori a.warn b { color: var(--warn); }
.esci-app { margin-top: 4px; }

/* --- menu in basso stile app (solo smartphone) --- */
.botnav { display: none; }
@media (max-width: 860px) {
  body.app-nav main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.app-nav .solo-desktop { display: none !important; }
  body.solo-visite .hamburger, body.solo-visite nav.side, body.solo-visite .velo { display: none !important; }
  .botnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff;
    border-top: 1px solid #e6e6ea; box-shadow: 0 -2px 12px rgba(0,0,0,.07); padding-bottom: env(safe-area-inset-bottom); }
  .botnav .bn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px;
    color: #9097a1; -webkit-tap-highlight-color: transparent; }
  .botnav .bn:hover { text-decoration: none; }
  .botnav .bn small { font-size: 11px; font-weight: 600; }
  .botnav .bn.on { color: var(--nav); }
  .botnav .bn.piu { color: var(--accent); }
  .botnav .bn .tondo { width: 44px; height: 44px; margin-top: -20px; border-radius: 50%; background: var(--accent); color: #fff;
    display: grid; place-items: center; box-shadow: 0 6px 16px rgba(37,99,235,.35); border: 3px solid #fff; }

  /* pagine visite più "da app" */
  body.app-nav header.top { margin-bottom: 12px; }
  body.app-nav h1 { font-size: 20px; }
  body.app-nav .panel { padding: 14px; margin-bottom: 14px; border-radius: 12px; }
  body.app-nav .contatori { max-width: none; }
  body.app-nav .sub.indietro { margin-bottom: 4px; }
  body.app-nav header.top .toolbar { width: 100%; }
  body.app-nav header.top .toolbar .btn, body.app-nav header.top .toolbar button { flex: 1; justify-content: center; min-height: 40px; font-size: 13px; }
  body.app-nav a.visita-card { padding: 12px; }
  body.app-nav .pannello-cal { padding: 10px; }
  body.app-nav #filtri-cal { margin-bottom: 10px !important; }
  body.app-nav .esci-app { width: 100%; justify-content: center; min-height: 44px; }
  /* niente zoom automatico di iOS sui campi: almeno 16px */
  body.app-nav select, body.app-nav input, body.app-nav textarea { font-size: 16px; min-height: 42px; }
  body.app-nav main > form.panel, body.app-nav main > .panel { max-width: none !important; }
  body.app-nav .voto label { font-size: 34px; padding: 0 2px; }
  /* modulo visita a tutto schermo */
  body.app-nav dialog.largo { max-width: none; width: 100%; height: 100%; max-height: none; margin: 0; border-radius: 0; border: 0;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
  body.app-nav dialog.largo .toolbar { position: sticky; bottom: 0; background: #fff; padding-top: 10px; }
  body.app-nav dialog.largo .toolbar button { flex: 1; justify-content: center; min-height: 46px; }
  body.app-nav dialog .riga-campi { grid-template-columns: 1fr 1fr; }
  body.app-nav dialog .riga-campi .campo-l:has(input[type=date]) { grid-column: 1 / -1; }
}

/* --- cruscotto squadra (responsabile visite) --- */
.kpi-team { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi-team .kt { background: #fff; border: 1px solid var(--line); border-left: 4px solid #cbd5e1; border-radius: 12px; padding: 12px 14px;
  color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.kpi-team .kt:hover { text-decoration: none; border-color: #bcd0f7; }
.kpi-team .kt > span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi-team .kt > b { font-size: 26px; line-height: 1.15; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; }
.kpi-team .kt > small { font-size: 12px; color: var(--muted); }
.kpi-team .kt.ok { border-left-color: var(--pos); }
.kpi-team .kt.warn { border-left-color: #f59e0b; background: #fffdf7; }
.kpi-team .kt.err { border-left-color: var(--neg); background: #fff8f8; }
.kpi-team .kt.err > b { color: var(--neg); }
.delta { font-size: 12px; font-weight: 600; }
.delta.su { color: var(--pos); } .delta.giu { color: var(--neg); }
i.barra { display: block; height: 6px; border-radius: 3px; background: #eef2f7; overflow: hidden; margin-top: 6px; font-style: normal; }
i.barra > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
i.barra.ok > i { background: var(--pos); } i.barra.warn > i { background: #f59e0b; } i.barra.err > i { background: var(--neg); }

ul.avvisi-team { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
ul.avvisi-team a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink); font-size: 13.5px; }
ul.avvisi-team a:hover { text-decoration: none; filter: brightness(.98); }
ul.avvisi-team li.err a { background: var(--err-bg); }
ul.avvisi-team li.warn a { background: var(--warn-bg); }
ul.avvisi-team a i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
ul.avvisi-team li.err a i { background: var(--neg); } ul.avvisi-team li.warn a i { background: #f59e0b; }
ul.avvisi-team a span { flex: 1; line-height: 1.35; }
ul.avvisi-team a b { color: var(--muted); font-size: 18px; }

.persone-team { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 18px; }
.persona-card .pc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.persona-card .pc-top > div { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.persona-card .pc-top small { color: var(--muted); font-size: 12px; }
.avatar.cat-visual { background: var(--visual); } .avatar.cat-am { background: var(--am); }
.persona-card .avatar { width: 38px; height: 38px; font-size: 16px; flex: none; }
.pc-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-stat > div { background: #f8fafc; border-radius: 9px; padding: 8px 10px; display: flex; flex-direction: column; }
.pc-stat b { font-size: 18px; display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.pc-stat span { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.pc-stat > div.warn { background: var(--warn-bg); } .pc-stat > div.warn b { color: var(--warn); }
.pc-stat > div.err { background: var(--err-bg); } .pc-stat > div.err b { color: var(--neg); }
.pc-nota { margin: 10px 0 0; font-size: 12.5px; }

ul.lista-negozi { list-style: none; padding: 0; margin: 0; }
ul.lista-negozi li { border-bottom: 1px solid var(--line); }
ul.lista-negozi li:last-child { border: 0; }
ul.lista-negozi a { display: flex; flex-direction: column; gap: 2px; padding: 8px 2px; color: var(--ink); }
ul.lista-negozi a:hover { text-decoration: none; background: #f8fafc; }
ul.lista-negozi small { font-size: 12px; color: var(--muted); }
ul.lista-negozi small.err { color: var(--neg); } ul.lista-negozi small.warn { color: var(--warn); } ul.lista-negozi small.ok { color: var(--pos); }
.barre-voci { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr 34px; gap: 10px 12px; align-items: center; font-size: 13px; }
.barre-voci i.barra { margin: 0; height: 9px; }
.barre-voci b { text-align: right; font-variant-numeric: tabular-nums; }

/* --- editor voci nel profilo --- */
.voci-edit h3 { margin: 14px 0 8px; }
.ve-riga { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ve-riga input[type=text] { flex: 1; min-width: 0; }
.ve-riga.spenta input[type=text] { color: var(--muted); text-decoration: line-through; }
.ve-frecce { display: flex; flex-direction: column; }
.ve-frecce button { padding: 0 6px; min-height: 18px; font-size: 10px; line-height: 1; }
.ve-frecce button:disabled { opacity: .25; cursor: default; }
.ve-attiva { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.ve-elimina { color: var(--neg) !important; font-size: 16px; padding: 4px 8px; }
.ve-nuova { border-bottom: 0; }
.ve-salva { margin-top: 10px; }

@media (max-width: 1100px) { .kpi-team { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .kpi-team { gap: 10px; }
  .kpi-team .kt { padding: 10px 12px; }
  .kpi-team .kt > b { font-size: 22px; }
  .persone-team { grid-template-columns: 1fr; }
  .pc-stat { gap: 6px; }
  .pc-stat > div { padding: 7px 8px; }
  .pc-stat b { font-size: 16px; }
  body.app-nav header.top .tabs { width: 100%; }
  .ve-attiva span { display: none; }
  body.app-nav .ve-attiva input { width: 22px; height: 22px; min-height: 0; }
  .ve-salva { width: 100%; justify-content: center; min-height: 44px; }
  .ve-frecce button { min-height: 22px; font-size: 12px; padding: 0 8px; }
}

/* --- andamento negozi --- */
.dd { display: inline-block; font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dd.na { color: #94a3b8; font-weight: 400; }
.dd.zero { color: var(--muted); background: #f1f5f9; }
.dd.su { color: #0f7a3d; } .dd.giu { color: #b42318; }
.dd.su.i1 { background: #effaf3; } .dd.su.i2 { background: #d5f2df; } .dd.su.i3 { background: #a9e5bd; }
.dd.giu.i1 { background: #fff1f0; } .dd.giu.i2 { background: #fddcd8; } .dd.giu.i3 { background: #f9b9b1; }
.kpi-team .kt .dd { font-size: 12px; }
.kpi-team .kt > b .dd { font-size: 22px; padding: 0 6px; }
.kpi-and { grid-template-columns: repeat(4, 1fr); }
small.prec { display: block; color: #94a3b8; font-size: 11px; font-weight: 400; }
table.and td { vertical-align: middle; }
table.and th a { color: inherit; }
table.and th a.on { color: var(--accent); text-decoration: underline; }
table.and tr.escluso td { background: #fafafa; }
table.and td.col-neg { background: #f8fafc; }
table.and tr.sub td.col-neg { background: #dfe7f2; }
table.and button.anomalo { color: var(--warn); font-weight: 600; }
table.and button.small { min-height: 24px; }
table.mensile tr.futuro td { color: #b6bfcc; }
table.mensile tr.sett td { background: #eef2f7; }
table.mensile td.ob input { width: 92px; text-align: right; min-height: 28px; padding: 3px 6px; font-size: 13px; }
table.mensile th.ob, table.mensile td.ob { background: #fffbeb; }
table.mensile td.pos { color: var(--pos); } table.mensile td.neg { color: var(--neg); }
.evid { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; font-size: 13.5px; line-height: 1.35; }
ul.avvisi-team li.err .evid { background: var(--err-bg); } ul.avvisi-team li.warn .evid { background: var(--warn-bg); }
ul.avvisi-team li.ok .evid { background: #e9f7ef; }
.evid i { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #f59e0b; }
ul.avvisi-team li.err .evid i { background: var(--neg); } ul.avvisi-team li.ok .evid i { background: var(--pos); }
.ripartisci { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.ripartisci p { flex: 1 1 260px; }
.card-and { display: none; }
.neg-card .nc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.neg-card .nc-top b { font-size: 15px; }
.neg-card .nc-top span { font-weight: 600; font-variant-numeric: tabular-nums; }
.nc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nc-grid > div { background: #f8fafc; border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.nc-grid > div > span { font-size: 11px; color: var(--muted); }
.nc-grid em { color: #94a3b8; font-style: normal; }
.nc-grid > div.neg-evid { background: var(--err-bg); }
@media (max-width: 1100px) { .kpi-and { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .tab-and { display: none; }
  .card-and { display: block; }
  .kpi-team .kt > b .dd { font-size: 18px; }
  .nc-grid { grid-template-columns: 1fr 1fr; }
  table.mensile td.ob input { width: 80px; font-size: 16px; }
}
