/* Comizio — dashboard e gate. Mobile-first; colori dal brand via --cmz-primary / --cmz-secondary.
 * Breakpoint: telefono < 720px, tablet 720–1024px, desktop > 1024px. Nessuna libreria, CSS unico. */
.cmz-app, .cmz-gate, .cmz-modal, .cmz-toast, .cmz-sheet {
    --cmz-primary: #8b5cf6; --cmz-secondary: #6366f1;
    --c-bg: #f4f5f9; --c-card: #fff; --c-line: #e5e7eb; --c-text: #111827; --c-muted: #5b6372;
    --c-ok: #047857; --c-warn: #b45309; --c-bad: #b91c1c;
    --c-radius: 16px; --c-shadow: 0 6px 24px rgba(17, 24, 39, .06);
    --c-tap: 44px; --c-tabbar: 60px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--c-text); line-height: 1.45; font-size: 15px; box-sizing: border-box;
}
.cmz-app *, .cmz-gate *, .cmz-modal *, .cmz-sheet *, .cmz-modal *::before, .cmz-app *::before { box-sizing: border-box; }
.cmz-app { background: var(--c-bg); border-radius: var(--c-radius); min-height: 70vh; overflow: hidden; overflow-x: clip; }
.cmz-app h3 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.cmz-app h4, .cmz-modal h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin: 0 0 8px; }
.cmz-app code, .cmz-modal code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: #eef0f5; padding: 2px 6px; border-radius: 6px; }
.cmz-muted { color: var(--c-muted); font-size: 13px; }
.cmz-empty { text-align: center; color: var(--c-muted); padding: 28px 12px; }
.cmz-hidden { display: none !important; }
body.cmz-lock { overflow: hidden; }
.cmz-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; color: var(--c-muted); }
.cmz-spinner { width: 36px; height: 36px; border: 3px solid var(--c-line); border-top-color: var(--cmz-primary); border-radius: 50%; animation: cmz-spin .8s linear infinite; margin-bottom: 12px; }
@keyframes cmz-spin { to { transform: rotate(360deg); } }

