/* =====================================================================
   FULLZCODEDEPTHV — Design system condiviso
   Estetica: "spatial OS" scuro, vetro smerigliato, profondità 3D,
   luci aurora, animazioni guidate dallo scroll e parallasse.
   Ogni modulo imposta --accent / --accent-2 tramite <ModuleShell>.
   ===================================================================== */

:root {
    color-scheme: dark;
    --bg-0: #05040f;
    --bg-1: #0b0a1f;
    --bg-2: #14123a;
    --surface: rgba(255, 255, 255, 0.055);
    --surface-2: rgba(255, 255, 255, 0.09);
    --surface-3: rgba(255, 255, 255, 0.14);
    --surface-solid: #16143a;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.22);
    --text: #f4f3ff;
    --text-2: #b9b6dc;
    --text-3: #7f7ba8;
    --accent: #8b5cf6;
    --accent-2: #22d3ee;
    --accent-soft: color-mix(in oklab, var(--accent) 22%, transparent);
    --success: #34d399;
    --danger: #fb7185;
    --warning: #fbbf24;
    --info: #60a5fa;
    --income: #34d399;
    --expense: #fb7185;
    --radius-s: 10px;
    --radius: 18px;
    --radius-l: 26px;
    --radius-xl: 34px;
    --shadow-1: 0 1px 0 rgba(255,255,255,.06) inset, 0 10px 30px -12px rgba(0,0,0,.6);
    --shadow-2: 0 1px 0 rgba(255,255,255,.08) inset, 0 30px 60px -20px rgba(0,0,0,.75), 0 0 0 1px rgba(255,255,255,.04);
    --shadow-glow: 0 0 0 1px color-mix(in oklab, var(--accent) 40%, transparent), 0 18px 50px -12px color-mix(in oklab, var(--accent) 55%, transparent);
    --blur: saturate(160%) blur(22px);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --scroll: 0;          /* 0..1 avanzamento scroll pagina (aggiornato da fullzcodedepthv.js) */
    --mx: 0;              /* -1..1 posizione puntatore X */
    --my: 0;              /* -1..1 posizione puntatore Y */
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-0);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body { background: radial-gradient(1200px 800px at 80% -10%, #2a1a6b 0%, transparent 60%), radial-gradient(900px 700px at -10% 110%, #0c3a5c 0%, transparent 55%), var(--bg-0); background-attachment: fixed; }

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
h1:focus { outline: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: color-mix(in oklab, var(--accent) 50%, transparent); }

/* ---------- Sfondo 3D ---------- */
#fullzcodedepthv-bg { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; opacity: .95; }
.bg-aurora {
    position: fixed; inset: -20%; z-index: 0; pointer-events: none; filter: blur(80px); opacity: .55;
    background:
        radial-gradient(35% 30% at calc(30% + var(--mx) * 4%) calc(25% + var(--my) * 4%), color-mix(in oklab, var(--accent) 70%, transparent), transparent 70%),
        radial-gradient(30% 30% at calc(75% - var(--mx) * 5%) calc(70% - var(--my) * 5%), color-mix(in oklab, var(--accent-2) 60%, transparent), transparent 70%);
    animation: aurora 18s ease-in-out infinite alternate;
    transition: background 1.2s var(--ease-out);
}
@keyframes aurora { 0% { transform: translate3d(0,0,0) rotate(0deg) scale(1); } 100% { transform: translate3d(3%,-2%,0) rotate(8deg) scale(1.08); } }

.app-root { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }

/* ---------- Superfici ---------- */
.glass {
    background: linear-gradient(145deg, rgba(255,255,255,.085), rgba(255,255,255,.025));
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
}
.card {
    position: relative;
    background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-l);
    padding: 20px;
    box-shadow: var(--shadow-1);
    transform-style: preserve-3d;
}
.card-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-3); font-size: .82rem; }
.card.accent { background: linear-gradient(145deg, color-mix(in oklab, var(--accent) 35%, transparent), color-mix(in oklab, var(--accent-2) 12%, transparent)); border-color: color-mix(in oklab, var(--accent) 35%, var(--border)); box-shadow: var(--shadow-glow); }

