:root {
  --gh: #e01249;
  --gh-hot: #f2295b;
  --gh-deep: #c3073f;
  --bg: #0b0b0d;
  --bg-2: #131317;
  --card: rgba(22, 22, 27, 0.72);
  --ink: #f6f4f5;
  --ink-2: rgba(246, 244, 245, 0.72);
  --ink-3: rgba(246, 244, 245, 0.46);
  --line: rgba(246, 244, 245, 0.12);
  --line-2: rgba(246, 244, 245, 0.26);
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5470;
  --c-iva: #3a3a44;
  --c-cogs: #6b6b78;
  --c-fee: #9d9daa;
  --c-ship: #c9c9d3;
  --c-adv: #e01249;
  --c-margin: #3ddc97;
  --radius: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 5vw, 64px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
::selection { background: var(--gh); color: #fff; }

/* ---------- Background (come il Questionario GH) ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.45; }
.orb-1 { width: 52vmax; height: 52vmax; left: -22vmax; top: -26vmax; background: radial-gradient(circle, var(--gh) 0%, transparent 65%); animation: drift1 24s ease-in-out infinite alternate; }
.orb-2 { width: 44vmax; height: 44vmax; right: -22vmax; bottom: -24vmax; background: radial-gradient(circle, var(--gh-deep) 0%, transparent 65%); animation: drift2 28s ease-in-out infinite alternate; opacity: 0.32; }
@keyframes drift1 { to { transform: translate(12vw, 14vh) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-12vw, -10vh) scale(0.92); } }
.grid {
  position: absolute; inset: -2px;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px; opacity: 0.22;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, #000 0%, transparent 70%);
}
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: 0.06; animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-3%)} 75%{transform:translate(3%,3%)} 100%{transform:translate(0,0)} }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px var(--gutter);
  background: linear-gradient(to bottom, rgba(11,11,13,0.92) 60%, rgba(11,11,13,0));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.mark { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 9; }
.mark-g { stroke-dasharray: 560; stroke-dashoffset: 560; animation: draw 1.6s var(--ease) 0.2s forwards; }
.mark-h { stroke-dasharray: 300; stroke-dashoffset: 300; animation: draw 1.2s var(--ease) 0.9s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.brand-name { font-weight: 600; letter-spacing: 0.02em; font-size: 15px; }
.brand-name .dot { color: var(--gh); }
.top-actions { display: flex; align-items: center; gap: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--gh); color: #fff; font-weight: 600; font-size: 15px;
  transition: transform 0.25s var(--ease), background 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-1px); background: var(--gh-hot); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); }
.btn.ghost:hover { background: rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px var(--ink-2); }
.btn.small { padding: 8px 16px; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; font-size: 14px; }
.link-btn:hover { color: var(--ink); }
:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------- Page ---------- */
.page { position: relative; z-index: 2; max-width: 1280px; margin: 0 auto; padding: 24px var(--gutter) 96px; }

.hero { max-width: 820px; padding: 40px 0 56px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-2); }
.eyebrow::before { content: ''; width: 28px; height: 2px; background: var(--gh); }
.hero-title { font-size: clamp(40px, 6.6vw, 80px); line-height: 1; font-weight: 600; letter-spacing: -0.03em; margin: 20px 0; }
.hero-title em { font-style: normal; color: var(--gh); position: relative; white-space: nowrap; }
.hero-title em::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0.04em; height: 0.08em; background: var(--gh); transform: scaleX(0); transform-origin: left; animation: underline 0.9s var(--ease) 0.9s forwards; }
@keyframes underline { to { transform: scaleX(1); } }
.lead { font-size: clamp(17px, 1.8vw, 20px); color: var(--ink-2); max-width: 640px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; color: var(--ink-2); background: rgba(255,255,255,0.03); }
.chip b { color: var(--ink); font-weight: 600; }

.reveal > * { opacity: 0; transform: translateY(16px); animation: rise 0.7s var(--ease) forwards; }
.reveal > *:nth-child(2) { animation-delay: 0.08s; }
.reveal > *:nth-child(3) { animation-delay: 0.16s; }
.reveal > *:nth-child(4) { animation-delay: 0.24s; }
.reveal-step { opacity: 0; transform: translateY(18px); animation: rise 0.7s var(--ease) forwards; animation-delay: calc(0.3s + var(--d)); }
@keyframes rise { to { opacity: 1; transform: none; } }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 40px; align-items: start; }

