/* =============================================================================================
   KCE Staff — design system in stile shadcn/ui (token, componenti) su tema scuro KCE.
   Mobile first, aspetto da app nativa: barra in alto, barra delle schede in basso, aree sicure
   (notch e barra di stato), fogli dal basso, toast. Nessun framework CSS.
   ============================================================================================= */
:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #111114;
  --card-2: #16161a;
  --popover: #141417;
  --muted: #1f1f23;
  --muted-foreground: #a1a1aa;
  --subtle: #71717a;
  --border: #27272a;
  --input: #2a2a2f;
  --primary: #ff3b30;          /* rosso KCE */
  --primary-hover: #ff5a50;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(255, 59, 48, .12);
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --accent: #2563eb;           /* blu KCE app */
  --ring: rgba(255, 59, 48, .55);
  --ok: #22c55e;     --ok-soft: rgba(34, 197, 94, .14);
  --warn: #f59e0b;   --warn-soft: rgba(245, 158, 11, .14);
  --danger: #ef4444; --danger-soft: rgba(239, 68, 68, .14);
  --info: #3b82f6;   --info-soft: rgba(59, 130, 246, .14);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --header-h: 56px;
  --tabbar-h: 64px;
  --font: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--background); }
body {
  margin: 0; min-height: 100dvh; background: var(--background); color: var(--foreground);
  font-family: var(--font); font-size: 15px; line-height: 1.45; letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--primary-soft); }
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }
.muted { color: var(--muted-foreground); }
.subtle { color: var(--subtle); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* transizioni tra le pagine (Chrome, Edge, Safari 18.2+) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }

