/*
VOICE   calmo, clinico, ordinato: un'agenda da studio, non un gadget
IDEA    il registro appuntamenti cartaceo dello studio, con la spunta a penna
PICTURE la griglia del mese stessa, grande, che riempie lo schermo del tablet
COLOUR  bianco carta, fascia petrolio profondo, verde conferma, indaco/arancio per fatturato/non fatturato
TYPE    sistema (Roboto su Android), cifre tabulari; LAYOUT: testata, barra comandi, area di lavoro, navigazione in basso
*/
:root {
  color-scheme: light dark;
  --bg: light-dark(#ffffff, #0d1719);
  --surf: light-dark(#ffffff, #142226);
  --soft: light-dark(#f2f6f7, #18292e);
  --ink: light-dark(#13252b, #e3ecee);
  --mute: light-dark(#5b6d73, #9fb2b8);
  --line: light-dark(#dde5e8, #253a40);
  --line2: light-dark(#eef2f3, #1b2e33);
  --band: light-dark(#15434f, #0f343d);
  --band-ink: #ffffff;
  --pri: light-dark(#17606f, #6cc6d4);
  --pri-soft: light-dark(#e3f0f3, #173941);
  --ok: light-dark(#23874d, #6fd49a);
  --ok-bg: light-dark(#dcf2e3, #163a27);
  --ok-ink: light-dark(#135b31, #a6ecc2);
  --wait-bg: light-dark(#eef4f6, #1b3036);
  --dis-bg: light-dark(#f1f1f1, #222a2c);
  --fat: light-dark(#4c46b6, #8f88f5);
  --nof: light-dark(#c25a17, #d9853e);
  --hol: light-dark(#b4412f, #ff8f7d);
  --warn-bg: light-dark(#fff3e0, #3a2a14);
  --warn-ink: light-dark(#8a4b00, #ffcf8f);
  --err: light-dark(#b42318, #ff8a80);
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 4px 14px rgb(0 0 0 / .08);
  --r: 12px;
  --top-h: 56px;
  --nav-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme=light] { color-scheme: light }
:root[data-theme=dark] { color-scheme: dark }
* { box-sizing: border-box; min-width: 0 }
[hidden] { display: none !important }
html, body { height: 100% }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.45; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  display: grid; grid-template-rows: auto auto 1fr auto; height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
.num, .tab { font-variant-numeric: tabular-nums }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pri) 60%, transparent); outline-offset: 2px }

/* ---------- Testata ---------- */
#top {
  background: var(--band); color: var(--band-ink);
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) max(12px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  min-height: var(--top-h);
}
#top h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: .1px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
#top h1 small { font-weight: 400; opacity: .75; font-size: 14px; margin-left: 8px }
.ibtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: inherit;
  display: inline-grid; place-items: center; flex: none;
}
.ibtn:hover { background: rgb(255 255 255 / .12) }
.ibtn svg { width: 24px; height: 24px }
#sync {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: rgb(255 255 255 / .1);
  color: inherit; border-radius: 999px; padding: 6px 12px; font-size: 13px; min-height: 36px; white-space: nowrap;
}
#sync i { width: 9px; height: 9px; border-radius: 50%; background: #9fb2b8; flex: none }
#sync[data-s=ok] i { background: #59d48c }
#sync[data-s=busy] i { background: #ffc857; animation: pulse 1s infinite alternate }
#sync[data-s=err] i { background: #ff6b5e }
#sync[data-s=demo] i { background: #c7b8ff }
@keyframes pulse { to { opacity: .35 } }

/* ---------- Barra comandi ---------- */
#bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--surf);
}
#bar:empty { padding: 0; border: 0 }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 2px }
.seg button {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-size: 15px; font-weight: 550;
  color: var(--mute); min-height: 38px; white-space: nowrap;
}
.seg button[aria-pressed=true] { background: var(--surf); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .14) }
.navg { display: inline-flex; align-items: center; gap: 2px; margin-left: auto }
.navg .lbl { font-weight: 650; font-size: 17px; padding: 0 6px; min-width: 9.5em; text-align: center; white-space: nowrap; text-transform: capitalize }
.navg .ibtn { color: var(--ink); width: 40px; height: 40px }
.navg .ibtn:hover { background: var(--soft) }
.btn {
  border: 1px solid var(--line); background: var(--surf); border-radius: 10px; padding: 9px 14px;
  font-weight: 600; font-size: 15px; min-height: 42px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--soft) }
.btn.pri { background: var(--pri); border-color: var(--pri); color: light-dark(#fff, #062126) }
.btn.pri:hover { filter: brightness(1.06) }
.btn.ghost { border-color: transparent; background: transparent; color: var(--pri) }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, var(--line)) }
.btn svg { width: 18px; height: 18px }
.btn[disabled] { opacity: .5; pointer-events: none }

/* ---------- Area principale ---------- */
#main { overflow: auto; position: relative; overscroll-behavior: contain; background: var(--bg) }
#main.fill { overflow: hidden; display: flex; flex-direction: column }
.pad { padding: 14px max(14px, env(safe-area-inset-right)) 96px max(14px, env(safe-area-inset-left)); max-width: 1240px; margin: 0 auto }

/* ---------- Navigazione ---------- */
#nav {
  display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surf); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav button {
  border: 0; background: transparent; display: grid; justify-items: center; gap: 2px; padding: 8px 4px 10px;
  color: var(--mute); font-size: 12.5px; font-weight: 600; min-height: var(--nav-h);
}
#nav button svg { width: 24px; height: 24px }
#nav button[aria-current=page] { color: var(--pri) }
#nav button[aria-current=page] span.pill { background: var(--pri-soft) }
#nav span.pill { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px }

#fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  height: 56px; border-radius: 18px; border: 0; padding: 0 20px 0 16px; background: var(--pri); color: light-dark(#fff, #062126);
  display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; box-shadow: var(--shadow); z-index: 20;
}
#fab svg { width: 24px; height: 24px }
#fab[hidden] { display: none }

/* ---------- Stato appuntamento ---------- */
.ck {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; background: transparent; flex: none;
  display: inline-grid; place-items: center; padding: 0; color: var(--pri); position: relative;
}
.ck::after { content: ""; position: absolute; inset: -10px }
.ck svg { width: 14px; height: 14px; opacity: 0 }
.st-ok .ck { background: var(--ok); border-color: var(--ok); color: #fff }
.st-ok .ck svg { opacity: 1 }
.st-dis .ck { color: var(--mute); border-style: dashed }
.ck.big { width: 34px; height: 34px; border-width: 2.5px }
.ck.big svg { width: 20px; height: 20px }

/* ---------- Mese (tablet) ---------- */
.mwrap { padding: 0 max(8px, env(safe-area-inset-right)) 10px max(8px, env(safe-area-inset-left)) }
.mhead { position: sticky; top: 0; z-index: 2; background: var(--bg) }
.mhead { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mhead div { font-size: 13px; font-weight: 650; color: var(--mute); padding: 8px 8px 6px; text-transform: uppercase; letter-spacing: .3px }
.mhead div.we { color: var(--hol) }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden }
.mc { background: var(--surf); padding: 4px 5px 6px; display: flex; flex-direction: column; gap: 3px; cursor: copy; position: relative }
.mc:hover { background: color-mix(in srgb, var(--soft) 60%, var(--surf)) }
.mc.out { background: var(--line2) }
.mc.out .mc-num { opacity: .5 }
.mc.allok { background: color-mix(in srgb, var(--ok-bg) 55%, var(--surf)) }
.mc-h { display: flex; align-items: center; gap: 6px; min-height: 26px }
.mc-num {
  border: 0; background: transparent; font-weight: 650; font-size: 15px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; flex: none;
}
.mc-num:hover { background: var(--soft) }
.mc.hol .mc-num { color: var(--hol) }
.mc.today .mc-num { background: var(--pri); color: light-dark(#fff, #062126) }
.mc-hn { font-size: 11px; color: var(--hol); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 }
.mc-cnt { margin-left: auto; font-size: 12px; color: var(--mute); white-space: nowrap }
.mc-list { display: flex; flex-direction: column; gap: 3px; flex: 1 }
.chip {
  display: flex; align-items: center; gap: 6px; padding: 1px 6px 1px 4px; border-radius: 7px; font-size: 13.5px; line-height: 1.25;
  background: var(--wait-bg); border-left: 3px solid var(--pri); cursor: pointer; min-height: 24px; flex: none;
}
.chip .ck { width: 19px; height: 19px }
.chip .ck svg { width: 12px; height: 12px }
.chip-t { font-weight: 650; font-variant-numeric: tabular-nums; flex: none }
.chip-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 }
.chip-f { flex: none; font-size: 10.5px; font-weight: 700; color: var(--fat); border: 1px solid currentColor; border-radius: 4px; padding: 0 3px }
.chip.st-ok { background: var(--ok-bg); border-left-color: var(--ok); color: var(--ok-ink) }
.chip.st-dis { background: var(--dis-bg); border-left-color: var(--mute); color: var(--mute) }
.chip.st-dis .chip-n { text-decoration: line-through }
.mc { container-type: inline-size }
@container (max-width: 150px) {
  .chip { flex-wrap: wrap; gap: 0 5px; padding: 2px 5px 3px 4px; line-height: 1.2 }
  .chip-t { font-size: 12.5px }
  .chip-n { flex-basis: 100%; font-size: 13px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical }
  .chip-f { margin-left: auto }
}
.more { border: 0; background: transparent; color: var(--pri); font-size: 12.5px; font-weight: 650; text-align: left; padding: 0 4px; flex: none; line-height: 16px }

/* ---------- Mese (smartphone) ---------- */
.pm { padding: 4px max(4px, env(safe-area-inset-right)) 96px max(4px, env(safe-area-inset-left)) }
.pm .mhead div { text-align: center; padding: 6px 0 4px; font-size: 12px }
.pgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px }

.pm .mhead { padding-top: 2px }
.pgrid { gap: 2px }
.pc {
  background: var(--surf); border-radius: 7px; min-height: 64px; padding: 2px 1px 3px; display: flex; flex-direction: column;
  align-items: stretch; gap: 2px; position: relative; border: 1px solid var(--line2); text-align: left; font: inherit; color: inherit;
}
.pc.out { opacity: .5 }
.pc .n { font-weight: 650; font-size: 14px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; align-self: center; flex: none }
.pnames { display: flex; flex-direction: column; gap: 2px }
.pn {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 10.5px; line-height: 13px; padding: 1px 1px 1px 2px;
  border-radius: 3px; white-space: normal; overflow: hidden; overflow-wrap: anywhere; letter-spacing: -.1px;
  background: var(--wait-bg); border-left: 2px solid var(--pri); font-weight: 500; color: var(--ink)
}
.pn.st-ok { background: var(--ok-bg); border-left-color: var(--ok); color: var(--ok-ink); font-weight: 650 }
.pn.st-dis { background: transparent; border-left-color: var(--mute); color: var(--mute); text-decoration: line-through }
.pm-hint { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--mute); margin: 10px 2px 0 }
.pm-hint { padding: 0 4px }
.pm-hint .pn { font-size: 12px; line-height: 16px; padding: 1px 6px }
.dmeta { margin: -8px 0 14px; color: var(--mute); font-size: 14.5px }
.tag.okt { color: var(--ok-ink); background: color-mix(in srgb, var(--ok) 15%, transparent) }
.switches.two { grid-template-columns: repeat(2, minmax(0, 1fr)) }
.pc.hol .n { color: var(--hol) }
.pc.today .n { background: var(--pri); color: light-dark(#fff, #062126) }
.pc.sel { border-color: var(--pri); background: var(--pri-soft) }
.pc.allok { background: color-mix(in srgb, var(--ok-bg) 45%, var(--surf)) }
.pc.sel.allok { background: color-mix(in srgb, var(--ok-bg) 45%, var(--surf)) }
.dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 40px }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--pri) }
.dots i.ok { background: var(--ok) }
.dots i.dis { background: var(--line); outline: 1px solid var(--mute) }
.dots b { font-size: 10px; color: var(--mute); line-height: 7px }

/* ---------- Righe appuntamento ---------- */
.dayhead { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 16px 2px 8px }
.dayhead h2 { font-size: 19px; margin: 0; text-transform: capitalize; line-height: 1.2 }
.dayhead .meta { color: var(--mute); font-size: 14px; display: block }
.dayhead.today h2 { color: var(--pri) }
.rows { display: grid; gap: 8px }
.row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 12px;
  background: var(--surf); border: 1px solid var(--line); border-left: 4px solid var(--pri); border-radius: var(--r);
  padding: 10px 12px; cursor: pointer; min-height: 64px;
}
.row.st-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); border-left-color: var(--ok) }
.row.st-dis { background: var(--dis-bg); border-left-color: var(--mute); color: var(--mute) }
.row.st-dis .row-n { text-decoration: line-through }
.row-time { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 17px; line-height: 1.1; text-align: right }
.row-time small { display: block; font-weight: 500; font-size: 13px; color: var(--mute) }
.row-n { font-weight: 650; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.row-sub { font-size: 13.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.row.st-ok .row-sub { color: var(--ok-ink); opacity: .85 }
.row-amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 5px; padding: 1px 6px; vertical-align: 1px; white-space: nowrap }
.tag.fat { color: var(--fat); background: color-mix(in srgb, var(--fat) 12%, transparent) }
.tag.nof { color: var(--nof); background: color-mix(in srgb, var(--nof) 12%, transparent) }
.tag.wait { color: var(--mute); background: var(--soft) }
.tag.dis { color: var(--mute); background: var(--soft) }
.empty { color: var(--mute); padding: 14px; border: 1px dashed var(--line); border-radius: var(--r); text-align: center; font-size: 15px }
.empty button { margin-top: 8px }
.empty.sm { padding: 8px; font-size: 14px; text-align: left; padding-left: 14px }

/* ---------- Griglia oraria (settimana / giorno) ---------- */
.tg { --hh: 64px; padding-bottom: 96px }
.tg-head { display: grid; position: sticky; top: 0; z-index: 5; background: var(--surf); border-bottom: 1px solid var(--line) }
.tg-dh { text-align: center; padding: 6px 2px 8px; border: 0; background: transparent; display: grid; gap: 0 }
.tg-dh .w { font-size: 12.5px; color: var(--mute); font-weight: 650; text-transform: uppercase }
.tg-dh .d { font-size: 20px; font-weight: 650; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto }
.tg-dh.today .d { background: var(--pri); color: light-dark(#fff, #062126) }
.tg-dh.hol .w, .tg-dh.hol .d { color: var(--hol) }
.tg-dh.today.hol .d { color: light-dark(#fff, #062126) }
.tg-dh .s { font-size: 11.5px; color: var(--mute); white-space: nowrap }
.tg-body { display: grid; position: relative }
.tg-times { position: relative }
.tg-times div { position: absolute; right: 8px; transform: translateY(-50%); font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums }
.tg-col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image:
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hh)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--hh) / 2), var(--line2) calc(var(--hh) / 2) calc(var(--hh) / 2 + 1px), transparent calc(var(--hh) / 2 + 1px) var(--hh));
}
.tg-col.hol { background-color: color-mix(in srgb, var(--hol) 4%, transparent) }
.ev {
  position: absolute; border-radius: 8px; padding: 4px 6px 4px 30px; overflow: hidden; cursor: pointer;
  background: var(--wait-bg); border: 1px solid color-mix(in srgb, var(--pri) 30%, var(--line)); border-left: 4px solid var(--pri);
  font-size: 13.5px; line-height: 1.25;
}
.ev .ck { position: absolute; left: 5px; top: 5px }
.ev-t { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ev-n { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ev-m { font-size: 12px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.tg.week .ev { padding-left: 25px }
.tg.week .ev .ck { width: 18px; height: 18px; left: 4px }
.tg.week .ev .ck svg { width: 11px; height: 11px }
.ev.short { display: flex; gap: 6px; align-items: center; padding-top: 2px; padding-bottom: 2px }
.ev.short .ck { top: 50%; transform: translateY(-50%) }
.ev.short .ev-m { display: none }
.ev.st-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); border-left-color: var(--ok); color: var(--ok-ink) }
.ev.st-ok .ev-m { color: var(--ok-ink); opacity: .8 }
.ev.st-dis { background: var(--dis-bg); border-left-color: var(--mute); color: var(--mute) }
.ev.st-dis .ev-n { text-decoration: line-through }
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--hol); z-index: 3; pointer-events: none }
.nowline::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--hol) }
.daysum { display: flex; gap: 8px 16px; flex-wrap: wrap; padding: 10px 16px; font-size: 14px; color: var(--mute); border-bottom: 1px solid var(--line); background: var(--surf) }
.daysum b { color: var(--ink); font-variant-numeric: tabular-nums }

/* ---------- Entrate ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px }
.kpi { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px }
.kpi .k { font-size: 13.5px; color: var(--mute); font-weight: 600; display: flex; align-items: center; gap: 6px }
.kpi .k i { width: 10px; height: 10px; border-radius: 3px; flex: none }
.kpi .v { font-size: clamp(22px, 3.2vw, 30px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap }
.kpi .s { font-size: 13px; color: var(--mute) }
.kpi.main { background: var(--band); border-color: var(--band); color: #fff }
.kpi.main .k, .kpi.main .s { color: rgb(255 255 255 / .78) }
.split { height: 12px; display: flex; gap: 2px; border-radius: 6px; overflow: hidden; background: var(--soft); margin: 2px 0 16px }
.split span { display: block; height: 100% }
.card { background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 14px }
.card h3 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap }
.card h3 .btn { margin-left: auto }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px }
.fchip { border: 1px solid var(--line); background: var(--surf); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; min-height: 36px; color: var(--mute) }
.fchip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--bg) }
table.t { width: 100%; border-collapse: collapse; font-size: 15px }
table.t th { text-align: left; font-size: 12.5px; color: var(--mute); font-weight: 650; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line2); vertical-align: middle }
table.t tr:last-child td { border-bottom: 0 }
table.t .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap }
table.t tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0 }
table.t tr.click { cursor: pointer }
table.t tr.click:hover td { background: var(--soft) }
.tgl {
  border: 1px solid var(--line); background: var(--surf); border-radius: 8px; padding: 5px 9px; font-size: 13px; font-weight: 650;
  color: var(--mute); white-space: nowrap; min-height: 34px; display: inline-flex; align-items: center; gap: 5px
}
.tgl[aria-pressed=true].fat { color: #fff; background: var(--fat); border-color: var(--fat) }
.tgl[aria-pressed=true].ok { color: #fff; background: var(--ok); border-color: var(--ok) }
.tgl svg { width: 14px; height: 14px }
.bars { display: grid; gap: 4px }
.bar-row { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 7.5em; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 8px; cursor: pointer; border: 0; background: transparent; text-align: left }
.bar-row:hover { background: var(--soft) }
.bar-row.cur { background: var(--pri-soft) }
.bar-row .m { font-weight: 650; text-transform: capitalize }
.bar-row .tr { height: 18px; display: flex; gap: 2px; background: transparent; position: relative }
.bar-row .tr span { display: block; height: 100% }
.bar-row .tr span:first-child { border-radius: 4px 0 0 4px }
.bar-row .tr span:last-child { border-radius: 0 4px 4px 0 }
.bar-row .tr span:only-child { border-radius: 4px }
.bar-row .v { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13.5px; color: var(--mute); margin-bottom: 8px }
.legend span { display: inline-flex; align-items: center; gap: 6px }
.legend i { width: 12px; height: 12px; border-radius: 3px }
.tip { position: fixed; z-index: 60; background: var(--ink); color: var(--bg); font-size: 13px; padding: 6px 9px; border-radius: 8px; pointer-events: none; white-space: nowrap; box-shadow: var(--shadow) }


.plist { display: grid; gap: 0 }
.prow { padding: 10px 2px; border-bottom: 1px solid var(--line2); display: grid; gap: 3px }
.prow:last-child { border-bottom: 0 }
.prow.tot { border-top: 1px solid var(--line); border-bottom: 0 }
.prow-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline }
.prow-top b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.prow-top .num { font-weight: 700; white-space: nowrap }
.prow-sub { font-size: 13.5px; color: var(--mute) }
.prow .tgl { justify-self: start; margin-top: 4px }
.erow { cursor: pointer }
.prow-d { font-size: 13.5px; color: var(--mute); font-variant-numeric: tabular-nums }
.prow-n { font-weight: 650 }
.prow-b { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px }

/* ---------- Contatti ---------- */
.search { width: 100%; border: 1px solid var(--line); background: var(--surf); border-radius: 12px; padding: 12px 14px; font-size: 16px; min-height: 48px }
.clist { display: grid; gap: 6px; margin-top: 12px }
.citem { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surf); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; min-height: 56px; width: 100%; text-align: left }
.citem:hover { background: var(--soft) }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none }
.citem .nm { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.citem .pr { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap }
.fileinfo { display: flex; gap: 8px 14px; align-items: center; flex-wrap: wrap; color: var(--mute); font-size: 14px; margin: 4px 0 12px }
.banner { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; font-size: 15px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
.banner .btn { margin-left: auto }
.banner.info { background: var(--pri-soft); color: var(--ink) }

/* ---------- Finestre (sheet) ---------- */
.scrim { position: fixed; inset: 0; background: rgb(6 20 24 / .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out }
.sheet {
  background: var(--surf); width: min(640px, 100%); max-height: 94dvh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgb(0 0 0 / .2); animation: up .2s ease-out;
}
.sheet.small { width: min(460px, 100%) }
@media (min-width: 760px) and (min-height: 560px) {
  .scrim { align-items: center }
  .sheet { border-radius: 20px; padding-bottom: 18px }
}
.grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px }
.sheet h2 { font-size: 20px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px }
.sheet h2 .ibtn { margin-left: auto; color: var(--mute) }
@keyframes up { from { transform: translateY(30px); opacity: 0 } }
@keyframes fade { from { opacity: 0 } }
.f { display: grid; gap: 5px; margin-bottom: 12px; position: relative }
.f > label, .f > .lb { font-size: 13.5px; font-weight: 650; color: var(--mute) }
.f input, .f select, .f textarea {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 12px; font-size: 16px; min-height: 46px; width: 100%;
}
.f textarea { min-height: 70px; resize: vertical }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid var(--pri); outline-offset: -1px; border-color: var(--pri) }
.f .hint { font-size: 13px; color: var(--mute) }
.f .hint.warn { color: var(--warn-ink); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 0 12px }
.switches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px }
.sw {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 52px;
  background: var(--bg); font-weight: 600; font-size: 15px; cursor: pointer; user-select: none
}
.sw input { width: 22px; height: 22px; accent-color: var(--pri); margin: 0; flex: none }
.sw.on-ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok-ink) }
.sw.on-fat { border-color: var(--fat); color: var(--fat); background: color-mix(in srgb, var(--fat) 8%, var(--bg)) }
.sw.on-dis { border-color: var(--mute); color: var(--mute); background: var(--dis-bg) }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px }
.actions .sp { flex: 1 }
.ac { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surf); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; margin-top: 4px }
.ac button { display: flex; width: 100%; border: 0; background: transparent; text-align: left; padding: 11px 14px; gap: 10px; align-items: center; min-height: 46px; border-bottom: 1px solid var(--line2) }
.ac button:last-child { border-bottom: 0 }
.ac button:hover, .ac button.hi { background: var(--soft) }
.ac .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ac .pr { color: var(--mute); font-variant-numeric: tabular-nums; white-space: nowrap }
.ac .add { color: var(--pri); font-weight: 650 }
.ac .add svg { width: 22px; height: 22px; flex: none; margin: 0 8px }
.newc { border: 1px dashed var(--pri); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--pri-soft) }
.newc .row2 { display: grid; grid-template-columns: minmax(0, 1fr) 8em auto; gap: 8px; align-items: end }
details.guide { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 6px 0 14px; background: var(--bg) }
details.guide summary { font-weight: 650; cursor: pointer; min-height: 32px; display: flex; align-items: center }
details.guide ol { padding-left: 20px; margin: 8px 0; font-size: 15px }
details.guide li { margin-bottom: 6px }
code.k { background: var(--soft); padding: 1px 6px; border-radius: 5px; font-size: 14px; overflow-wrap: anywhere }