/* ---------- Steps ---------- */
.steps { display: flex; flex-direction: column; gap: 20px; margin: 0; }
.step {
  position: relative; padding: 28px 28px 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.3s;
}
.step:focus-within { border-color: rgba(224, 18, 73, 0.55); }
.step-head { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.step-num { font-size: 40px; line-height: 0.9; font-weight: 700; letter-spacing: -0.04em; color: transparent; -webkit-text-stroke: 1.5px var(--gh); transition: color 0.3s; }
.step:focus-within .step-num { color: var(--gh); }
.step h2 { margin: 0 0 2px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.step-head p { margin: 0; color: var(--ink-3); font-size: 15px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 28px; }

.fieldrow { padding: 6px 0 22px; }
.f-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.f-top label { font-size: 15px; color: var(--ink-2); font-weight: 500; }
.f-hint { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.f-input { position: relative; display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line-2); transition: border-color 0.3s; }
.f-input::after { content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--gh); transform: scaleX(0); transform-origin: left; transition: transform 0.5s var(--ease); }
.f-input:focus-within::after { transform: scaleX(1); }
.f-input input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; padding: 4px 0 8px; font-size: 30px; font-weight: 500; letter-spacing: -0.01em; caret-color: var(--gh); font-variant-numeric: tabular-nums; }
.unit { font-size: 22px; color: var(--ink-3); font-weight: 400; }
.invalid .f-input { border-color: var(--bad); }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 12px 0 0; background: transparent; cursor: pointer; --p: 0%; }
.range::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gh) var(--p), rgba(255,255,255,0.12) var(--p)); }
.range::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gh) var(--p), rgba(255,255,255,0.12) var(--p)); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 3px solid var(--gh); box-shadow: 0 0 0 6px rgba(224,18,73,0); transition: box-shadow 0.2s; }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--gh); }
.range:hover::-webkit-slider-thumb, .range:active::-webkit-slider-thumb { box-shadow: 0 0 0 6px rgba(224,18,73,0.22); }

/* ---------- Tip button + popover ---------- */
.tip {
  flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line-2); background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 600; font-style: italic; font-family: Georgia, serif; line-height: 1;
  color: var(--ink-2); vertical-align: middle; transition: all 0.2s;
  position: relative;
}
.tip::before { content: ''; position: absolute; inset: -10px; } /* area di tocco più ampia */
.tip:hover, .tip[aria-expanded="true"] { background: var(--gh); border-color: var(--gh); color: #fff; }
.pop {
  position: fixed; z-index: 50; padding: 14px 16px; border-radius: 14px;
  background: #1b1b21; border: 1px solid var(--line-2); color: var(--ink-2);
  font-size: 14px; line-height: 1.55; box-shadow: 0 20px 50px -10px rgba(0,0,0,0.7);
}
.pop b { color: var(--ink); font-weight: 600; }
.pop i { color: var(--ink); font-style: normal; background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 5px; }
.pop.in { animation: popIn 0.25s var(--ease); }
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* ---------- Results ---------- */
.results { position: sticky; top: 84px; }
.res-card {
  padding: 26px; border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(36, 18, 26, 0.85), rgba(19, 19, 23, 0.9));
  border: 1px solid rgba(224, 18, 73, 0.3);
  box-shadow: 0 30px 80px -30px rgba(224, 18, 73, 0.45);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.res-title { font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2); }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 500; background: rgba(255,255,255,0.05); }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.6s ease-in-out infinite; }