/* ---------------------------------------------------------------- struttura dell'app */
.app-header {
  position: sticky; top: 0; z-index: 30;
  padding: var(--sat) calc(12px + var(--sar)) 0 calc(12px + var(--sal));
  background: rgba(9, 9, 11, .82); backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(39, 39, 42, .7);
}
.app-header .bar { height: var(--header-h); display: flex; align-items: center; gap: 8px; }
.app-header .titolo { flex: 1; min-width: 0; font-weight: 650; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .titolo small { display: block; font-weight: 450; font-size: 12px; color: var(--muted-foreground); letter-spacing: 0; }
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.brand img { height: 22px; width: auto; }
.brand b { font-size: 13px; font-weight: 650; letter-spacing: .14em; color: var(--muted-foreground); }
.app-main {
  padding: 16px calc(16px + var(--sar)) calc(var(--tabbar-h) + var(--sab) + 24px) calc(16px + var(--sal));
  max-width: 760px; margin: 0 auto;
}
.app-main.largo { max-width: 1180px; }
.app-main.senza-tab { padding-bottom: calc(24px + var(--sab)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px calc(6px + var(--sar)) calc(6px + var(--sab)) calc(6px + var(--sal));
  background: rgba(13, 13, 16, .9); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid rgba(39, 39, 42, .8);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 52px;
  border-radius: 12px; color: var(--subtle); font-size: 11px; font-weight: 550; letter-spacing: .01em; position: relative;
  transition: color .15s, background .15s;
}
.tabbar a .i { width: 22px; height: 22px; }
.tabbar a.on { color: var(--foreground); }
.tabbar a.on .i { color: var(--primary); }
.tabbar a:active { background: var(--muted); }
.tabbar .pallino { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* ---------------------------------------------------------------- tipografia di pagina */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-head h1 { font-size: 26px; font-weight: 700; }
.page-head p { color: var(--muted-foreground); margin-top: 4px; font-size: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.section-title h2 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.section-title a { font-size: 13px; color: var(--muted-foreground); }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-foreground); }

/* ---------------------------------------------------------------- card */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card + .card { margin-top: 10px; }
.grid > .card + .card { margin-top: 0; }
.card-pad { padding: 16px; }
.card-header { padding: 16px 16px 0; }
.card-title { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.card-desc { color: var(--muted-foreground); font-size: 13px; margin-top: 2px; }
.card-content { padding: 14px 16px 16px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.card.link { display: block; transition: background .15s, border-color .15s, transform .1s; }
.card.link:active { transform: scale(.99); background: var(--card-2); }
@media (hover: hover) { .card.link:hover { border-color: #3f3f46; } }
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 520px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.stat { padding: 14px; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat .l { font-size: 12px; color: var(--muted-foreground); display: flex; align-items: center; gap: 6px; }
.stat .dot { width: 8px; height: 8px; border-radius: 99px; }

/* ---------------------------------------------------------------- bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 14px; font-weight: 550; letter-spacing: -.005em;
  background: var(--foreground); color: var(--background); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, color .15s, border-color .15s, opacity .15s, transform .08s;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .input:focus-visible, .select:focus-visible, .textarea:focus-visible, a:focus-visible, .chk:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
@media (hover: hover) { .btn-primary:hover { background: var(--primary-hover); } .btn-secondary:hover, .btn-outline:hover, .btn-ghost:hover { background: #2e2e33; } }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-outline { background: transparent; color: var(--foreground); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-destructive { background: var(--danger-soft); color: #fca5a5; border-color: rgba(239, 68, 68, .25); }
.btn-ok { background: var(--ok); color: #052e14; }
.btn-warn { background: var(--warn); color: #3a2400; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: gira .7s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- moduli */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 6px; color: #e4e4e7; }
.label .req { color: var(--primary); }
.hint { font-size: 12px; color: var(--muted-foreground); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--input);
  background: #0d0d10; color: var(--foreground); font-size: 16px; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.select { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input::placeholder, .textarea::placeholder { color: #52525b; }
.input:focus, .select:focus, .textarea:focus { border-color: #52525b; }
input[type="date"].input, input[type="time"].input { min-width: 0; }
input[type="color"].input { padding: 4px; width: 56px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.input-group { position: relative; }
.input-group .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.input-group .input { padding-left: 38px; }

/* interruttore (switch) e casella */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .t { flex: 1; }
.switch .t b { display: block; font-weight: 550; font-size: 14px; }
.switch .t span { display: block; font-size: 12px; color: var(--muted-foreground); }
.switch .s { width: 42px; height: 24px; border-radius: 99px; background: var(--input); position: relative; flex: none; transition: background .2s; }
.switch .s::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 99px; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.switch input:checked + .s { background: var(--primary); }
.switch input:checked + .s::after { transform: translateX(18px); }
.switch input:focus-visible + .s { box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }

/* scelte a pillola (persone, giorni, destinatari) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 6px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--card-2); font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
}
.choice span.no-av { padding-left: 12px; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: #fff; }
.choice input:focus-visible + span { box-shadow: 0 0 0 2px var(--ring); }

/* controllo a segmenti (tabs) */
.segmented { display: flex; padding: 3px; border-radius: 12px; background: var(--muted); gap: 2px; }
.segmented a, .segmented button, .segmented label {
  flex: 1; height: 34px; display: grid; place-items: center; border-radius: 9px; font-size: 13px; font-weight: 550;
  color: var(--muted-foreground); border: 0; background: none; cursor: pointer; white-space: nowrap; padding: 0 10px;
}
.segmented .on, .segmented input:checked + label { background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.segmented input { display: none; }

/* ---------------------------------------------------------------- badge, avatar, chip di stato */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 550; border: 1px solid var(--border); color: var(--muted-foreground); white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.badge-solid { background: var(--secondary); color: var(--foreground); border-color: transparent; }
.b-da_eseguire { color: #93c5fd; background: var(--info-soft); border-color: transparent; }
.b-in_corso { color: #fcd34d; background: var(--warn-soft); border-color: transparent; }
.b-completata { color: #86efac; background: var(--ok-soft); border-color: transparent; }
.b-in_ritardo { color: #fca5a5; background: var(--danger-soft); border-color: transparent; }
.b-primary { color: #fff; background: var(--primary); border-color: transparent; }
.b-alta { color: #fda4af; background: rgba(244, 63, 94, .14); border-color: transparent; }

.avatar {
  width: 32px; height: 32px; border-radius: 99px; display: inline-grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 650; color: #fff; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatars { display: flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--card); }
.avatars .avatar + .avatar { margin-left: -8px; }

/* ---------------------------------------------------------------- liste */
.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; position: relative; }
.list-item + .list-item { border-top: 1px solid var(--border); }
a.list-item:active, button.list-item:active { background: var(--muted); }
@media (hover: hover) { a.list-item:hover { background: #141418; } }
.list-item .body { flex: 1; min-width: 0; }
.list-item .t { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .d { font-size: 12.5px; color: var(--muted-foreground); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.list-item .chev { color: var(--subtle); }
.list-item .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--muted); color: var(--foreground); flex: none; }
.list-group-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--subtle); padding: 18px 4px 8px; }

/* ---------------------------------------------------------------- incarichi (occorrenze) */
.task { display: flex; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); position: relative; overflow: hidden; }
.task + .task { margin-top: 10px; }
.task::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--info); }
.task.s-in_corso::before { background: var(--warn); }
.task.s-completata::before { background: var(--ok); }
.task.s-in_ritardo::before { background: var(--danger); }
.task.s-completata .task-title { color: var(--muted-foreground); text-decoration: line-through; text-decoration-color: rgba(161, 161, 170, .5); }
.task .ora { width: 50px; flex: none; text-align: left; }
.task .ora b { display: block; font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.task .ora span { font-size: 12px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.task .body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 5px; font-size: 12.5px; color: var(--muted-foreground); }
.task .meta span { display: inline-flex; align-items: center; gap: 4px; }
.task .actions { display: flex; gap: 8px; margin-top: 12px; }
.task .actions .btn { flex: 1; }
.task-link { position: absolute; inset: 0; z-index: 1; }
.task .actions, .task .z { position: relative; z-index: 2; }

/* anello di avanzamento */
.ring { --p: 0; width: 64px; height: 64px; border-radius: 99px; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--muted) 0); }
.ring > div { width: 52px; height: 52px; border-radius: 99px; background: var(--card); display: grid; place-items: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 99px; background: var(--muted); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: var(--primary); transition: width .3s; }
.progress.ok > div { background: var(--ok); }

/* hero di "Oggi" */
.hero { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--radius-lg);
  background: radial-gradient(120% 140% at 100% 0%, rgba(255, 59, 48, .18), transparent 55%), var(--card); border: 1px solid var(--border); }
.hero h1 { font-size: 22px; font-weight: 700; }
.hero p { color: var(--muted-foreground); font-size: 14px; margin-top: 3px; }

/* ---------------------------------------------------------------- checklist */
.cl-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; cursor: pointer; user-select: none; }
.cl-item + .cl-item { border-top: 1px solid var(--border); }
.cl-item input { display: none; }
.chk { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid #52525b; display: grid; place-items: center; flex: none; margin-top: 1px; transition: all .15s; }
.chk .i { width: 14px; height: 14px; stroke-width: 3; opacity: 0; transform: scale(.6); transition: all .15s; color: #fff; }
.cl-item input:checked + .chk { background: var(--ok); border-color: var(--ok); }
.cl-item input:checked + .chk .i { opacity: 1; transform: none; }
.cl-item input:checked ~ .tx { color: var(--muted-foreground); text-decoration: line-through; }
.cl-item .tx { flex: 1; font-size: 14.5px; }

/* ---------------------------------------------------------------- vuoto, avvisi, toast */
.empty { text-align: center; padding: 36px 20px; color: var(--muted-foreground); }
.empty .ico { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--muted); color: var(--foreground); }
.empty b { display: block; color: var(--foreground); font-size: 15px; margin-bottom: 4px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); font-size: 14px; }
.alert + .alert, .alert + .card, .card + .alert { margin-top: 10px; }
.alert .i { margin-top: 2px; }
.alert-danger { border-color: rgba(239, 68, 68, .35); background: var(--danger-soft); color: #fecaca; }
.alert-warn { border-color: rgba(245, 158, 11, .35); background: var(--warn-soft); color: #fde68a; }
.alert-ok { border-color: rgba(34, 197, 94, .35); background: var(--ok-soft); color: #bbf7d0; }
.alert-info { border-color: rgba(59, 130, 246, .35); background: var(--info-soft); color: #bfdbfe; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.toasts { position: fixed; left: 0; right: 0; top: calc(var(--sat) + 10px); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 440px; width: 100%; padding: 12px 14px; border-radius: 14px;
  background: rgba(24, 24, 27, .96); border: 1px solid #3f3f46; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-size: 14px; font-weight: 500; pointer-events: auto; animation: tin .25s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.ok .i { color: var(--ok); }
.toast.errore .i { color: var(--danger); }
.toast.esce { animation: tout .2s ease forwards; }
@keyframes tin { from { opacity: 0; transform: translateY(-12px) scale(.97); } }
@keyframes tout { to { opacity: 0; transform: translateY(-8px); } }

/* ---------------------------------------------------------------- foglio dal basso (sheet) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .6); opacity: 0; transition: opacity .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; max-height: 88dvh; overflow-y: auto;
  background: var(--popover); border-top: 1px solid var(--border); border-radius: 22px 22px 0 0;
  padding: 8px calc(18px + var(--sar)) calc(18px + var(--sab)) calc(18px + var(--sal));
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .9, .25, 1);
}
.sheet .grip { width: 38px; height: 5px; border-radius: 99px; background: #3f3f46; margin: 0 auto 14px; }
.sheet h3 { font-size: 18px; font-weight: 650; margin-bottom: 4px; }
.sheet.aperto { transform: none; }
.sheet-backdrop.aperto { opacity: 1; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 520px; bottom: 50%; transform: translate(-50%, 60%) scale(.98); opacity: 0; border-radius: 20px; border: 1px solid var(--border); transition: transform .2s, opacity .2s; }
  .sheet.aperto { transform: translate(-50%, 50%); opacity: 1; }
}

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--sat)) 20px calc(24px + var(--sab));
  background: radial-gradient(80% 60% at 50% -10%, rgba(255, 59, 48, .22), transparent 60%), var(--background); }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-logo img { height: 44px; }
.login-logo b { letter-spacing: .3em; font-size: 12px; color: var(--muted-foreground); font-weight: 650; }

/* ---------------------------------------------------------------- dettaglio attivita' */
.det-head { padding: 18px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card); position: relative; overflow: hidden; }
.det-head::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--det-colore, var(--primary)); }
.det-head h1 { font-size: 22px; font-weight: 700; margin: 8px 0 10px; }
.kv { display: grid; grid-template-columns: 22px 1fr; gap: 10px 10px; font-size: 14px; }
.kv .i { color: var(--muted-foreground); margin-top: 1px; }
.prose { font-size: 14.5px; line-height: 1.6; white-space: pre-line; color: #e4e4e7; }
.materiali { list-style: none; padding: 0; margin: 0; }
.materiali li { display: flex; gap: 10px; align-items: center; padding: 9px 0; font-size: 14px; }
.materiali li + li { border-top: 1px dashed var(--border); }
.materiali li .i { color: var(--muted-foreground); }

/* barra di azioni fissa in basso (dettaglio) */
.actionbar { position: sticky; bottom: calc(var(--tabbar-h) + var(--sab) + 10px); z-index: 20; margin-top: 16px; padding: 10px; border-radius: 16px;
  background: rgba(20, 20, 23, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }

/* ---------------------------------------------------------------- timeline */
.tl-tools { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tl-tools .data { flex: 1; text-align: center; font-weight: 600; font-size: 15px; }
.tl { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tl-grid { position: relative; min-width: var(--tl-w, 900px); }
.tl-row { display: flex; height: 58px; border-top: 1px solid var(--border); position: relative; }
.tl-row.head { height: 34px; border-top: 0; background: #0e0e11; }
.tl-name { position: sticky; left: 0; z-index: 5; width: 132px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px;
  background: var(--card); border-right: 1px solid var(--border); font-size: 13px; font-weight: 550; }
.tl-row.head .tl-name { background: #0e0e11; font-size: 11px; color: var(--subtle); text-transform: uppercase; letter-spacing: .08em; }
.tl-name small { display: block; font-size: 11px; color: var(--muted-foreground); font-weight: 450; }
.tl-name .n { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-lane { position: relative; flex: 1; }
.tl-hour { position: absolute; top: 0; bottom: 0; border-left: 1px solid rgba(39, 39, 42, .7); }
.tl-hour span { position: absolute; top: 9px; left: 5px; font-size: 11px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.tl-bar { position: absolute; top: 9px; bottom: 9px; border-radius: 8px; padding: 4px 8px; overflow: hidden; font-size: 12px; font-weight: 600; line-height: 1.2;
  background: var(--info-soft); border: 1px solid rgba(59, 130, 246, .45); color: #dbeafe; display: flex; flex-direction: column; justify-content: center; min-width: 6px; }
.tl-bar small { font-weight: 450; opacity: .8; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-bar b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-bar.s-in_corso { background: var(--warn-soft); border-color: rgba(245, 158, 11, .55); color: #fef3c7; }
.tl-bar.s-completata { background: var(--ok-soft); border-color: rgba(34, 197, 94, .5); color: #dcfce7; }
.tl-bar.s-in_ritardo { background: var(--danger-soft); border-color: rgba(239, 68, 68, .6); color: #fee2e2; }
.tl-bar.conflitto { box-shadow: 0 0 0 2px var(--warn); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); z-index: 3; }
.tl-now::before { content: ""; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 99px; background: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* ---------------------------------------------------------------- tabella (admin, schermi larghi) */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 550; color: var(--muted-foreground); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.table tr:first-child td { border-top: 0; }

/* ---------------------------------------------------------------- calendario (FullCalendar in tema) */
.cal { --fc-border-color: var(--border); --fc-page-bg-color: transparent; --fc-neutral-bg-color: #111114; --fc-list-event-hover-bg-color: #18181b;
  --fc-today-bg-color: rgba(255, 59, 48, .06); --fc-now-indicator-color: var(--primary); --fc-event-text-color: #fff; font-size: 13px; }
.cal .fc { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.cal .fc .fc-toolbar { gap: 8px; flex-wrap: wrap; }
.cal .fc .fc-toolbar-title { font-size: 16px; font-weight: 650; letter-spacing: -.02em; text-transform: capitalize; }
.cal .fc .fc-button { background: var(--secondary); border: 1px solid var(--border); color: var(--foreground); border-radius: 9px; font-size: 13px; font-weight: 550; padding: 6px 10px; box-shadow: none !important; text-transform: capitalize; }
.cal .fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.cal .fc .fc-button:disabled { opacity: .45; }
.cal .fc-theme-standard td, .cal .fc-theme-standard th { border-color: var(--border); }
.cal .fc .fc-col-header-cell-cushion, .cal .fc .fc-daygrid-day-number { color: var(--muted-foreground); font-weight: 500; text-transform: capitalize; }
.cal .fc .fc-event { border-radius: 6px; padding: 1px 3px; font-weight: 550; cursor: pointer; }
.cal .fc .fc-list-day-cushion { background: #0e0e11; }
.cal .fc .fc-list-event-title a { color: var(--foreground); }
.cal .fc .fc-list-day-text, .cal .fc .fc-list-day-side-text { color: var(--foreground); text-transform: capitalize; }
.cal .fc .fc-timegrid-slot-label-cushion { color: var(--subtle); font-variant-numeric: tabular-nums; }
.cal .fc .fc-gara { opacity: .9; }
.cal .fc-list-empty { background: transparent !important; color: var(--muted-foreground); }

/* ---------------------------------------------------------------- varie */
.sep { height: 1px; background: var(--border); margin: 16px 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 14px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; border: 1px solid var(--border); background: var(--card); font-size: 13px; font-weight: 550; color: var(--muted-foreground); }
.chip.on { background: var(--foreground); color: var(--background); border-color: var(--foreground); }
.day-head { position: sticky; top: calc(var(--header-h) + var(--sat)); z-index: 10; padding: 10px 2px 8px; background: linear-gradient(var(--background) 75%, transparent); font-weight: 650; font-size: 14px; text-transform: capitalize; display: flex; justify-content: space-between; align-items: center; }
.day-head + .task { margin-top: 2px; }
.fab { position: fixed; right: calc(16px + var(--sar)); bottom: calc(var(--tabbar-h) + var(--sab) + 16px); z-index: 35; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: var(--primary); color: #fff; box-shadow: 0 10px 30px rgba(255, 59, 48, .35); border: 0; }
.fab .i { width: 24px; height: 24px; }
.kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--muted); }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.install-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid rgba(255, 59, 48, .35); background: var(--primary-soft); margin-bottom: 14px; }
.install-banner .body { flex: 1; font-size: 13.5px; }
.install-banner b { display: block; font-size: 14px; }
.swatch { width: 14px; height: 14px; border-radius: 5px; display: inline-block; flex: none; }
.desktop-only { display: none; }
@media (min-width: 900px) {
  .desktop-only { display: initial; }
  .app-main { padding-top: 24px; }
}