/* ---------- Dettatura ---------- */
.inmic { position: relative }
.inmic input { padding-right: 58px }
.mic {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 46px; height: 38px; border-radius: 9px; border: 0;
  background: var(--pri-soft); color: var(--pri); display: grid; place-items: center; padding: 0
}
.mic svg { width: 22px; height: 22px }
.mic.on { background: var(--err); color: #fff; animation: ring 1.1s ease-out infinite }
@keyframes ring { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 55%, transparent) } to { box-shadow: 0 0 0 12px transparent } }
.f input.matched { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 28%, transparent); transition: box-shadow .2s }
.okh { color: var(--ok-ink); display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap }
.okh svg { width: 15px; height: 15px; color: var(--ok) }
.ac .ttl { padding: 8px 14px 4px; font-size: 12.5px; color: var(--mute); font-weight: 650 }

/* ---------- Avvisi ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 86px); z-index: 70; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 15px; display: flex; align-items: center; gap: 12px; pointer-events: auto; animation: up .2s ease-out }
.toast.err { background: var(--err); color: #fff }
.toast button { margin-left: auto; border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; padding: 4px }

/* ---------- Benvenuto ---------- */
.welcome { max-width: 560px; margin: 0 auto; padding: 36px 20px 100px; display: grid; gap: 16px }
.welcome h2 { font-size: clamp(26px, 5vw, 34px); line-height: 1.1; margin: 0; text-wrap: balance }
.welcome p { margin: 0; color: var(--mute); font-size: 16.5px }
.welcome .actions { margin-top: 8px }
.welcome svg.hero { width: 120px; height: 120px }

