*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg-app); color: var(--text-primary); font: 15px/1.4 var(--font-sans); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 16px; height: 16px; }
.ico--lg { width: 56px; height: 56px; stroke-width: 1.4; }

/* categorie: variabili per card, swatch, chip */
[data-cat] { --c-bg: var(--cat-blue-bg); --c-fg: var(--cat-blue-fg); }
[data-cat="teal"]   { --c-bg: var(--cat-teal-bg);   --c-fg: var(--cat-teal-fg); }
[data-cat="amber"]  { --c-bg: var(--cat-amber-bg);  --c-fg: var(--cat-amber-fg); }
[data-cat="purple"] { --c-bg: var(--cat-purple-bg); --c-fg: var(--cat-purple-fg); }
[data-cat="coral"]  { --c-bg: var(--cat-coral-bg);  --c-fg: var(--cat-coral-fg); }
[data-cat="pink"]   { --c-bg: var(--cat-pink-bg);   --c-fg: var(--cat-pink-fg); }
[data-cat="green"]  { --c-bg: var(--cat-green-bg);  --c-fg: var(--cat-green-fg); }
[data-cat="gray"]   { --c-bg: var(--cat-gray-bg);   --c-fg: var(--cat-gray-fg); }

/* ---------- layout ---------- */
.app { padding: 0 var(--sp-4); }
.layout { max-width: 420px; margin: 0 auto; }
.screen { padding: max(var(--sp-5), env(safe-area-inset-top)) 0 calc(150px + env(safe-area-inset-bottom)); }
.aside { display: none; }

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.header h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.header__date { font-size: 13px; color: var(--text-secondary); }
.header__tools { display: flex; gap: 2px; margin-right: -10px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--text-secondary); transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.icon-btn { position: relative; }
.badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--now); color: #fff; font-size: 11px; font-weight: 600; line-height: 1; display: grid; place-items: center; border: 2px solid var(--bg-app); font-variant-numeric: tabular-nums; animation: check-pop var(--t-base) var(--ease-spring); }
.icon-btn:active { transform: scale(.92); background: var(--bg-input); }