/* Tilt 3D: aggiungere data-tilt a qualsiasi elemento. fullzcodedepthv.js aggiorna --rx, --ry, --gx, --gy */
[data-tilt] {
    --rx: 0deg; --ry: 0deg; --gx: 50%; --gy: 50%; --lift: 0px;
    transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateZ(var(--lift));
    transition: transform .5s var(--ease-out), box-shadow .4s var(--ease-out);
    will-change: transform;
}
[data-tilt].is-tilting { transition: transform .08s linear, box-shadow .3s; --lift: 14px; }
[data-tilt]::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    background: radial-gradient(420px circle at var(--gx) var(--gy), rgba(255,255,255,.16), transparent 45%);
    opacity: 0; transition: opacity .35s;
}
[data-tilt].is-tilting::after { opacity: 1; }
.depth-1 { transform: translateZ(20px); }
.depth-2 { transform: translateZ(40px); }
.depth-3 { transform: translateZ(70px); }

/* ---------- Reveal on scroll (IntersectionObserver in fullzcodedepthv.js) ---------- */
[data-reveal] { opacity: 0; transform: perspective(1000px) translate3d(0, 40px, -60px) rotateX(14deg); transition: opacity .9s var(--ease-out), transform 1s var(--ease-out); transition-delay: calc(var(--i, 0) * 60ms); }
[data-reveal].is-in { opacity: 1; transform: none; }
[data-reveal="left"] { transform: perspective(1000px) translate3d(-50px,0,-40px) rotateY(-14deg); }
[data-reveal="right"] { transform: perspective(1000px) translate3d(50px,0,-40px) rotateY(14deg); }
[data-reveal="zoom"] { transform: perspective(1000px) scale(.85) translateZ(-80px); }
[data-reveal].is-in[data-reveal] { transform: none; }

/* ---------- Scroll-driven 3D (CSS nativo dove supportato) ---------- */
@supports (animation-timeline: view()) {
    .sd-rise { animation: sd-rise linear both; animation-timeline: view(); animation-range: entry 0% cover 35%; }
    .sd-flip { animation: sd-flip linear both; animation-timeline: view(); animation-range: entry 0% cover 40%; }
    .sd-parallax { animation: sd-parallax linear both; animation-timeline: view(); animation-range: cover 0% cover 100%; }
    @keyframes sd-rise { from { opacity: 0; transform: perspective(900px) translateY(60px) rotateX(22deg) scale(.94); } to { opacity: 1; transform: none; } }
    @keyframes sd-flip { from { opacity: 0; transform: perspective(900px) rotateY(-28deg) translateX(-30px); } to { opacity: 1; transform: none; } }
    @keyframes sd-parallax { from { transform: translateY(40px); } to { transform: translateY(-40px); } }
}

/* Parallasse: data-depth="0.2" → fullzcodedepthv.js imposta translate3d in base a scroll + mouse */
[data-depth] { will-change: transform; }