/* ---------- Adattamenti ---------- */
@media (max-width: 759px) {
  #fab { width: 60px; height: 60px; padding: 0; justify-content: center; border-radius: 50% }
  #fab span { display: none }
  #fab svg { width: 28px; height: 28px }
  .navg { margin-left: 0; width: 100%; justify-content: space-between }
  .navg .lbl { flex: 1; min-width: 0; font-size: 16px }
  #bar .seg { flex: 1 }
  #bar .seg button { flex: 1; padding: 8px 6px; font-size: 14.5px }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .switches { grid-template-columns: 1fr 1fr 1fr; gap: 6px }
  .sw { padding: 8px; font-size: 14px; gap: 6px }
  .grid3 { grid-template-columns: 1fr 1fr }
  .grid3 > :first-child { grid-column: 1 / -1 }
  .row { gap: 10px; padding: 10px }
  .row-amt { font-size: 15px }
  .row-time { font-size: 16px }
  .hide-s { display: none }
  #top h1 small { display: none }
  #sync span { display: none }
  #sync { padding: 6px 10px }
  .bar-row { grid-template-columns: 3.2em minmax(0, 1fr) 6.2em; gap: 8px }
}
@media (max-width: 600px) {
  table.t { font-size: 14px }
  .stack thead { display: none }
  .stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 8px 0; border-bottom: 1px solid var(--line2); gap: 2px 10px }
  .stack td { border: 0; padding: 2px 4px }
  .stack td.r { text-align: right }
  .stack tfoot tr { border-bottom: 0 }
  .newc .row2 { grid-template-columns: 1fr 1fr }
  .newc .row2 > :first-child { grid-column: 1 / -1 }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
}
