/* Mc&Co OS — portale mobile. Una colonna, bersagli da 44 px, nessuna risorsa esterna. */
:root {
  --navy: #0f1c3f;
  --navy-2: #1b2b5a;
  --blu: #2e72b8;
  --blu-scuro: #245e99;
  --blu-chiaro: #e8f0fa;
  --blu-bordo: #c9dbf0;
  --testo: #0f1c3f;
  --testo-2: #46526f;
  --testo-3: #7a84a3;
  --linea: #e3e8f1;
  --sfondo: #f4f6fb;
  --bianco: #ffffff;
  --rosso: #b4322a;
  --rosso-chiaro: #fbeceb;
  --verde: #1b7f55;
  --verde-chiaro: #e5f4ed;
  --ombra: 0 1px 2px rgba(15, 28, 63, 0.06), 0 2px 8px rgba(15, 28, 63, 0.04);
  --raggio: 16px;
  --raggio-s: 12px;
  --altezza-nav: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
/* Un'icona senza regola propria non deve mai prendere tutta la larghezza del contenitore. */
svg { width: 20px; height: 20px; flex: none; }
body {
  margin: 0; background: var(--sfondo); color: var(--testo); font-family: var(--font);
  font-size: 16px; line-height: 1.45; font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--altezza-nav) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--blu); text-decoration: none; }
a:active { opacity: 0.7; }
h1, h2, h3 { margin: 0; color: var(--navy); letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 750; }
h2 { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--testo-3); }
h3 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0 0 0.75rem; }
small, .piccolo { font-size: 0.8125rem; color: var(--testo-2); }
.muto { color: var(--testo-3); }
.destra { margin-left: auto; text-align: right; }

/* ── Struttura ─────────────────────────────────────────────── */
.testata {
  position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.testata-in {
  max-width: 640px; margin: 0 auto; height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.testata img { height: 28px; width: auto; display: block; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blu); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8125rem; font-weight: 700;
  letter-spacing: 0.02em; flex: none;
}
.avatar.s { width: 26px; height: 26px; font-size: 0.6875rem; }
.avatar.chiaro { background: var(--blu-chiaro); color: var(--blu-scuro); }
main { max-width: 640px; margin: 0 auto; padding: 20px 16px 8px; }
.intestazione { margin-bottom: 20px; }
.intestazione .sopra { font-size: 0.875rem; color: var(--testo-2); margin-bottom: 2px; }
.intestazione .sotto { margin-top: 6px; color: var(--testo-2); font-size: 0.9375rem; }
.sezione { margin-top: 28px; }
.sezione > .titolo-sezione { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; padding: 0 2px; }
.sezione > .titolo-sezione a { font-size: 0.875rem; font-weight: 600; }

/* ── Navigazione in basso ──────────────────────────────────── */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bianco);
  border-top: 1px solid var(--linea); padding-bottom: env(safe-area-inset-bottom);
}
.nav-in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav a {
  position: relative; min-height: var(--altezza-nav); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--testo-3); font-size: 0.6875rem; font-weight: 600;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.attiva { color: var(--blu); }
.nav a.attiva::before {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--blu);
}

/* ── Card, righe, elenchi ──────────────────────────────────── */
.card { background: var(--bianco); border: 1px solid var(--linea); border-radius: var(--raggio); box-shadow: var(--ombra); }
.card.pad { padding: 16px; }
.card + .card { margin-top: 10px; }
.elenco { list-style: none; margin: 0; padding: 0; background: var(--bianco); border: 1px solid var(--linea); border-radius: var(--raggio); box-shadow: var(--ombra); overflow: hidden; }
.elenco > li { border-top: 1px solid var(--linea); }
.elenco > li:first-child { border-top: 0; }
.riga { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 56px; color: inherit; }
a.riga:active { background: var(--blu-chiaro); }
.riga .corpo { flex: 1; min-width: 0; }
.riga .titolo { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.riga .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: 0.8125rem; color: var(--testo-2); }
.freccia { width: 18px; height: 18px; color: var(--testo-3); flex: none; }
.ora { flex: none; width: 52px; font-size: 0.9375rem; font-weight: 700; color: var(--blu); }
.ora small { display: block; font-weight: 500; color: var(--testo-3); }