.week { display: flex; justify-content: space-between; margin-bottom: var(--sp-3); touch-action: pan-y; }
.day { width: 40px; padding: 6px 0 8px; text-align: center; border-radius: var(--r-day); font-size: 11px; font-weight: 500; color: var(--text-secondary); position: relative; transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.day b { display: block; font-size: 15px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }
.day:active { transform: scale(.94); }
.day.is-today b { color: var(--accent); }
.day.is-selected { background: var(--accent); color: #fff; }
.day.is-selected b { color: #fff; }
.day i { position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--text-muted); }
.day i.is-red { background: var(--now); }
.day.is-selected i { background: rgba(255,255,255,.8); }

.filters { display: flex; gap: var(--sp-2); overflow-x: auto; margin: 0 calc(-1 * var(--sp-4)) var(--sp-5); padding: 0 var(--sp-4); scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.pill { flex: none; height: 32px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 500; color: var(--text-secondary); background: var(--bg-surface); display: inline-flex; align-items: center; gap: 6px; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.pill[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- timeline ---------- */
.timeline { position: relative; touch-action: pan-y; }
.timeline.slide-l { animation: slide-l var(--t-base) var(--ease); }
.timeline.slide-r { animation: slide-r var(--t-base) var(--ease); }
@keyframes slide-l { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-r { from { opacity: 0; transform: translateX(-28px); } }
.timeline::before { content: ""; position: absolute; left: calc(var(--time-col) + 4px); top: 0; bottom: 0; width: 2px; background: var(--line); border-radius: 1px; }
.slot { display: grid; grid-template-columns: var(--time-col) 1fr; gap: var(--sp-2); }
.slot__time { font-size: 12px; color: var(--text-muted); text-align: right; padding-top: 14px; padding-right: 10px; font-variant-numeric: tabular-nums; }
.slot__body { padding-left: var(--sp-2); min-width: 0; }

.event { display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; margin: 4px 0; padding: 10px 12px; border-radius: var(--r-card); background: var(--c-bg); color: var(--c-fg); cursor: pointer; width: 100%; transition: transform var(--t-fast) var(--ease); }
.timeline[class*="slide-"] .event { animation: pop-in var(--t-base) var(--ease) both; }
.event:active { transform: scale(.98); }
.event__icon { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.55); }
[data-theme="dark"] .event__icon { background: rgba(255,255,255,.14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .event__icon { background: rgba(255,255,255,.14); } }
.event__text { flex: 1; min-width: 0; }
.event__title { font-weight: 600; word-break: break-word; }
.event__time { font-size: 12px; opacity: .75; }
.event.is-late { background: var(--late-bg); color: var(--late-fg); --c-bg: var(--late-bg); --c-fg: var(--late-fg); }
.event.is-late .event__time { opacity: 1; font-weight: 600; }
.slot__time--late { color: var(--now); font-weight: 500; }
.event__flag { flex: none; color: var(--now); display: grid; }
.event__flag .ico { fill: currentColor; width: 18px; height: 18px; }
.event.is-done .event__title { text-decoration: line-through; opacity: .6; }
.event.is-done .event__icon { opacity: .6; }

.check { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; opacity: .7; background: transparent; color: inherit; display: grid; place-items: center; padding: 0; }
.check::after { content: ""; position: absolute; inset: -11px; }
.check svg { width: 12px; height: 12px; fill: none; stroke: var(--c-bg); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 16; stroke-dashoffset: 16; }
.is-done .check { background: currentColor; opacity: 1; }
.check.pop { animation: check-pop var(--t-base) var(--ease-spring); }
.is-done .check svg { stroke-dashoffset: 0; transition: stroke-dashoffset var(--t-base) var(--ease) 60ms; }

.now { display: grid; grid-template-columns: var(--time-col) 1fr; gap: var(--sp-2); align-items: center; margin: 6px 0; position: relative; z-index: 1; }
.now__label { font-size: 11px; font-weight: 500; color: var(--now); text-align: right; padding-right: 10px; font-variant-numeric: tabular-nums; }
.now__line { height: 2px; background: var(--now); position: relative; margin-left: -4px; border-radius: 1px; }
.now__line::before { content: ""; position: absolute; left: -1px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

.empty { text-align: center; color: var(--text-muted); padding: var(--sp-8) var(--sp-4); }
.empty h2 { margin: var(--sp-3) 0 var(--sp-1); font-size: 17px; font-weight: 600; color: var(--text-primary); }
.empty p { margin: 0 0 var(--sp-4); font-size: 14px; color: var(--text-secondary); }


/* ---------- FAB ---------- */
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; font: 600 15px var(--font-sans); box-shadow: var(--shadow-fab); cursor: pointer; z-index: 10; transition: transform var(--t-fast) var(--ease); white-space: nowrap; }
.fab:active { transform: translateX(-50%) scale(.96); }

/* ---------- bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; background: var(--backdrop); z-index: 30; animation: fade var(--t-base) var(--ease); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 460px; max-height: 92vh; max-height: 92dvh; overflow: auto; overscroll-behavior: contain; background: var(--bg-surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; box-shadow: var(--shadow-sheet); padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom)); z-index: 31; animation: sheet-up var(--t-slow) var(--ease) both; }
.sheet::before { content: ""; display: block; width: 36px; height: 4px; margin: 0 auto var(--sp-4); border-radius: 2px; background: var(--line); }
.sheet h2 { margin: 0 0 var(--sp-1); font-size: 20px; font-weight: 600; }
.sheet__sub { font-size: 13px; color: var(--text-secondary); margin: 0 0 var(--sp-4); }

.s-title { width: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 600; padding: 4px 0; }
.s-title::placeholder, .s-notes::placeholder { color: var(--text-muted); }
.s-title:focus, .s-notes:focus { outline: none; }
.s-notes { width: 100%; border: 0; background: transparent; resize: none; font-size: 16px; color: var(--text-secondary); padding: 4px 0; min-height: 44px; }
.s-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0; }
.chip-in { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--r-pill); background: var(--bg-input); font-size: 14px; color: var(--text-secondary); position: relative; }
.chip-in input, .chip-in select { border: 0; background: transparent; font-size: 16px; color: var(--text-primary); padding: 0; min-width: 0; appearance: none; -webkit-appearance: none; }
.chip-in input[type=date] { width: 128px; } .chip-in input[type=time] { width: 76px; }
.chip-in select { max-width: 150px; padding-right: 2px; }
.chip-in:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-in--flag { color: var(--text-secondary); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.chip-in--flag[aria-pressed="true"] { background: color-mix(in srgb, var(--now) 14%, transparent); color: var(--now); font-weight: 500; }
.chip-in--flag[aria-pressed="true"] .ico { fill: currentColor; }
.s-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); margin: var(--sp-4) 0 var(--sp-2); }
.swatches { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; background: var(--c-bg); border: 2px solid var(--c-fg); opacity: .9; position: relative; }
.swatch::after { content: ""; position: absolute; inset: -6px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--accent); }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--sp-2); justify-items: center; }
.icon-opt { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-input); color: var(--text-secondary); position: relative; }
.icon-opt[aria-pressed="true"] { background: var(--c-bg); color: var(--c-fg); box-shadow: 0 0 0 2px var(--accent); }
.sheet__foot { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-5); }
.sheet__foot .sp { flex: 1; }
.btn { height: 44px; padding: 0 20px; border-radius: var(--r-pill); font-size: 15px; font-weight: 600; background: var(--bg-input); display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform var(--t-fast) var(--ease); }
.btn:active { transform: scale(.96); }
.btn--primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-fab); }
.btn--danger { background: transparent; color: var(--now); padding: 0 12px; }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.by { font-size: 12px; color: var(--text-muted); margin-top: var(--sp-3); }

.move { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500; margin: 0 0 var(--sp-2) 12px; }

/* novità */
.news { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 56px; padding: 8px 4px; border-radius: var(--r-card); }
.news:disabled { opacity: .55; }
.news:not(:disabled):active { background: var(--bg-input); }
.news__av { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; }
.news__txt { flex: 1; min-width: 0; font-size: 14px; word-break: break-word; }
.news__txt small { display: block; font-size: 12px; color: var(--text-muted); }
.news.is-new .news__txt { font-weight: 500; }
.news__dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

/* schermata novità a tutto schermo */
.nw { position: fixed; inset: 0; z-index: 40; background: var(--bg-app); display: flex; flex-direction: column; padding: max(var(--sp-5), env(safe-area-inset-top)) var(--sp-5) max(var(--sp-5), env(safe-area-inset-bottom)); animation: fade var(--t-base) var(--ease); touch-action: pan-y; }
.nw__top { display: flex; align-items: center; justify-content: space-between; max-width: 420px; width: 100%; margin: 0 auto; }
.nw__count { font-size: 13px; color: var(--text-secondary); }
.nw__dots { display: flex; gap: 6px; align-items: center; }
.nw__dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); transition: width var(--t-base) var(--ease), background var(--t-base) var(--ease); }
.nw__dots i.on { width: 18px; background: var(--accent); }
.nw__body { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 420px; width: 100%; margin: 0 auto; }
.nw__body.slide-l { animation: slide-l var(--t-base) var(--ease); }
.nw__body.slide-r { animation: slide-r var(--t-base) var(--ease); }
.nw__av { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 30px; font-weight: 600; display: grid; place-items: center; margin-bottom: var(--sp-4); }
.nw h2 { font-size: 26px; font-weight: 600; margin: 0 0 2px; letter-spacing: -.01em; }
.nw__what { color: var(--text-secondary); font-size: 15px; margin-bottom: var(--sp-3); }
.nw__changes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.nw__changes .tag { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: var(--r-pill); }
.nw__date { font-size: 13px; color: var(--text-secondary); margin: var(--sp-2) 0 var(--sp-2); }
.nw .event { cursor: default; margin: 0; }
.nw .event:active { transform: none; }
.nw__notes { margin-top: var(--sp-2); padding: var(--sp-3); background: var(--bg-surface); border-radius: var(--r-card); font-size: 14px; color: var(--text-secondary); white-space: pre-wrap; }
.nw__foot { display: flex; align-items: center; justify-content: space-between; max-width: 420px; width: 100%; margin: 0 auto; min-height: 56px; }
.nw__hint { font-size: 12px; color: var(--text-muted); }
.nw__next { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-fab); margin-left: auto; transition: transform var(--t-fast) var(--ease); }
.nw__next:active { transform: scale(.94); }
.nw__next .ico { width: 24px; height: 24px; stroke-width: 2; }
.nw__next--ok { width: auto; padding: 0 32px; border-radius: var(--r-pill); font: 600 16px var(--font-sans); }

/* mese */
.month { margin: 0 0 var(--sp-2); }
.month__nav { display: flex; align-items: center; gap: 2px; margin-bottom: var(--sp-2); }
.month__nav h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; text-transform: capitalize; }
.month__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.month__dow { text-align: center; font-size: 11px; font-weight: 500; color: var(--text-secondary); padding: 4px 0; }
.mday { height: 44px; border-radius: var(--r-day); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; gap: 2px; position: relative; }
.mday i { width: 4px; height: 4px; border-radius: 50%; background: var(--text-muted); }
.mday i.is-red { background: var(--now); }
.mday i.is-none { background: transparent; }
.mday.is-other { color: var(--text-muted); font-weight: 400; }
.mday.is-today { color: var(--accent); }
.mday.is-selected { background: var(--accent); color: #fff; }
.mday.is-selected i { background: rgba(255,255,255,.8); }
.card-surface { background: var(--bg-surface); border-radius: var(--r-card); padding: var(--sp-4); }

/* popup di avviso */
.alert { text-align: center; }
.alert__ico { width: 64px; height: 64px; border-radius: 50%; background: var(--c-bg); color: var(--c-fg); display: grid; place-items: center; margin: var(--sp-2) auto var(--sp-3); }
.alert__ico .ico { width: 30px; height: 30px; }
.alert__kind { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.alert.is-urgent .alert__kind { color: var(--now); }
.alert h2 { font-size: 22px; margin: 2px 0 var(--sp-1); }
.alert__when { font-size: 14px; color: var(--text-secondary); margin-bottom: var(--sp-3); }
.alert__notes { text-align: left; white-space: pre-wrap; background: var(--bg-input); padding: var(--sp-3); border-radius: var(--r-card); margin-bottom: var(--sp-4); font-size: 14px; }
.alert__actions { display: flex; flex-direction: column; gap: var(--sp-2); }
.alert__actions .btn { width: 100%; }

.account-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 48px; padding: 0 var(--sp-3); border-radius: var(--r-card); background: var(--bg-input); margin-bottom: var(--sp-2); font-weight: 500; }
.hint { font-size: 12px; color: var(--text-secondary); margin: var(--sp-2) 0 0; }

#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); background: var(--text-primary); color: var(--bg-app); padding: 8px 16px; border-radius: var(--r-pill); font-size: 13px; z-index: 60; opacity: 0; transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); pointer-events: none; }
#toast.show { opacity: .95; transform: translate(-50%, 0); }

/* accesso: scelta utente, PIN, Face ID */
.gate-wrap { min-height: 100vh; min-height: 100dvh; }
.gate { max-width: 360px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(var(--sp-6), env(safe-area-inset-top)) var(--sp-5) max(var(--sp-6), env(safe-area-inset-bottom)); text-align: center; animation: pop-in var(--t-base) var(--ease); }
.gate__app { width: 76px; height: 76px; border-radius: 19px; margin-bottom: var(--sp-3); box-shadow: 0 6px 20px rgba(10,31,92,.25); }
.gate__logo { font-size: 13px; font-weight: 600; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: var(--sp-5); }
.gate h1 { font-size: 26px; font-weight: 600; margin: 0 0 var(--sp-1); letter-spacing: -.01em; }
.gate__sub { color: var(--text-secondary); font-size: 15px; margin: 0 0 var(--sp-5); min-height: 22px; }
.gate__sub.is-err, .hint.is-err { color: var(--now); }
.gate__icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: var(--sp-4); }
.gate__icon .ico { width: 34px; height: 34px; }
.gate__or { font-size: 12px; color: var(--text-muted); margin: var(--sp-5) 0 var(--sp-4); }
.gate h1.gate__h2 { font-size: 20px; }
.gate__users { width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); }
.gate-user { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 64px; padding: 10px 14px; border-radius: var(--r-card); background: var(--bg-surface); font-size: 17px; font-weight: 600; transition: transform var(--t-fast) var(--ease); }
.gate-user:active { transform: scale(.98); }
.gate-user small { display: block; font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.gate-input { width: 100%; height: 48px; padding: 0 16px; border: 0; border-radius: var(--r-card); background: var(--bg-surface); font-size: 18px; text-align: center; letter-spacing: .04em; margin-bottom: var(--sp-3); color: var(--text-primary); }
.gate-input:focus { outline: 2px solid var(--accent); }
.gate-btn { width: 100%; }
.gate__extra { margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; min-height: 44px; }
.gate-link { color: var(--accent); font-size: 15px; font-weight: 500; padding: 10px 14px; display: inline-flex; align-items: center; gap: 6px; text-align: center; margin-top: var(--sp-2); }
.pin-dots { display: flex; gap: 16px; margin-bottom: var(--sp-6); }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-muted); transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease-spring); }
.pin-dots i.on { background: var(--accent); border-color: var(--accent); transform: scale(1.15); }
.pin-dots.shake { animation: shake 360ms var(--ease); }
@keyframes shake { 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; justify-content: center; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; background: var(--bg-surface); font-size: 28px; font-weight: 500; text-align: center; transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.keypad button:active { transform: scale(.92); background: var(--accent-soft); }
.keypad button[data-k="del"] { background: transparent; font-size: 24px; color: var(--text-secondary); }

/* gestione utenti / profilo */
.role-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); vertical-align: 2px; margin-left: 4px; }
.user-row { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 0; flex-wrap: wrap; }
.user-row__t { flex: 1; min-width: 140px; font-weight: 600; }
.user-row__t small { display: block; font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.user-row .move { margin: 0; }
.code-box { background: var(--accent-soft); border-radius: var(--r-card); padding: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-3); font-size: 14px; }
.code-box .code { display: block; font-size: 28px; font-weight: 700; letter-spacing: .08em; color: var(--accent); margin: 4px 0; font-variant-numeric: tabular-nums; }
.code-box small { display: block; color: var(--text-secondary); font-size: 12px; }