/* Accessibilità: focus visibile ovunque, movimento ridotto */
.cmz-app :focus-visible, .cmz-gate :focus-visible, .cmz-modal :focus-visible, .cmz-sheet :focus-visible { outline: 3px solid var(--cmz-primary); outline-offset: 2px; border-radius: 6px; }
.cmz-topbar :focus-visible, .cmz-tabbar :focus-visible { outline-color: currentColor; }
@media (prefers-reduced-motion: reduce) {
    .cmz-app *, .cmz-modal, .cmz-sheet, .cmz-toast, .cmz-overlay { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ */
/* Topbar: una riga, logo + nome campagna troncato + avatar/menu      */
/* ------------------------------------------------------------------ */
.cmz-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: linear-gradient(120deg, var(--cmz-primary), var(--cmz-secondary)); color: #fff; min-height: 60px; }
.cmz-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.cmz-brand-mark { width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; flex: none; }
.cmz-brand-text { min-width: 0; }
.cmz-brand-title { display: block; font-weight: 800; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-brand-sub { display: none; font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-user { display: flex; align-items: center; gap: 10px; flex: none; }
.cmz-user-name, .cmz-user .cmz-pill, .cmz-user .cmz-btn { display: none; }
.cmz-user-name { font-weight: 600; font-size: 14px; }
.cmz-pill { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.2); white-space: nowrap; }
.cmz-pill--warn { background: #fbbf24; color: #78350f; }
.cmz-avatar-btn { width: var(--c-tap); height: var(--c-tap); border-radius: 50%; border: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.18); color: #fff; font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; position: relative; flex: none; padding: 0; }
.cmz-avatar-btn .cmz-dot { position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: #fbbf24; border: 2px solid var(--cmz-primary); }
@media (min-width: 720px) {
    .cmz-topbar { padding: 14px 20px; min-height: 68px; }
    .cmz-brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
    .cmz-brand-title { font-size: 18px; }
    .cmz-brand-sub { display: block; }
    .cmz-user-name, .cmz-user .cmz-pill, .cmz-user .cmz-btn { display: inline-flex; }
    .cmz-user-name { display: inline; }
}

/* Strisce sottili sotto l'header (account, scadenza, demo, sola lettura): 28px, chiudibili */
.cmz-strips { display: flex; flex-direction: column; }
.cmz-strip { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 2px 8px 2px 14px; font-size: 12px; line-height: 1.25; border-bottom: 1px solid rgba(0,0,0,.05); }
.cmz-strip > span { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-strip b { font-weight: 700; }
.cmz-strip--info { background: #ede9fe; color: #4c1d95; }
.cmz-strip--warn { background: #fef3c7; color: #78350f; }
.cmz-strip--demo { background: #fff7ed; color: #7c2d12; }
.cmz-strip--bad { background: #fee2e2; color: #7f1d1d; }
.cmz-strip-act { border: 0; background: rgba(0,0,0,.06); color: inherit; font: inherit; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; cursor: pointer; white-space: nowrap; min-height: 24px; }
.cmz-strip-x { border: 0; background: none; color: inherit; width: 32px; height: 28px; font-size: 18px; line-height: 1; cursor: pointer; opacity: .7; flex: none; border-radius: 6px; }
.cmz-strip-x:hover { opacity: 1; background: rgba(0,0,0,.06); }
@media (min-width: 720px) { .cmz-strip { padding-left: 20px; font-size: 13px; } }

/* ------------------------------------------------------------------ */
/* Navigazione: tab in alto (≥720px), tab bar fissa in basso (<720px)  */
/* ------------------------------------------------------------------ */
.cmz-nav { display: none; gap: 4px; padding: 10px 20px 0; background: var(--c-card); border-bottom: 1px solid var(--c-line); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cmz-nav button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--c-muted); padding: 10px 12px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; position: relative; min-height: var(--c-tap); }
.cmz-nav button.is-on { color: var(--cmz-primary); border-bottom-color: var(--cmz-primary); }
.cmz-nav .cmz-badge, .cmz-tabbar .cmz-badge, .cmz-sheet .cmz-badge { position: absolute; top: 4px; right: -2px; background: var(--c-bad); color: #fff; font-size: 10px; border-radius: 999px; padding: 1px 6px; font-weight: 700; line-height: 1.4; }
@media (min-width: 720px) { .cmz-nav { display: flex; } }

.cmz-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9999; display: flex; justify-content: space-around; background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--c-line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 20px rgba(17,24,39,.06); }
.cmz-tabbar button { flex: 1 1 0; min-width: 0; max-width: 120px; min-height: 52px; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600; color: var(--c-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 4px 2px; border-radius: 12px; cursor: pointer; position: relative; line-height: 1; }
.cmz-tabbar button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cmz-tabbar svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cmz-tabbar button.is-on { color: var(--cmz-primary); }
.cmz-tabbar button.is-on svg { stroke-width: 2.3; }
.cmz-tabbar .cmz-badge { top: 2px; right: calc(50% - 22px); }
.cmz-tabbar:empty { display: none; }
@media (min-width: 720px) { .cmz-tabbar { display: none; } }

/* Foglio dal basso (menu account, "Altro", filtri) */
.cmz-sheet-overlay { position: fixed; inset: 0; background: rgba(15,16,33,.5); z-index: 99998; display: flex; align-items: flex-end; justify-content: center; animation: cmz-fade .15s ease-out; }
@keyframes cmz-fade { from { opacity: 0; } }
.cmz-sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -20px 60px rgba(0,0,0,.3); animation: cmz-up .2s ease-out; max-height: 85vh; max-height: 85svh; overflow: auto; }
@keyframes cmz-up { from { transform: translateY(40px); opacity: 0; } }
.cmz-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--c-line); margin: 4px auto 12px; }
.cmz-sheet-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; border-bottom: 1px solid var(--c-line); margin-bottom: 8px; }
.cmz-sheet-head .cmz-avatar { width: 44px; height: 44px; border-radius: 50%; font-size: 15px; }
.cmz-sheet-head b { display: block; font-size: 16px; }
.cmz-sheet-head small { color: var(--c-muted); font-size: 13px; }
.cmz-sheet-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.cmz-sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--c-line); background: none; font: inherit; font-size: 15px; font-weight: 500; color: var(--c-text); text-align: left; cursor: pointer; text-decoration: none; border-radius: 0; position: relative; }
.cmz-sheet-item:last-child { border-bottom: 0; }
.cmz-sheet-item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; color: var(--c-muted); }
.cmz-sheet-item.is-on { color: var(--cmz-primary); }
.cmz-sheet-item.is-on svg { color: inherit; }
.cmz-sheet-item--danger { color: var(--c-bad); }
.cmz-sheet-item .cmz-badge { position: static; margin-left: auto; }
.cmz-sheet-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); font-weight: 700; padding: 10px 6px 4px; }
.cmz-sheet .cmz-form-actions { position: sticky; bottom: 0; background: #fff; padding: 12px 0 0; margin: 8px 0 0; }
@media (min-width: 720px) { .cmz-sheet-overlay { align-items: center; padding: 16px; } .cmz-sheet { border-radius: 20px; padding: 12px 20px 20px; } .cmz-sheet-grip { display: none; } }

/* Contenuto */
.cmz-main { padding: 12px 12px calc(var(--c-tabbar) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 720px) { .cmz-main { padding: 18px 20px 28px; gap: 16px; } }
.cmz-banner { padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.cmz-banner--warn { background: #fef3c7; color: #78350f; }
.cmz-banner--info { background: #ede9fe; color: #4c1d95; }

/* layout */
.cmz-grid { display: grid; gap: 12px; }
.cmz-grid--2, .cmz-grid--3, .cmz-grid--eq { grid-template-columns: 1fr; }
@media (min-width: 720px) { .cmz-grid { gap: 16px; } .cmz-grid--eq { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1025px) { .cmz-grid--2 { grid-template-columns: 3fr 2fr; } .cmz-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.cmz-card { background: var(--c-card); border-radius: var(--c-radius); box-shadow: var(--c-shadow); padding: 14px; min-width: 0; }
@media (min-width: 720px) { .cmz-card { padding: 16px 18px; } }
.cmz-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cmz-count { display: inline-block; background: var(--c-bg); color: var(--c-muted); font-size: 12px; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 500; }

/* ------------------------------------------------------------------ */
/* KPI: auto-fit (2 colonne a 390px), etichette a capo, numeri fluidi  */
/* ------------------------------------------------------------------ */
.cmz-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
@media (min-width: 720px) { .cmz-kpis { gap: 12px; } }
.cmz-kpi { background: var(--c-card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--c-shadow); border: 2px solid transparent; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s; min-width: 0; min-height: var(--c-tap); }
.cmz-kpi:hover { border-color: var(--c-line); }
.cmz-kpi.is-on { border-color: var(--cmz-primary); }
.cmz-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); display: block; white-space: normal; overflow-wrap: anywhere; hyphens: auto; line-height: 1.25; }
.cmz-kpi-value { font-size: clamp(22px, 2.2vw + 14px, 30px); font-weight: 800; line-height: 1.1; margin: 4px 0 2px; letter-spacing: -.02em; display: block; font-variant-numeric: tabular-nums; }
.cmz-kpi-sub { font-size: 12px; color: var(--c-muted); display: block; overflow-wrap: anywhere; }
/* Quattro KPI in una riga sola: su telefono scorrimento orizzontale a snap con card da 150px */
.cmz-kpis--row { grid-template-columns: repeat(4, 1fr); }
.cmz-kpis--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 719.98px) {
    .cmz-kpis--row, .cmz-kpis--3 { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 12px; gap: 10px; margin: 0 -12px; padding: 2px 12px 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .cmz-kpis--row::-webkit-scrollbar, .cmz-kpis--3::-webkit-scrollbar { display: none; }
    .cmz-kpis--row .cmz-kpi, .cmz-kpis--3 .cmz-kpi { flex: 0 0 150px; scroll-snap-align: start; }
    .cmz-modal .cmz-kpis--3 { margin: 0; padding: 2px 0 6px; scroll-padding-inline: 0; }
}

/* map / schematic */
.cmz-map { position: relative; min-height: 240px; border-radius: 12px; overflow: hidden; background: #eef0f5; }
@media (min-width: 720px) { .cmz-map { min-height: 320px; } }
.cmz-map-gl { position: absolute; inset: 0; }
.cmz-schema { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 6px; }
@media (min-width: 720px) { .cmz-schema { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 8px; } }
.cmz-tile { position: relative; border: 0; border-radius: 12px; padding: 10px 8px 8px; color: #fff; text-align: left; font: inherit; cursor: pointer; min-height: 76px; display: flex; flex-direction: column; justify-content: space-between; background: var(--tc, #888); transition: transform .12s, box-shadow .12s; min-width: 0; }
@media (min-width: 720px) { .cmz-tile { min-height: 92px; padding: 12px 10px 10px; } }
.cmz-tile:hover { transform: translateY(-2px); }
.cmz-tile.is-on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--tc); }
.cmz-tile.is-dim { opacity: .45; }
.cmz-tile-name { font-weight: 700; font-size: 12px; line-height: 1.15; text-shadow: 0 1px 2px rgba(0,0,0,.25); overflow-wrap: anywhere; }
@media (min-width: 720px) { .cmz-tile-name { font-size: 13px; } }
.cmz-tile-n { font-size: 20px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
@media (min-width: 720px) { .cmz-tile-n { font-size: 24px; } }
.cmz-tile-sub { font-size: 11px; opacity: .9; display: none; }
@media (min-width: 720px) { .cmz-tile-sub { display: block; } }
.cmz-tile-dot { position: absolute; top: 6px; right: 6px; background: #fff; color: var(--c-bad); font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; }
.cmz-map-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 2px 0; }
.cmz-legend { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--c-muted); }
.cmz-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; background: var(--tc); }
.cmz-crumb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; min-width: 0; }
.cmz-crumb button { border: 0; background: var(--c-bg); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--cmz-primary); font-weight: 600; min-height: 36px; }

/* ranking rows */
.cmz-rows { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.cmz-row { display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid var(--c-line); background: #fff; border-radius: 12px; padding: 8px 10px; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color .12s, background-color .12s; min-height: var(--c-tap); }
.cmz-row:hover { border-color: var(--rc, var(--cmz-primary)); }
.cmz-row.is-on { border-color: var(--rc, var(--cmz-primary)); background: color-mix(in srgb, var(--rc, var(--cmz-primary)) 8%, #fff); }
.cmz-avatar { width: 36px; height: 36px; border-radius: 10px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none; background: var(--rc, var(--cmz-primary)); }
.cmz-row-body { flex: 1; min-width: 0; }
.cmz-row-title { display: block; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-row-sub { display: block; font-size: 12px; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-row-num { font-weight: 800; font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmz-row-num small { font-weight: 500; font-size: 11px; color: var(--c-muted); display: block; text-align: right; }
.cmz-bar { height: 6px; background: var(--c-bg); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.cmz-bar i { display: block; height: 100%; background: var(--rc, var(--cmz-primary)); border-radius: 999px; }

/* chart (svg) */
.cmz-chart { width: 100%; height: 180px; }
@media (min-width: 720px) { .cmz-chart { height: 220px; } }
.cmz-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cmz-chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--c-muted); margin-top: 4px; flex-wrap: wrap; }
.cmz-chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.cmz-segs { display: inline-flex; gap: 2px; background: var(--c-bg); padding: 3px; border-radius: 999px; }
.cmz-seg { border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 13px; cursor: pointer; color: var(--c-muted); min-height: 36px; }
.cmz-seg.is-on { background: var(--cmz-primary); color: #fff; }

/* ------------------------------------------------------------------ */
/* Filtri: ricerca a tutta larghezza + riga scorrevole di select/chip  */
/* ------------------------------------------------------------------ */
.cmz-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.cmz-tools-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.cmz-tools input, .cmz-tools select, .cmz-form input, .cmz-form select, .cmz-form textarea {
    font: inherit; font-size: 16px; padding: 9px 12px; border: 1px solid var(--c-line); border-radius: 10px; background: #fff; color: inherit; min-width: 0; min-height: var(--c-tap); }
.cmz-tools select, .cmz-form select { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
.cmz-tools input[type=search] { width: 100%; flex: 1 1 100%; }
.cmz-tools .cmz-check { min-height: var(--c-tap); display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
@media (max-width: 719.98px) {
    .cmz-tools { width: 100%; }
    .cmz-tools-row { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 28px); margin: 0 -14px; padding: 2px 14px 6px; scroll-snap-type: x proximity; scroll-padding-inline: 14px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .cmz-tools-row::-webkit-scrollbar { display: none; }
    .cmz-tools-row > * { flex: 0 0 auto; scroll-snap-align: start; max-width: 70vw; }
    .cmz-tools-row select { max-width: 56vw; }
    .cmz-tools-row input[type=date] { width: 150px; }
    .cmz-tools-row .cmz-btn, .cmz-tools-row .cmz-check { min-height: var(--c-tap); }
}
@media (min-width: 720px) {
    .cmz-tools input, .cmz-tools select { font-size: 14px; min-height: 40px; }
    .cmz-tools input[type=search] { width: 190px; flex: 0 1 auto; }
    .cmz-form input, .cmz-form select, .cmz-form textarea { font-size: 14px; min-height: 40px; }
}
.cmz-form { display: grid; gap: 12px; }
.cmz-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--c-muted); }
.cmz-form label > span { font-weight: 600; }
.cmz-form .cmz-check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; color: var(--c-text); min-height: var(--c-tap); }
.cmz-form .cmz-check input, .cmz-tools .cmz-check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--cmz-primary); margin: 0; flex: none; }
.cmz-form-row { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 720px) { .cmz-form-row { grid-template-columns: 1fr 1fr; } }
.cmz-form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.cmz-form-error { background: #fef2f2; color: #991b1b; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.cmz-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cmz-chip { border: 1px solid var(--c-line); background: #fff; border-radius: 999px; padding: 8px 13px; font: inherit; font-size: 13px; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.cmz-chip.is-on { background: var(--cc, var(--cmz-primary)); border-color: var(--cc, var(--cmz-primary)); color: #fff; }

/* buttons */
.cmz-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--cmz-primary); background: var(--cmz-primary); color: #fff !important; font: inherit; font-weight: 600; font-size: 14px; padding: 9px 14px; border-radius: 10px; cursor: pointer; text-decoration: none !important; line-height: 1.2; white-space: nowrap; transition: filter .15s; min-height: var(--c-tap); }
.cmz-btn:hover { filter: brightness(1.08); }
.cmz-btn:disabled { opacity: .5; cursor: wait; }
.cmz-btn--ghost { background: transparent; color: var(--cmz-primary) !important; border-color: currentColor; }
.cmz-topbar .cmz-btn--ghost { color: #fff !important; border-color: rgba(255,255,255,.5); }
.cmz-btn--danger { background: transparent; color: var(--c-bad) !important; border-color: var(--c-bad); }
.cmz-btn--sm { padding: 6px 11px; font-size: 13px; min-height: 36px; }
@media (min-width: 720px) { .cmz-btn { min-height: 40px; } .cmz-btn--sm { padding: 5px 10px; font-size: 12px; min-height: 30px; } }
.cmz-btn--block { width: 100%; }
.cmz-link { border: 0; background: none; color: var(--cmz-primary); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 6px 0; min-height: 32px; }

/* ------------------------------------------------------------------ */
/* Tabelle → card su telefono; azioni 44px; menu "⋯" per le secondarie */
/* ------------------------------------------------------------------ */
.cmz-table-wrap { overflow: auto; max-width: 100%; }
.cmz-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cmz-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); padding: 8px 10px; border-bottom: 2px solid var(--c-line); white-space: nowrap; }
.cmz-table td { padding: 10px; border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.cmz-table tr[data-id] { cursor: pointer; }
.cmz-table tr[data-id]:hover td { background: #fafafe; }
.cmz-table small { display: block; color: var(--c-muted); font-size: 12px; }
.cmz-table tr.is-archived td { opacity: .5; }
.cmz-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--c-bg); color: var(--c-muted); white-space: nowrap; }
.cmz-tag--ok { background: #d1fae5; color: #065f46; }
.cmz-tag--warn { background: #fef3c7; color: #92400e; }
.cmz-tag--bad { background: #fee2e2; color: #991b1b; }
.cmz-tag--info { background: #ede9fe; color: #5b21b6; }
.cmz-actions { white-space: nowrap; text-align: right; }
.cmz-actions .cmz-btn { margin-left: 4px; }
.cmz-more { display: inline-block; position: relative; margin-left: 4px; vertical-align: middle; }
.cmz-more > summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--c-line); background: #fff; cursor: pointer; font-size: 18px; font-weight: 700; color: var(--c-muted); line-height: 1; }
.cmz-more > summary::-webkit-details-marker { display: none; }
.cmz-more[open] > summary { border-color: var(--cmz-primary); color: var(--cmz-primary); }
.cmz-more-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 100001; background: #fff; border: 1px solid var(--c-line); border-radius: 12px; box-shadow: 0 12px 30px rgba(17,24,39,.14); padding: 6px; min-width: 180px; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.cmz-more-menu .cmz-btn { margin: 0; width: 100%; justify-content: flex-start; border-color: transparent; background: transparent; color: var(--c-text) !important; font-weight: 500; min-height: var(--c-tap); }
.cmz-more-menu .cmz-btn:hover { background: var(--c-bg); filter: none; }
.cmz-more-menu .cmz-btn--danger { color: var(--c-bad) !important; }
.cmz-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--c-muted); flex-wrap: wrap; }
.cmz-pager .cmz-btn { min-height: var(--c-tap); min-width: var(--c-tap); }
.cmz-pager-btns { display: flex; gap: 8px; }
@media (max-width: 719.98px) {
    .cmz-table thead { display: none; }
    .cmz-table, .cmz-table tbody, .cmz-table tr, .cmz-table td { display: block; width: 100%; }
    .cmz-table tr { border: 1px solid var(--c-line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
    .cmz-table tr[data-id] { min-height: var(--c-tap); }
    .cmz-table td { border: 0; padding: 3px 0; overflow-wrap: anywhere; }
    .cmz-table td[data-l]::before { content: attr(data-l) ": "; color: var(--c-muted); font-size: 12px; }
    .cmz-table td.cmz-actions { text-align: left; padding-top: 10px; white-space: normal; display: flex; flex-wrap: wrap; gap: 8px; }
    .cmz-table td.cmz-actions:empty { display: none; }
    .cmz-table td.cmz-actions .cmz-btn { margin: 0; flex: 1 1 calc(50% - 4px); min-height: var(--c-tap); font-size: 14px; }
    .cmz-table td.cmz-actions .cmz-btn:only-child { flex-basis: 100%; }
    .cmz-table td.cmz-actions .cmz-more { margin: 0; flex: 0 0 var(--c-tap); }
    .cmz-table td.cmz-actions .cmz-more > summary { width: var(--c-tap); height: var(--c-tap); }
    .cmz-table td.cmz-actions .cmz-more-menu { position: static; box-shadow: none; border: 0; padding: 6px 0 0; min-width: 0; width: 100%; }
    .cmz-table td.cmz-actions .cmz-more[open] { flex-basis: 100%; }
    .cmz-table td.cmz-actions .cmz-more[open] > summary { display: none; }
    .cmz-table td.cmz-actions .cmz-more-menu .cmz-btn { border: 1px solid var(--c-line); flex: 1 1 100%; }
    .cmz-hide-sm { display: none !important; }
    .cmz-pager { justify-content: center; }
    .cmz-pager > span:first-child { flex: 1 1 100%; text-align: center; }
    .cmz-pager-btns { width: 100%; }
    .cmz-pager-btns .cmz-btn { flex: 1 1 0; font-size: 15px; }
}

/* ------------------------------------------------------------------ */
/* Modali: su telefono foglio a schermo intero con barra sticky       */
/* ------------------------------------------------------------------ */
.cmz-overlay { position: fixed; inset: 0; background: rgba(15, 16, 33, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); z-index: 99999; display: flex; align-items: flex-end; justify-content: center; padding: 0; overflow: hidden; }
.cmz-modal { position: relative; background: #fff; width: 100%; height: 100%; max-height: 100dvh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0,0,0,.35); animation: cmz-up .2s ease-out; border-radius: 0; padding: 0; }
.cmz-modal-bar { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 6px 6px 16px; padding-top: calc(6px + env(safe-area-inset-top)); border-bottom: 1px solid var(--c-line); flex: none; background: #fff; }
.cmz-modal-bar-title { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmz-modal-close { border: 0; background: var(--c-bg); width: var(--c-tap); height: var(--c-tap); border-radius: 50%; font-size: 24px; line-height: 1; cursor: pointer; color: var(--c-muted); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.cmz-modal-body { flex: 1 1 auto; min-height: 0; overflow: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.cmz-modal-body > .cmz-modal-close { display: none; } /* chi riscrive il contenuto aggiunge una X: la barra ha già la sua */
.cmz-modal h3 { font-size: 20px; margin: 0 0 4px; overflow-wrap: anywhere; }
.cmz-modal .cmz-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--cmz-primary); }
.cmz-modal-body > .cmz-form:last-child > .cmz-form-actions:last-child, .cmz-modal-body > .cmz-form-actions:last-child { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: #fff; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); margin: 8px 0 calc(-16px - env(safe-area-inset-bottom)); border-top: 1px solid var(--c-line); z-index: 2; }
@media (max-width: 719.98px) {
    .cmz-modal .cmz-form-actions .cmz-btn { flex: 1 1 100%; min-height: 48px; font-size: 15px; }
    .cmz-modal .cmz-form-actions .cmz-btn--sm { flex: 1 1 calc(50% - 4px); }
}
@media (min-width: 720px) {
    .cmz-overlay { align-items: center; padding: 16px; overflow: auto; }
    .cmz-modal { height: auto; max-height: 92vh; max-width: 560px; border-radius: 18px; animation: cmz-pop .18s ease-out; }
    .cmz-modal--wide { max-width: 860px; }
    .cmz-modal-bar { position: absolute; top: 0; right: 0; border: 0; background: none; padding: 12px; min-height: 0; z-index: 3; pointer-events: none; }
    .cmz-modal-bar-title { display: none; }
    .cmz-modal-close { width: 34px; height: 34px; font-size: 22px; pointer-events: auto; }
    .cmz-modal-body { padding: 24px; }
    .cmz-modal-body > .cmz-form:last-child > .cmz-form-actions:last-child, .cmz-modal-body > .cmz-form-actions:last-child { position: static; border: 0; padding: 0; margin: 4px 0 0; }
}
@keyframes cmz-pop { from { transform: translateY(12px); opacity: 0; } }
.cmz-dl { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 14px; margin: 12px 0; }
.cmz-dl dt { color: var(--c-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.cmz-dl dd { margin: 0 0 6px; word-break: break-word; }
@media (min-width: 720px) { .cmz-dl { grid-template-columns: 140px 1fr; gap: 6px 12px; } .cmz-dl dd { margin-bottom: 0; } }
.cmz-qr-view { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.cmz-qr-view > div { min-width: 0; }
@media (min-width: 720px) { .cmz-qr-view { grid-template-columns: 240px 1fr; gap: 20px; } }
.cmz-qr-box { background: #fff; border: 1px solid var(--c-line); border-radius: 14px; padding: 10px; max-width: 280px; margin: 0 auto; }
@media (min-width: 720px) { .cmz-qr-box { max-width: none; margin: 0; } }
.cmz-qr-box svg { width: 100%; height: auto; display: block; }
.cmz-copy { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.cmz-copy code { font-size: 12px; word-break: break-all; }
.cmz-notes { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.cmz-note { background: var(--c-bg); border-radius: 10px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmz-note--reply { background: #ede9fe; }
.cmz-note--status { background: transparent; color: var(--c-muted); padding: 2px 12px; font-size: 12px; }
.cmz-note small { display: block; color: var(--c-muted); font-size: 11px; margin-top: 2px; }
.cmz-toast { position: fixed; left: 50%; bottom: calc(var(--c-tabbar) + 16px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 100000; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); }
.cmz-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.cmz-toast--error { background: var(--c-bad); }
@media (min-width: 720px) { .cmz-toast { bottom: 24px; } }
.cmz-cred { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 12px; padding: 12px 14px; font-size: 14px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ */
/* Agenda: elenco per giorno + selettore settimana a snap (telefono)   */
/* ------------------------------------------------------------------ */
.cmz-agenda-day { margin-bottom: 14px; }
.cmz-agenda-date { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); margin-bottom: 6px; }
.cmz-event { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--c-line); border-left: 5px solid var(--ec, var(--cmz-primary)); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; min-height: var(--c-tap); }
.cmz-event.is-draft { border-style: dashed; }
.cmz-event.is-cancelled { opacity: .5; text-decoration: line-through; }
.cmz-event-time { font-weight: 700; font-size: 14px; white-space: nowrap; min-width: 52px; font-variant-numeric: tabular-nums; }
.cmz-event-body { flex: 1; min-width: 0; }
.cmz-event-title { font-weight: 600; overflow-wrap: anywhere; }
.cmz-event-sub { font-size: 12px; color: var(--c-muted); overflow-wrap: anywhere; }
.cmz-weeks { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; margin: 0 0 12px; padding: 0 0 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cmz-weeks::-webkit-scrollbar { display: none; }
.cmz-week { flex: 0 0 100%; scroll-snap-align: start; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cmz-wday { border: 0; background: var(--c-bg); border-radius: 12px; padding: 6px 0 4px; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; color: var(--c-text); position: relative; }
.cmz-wday small { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--c-muted); }
.cmz-wday b { font-size: 16px; font-variant-numeric: tabular-nums; }
.cmz-wday i { width: 5px; height: 5px; border-radius: 50%; background: var(--cmz-primary); opacity: 0; }
.cmz-wday.has-ev i { opacity: 1; }
.cmz-wday.is-today b { color: var(--cmz-primary); }
.cmz-wday.is-on { background: var(--cmz-primary); color: #fff; }
.cmz-wday.is-on small, .cmz-wday.is-on b { color: #fff; }
.cmz-wday.is-on i { background: #fff; }
.cmz-wday.is-past { opacity: .55; }
.cmz-week-label { font-size: 12px; color: var(--c-muted); text-align: center; margin: -4px 0 10px; }
.cmz-month { display: none; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cmz-month-h { font-size: 11px; text-transform: uppercase; color: var(--c-muted); text-align: center; padding: 4px 0; }
.cmz-day { min-height: 70px; border: 1px solid var(--c-line); border-radius: 8px; padding: 4px; font-size: 11px; cursor: pointer; background: #fff; }
.cmz-day.is-other { opacity: .35; }
.cmz-day.is-today { border-color: var(--cmz-primary); }
.cmz-day b { display: block; margin-bottom: 2px; }
.cmz-day i { display: block; height: 6px; border-radius: 3px; margin-top: 2px; background: var(--ec); }
@media (min-width: 720px) { .cmz-month { display: grid; } .cmz-weeks, .cmz-week-label { display: none; } }
.cmz-agenda-nav { display: flex; align-items: center; gap: 6px; }
.cmz-agenda-nav button { min-width: 36px; }
@media (max-width: 719.98px) { .cmz-only-desk { display: none !important; } }
@media (min-width: 720px) { .cmz-only-phone { display: none !important; } }

/* ------------------------------------------------------------------ */
/* Gate                                                                */
/* ------------------------------------------------------------------ */
.cmz-gate { display: flex; justify-content: center; padding: 12px 0 24px; }
@media (min-width: 720px) { .cmz-gate { padding: 30px 0; } }
.cmz-gate-card { background: #fff; border-radius: 20px; padding: 28px 20px; width: 100%; max-width: 440px; box-shadow: 0 30px 80px rgba(0,0,0,.3); text-align: center; }
@media (min-width: 720px) { .cmz-gate-card { padding: 32px 28px; } }
.cmz-gate-badge { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(120deg, var(--cmz-primary), var(--cmz-secondary)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 24px; margin-bottom: 12px; }
.cmz-gate-badge--ok { background: var(--c-ok); }
.cmz-gate-badge--warn { background: var(--c-warn); }
.cmz-gate-card h2 { margin: 0 0 6px; font-size: 22px; }
.cmz-gate-card p { color: var(--c-muted); font-size: 14px; margin: 0 0 14px; }
.cmz-gate-form { display: flex; flex-direction: column; gap: 12px; text-align: left; margin: 14px 0; }
.cmz-gate-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--c-muted); }
.cmz-gate-form input[type=text], .cmz-gate-form input[type=password] { font: inherit; font-size: 16px; padding: 11px 14px; border: 1.5px solid var(--c-line); border-radius: 12px; min-height: 48px; width: 100%; }
.cmz-gate-form input:focus { outline: none; border-color: var(--cmz-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cmz-primary) 18%, transparent); }
.cmz-gate-code { letter-spacing: 8px; text-align: center; font-size: 22px !important; }
.cmz-gate-check { flex-direction: row !important; align-items: center; font-weight: 500 !important; color: var(--c-text) !important; min-height: var(--c-tap); gap: 10px !important; }
.cmz-gate-check input { width: 22px; height: 22px; accent-color: var(--cmz-primary); margin: 0; flex: none; }
.cmz-gate-submit { display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px; background: linear-gradient(120deg, var(--cmz-primary), var(--cmz-secondary)); color: #fff !important; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; text-align: center; min-height: 50px; }
.cmz-gate-lost, .cmz-gate-link { display: inline-block; border: 0; background: none; color: var(--cmz-primary); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; margin-top: 4px; padding: 10px 6px; min-height: var(--c-tap); }
.cmz-gate-links { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-top: 10px; }
.cmz-gate-msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 10px; }
.cmz-gate-msg--error { background: #fef2f2; color: #991b1b; }
.cmz-gate-msg--ok { background: #ecfdf5; color: #065f46; }
.cmz-gate-choice { width: 100%; text-align: left; border: 1.5px solid var(--c-line); background: #fff; border-radius: 14px; padding: 14px; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-height: var(--c-tap); color: inherit; }
.cmz-gate-choice:hover, .cmz-gate-choice:active { border-color: var(--cmz-primary); }
.cmz-gate-choice b { font-size: 15px; }
.cmz-gate-choice span { font-size: 13px; color: var(--c-muted); }
.cmz-gate-qr { max-width: 220px; margin: 0 auto 10px; }
.cmz-gate-qr svg { width: 100%; height: auto; }
.cmz-gate-secret { font-size: 14px; letter-spacing: 1px; overflow-wrap: anywhere; }
.cmz-gate-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.cmz-gate-codes code { font-size: 15px; padding: 8px; background: var(--c-bg); border-radius: 8px; }
.cmz-gate-row { display: flex; gap: 16px; justify-content: center; margin-bottom: 10px; }
.cmz-gate-site { font-size: 12px; color: var(--c-muted); margin: 18px 0 0 !important; }
@media print { .cmz-gate-submit, .cmz-gate-row { display: none; } }

/* demo e spazi di lavoro */
.cmz-banner--demo { background: #fff7ed; border: 1px solid #fdba74; color: #7c2d12; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.cmz-banner-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cmz-gate-demo { margin-top: 22px; padding-top: 18px; border-top: 1px dashed #d1d5db; text-align: left; }
.cmz-gate-demo h3 { margin: 0 0 4px; font-size: 16px; }
.cmz-gate-demo-roles { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
