/* AI-IO GESTIONE — stile del pannello. Colori del marchio (crema, inchiostro, pomodoro, basilico),
   pensato prima per il telefono e poi per il Mac. Struttura ripresa dalla dashboard Carminello. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../font/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
:root {
  --bg: #FFF8E6; --paper: #FFFDF8; --ink: #1E1B16; --ink-2: #5C5341; --ink-3: #75694F; --line: #F0E2BF; --line-2: #EAD9AE;
  --pomodoro: #E0492F; --pomodoro-d: #C4381F; --pomodoro-l: #FBE1DB;
  --basilico: #2F8F4E; --basilico-d: #246F3C; --basilico-l: #E2F1E6;
  --crema: #FFF1CF; --crema-s: #F9E2A8;
  --ambra-l: #FCEFC7; --ambra-t: #7A5410; --arancio-l: #FDE3CF; --arancio-t: #8A3E0A; --arancio: #D9731F;
  --blu-l: #E1EEF7; --blu-t: #1F5F8B; --viola-l: #EEE6F5; --viola-t: #5B3B7A; --grigio-l: #ECE7DC;
  --r: 12px; --r-lg: 18px; --shadow: 0 1px 0 rgba(30,27,22,.04), 0 8px 24px -14px rgba(30,27,22,.28);
  --font: "Bricolage Grotesque", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--pomodoro-d); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--basilico); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-3); } .small { font-size: .88rem; } .b { font-weight: 600; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---- struttura ---- */
.banda-prova { background: var(--crema-s); color: var(--ink); text-align: center; font-size: .82rem; font-weight: 600; padding: .3rem 1rem; }
.top { position: sticky; top: 0; z-index: 40; background: var(--ink); color: var(--crema); }
.top-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; }
.top .brand { display: flex; align-items: center; gap: .6rem; color: var(--crema); font-weight: 600; }
.top .brand:hover { text-decoration: none; }
.top .brand img { height: 34px; width: 34px; border-radius: 9px; }
.top .brand span { font-size: 1.1rem; } .top .brand small { display: block; font-size: .72rem; font-weight: 400; opacity: .75; line-height: 1; }
.nav { display: flex; gap: .2rem; margin-left: auto; }
.nav a { color: rgba(255,241,207,.8); padding: .45rem .8rem; border-radius: 999px; font-weight: 500; font-size: .95rem; position: relative; }
.nav a.on, .nav a:hover { background: rgba(255,241,207,.14); color: var(--crema); text-decoration: none; }
.nav a .cnt { background: var(--pomodoro); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 0 6px; margin-left: .3rem; }
.top .user { font-size: .85rem; opacity: .85; white-space: nowrap; }
.top .user button { background: transparent; border: 1px solid rgba(255,241,207,.4); color: var(--crema); border-radius: 999px; padding: .25rem .7rem; font: 500 .8rem var(--font); cursor: pointer; margin-left: .5rem; }
main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 6rem; }
.nav a svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: .3rem; }
.nav a .l-corto { display: none; }
@media (max-width: 820px) { .nav a .l-corto { display: inline; } }
@media (min-width: 821px) { .nav a svg { display: none; } }
@media (max-width: 820px) {
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; background: var(--paper); border-top: 1px solid var(--line-2); justify-content: space-around; padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); z-index: 40; }
  .nav a { color: var(--ink-3); font-size: .68rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .3rem .15rem; border-radius: 10px; flex: 1 1 0; min-width: 0; white-space: nowrap; }
  .nav a .l-lungo { display: none; }
  .nav a.on, .nav a:hover { background: var(--crema); color: var(--ink); }
  .nav a .cnt { position: absolute; top: 0; right: 0; margin: 0; }
  .nav a svg { width: 22px; height: 22px; margin: 0; }
  .top .user { margin-left: auto; }
  .top .user span { display: none; }
}