/* ---------- Tipografia & utility ---------- */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: .82rem; }
.tiny { font-size: .72rem; }
.mono { font-variant-numeric: tabular-nums; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.grad-text { background: linear-gradient(120deg, #fff 10%, var(--accent-2) 55%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.lg { gap: 20px; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); } .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide-mobile { } @media (max-width: 700px) { .hide-mobile { display: none !important; } }
.only-mobile { display: none !important; } @media (max-width: 700px) { .only-mobile { display: initial !important; } }
.scroll-x { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.scroll-x > * { scroll-snap-align: start; flex: 0 0 auto; }
.scroll-x::-webkit-scrollbar { display: none; }
.divider { height: 1px; background: var(--border); margin: 12px 0; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Bottoni ---------- */
.btn {
    --b-bg: var(--surface-2);
    position: relative; overflow: hidden; isolation: isolate;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--border);
    background: var(--b-bg); color: var(--text); font-weight: 600; font-size: .92rem; cursor: pointer;
    transition: transform .25s var(--ease-spring), background .2s, box-shadow .25s, border-color .2s;
    user-select: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: scale(.96); }
.btn:focus-visible, .input:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), color-mix(in oklab, var(--accent) 50%, var(--accent-2))); border-color: transparent; box-shadow: 0 10px 30px -10px color-mix(in oklab, var(--accent) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.25); }
.btn-primary:hover { background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 85%, white), var(--accent-2)); box-shadow: 0 16px 40px -10px color-mix(in oklab, var(--accent) 90%, transparent), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: color-mix(in oklab, var(--danger) 22%, transparent); border-color: color-mix(in oklab, var(--danger) 40%, transparent); color: #ffd5dc; }
.btn-success { background: color-mix(in oklab, var(--success) 22%, transparent); border-color: color-mix(in oklab, var(--success) 40%, transparent); color: #d1fae5; }
.btn-sm { height: 34px; padding: 0 12px; border-radius: 11px; font-size: .84rem; }
.btn-lg { height: 52px; padding: 0 24px; border-radius: 17px; font-size: 1rem; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-block { width: 100%; }
.ripple { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255,255,255,.35); animation: ripple .6s ease-out forwards; pointer-events: none; z-index: -1; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* Floating action button */
.fab {
    position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(24px + var(--safe-bottom)); z-index: 40;
    width: 62px; height: 62px; border-radius: 22px; border: 0; cursor: pointer; font-size: 28px; color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 20px 40px -10px color-mix(in oklab, var(--accent) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.35);
    display: grid; place-items: center; transition: transform .35s var(--ease-spring);
    animation: fab-in .7s var(--ease-spring) both .3s;
}
.fab:hover { transform: translateY(-4px) rotate(90deg) scale(1.05); }
.fab:active { transform: scale(.9); }
@keyframes fab-in { from { transform: scale(0) rotate(-180deg); } to { transform: none; } }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .75rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.input, .select, .textarea {
    width: 100%; height: 46px; padding: 0 14px; border-radius: 14px;
    background: rgba(0,0,0,.25); border: 1px solid var(--border); color: var(--text); font: inherit; font-size: 16px;
    transition: border-color .2s, box-shadow .2s, background .2s; appearance: none; -webkit-appearance: none;
}
.textarea { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.select { background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.select option { background: var(--surface-solid); color: var(--text); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: color-mix(in oklab, var(--accent) 70%, white); box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 25%, transparent); background: rgba(0,0,0,.35); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-lg { height: 58px; font-size: 1.1rem; border-radius: 18px; }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Switch */
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: .3s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; transition: .35s var(--ease-spring); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }

/* Segmented control */
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 14px; background: rgba(0,0,0,.28); border: 1px solid var(--border); position: relative; }
.seg button, .seg a { border: 0; background: transparent; padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: .86rem; color: var(--text-2); cursor: pointer; transition: color .2s, background .3s var(--ease-out); white-space: nowrap; }
.seg button:hover, .seg a:hover { color: var(--text); }
.seg .active { background: var(--surface-3); color: var(--text); box-shadow: 0 4px 14px -4px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.12); }
.seg.full { display: flex; } .seg.full > * { flex: 1; text-align: center; }

/* Chip */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .85rem; font-weight: 500; cursor: pointer; transition: all .25s var(--ease-out); white-space: nowrap; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: color-mix(in oklab, var(--accent) 30%, transparent); border-color: color-mix(in oklab, var(--accent) 60%, transparent); color: white; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--text-2); letter-spacing: .02em; }
.badge.success { background: color-mix(in oklab, var(--success) 20%, transparent); color: #a7f3d0; }
.badge.danger { background: color-mix(in oklab, var(--danger) 22%, transparent); color: #fecdd3; }
.badge.warning { background: color-mix(in oklab, var(--warning) 22%, transparent); color: #fde68a; }
.badge.info { background: color-mix(in oklab, var(--info) 22%, transparent); color: #bfdbfe; }
.badge.accent { background: var(--accent-soft); color: white; }

/* Progress */
.progress { height: 10px; border-radius: 99px; background: rgba(0,0,0,.3); overflow: hidden; position: relative; }
.progress > span { display: block; height: 100%; border-radius: inherit; width: var(--v, 0%); background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 16px color-mix(in oklab, var(--accent-2) 60%, transparent); transition: width 1.1s var(--ease-out); position: relative; }
.progress > span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: shimmer 2.2s infinite; }
.progress.danger > span { background: linear-gradient(90deg, #f97316, var(--danger)); }
.progress.warning > span { background: linear-gradient(90deg, #eab308, #f97316); }
.progress.success > span { background: linear-gradient(90deg, #10b981, #84cc16); }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Liste */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid transparent; transition: background .2s, border-color .2s, transform .35s var(--ease-spring); cursor: pointer; }
.list-item:hover { background: var(--surface-2); border-color: var(--border); transform: translateX(3px); }
.avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; flex: none; background: var(--surface-2); box-shadow: inset 0 1px 0 rgba(255,255,255,.12); }
.avatar.sm { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }
.avatar.lg { width: 58px; height: 58px; border-radius: 18px; font-size: 30px; }

.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .kpi-label { font-size: .75rem; color: var(--text-2); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.kpi .kpi-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .kpi-delta { font-size: .8rem; font-weight: 600; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .empty-icon { font-size: 56px; display: inline-block; animation: float 4s ease-in-out infinite; filter: drop-shadow(0 20px 20px rgba(0,0,0,.4)); }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }

.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 12px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Module shell ---------- */
.module { position: relative; max-width: 1280px; margin: 0 auto; padding: calc(14px + var(--safe-top)) 20px calc(110px + var(--safe-bottom)); animation: module-in .7s var(--ease-out) backwards; } /* backwards: finita l'animazione non resta un transform che "intrappola" gli elementi position:fixed */
@keyframes module-in { from { opacity: 0; transform: perspective(1200px) translateZ(-120px) rotateX(6deg); } to { opacity: 1; transform: none; } }
.module-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 0; margin: 0 -4px; }
.module-top::before { content: ""; position: absolute; inset: 0 -100vw; z-index: -1; background: linear-gradient(to bottom, rgba(5,4,15,.85), rgba(5,4,15,.55) 70%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); opacity: calc(var(--scroll) * 30); mask-image: linear-gradient(to bottom, black 70%, transparent); }
.home-btn { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-size: 20px; }
.module-hero { position: relative; padding: 18px 0 26px; perspective: 900px; }
.module-hero .hero-icon { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; font-size: 40px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 24px 50px -16px color-mix(in oklab, var(--accent) 90%, transparent), inset 0 2px 0 rgba(255,255,255,.35), inset 0 -8px 20px rgba(0,0,0,.2); animation: hero-icon-in 1s var(--ease-spring) both; transform-style: preserve-3d; }
@keyframes hero-icon-in { from { transform: rotateY(-120deg) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.module-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 700; }
.module-hero .hero-sub { color: var(--text-2); margin-top: 4px; }
.module-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px; margin-bottom: 20px; border-radius: 18px; background: rgba(0,0,0,.25); border: 1px solid var(--border); width: fit-content; max-width: 100%; }
.module-tabs::-webkit-scrollbar { display: none; }
.module-tabs a { padding: 9px 16px; border-radius: 13px; font-weight: 600; font-size: .88rem; color: var(--text-2); white-space: nowrap; transition: all .3s var(--ease-out); display: inline-flex; align-items: center; gap: 6px; }
.module-tabs a:hover { color: var(--text); background: var(--surface); }
.module-tabs a.active { color: white; background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 70%, transparent), color-mix(in oklab, var(--accent-2) 40%, transparent)); box-shadow: 0 8px 20px -8px color-mix(in oklab, var(--accent) 80%, transparent); }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(3, 2, 12, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: fade-in .3s ease both; display: flex; align-items: center; justify-content: center; padding: 20px; perspective: 1400px; }
.sheet { width: min(560px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; border-radius: var(--radius-xl); background: linear-gradient(160deg, rgba(34,30,80,.92), rgba(14,12,40,.96)); border: 1px solid var(--border-strong); box-shadow: 0 50px 100px -20px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.12); animation: sheet-in .55s var(--ease-spring) both; overflow: hidden; }
.sheet.wide { width: min(820px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 12px; }
.sheet-head h2 { font-size: 1.3rem; flex: 1; }
.sheet-body { padding: 8px 22px 20px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px calc(18px + var(--safe-bottom)); border-top: 1px solid var(--border); background: rgba(0,0,0,.18); }
.sheet-grip { display: none; }
@keyframes sheet-in { from { opacity: 0; transform: rotateX(-18deg) translateY(40px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 640px) {
    .sheet-backdrop { align-items: flex-end; padding: 0; }
    .sheet, .sheet.wide { width: 100%; max-height: 92vh; border-radius: 30px 30px 0 0; animation: sheet-up .5s var(--ease-out) both; }
    .sheet-grip { display: block; width: 42px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 10px auto 0; }
    .sheet-foot > .btn { flex: 1; }
    @keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
}

/* ---------- Toast ---------- */
.toast-host { position: fixed; z-index: 200; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 10px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: rgba(24, 21, 60, .92); backdrop-filter: blur(20px); border: 1px solid var(--border-strong); box-shadow: 0 20px 50px -10px rgba(0,0,0,.7); animation: toast-in .5s var(--ease-spring) both; }
.toast .t-ico { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--surface-3); flex: none; }
.toast.success .t-ico { background: var(--success); color: #052e1f; }
.toast.error .t-ico { background: var(--danger); color: #3f0612; }
.toast.warning .t-ico { background: var(--warning); color: #3d2a00; }
@keyframes toast-in { from { opacity: 0; transform: translateY(30px) scale(.9) rotateX(30deg); } to { opacity: 1; transform: none; } }

/* ---------- Launch overlay (animazione apertura app) ---------- */
#launch-overlay { position: fixed; z-index: 500; pointer-events: none; opacity: 0; border-radius: 26px; }

/* ---------- Errori Blazor ---------- */
#blazor-error-ui { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 1000; padding: 12px 18px; border-radius: 16px; background: #3b0a18; border: 1px solid var(--danger); color: #ffe4e6; box-shadow: var(--shadow-2); }
#blazor-error-ui .reload { color: white; font-weight: 700; margin-left: 10px; text-decoration: underline; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 10px; }
.blazor-error-boundary { padding: 1rem 1.2rem; border-radius: 16px; background: #3b0a18; color: white; }
.blazor-error-boundary::after { content: "Si è verificato un errore."; }
.validation-message { color: var(--danger); font-size: .8rem; }
.invalid { border-color: var(--danger) !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.22); background-clip: padding-box; border: 2px solid transparent; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    [data-reveal] { opacity: 1; transform: none; }
}

/* In home le notifiche stanno sopra il dock invece di coprirlo */
body:has(.dock-wrap) .toast-host { bottom: calc(130px + var(--safe-bottom)); }

/* ---------- Schermata d'avvio (App.razor) ----------
   Senza prerendering la pagina arriva quando il circuito è pronto: fino ad allora il logo MG.
   Compare solo dopo 150ms (caricamenti rapidi = nessun lampo) e sparisce appena esiste .app-root. */
#app-splash { position: fixed; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 22px; pointer-events: none;
    animation: splash-in .4s ease .15s both; }
body:has(.app-root) #app-splash { display: none; }
.splash-mark { width: 84px; height: 84px; border-radius: 24px; display: grid; place-items: center; background: #000; color: #fff;
    font: 700 34px/1 "Segoe UI", "Helvetica Neue", Arial, sans-serif; letter-spacing: -.03em;
    box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 24px 60px -18px rgba(139, 92, 246, .8); animation: splash-pulse 1.6s ease-in-out infinite; }
.splash-bar { width: 120px; height: 3px; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,.1); }
.splash-bar i { display: block; width: 40%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-2)); animation: splash-run 1.1s ease-in-out infinite; }
@keyframes splash-in { from { opacity: 0; } }
@keyframes splash-pulse { 50% { transform: scale(1.05); box-shadow: 0 0 0 1px rgba(255,255,255,.18), 0 30px 70px -16px rgba(34, 211, 238, .7); } }
@keyframes splash-run { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- Fluidità su telefoni e schermi touch ----------
   Il "vetro smerigliato" (backdrop-filter) sopra lo sfondo 3D animato costringe la GPU a ricalcolare la
   sfocatura di ogni pannello a ogni fotogramma: è la causa principale dei tocchi lenti sui telefoni.
   Qui il vetro diventa un vetro scuro semitrasparente (aspetto quasi identico, costo zero). */
@media (pointer: coarse), (max-width: 700px) {
    :root { --blur: none; }
    *, *::before, *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
    .glass { background: linear-gradient(145deg, rgba(34, 30, 78, .86), rgba(14, 12, 38, .88)); }
    .card { background: linear-gradient(145deg, rgba(30, 27, 70, .82), rgba(12, 10, 32, .86)); }
    .sheet-backdrop { background: rgba(3, 2, 12, .78); }
    .toast { background: rgba(24, 21, 60, .97); }
    .module-top::before { background: linear-gradient(to bottom, rgba(5,4,15,.96), rgba(5,4,15,.8) 70%, transparent); }
    /* Ombre enormi e sfocate costano a ogni animazione: più contenute sui telefoni */
    .card, .glass { box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 10px 24px -14px rgba(0,0,0,.7); }
}
/* Tocchi: nessun ritardo del doppio tocco, risposta visiva immediata */
html { touch-action: manipulation; }
@media (hover: none) {
    .btn:active, .chip:active, .fab:active, .list-item:active { transform: scale(.96); transition-duration: .08s; }
}
/* Aurora sui telefoni: niente sfocatura da 80px ricalcolata a ogni movimento del giroscopio né animazione
   continua (era l'unica fonte di ricalcoli di stile a riposo). I gradienti radiali sono già morbidi. */
@media (pointer: coarse), (max-width: 700px) {
    .bg-aurora {
        filter: none; animation: none; opacity: .42; transition: none;
        background:
            radial-gradient(40% 32% at 30% 22%, color-mix(in oklab, var(--accent) 55%, transparent), transparent 72%),
            radial-gradient(38% 34% at 75% 72%, color-mix(in oklab, var(--accent-2) 45%, transparent), transparent 72%);
    }
}