@keyframes check-pop { 0% { transform: scale(.85); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- desktop: timeline + mese ---------- */
@media (min-width: 900px) {
  .app { padding: 0 var(--sp-8); }
  .layout { max-width: 880px; display: grid; grid-template-columns: 420px 1fr; gap: var(--sp-8); align-items: start; }
  .screen { padding-bottom: 120px; }
  .aside { display: block; position: sticky; top: var(--sp-8); padding-top: max(var(--sp-5), env(safe-area-inset-top)); }
  .aside .card-surface + .card-surface { margin-top: var(--sp-3); }
  #btn-month { display: none; }
  .fab { left: calc(50% - 230px); }
  .fab:active { transform: translateX(-50%) scale(.96); }
  .event:hover { filter: brightness(.98); }
  .mday:hover:not(.is-selected), .day:hover:not(.is-selected) { background: var(--bg-input); }
}


/* ---------- sezioni: riquadri, selettore vista, mese, anno ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.tile { display: flex; flex-direction: column; justify-content: space-between; min-height: 84px; padding: 12px; border-radius: var(--r-card); background: var(--c-bg); color: var(--c-fg); text-align: left; transition: transform var(--t-fast) var(--ease), opacity var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease); }
.tile:active { transform: scale(.97); }
.tile__top { display: flex; align-items: center; justify-content: space-between; }
.tile__top .ico { width: 22px; height: 22px; }
.tile__n { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.tile__l { font-size: 14px; font-weight: 600; }
.tile.is-on { box-shadow: 0 0 0 2px var(--bg-app), 0 0 0 4px var(--c-fg); }
.tile.is-dim { opacity: .5; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin-bottom: var(--sp-3); background: var(--bg-input); border-radius: 12px; }
.seg__b { height: 34px; border-radius: 10px; text-align: center; font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg__b.is-on { background: var(--bg-surface); color: var(--text-primary); font-weight: 600; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); flex: none; display: inline-block; }
.cal-t { font-size: 11px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; text-align: left; }
.cal-t.is-done { opacity: .5; text-decoration: line-through; }
.cal-more { font-size: 11px; color: var(--text-muted); text-align: left; }
.dot[data-cat] { background: var(--c-fg); }
.dot--red { background: var(--now) !important; }
.mview.slide-l, .yview.slide-l { animation: slide-l var(--t-base) var(--ease); }
.mview.slide-r, .yview.slide-r { animation: slide-r var(--t-base) var(--ease); }
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.mcell { min-height: 58px; padding: 6px 4px; border-radius: 12px; background: var(--bg-surface); display: flex; flex-direction: column; align-items: center; gap: 4px; overflow: hidden; transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.mcell:active { transform: scale(.96); }
.mcell.is-other { background: transparent; opacity: .45; }
.mcell.is-selected { box-shadow: 0 0 0 2px var(--accent); }
.mcell__n { font-size: 13px; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; font-variant-numeric: tabular-nums; }
.mcell.is-today .mcell__n { background: var(--accent); color: #fff; }
.mcell__dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; min-height: 6px; }
.mcell__t { display: none; flex-direction: column; gap: 2px; width: 100%; }
.agenda { margin-top: var(--sp-5); }
.agenda__head { display: flex; align-items: center; gap: var(--sp-3); }
.agenda__head .section-header { flex: 1; margin: 0; padding: 0; border: 0; font-size: 15px; font-weight: 600; }
.empty--sm { padding: var(--sp-5) 0; }

.ygrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.ymonth { background: var(--bg-surface); border-radius: var(--r-card); padding: 10px 10px 8px; }
.ymonth__t { font-size: 14px; font-weight: 600; margin-bottom: 4px; display: block; width: 100%; }
.ydays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.ydays i { display: block; }
.ydow { text-align: center; font-size: 9px; color: var(--text-muted); font-weight: 500; padding-bottom: 2px; }
.ycell { position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: 11px; font-variant-numeric: tabular-nums; }
.ycell.has { font-weight: 700; }
.ycell.has::after { content: ""; position: absolute; bottom: 1px; width: 4px; height: 4px; border-radius: 50%; background: var(--c-fg, var(--accent)); }
.ycell.is-red::after { background: var(--now); }
.ycell.is-today { background: var(--accent); color: #fff; }
.ycell.is-today::after { background: #fff; }
.ycell.is-selected:not(.is-today) { box-shadow: 0 0 0 1.5px var(--accent); }

/* scelta sezione nel form */
.sec-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.sec-opt { height: 44px; border-radius: 14px; background: var(--bg-input); color: var(--text-secondary); font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.sec-opt:active { transform: scale(.97); }
.sec-opt[aria-checked="true"] { background: var(--c-bg); color: var(--c-fg); box-shadow: 0 0 0 2px var(--c-fg); }

/* viste mese/anno: colonna più larga su schermi grandi */
@media (min-width: 900px) {
  .layout.wide { grid-template-columns: 1fr; max-width: 760px; }
  .layout.wide .aside { display: none; }
  .mcell { min-height: 92px; align-items: flex-start; padding: 6px 8px; }
  .mcell__dots { display: none; }
  .mcell__t { display: flex; }
  .mcell__n { align-self: flex-start; }
  .ygrid { grid-template-columns: repeat(3, 1fr); }
  .fab { left: 50%; }
}

/* allegati */
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-2); }
.att { display: flex; align-items: center; gap: var(--sp-2); background: var(--bg-input); border-radius: 12px; padding: 6px 6px 6px 6px; }
.att__main { display: flex; align-items: center; gap: var(--sp-3); flex: 1; min-width: 0; text-align: left; }
.att__ico { flex: none; width: 44px; height: 44px; border-radius: 10px; background: var(--bg-surface); display: grid; place-items: center; overflow: hidden; }
.att__ico b { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.att__ico img { width: 100%; height: 100%; object-fit: cover; }
.att__t { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att__t small { display: block; font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.att__x { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--text-secondary); }
.att__x:active { background: var(--bg-surface); }
.att.is-busy { opacity: .85; }
.att__bar { display: block; height: 4px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.att__bar i { display: block; height: 100%; background: var(--accent); transition: width var(--t-fast) linear; }
.att-add { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; }
.att-add:active { transform: scale(.97); }
.event__clip { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 12px; opacity: .8; }

.viewer { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; animation: fade var(--t-base) var(--ease); }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer__bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: var(--sp-3); padding: max(var(--sp-3), env(safe-area-inset-top)) var(--sp-4) var(--sp-3); color: #fff; font-size: 14px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.viewer__bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer__btn { color: #fff; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: var(--r-pill); background: rgba(255,255,255,.18); text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