/* ── Contatori ─────────────────────────────────────────────── */
.contatori { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.contatore { background: var(--bianco); border: 1px solid var(--linea); border-radius: var(--raggio); padding: 12px 14px; box-shadow: var(--ombra); color: inherit; display: block; }
.contatore .n { font-size: 1.75rem; font-weight: 750; color: var(--navy); line-height: 1.1; }
.contatore .e { font-size: 0.75rem; color: var(--testo-2); font-weight: 600; margin-top: 2px; }
.contatore.allarme { background: var(--rosso-chiaro); border-color: #f1c9c5; }
.contatore.allarme .n { color: var(--rosso); }
.contatore.allarme .e strong { color: var(--rosso); }

/* ── Chip, badge, filtri ───────────────────────────────────── */
.chip, .badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 650;
  background: var(--blu-chiaro); color: var(--blu-scuro); white-space: nowrap;
}
.badge.rosso, .chip.rosso { background: var(--rosso-chiaro); color: var(--rosso); }
.badge.verde, .chip.verde { background: var(--verde-chiaro); color: var(--verde); }
.badge.grigio { background: #eceff5; color: var(--testo-2); }
.badge.demo { background: transparent; border: 1px solid var(--testo-3); color: var(--testo-3); letter-spacing: 0.06em; font-size: 0.625rem; padding: 1px 7px; }
.filtri { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filtri::-webkit-scrollbar { display: none; }
.filtro {
  flex: none; min-height: 40px; padding: 0 16px; display: inline-flex; align-items: center; border-radius: 999px; background: var(--bianco);
  border: 1px solid var(--linea); color: var(--testo-2); font-size: 0.875rem; font-weight: 600;
}
.filtro.attivo { background: var(--navy); border-color: var(--navy); color: #fff; }
.segmenti { display: flex; background: #e9edf5; border-radius: var(--raggio-s); padding: 3px; gap: 3px; margin-bottom: 14px; }
.segmenti a { flex: 1; min-height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 0.875rem; font-weight: 650; color: var(--testo-2); }
.segmenti a.attivo { background: var(--bianco); color: var(--navy); box-shadow: var(--ombra); }

/* ── Form ──────────────────────────────────────────────────── */
label { display: block; font-size: 0.8125rem; font-weight: 650; color: var(--testo-2); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=search], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid #ccd4e3; border-radius: var(--raggio-s); background: #fff;
  font: inherit; color: var(--testo); appearance: none; -webkit-appearance: none;
}
select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a84a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blu); outline-offset: 1px; border-color: var(--blu); }
.campi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spunta { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 0.9375rem; font-weight: 500; color: var(--testo); margin: 8px 0 0; }
.spunta input { width: 22px; height: 22px; accent-color: var(--blu); flex: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: var(--raggio-s);
  border: 0; background: var(--blu); color: #fff; font: inherit; font-weight: 650; cursor: pointer; text-align: center;
}
.btn:active { background: var(--blu-scuro); }
.btn.pieno { width: 100%; }
.btn.secondario { background: var(--bianco); color: var(--blu-scuro); border: 1px solid var(--blu-bordo); }
.btn.secondario:active { background: var(--blu-chiaro); }
.btn.nav-scuro { background: var(--navy); }
.btn svg { width: 20px; height: 20px; }
.btn.s { min-height: 44px; padding: 0 14px; font-size: 0.875rem; }
.btn.rosso { background: var(--bianco); color: var(--rosso); border: 1px solid #efc7c3; }
.azioni { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.azioni form { margin: 0; }
details.apri { background: var(--bianco); border: 1px solid var(--linea); border-radius: var(--raggio); box-shadow: var(--ombra); margin-bottom: 14px; }
details.apri > summary { list-style: none; cursor: pointer; min-height: 52px; padding: 0 16px; display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--blu-scuro); }
details.apri > summary::-webkit-details-marker { display: none; }
details.apri > summary svg { width: 20px; height: 20px; }
details.apri[open] > summary { border-bottom: 1px solid var(--linea); }
details.apri .contenuto { padding: 4px 16px 18px; }
.ricerca { position: relative; margin-bottom: 12px; }
.ricerca svg { position: absolute; left: 14px; top: 14px; width: 20px; height: 20px; color: var(--testo-3); pointer-events: none; }
.ricerca input { padding-left: 44px; border-radius: 999px; }

/* ── Task ──────────────────────────────────────────────────── */
.spunta-task { margin: 0; flex: none; }
.spunta-task button {
  width: 44px; height: 44px; margin: -6px; padding: 0; border: 0; background: none; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.spunta-task .cerchio { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #b6c0d6; display: block; background: #fff; }
.spunta-task button:active .cerchio { border-color: var(--blu); background: var(--blu-chiaro); }
.task-fatta .titolo { text-decoration: line-through; color: var(--testo-3); }
.scadenza { font-weight: 600; }
.scadenza.ritardo { color: var(--rosso); }
.scadenza.oggi { color: var(--blu-scuro); }
.riga.in-ritardo { box-shadow: inset 3px 0 0 var(--rosso); }
.persona-gruppo { display: flex; align-items: center; gap: 8px; margin: 18px 2px 8px; font-weight: 650; font-size: 0.875rem; color: var(--testo-2); }

/* ── Stati vuoti, avvisi ───────────────────────────────────── */
.vuoto { text-align: center; padding: 34px 24px 30px; background: var(--bianco); border: 1px dashed #cdd5e5; border-radius: var(--raggio); }
.vuoto .icona-vuoto { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; background: var(--blu-chiaro); color: var(--blu); display: flex; align-items: center; justify-content: center; }
.vuoto .icona-vuoto svg { width: 28px; height: 28px; }
.vuoto h3 { margin-bottom: 4px; }
.vuoto p { color: var(--testo-2); font-size: 0.9375rem; margin: 0 auto 14px; max-width: 30ch; }
.avviso { padding: 12px 14px; border-radius: var(--raggio-s); background: var(--blu-chiaro); color: var(--navy); font-size: 0.9375rem; margin-bottom: 14px; border: 1px solid var(--blu-bordo); }
.avviso.errore { background: var(--rosso-chiaro); border-color: #f1c9c5; color: var(--rosso); }
.avviso strong { display: block; margin-bottom: 2px; }
.simulazione {
  padding: 12px 14px; border-radius: var(--raggio-s); margin-bottom: 14px; font-size: 0.9375rem; color: var(--navy); font-weight: 600;
  border: 1px solid var(--blu); background: repeating-linear-gradient(135deg, #e8f0fa, #e8f0fa 10px, #dbe8f7 10px, #dbe8f7 20px);
}
.simulazione strong { letter-spacing: 0.08em; text-transform: uppercase; color: var(--blu-scuro); }

/* ── Dettaglio ─────────────────────────────────────────────── */
dl.scheda { margin: 0; display: grid; grid-template-columns: 112px 1fr; gap: 10px 12px; }
dl.scheda dt { color: var(--testo-3); font-size: 0.8125rem; font-weight: 600; padding-top: 2px; }
dl.scheda dd { margin: 0; overflow-wrap: anywhere; }
.testo-lungo { white-space: pre-wrap; overflow-wrap: anywhere; }
.cronologia { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--linea); }
.cronologia li { position: relative; padding: 0 0 16px 14px; }
.cronologia li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--blu); border: 2px solid var(--sfondo); }
.cronologia .quando { font-size: 0.75rem; color: var(--testo-3); font-weight: 600; }
.tabella-righe { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.tabella-righe th { text-align: left; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--testo-3); padding: 0 0 6px; }
.tabella-righe td { padding: 9px 0; border-top: 1px solid var(--linea); vertical-align: top; }
.tabella-righe .num { text-align: right; white-space: nowrap; padding-left: 14px; }
.totale { display: flex; justify-content: space-between; padding: 6px 0; }
.totale.grande { font-size: 1.25rem; font-weight: 750; color: var(--navy); border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 10px; }
.paginazione { display: flex; justify-content: space-between; margin-top: 14px; }
.riga-form { padding: 14px; border: 1px solid var(--linea); border-radius: var(--raggio-s); background: #fafbfd; margin-top: 10px; }
.riga-form .intest { font-size: 0.75rem; font-weight: 700; color: var(--testo-3); text-transform: uppercase; letter-spacing: 0.06em; }
.giorno-agenda { margin-top: 18px; }
.giorno-agenda > .nome { display: flex; align-items: center; gap: 8px; font-weight: 700; margin: 0 2px 8px; color: var(--navy); }
.giorno-agenda.oggi > .nome { color: var(--blu-scuro); }
.giorno-agenda.vuoto-g .riga { color: var(--testo-3); min-height: 44px; }
.annullato { text-decoration: line-through; color: var(--testo-3); }

/* ── Accesso ───────────────────────────────────────────────── */
.accesso { min-height: 100vh; background: linear-gradient(180deg, var(--navy) 0, var(--navy) 38vh, var(--sfondo) 38vh); padding-bottom: 0; }
.accesso-in { max-width: 420px; margin: 0 auto; padding: 18vh 20px 40px; }
.accesso-in img { height: 40px; display: block; margin: 0 auto 28px; }
.accesso-in .card { padding: 24px 20px 22px; }
.accesso-in h1 { font-size: 1.375rem; margin-bottom: 4px; }

.errore-pagina { text-align: center; padding: 48px 0; }
.errore-pagina .codice { font-size: 3.5rem; font-weight: 800; color: var(--blu-chiaro); letter-spacing: -0.03em; line-height: 1; -webkit-text-stroke: 2px var(--blu-bordo); }

/* ── Report ────────────────────────────────────────────────── */
.griglia-numeri { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.numero { background: #f7f9fd; border-radius: var(--raggio-s); padding: 12px 14px; }
.numero .n { font-size: 1.5rem; font-weight: 750; color: var(--navy); line-height: 1.1; }
.numero .e { font-size: 0.75rem; color: var(--testo-2); font-weight: 600; }
.fonte-spenta { border: 1px dashed #c4cde0; border-radius: var(--raggio-s); padding: 12px 14px; color: var(--testo-2); background: #fafbfd; font-size: 0.9375rem; }
.fascia-demo { text-align: center; background: var(--navy); color: #fff; font-weight: 700; letter-spacing: 0.12em; font-size: 0.75rem; padding: 6px; border-radius: 8px; margin-bottom: 14px; }

@media (min-width: 700px) {
  body { background: #e9edf5; }
  main { background: transparent; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .filtro, a.riga { transition: background-color 0.12s ease; }
}

.btn-riga { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.errore-pagina .azioni { justify-content: center; }
.piede { margin-top: 26px; text-align: center; }
.avatar svg { width: 20px; height: 20px; }
details.apri > summary .corpo-sommario { flex: 1; min-width: 0; color: var(--testo); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.apri > summary .badge { margin-left: auto; }
.bozza { padding: 12px 0; border-top: 1px solid var(--linea); }
.bozza:first-child { border-top: 0; }
.bozza .testo-lungo { max-height: 12em; overflow: auto; }
.intestazione .sotto .badge { vertical-align: middle; }
.azioni + .filtri { margin-top: 14px; }
details.altre-righe { margin-top: 12px; }
.barra-selezione { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.spunta { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 0.9375rem; font-weight: 500; }
.spunta input { width: 22px; height: 22px; accent-color: var(--blu); }
.filtri-form { margin-bottom: 14px; }
.manca { border-color: var(--rosso) !important; background: var(--rosso-chiaro); }
label.manca { background: none; color: var(--rosso); }
.elenco-semplice { margin: 6px 0 0; padding-left: 18px; }
.elenco-semplice li { margin: 2px 0; }