.page-title { display: flex; align-items: baseline; gap: .4rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-title h1 { margin: 0; } .page-title .sub { color: var(--ink-3); }
.page-title .azioni { margin-left: auto; }
.card { background: var(--paper); border-radius: var(--r-lg); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; border: 1px solid var(--line); }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 1rem; } .grid.two { grid-template-columns: 1fr 1fr; } .grid > * { min-width: 0; }
.grid.two-uneven { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .grid.two, .grid.two-uneven { grid-template-columns: 1fr; } }

/* ---- KPI ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--paper); border-radius: var(--r); padding: .9rem 1rem; box-shadow: var(--shadow); border: 1px solid var(--line); display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--line-2); }
.kpi .l { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.kpi .v { font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin: .15rem 0; font-variant-numeric: tabular-nums; }
.kpi .v.warn { color: var(--pomodoro-d); }
.kpi .d { font-size: .82rem; color: var(--ink-3); }
.kpi.alert { border-left: 4px solid var(--pomodoro); }

/* ---- filtri ---- */
.seg { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.seg button { border: 1.5px solid var(--line-2); background: var(--paper); padding: .4rem .85rem; border-radius: 999px; font: 500 .88rem var(--font); cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--crema); border-color: var(--ink); }
.seg button .cnt { opacity: .7; margin-left: .3rem; font-size: .8rem; }
.search { width: 100%; max-width: 340px; margin-left: auto; }
@media (max-width: 640px) { .search { max-width: none; margin-left: 0; } }

/* ---- tabelle ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.2rem; padding: 0 1.2rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); padding: .5rem .6rem; border-bottom: 2px solid var(--line-2); white-space: nowrap; }
table.data th.sort { cursor: pointer; user-select: none; } table.data th.on { color: var(--ink); }
table.data td { padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr.click { cursor: pointer; } table.data tr.click:hover td { background: #FFF6DE; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: .16rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--grigio-l); color: var(--ink-2); }
.pill.nuovo { background: var(--viola-l); color: var(--viola-t); } .pill.prova { background: var(--blu-l); color: var(--blu-t); }
.pill.attivo, .pill.ok { background: var(--basilico-l); color: var(--basilico-d); }
.pill.scadenza { background: var(--ambra-l); color: var(--ambra-t); } .pill.ritardo { background: var(--arancio-l); color: var(--arancio-t); }
.pill.sospeso, .pill.ko { background: var(--pomodoro-l); color: #A42E19; } .pill.disdetto { background: var(--grigio-l); color: var(--ink-2); }
.pill.agente { background: var(--blu-l); color: var(--blu-t); }
.menu-on, .menu-off { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; font-weight: 600; }
.menu-on::before, .menu-off::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.menu-on { color: var(--basilico-d); } .menu-on::before { background: var(--basilico); }
.menu-off { color: #A42E19; } .menu-off::before { background: var(--pomodoro); }

/* ---- pulsanti / moduli ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1.05rem; border-radius: 999px; border: 1.5px solid var(--pomodoro-d); background: var(--pomodoro-d); color: #FFF8E6; font: 600 .92rem var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #A92F18; border-color: #A92F18; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); } .btn.ghost:hover { background: var(--crema); }
.btn.verde { background: var(--basilico-d); border-color: var(--basilico-d); } .btn.verde:hover { background: #1B5A30; }
.btn.wa { background: #128C7E; border-color: #128C7E; color: #fff; } .btn.wa:hover { background: #0E6F64; }
.btn.blu { background: var(--blu-t); border-color: var(--blu-t); color: #fff; }
.btn.sm { padding: .35rem .75rem; font-size: .84rem; } .btn.block { width: 100%; } .btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
label.check { display: flex; gap: .55rem; align-items: center; font-size: .95rem; font-weight: 500; color: var(--ink); cursor: pointer; margin: 0 0 .6rem; }
label.check input { width: 20px; height: 20px; accent-color: var(--pomodoro-d); margin: 0; }
input, select, textarea { width: 100%; font: 400 1rem var(--font); padding: .6rem .8rem; border: 1.5px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--crema-s); }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.field { margin-bottom: .9rem; } .field .aiuto { font-size: .8rem; color: var(--ink-3); margin-top: .2rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; } .row.tre { grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 560px) { .row, .row.tre { grid-template-columns: 1fr; gap: 0; } }
.err { color: var(--pomodoro-d); font-size: .9rem; margin: .4rem 0; }
.notice { border-radius: var(--r); padding: .8rem 1rem; margin-bottom: 1rem; font-size: .95rem; }
.notice.warn { background: var(--ambra-l); color: #5E400B; } .notice.ok { background: var(--basilico-l); color: var(--basilico-d); }
.notice.err { background: var(--pomodoro-l); color: #8E2814; } .notice.info { background: var(--blu-l); color: #174A6C; }
fieldset { border: 1px solid var(--line-2); border-radius: var(--r); padding: .8rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }

/* ---- accesso ---- */
.login { max-width: 400px; margin: 3rem auto; }
.login .logo { display: block; width: 76px; height: 76px; border-radius: 20px; margin: 0 auto 1rem; box-shadow: var(--shadow); }