.status.ok { color: var(--ok); background: rgba(61,220,151,0.1); }
.status.warn { color: var(--warn); background: rgba(255,181,71,0.1); }
.status.bad { color: var(--bad); background: rgba(255,84,112,0.12); }
@keyframes blink { 50% { opacity: 0.3; } }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: 14px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); min-width: 0; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.kpi-value { font-size: clamp(28px, 3vw, 36px); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-sub { font-size: 13px; color: var(--ink-3); }
.kpi-sub b { color: var(--ink-2); font-weight: 500; }
body[data-health="bad"] .kpi-value { color: var(--bad); }

.split { margin: 24px 0 8px; }
.split-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-2); margin-bottom: 10px; }
.split-head b { color: var(--ink); }
/* la barra è alta 20px; i segmenti 14px, quello attivo cresce a 20px (niente scale: deformerebbe l'etichetta) */
.bar { display: flex; align-items: center; height: 20px; gap: 2px; margin-top: 24px; }
.bar i {
  position: relative; flex: 1 1 0; min-width: 0; height: 14px; cursor: pointer;
  transition: flex-grow 0.6s var(--ease), opacity 0.25s, height 0.25s var(--ease), filter 0.25s;
}
.bar i:first-child { border-radius: 7px 0 0 7px; }
.bar i:last-child { border-radius: 0 7px 7px 0; }
.seg-pct {
  --tx: -50%;
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translate(var(--tx), 4px);
  padding: 2px 7px; border-radius: 6px; background: #fff; color: #111;
  font-size: 12px; font-weight: 600; font-style: normal; line-height: 1.4; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.25s var(--ease);
}
/* primo e ultimo segmento: etichetta allineata al bordo, così non esce dalla card */
.bar i:first-child .seg-pct { left: 0; --tx: 0%; }
.bar i:last-child .seg-pct { left: auto; right: 0; --tx: 0%; }
/* evidenziazione collegata barra ↔ legenda */
.split.focusing .bar i { opacity: 0.22; filter: saturate(0.4); }
.split.focusing .bar i.on { opacity: 1; filter: none; height: 20px; }
.split .bar i.on .seg-pct { opacity: 1; transform: translate(var(--tx), 0); }
.legend li { cursor: pointer; border-radius: 6px; transition: opacity 0.25s, background 0.25s; outline-offset: 2px; }
.split.focusing .legend li { opacity: 0.32; }
.split.focusing .legend li.on { opacity: 1; background: rgba(255,255,255,0.06); }
.split.focusing .legend li.on .lg-l, .split.focusing .legend li.on b { color: var(--ink); }
.split.focusing .legend li.on .sw { transform: scale(1.25); }
.sw { transition: transform 0.25s var(--ease); }
.legend { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 8px; color: var(--ink-3); min-width: 0; padding: 2px 6px; margin: 0 -6px; }
.legend .lg-l { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend b { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend li.neg b { color: var(--bad); }
.sw { flex: none; width: 10px; height: 10px; border-radius: 3px; }

.rows { margin: 18px 0 0; padding: 0; }
.rows > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rows dt { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 15px; }
.rows dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.monthly { margin-top: 18px; padding: 18px; border-radius: 14px; background: var(--gh); color: #fff; box-shadow: 0 16px 40px -14px rgba(224,18,73,0.8); }
.monthly-title { font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.85; }
.m-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 10px; }
.m-value { display: block; font-size: clamp(18px, 1.9vw, 24px); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-label { display: flex; align-items: center; gap: 6px; font-size: 13px; opacity: 0.9; }
.monthly .tip { width: 18px; height: 18px; font-size: 11px; color: #fff; border-color: rgba(255,255,255,0.5); }
.monthly .tip:hover, .monthly .tip[aria-expanded="true"] { background: #fff; color: var(--gh); border-color: #fff; }

.fineprint { margin: 14px 4px 0; font-size: 13px; color: var(--ink-3); }

.bump { animation: bump 0.4s var(--ease); }
@keyframes bump { 40% { transform: translateY(-2px); color: var(--gh-hot); } }
.monthly .bump { animation-name: bumpW; }
@keyframes bumpW { 40% { transform: translateY(-2px); } }
.kpi-value, .rows dd, .m-value { display: inline-block; }

/* ---------- Mobile bar ---------- */
.mbar {
  position: fixed; z-index: 30; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  display: none; justify-content: space-between; gap: 8px; padding: 12px 18px;
  border-radius: 16px; background: var(--gh); color: #fff; text-decoration: none;
  box-shadow: 0 14px 40px -10px rgba(224,18,73,0.9);
  transition: transform 0.4s var(--ease), opacity 0.3s;
}
.mbar span { display: flex; flex-direction: column; min-width: 0; }
.mbar small { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.mbar b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.res-visible .mbar { transform: translateY(140%); opacity: 0; pointer-events: none; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; padding: 12px 18px; border-radius: 12px; background: #fff; color: #111; font-size: 14px; font-weight: 500; transition: all 0.35s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .results { position: static; }
  .mbar { display: flex; }
  .page { padding-bottom: 120px; }
}
@media (max-width: 560px) {
  .hero { padding: 16px 0 36px; }
  .step { padding: 22px 18px 4px; }
  .step-num { font-size: 32px; }
  .res-card { padding: 20px 16px; }
  .kpis { gap: 8px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 24px; }
  .legend { grid-template-columns: 1fr; }
  .m-grid { grid-template-columns: 1fr; gap: 12px; }
  .m-item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .top-actions .link-btn { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