/* ---- scheda cliente ---- */
.head-cli { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.head-cli .info { flex: 1; min-width: 240px; }
.head-cli h1 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .93rem; margin: 0; } .kv dt { color: var(--ink-3); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.stato-box { border-radius: var(--r); padding: .9rem 1rem; margin-bottom: .9rem; background: var(--crema); }
.stato-box p { margin: .3rem 0 0; }
.incasso { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.incasso:last-child { border-bottom: 0; }
.incasso .testa { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; align-items: baseline; }
.incasso .riga { display: flex; justify-content: space-between; gap: .8rem; font-size: .9rem; color: var(--ink-2); margin-top: .2rem; }
.incasso.annullato { opacity: .6; } .incasso.annullato .testa b { text-decoration: line-through; }
.lista-mini { list-style: none; padding: 0; margin: 0; } .lista-mini li { padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.lista-mini li:last-child { border-bottom: 0; }
.note .m { color: var(--ink-3); font-size: .8rem; }

/* ---- avvisi ---- */
.avviso { display: grid; grid-template-columns: 1fr auto; gap: .6rem 1rem; background: var(--paper); border-radius: var(--r); padding: .95rem 1rem; box-shadow: var(--shadow); margin-bottom: .8rem; border: 1px solid var(--line); border-left: 5px solid var(--ambra-t); }
.avviso.q2 { border-left-color: var(--arancio); } .avviso.q3 { border-left-color: var(--pomodoro); }
.avviso.benvenuto { border-left-color: var(--blu-t); } .avviso.pronto { border-left-color: var(--basilico); }
.avviso .nome { font-weight: 600; font-size: 1.02rem; }
.avviso .perche { color: var(--ink-2); font-size: .9rem; margin: .15rem 0 .4rem; }
.avviso .testo { background: var(--crema); border-radius: 10px; padding: .6rem .8rem; font-size: .9rem; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
.avviso .side { display: flex; flex-direction: column; gap: .4rem; align-items: stretch; min-width: 150px; }
@media (max-width: 640px) { .avviso { grid-template-columns: 1fr; } .avviso .side { flex-direction: row; flex-wrap: wrap; min-width: 0; } }

/* ---- fatture ---- */
.fattura .dati { display: grid; grid-template-columns: max-content 1fr auto; gap: .25rem .8rem; font-size: .92rem; align-items: center; }
.fattura .dati dt { color: var(--ink-3); } .fattura .dati dd { margin: 0; user-select: text; -webkit-user-select: text; overflow-wrap: anywhere; }
.copia { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font: 500 .78rem var(--font); padding: .15rem .4rem; border-radius: 6px; }
.copia:hover { background: var(--crema); color: var(--ink); }
.righe-fattura { margin: .7rem 0; border-top: 1px dashed var(--line-2); }
.righe-fattura div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--line-2); font-size: .9rem; }
.conto { font-weight: 700; } .conto.urgente { color: var(--pomodoro-d); }

/* ---- grafici ---- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--basilico-d); } .chart .bar.oggi { fill: var(--pomodoro-d); }
.chart .hit { fill: transparent; cursor: default; } .chart .hit:hover + .bar, .chart g:hover .bar { opacity: .8; }
.chart text { font: 500 11px var(--font); fill: var(--ink-3); } .chart text.val { fill: var(--ink-2); font-weight: 600; }
.chart .base { stroke: var(--line-2); stroke-width: 1; }
.tip { position: fixed; z-index: 300; background: var(--ink); color: var(--crema); font-size: .82rem; padding: .35rem .6rem; border-radius: 8px; pointer-events: none; white-space: nowrap; }
.barre-stato { display: grid; gap: .45rem; }
.barre-stato a { display: grid; grid-template-columns: 7.5rem 1fr 2.5rem; gap: .6rem; align-items: center; color: inherit; padding: .15rem 0; }
.barre-stato a:hover { text-decoration: none; background: var(--crema); border-radius: 8px; }
.barre-stato .barra { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.barre-stato .barra i { display: block; height: 100%; border-radius: 999px; background: var(--ink-2); }
details.numeri summary { cursor: pointer; font-size: .85rem; color: var(--ink-3); margin-top: .6rem; }

/* ---- modale / avvisi a comparsa ---- */
.modal { position: fixed; inset: 0; background: rgba(30,27,22,.5); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal-in { background: var(--bg); border-radius: var(--r-lg); padding: 1.3rem; width: min(580px, 100%); max-height: 92vh; overflow: auto; }
.anteprima { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r); padding: .7rem .9rem; margin: .4rem 0 1rem; font-size: .92rem; }
.anteprima .r { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--line-2); }
.anteprima .tot { display: flex; justify-content: space-between; padding-top: .45rem; font-weight: 700; font-size: 1.05rem; }
#toast-box { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 200; display: grid; gap: .5rem; width: min(420px, calc(100% - 2rem)); }
.toast { background: var(--ink); color: var(--crema); padding: .7rem 1rem; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: .3s; font-size: .92rem; }
.toast.show { opacity: 1; transform: none; } .toast.ok { background: var(--basilico-d); color: #fff; } .toast.err { background: var(--pomodoro-d); color: #fff; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.12); border-top-color: var(--pomodoro); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: .4rem; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .toast { transition: none; } }

/* Telefono: niente selezione del testo al tocco, tranne dove serve copiare o scrivere */
body { -webkit-tap-highlight-color: transparent; }

/* fase 4: interruttori delle automazioni, spunte piccole, testo delle email */
.interruttore { display: flex; gap: .8rem; align-items: flex-start; padding: .75rem 0; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 400; }
.interruttore input { width: 22px; height: 22px; margin: .1rem 0 0; accent-color: var(--basilico-d); flex: 0 0 auto; }
form .interruttore + .btn { margin-top: .9rem; }
label.chk { display: flex; gap: .4rem; align-items: center; font-weight: 400; margin: 0 0 .15rem; cursor: pointer; font-size: .9rem; }
label.chk input { width: 18px; height: 18px; accent-color: var(--basilico-d); }
.modal-in .testo { background: var(--crema); border-radius: 10px; padding: .7rem .9rem; font-size: .92rem; user-select: text; -webkit-user-select: text; }

/* mappe */
.mappa { height: min(62vh, 560px); border-radius: var(--r); border: 1px solid var(--line-2); margin-top: .6rem; z-index: 0; }
.legenda { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin-top: .6rem; color: var(--ink-2); }
.legenda span { display: inline-flex; align-items: center; gap: .35rem; }
.legenda i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; opacity: .75; }
.legenda i.tondo { border-radius: 50%; opacity: 1; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.legenda i.anello { border-radius: 50%; border: 2px dashed #C4381F; background: transparent; opacity: 1; }
.leaflet-container { font-family: var(--font); }
.mappa .leaflet-tile-pane { filter: grayscale(1) contrast(.85) brightness(1.08); }   /* mappa in grigio: le zone colorate si leggono meglio */
