/* ── RESET & SCOPE ──────────────────────────────────── */
#wmaGadsTool,#wmaGadsTool *{box-sizing:border-box;margin:0;padding:0;}
#wmaGadsTool{isolation:isolate;}
/* ── VARIABLES ──────────────────────────────────────── */
#wmaGadsTool{
--ff:'DM Sans',system-ui,sans-serif;
--ffm:'DM Mono','Courier New',monospace;
--bg:#f5f4f0;
--surface:#ffffff;
--surface2:#fafaf8;
--surface3:#f0ede7;
--ink:#1a1714;
--ink2:#4a4540;
--ink3:#8a8278;
--line:#e4e0d8;
--line2:#d0cbc2;
--blue:#1d4ed8;
--blue-light:#eff4ff;
--blue-mid:rgba(29,78,216,.12);
--amber:#b45309;
--amber-light:#fffbeb;
--green:#15803d;
--green-light:#f0fdf4;
--red:#be123c;
--red-light:#fff1f2;
--r4:4px;
--r8:8px;
--r12:12px;
--r16:16px;
--r24:24px;
--r99:999px;
--sh1:0 1px 2px rgba(26,23,20,.04),0 2px 6px rgba(26,23,20,.04);
--sh2:0 2px 8px rgba(26,23,20,.06),0 8px 24px rgba(26,23,20,.06);
--sh3:0 4px 16px rgba(26,23,20,.08),0 16px 40px rgba(26,23,20,.08);
font-family:var(--ff);
background:var(--bg);
color:var(--ink);
max-width:1380px;
border-radius:var(--r24);
padding:0;
overflow:hidden;
box-shadow:var(--sh3);
border:1px solid var(--line);
}
/* ── HEADER ─────────────────────────────────────────── */
#wmaGadsTool .wma-header{
background:var(--surface);
border-bottom:1px solid var(--line);
padding:28px 32px 24px;
display:flex;
align-items:flex-start;
justify-content:space-between;
gap:16px;
flex-wrap:wrap;
}
#wmaGadsTool .wma-header-text{}
#wmaGadsTool .wma-title{
font-size:21px;
font-weight:800;
letter-spacing:-.4px;
color:var(--ink);
line-height:1.15;
margin-bottom:6px;
}
#wmaGadsTool .wma-title span{
background:linear-gradient(90deg,var(--blue),#6366f1);
-webkit-background-clip:text;
-webkit-text-fill-color:transparent;
background-clip:text;
}
#wmaGadsTool .wma-subtitle{
font-size:14px;
color:var(--ink3);
line-height:1.5;
font-weight:400;
}
#wmaGadsTool .wma-badge{
display:inline-flex;
align-items:center;
gap:6px;
padding:6px 12px;
border-radius:var(--r99);
background:var(--surface3);
border:1px solid var(--line);
font-size:11px;
font-weight:600;
color:var(--ink3);
letter-spacing:.3px;
text-transform:uppercase;
white-space:nowrap;
flex-shrink:0;
}
#wmaGadsTool .wma-badge::before{
content:'';
width:6px;height:6px;
border-radius:50%;
background:#f59e0b;
flex-shrink:0;
}
/* ── TABS ────────────────────────────────────────────── */
#wmaGadsTool .wma-tabs-bar{
background:var(--surface);
border-bottom:1px solid var(--line);
padding:0 32px;
display:flex;
gap:0;
}
#wmaGadsTool .tab{
appearance:none;
border:none;
background:none;
color:var(--ink3);
padding:14px 20px 13px;
font-family:var(--ff);
font-size:14px;
font-weight:600;
cursor:pointer;
border-bottom:2px solid transparent;
margin-bottom:-1px;
transition:color .15s,border-color .15s;
position:relative;
}
#wmaGadsTool .tab:hover{color:var(--ink);}
#wmaGadsTool .tab[aria-selected="true"]{
color:var(--blue);
border-bottom-color:var(--blue);
}
#wmaGadsTool .tab-badge{
display:inline-flex;
align-items:center;
margin-left:7px;
padding:2px 7px;
border-radius:var(--r99);
background:var(--blue-mid);
color:var(--blue);
font-size:10px;
font-weight:700;
letter-spacing:.2px;
}
/* ── BODY LAYOUT ─────────────────────────────────────── */
#wmaGadsTool .wma-body{
display:grid;
grid-template-columns:1fr 1fr;
gap:0;
min-height:0;
}
@media(max-width:780px){
#wmaGadsTool .wma-body{grid-template-columns:1fr;}
#wmaGadsTool .wma-header{padding:20px;}
#wmaGadsTool .wma-tabs-bar{padding:0 20px;}
#wmaGadsTool .wma-left,.wma-right{padding:20px;}
}
/* ── PANELS ──────────────────────────────────────────── */
#wmaGadsTool .wma-left{
padding:28px 32px;
background:var(--surface);
border-right:1px solid var(--line);
display:flex;
flex-direction:column;
gap:0;
}
#wmaGadsTool .wma-right{
padding:28px 32px;
background:var(--bg);
display:flex;
flex-direction:column;
gap:16px;
}
/* ── SECTION LABELS ──────────────────────────────────── */
#wmaGadsTool .sec-label{
font-size:10px;
font-weight:700;
letter-spacing:.8px;
text-transform:uppercase;
color:var(--ink3);
margin-bottom:12px;
display:flex;
align-items:center;
gap:8px;
}
#wmaGadsTool .sec-label::after{
content:'';
flex:1;
height:1px;
background:var(--line);
}
/* ── FORM ELEMENTS (FIX VISIBILITY) ───────────────────── */
#wmaGadsTool .field{ margin-bottom:16px; }
#wmaGadsTool .field:last-child{margin-bottom:0;}
#wmaGadsTool label.lbl{
display:block;
font-size:12px;
font-weight:700;
color:var(--ink2);
margin-bottom:6px;
letter-spacing:.1px;
}
/* input/select: più contrasto + altezza touch + anti override tema */
#wmaGadsTool select,
#wmaGadsTool input[type="number"]{
width:100%;
min-height:44px; /* tap-friendly + evita testi “tagliati” */
padding:12px 14px;
border-radius:var(--r8);
border:1.5px solid var(--line2) !important;
background:#fff !important;
color:var(--ink) !important;
-webkit-text-fill-color:var(--ink); /* FIX: valore che “sparisce” su alcuni temi/iOS */
font-family:var(--ff) !important;
font-size:14px !important;
font-weight:600;
line-height:1.2;
outline:none;
transition:border-color .15s,box-shadow .15s,background .15s;
appearance:none;
-webkit-appearance:none;
background-clip:padding-box;
box-shadow: inset 0 1px 0 rgba(26,23,20,.03);
}
/* Select arrow + spazio testo */
#wmaGadsTool select{
background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8278' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
background-repeat:no-repeat;
background-position:right 14px center;
padding-right:44px;
cursor:pointer;
}
/* Opzioni sempre leggibili */
#wmaGadsTool select option{
color:var(--ink);
background:#fff;
}
/* Focus */
#wmaGadsTool select:focus,
#wmaGadsTool input[type="number"]:focus{
border-color:var(--blue) !important;
box-shadow:0 0 0 4px rgba(29,78,216,.12);
}
/* Placeholder */
#wmaGadsTool input::placeholder{
color:var(--ink3);
opacity:1;
}
/* Autofill (Chrome) */
#wmaGadsTool input:-webkit-autofill,
#wmaGadsTool input:-webkit-autofill:hover,
#wmaGadsTool input:-webkit-autofill:focus{
-webkit-text-fill-color:var(--ink) !important;
box-shadow: 0 0 0 1000px #fff inset !important;
border:1.5px solid var(--line2) !important;
}
/* Mobile: evita zoom iOS e aumenta leggibilità */
@media(max-width:780px){
#wmaGadsTool select,
#wmaGadsTool input[type="number"]{
font-size:16px !important;
}
}
/* ── FIELD ROW ───────────────────────────────────────── */
#wmaGadsTool .field-row{
display:grid;
grid-template-columns:1fr 1fr;
gap:12px;
margin-bottom:16px;
}
@media(max-width:500px){
#wmaGadsTool .field-row{grid-template-columns:1fr;}
}
/* ── SCENARIO CHIPS ──────────────────────────────────── */
#wmaGadsTool .chip-group{
display:grid;
grid-template-columns:1fr 1fr 1fr;
gap:8px;
margin-bottom:16px;
}
#wmaGadsTool .chip-option{
position:relative;
}
#wmaGadsTool .chip-option input[type="radio"]{
position:absolute;
opacity:0;
width:0;height:0;
}
#wmaGadsTool .chip-label{
display:flex;
flex-direction:column;
align-items:center;
justify-content:center;
gap:2px;
padding:10px 8px;
border-radius:var(--r8);
border:1.5px solid var(--line);
background:var(--surface2);
cursor:pointer;
text-align:center;
transition:border-color .15s,background .15s,box-shadow .15s;
min-height:58px;
}
#wmaGadsTool .chip-label:hover{
border-color:var(--line2);
background:var(--surface);
}
#wmaGadsTool .chip-option input:checked + .chip-label{
border-color:var(--blue);
background:var(--blue-light);
box-shadow:0 0 0 3px rgba(29,78,216,.08);
}
#wmaGadsTool .chip-name{
font-size:12px;
font-weight:700;
color:var(--ink);
line-height:1.2;
}
#wmaGadsTool .chip-desc{
font-size:10px;
color:var(--ink3);
font-weight:400;
}
/* Direction chips (2 col) */
#wmaGadsTool .chip-group2{
display:grid;
grid-template-columns:1fr 1fr;
gap:8px;
margin-bottom:16px;
}
#wmaGadsTool .chip-group2 .chip-label{
padding:12px;
align-items:flex-start;
text-align:left;
min-height:64px;
}
#wmaGadsTool .chip-label .chip-icon{
font-size:18px;
margin-bottom:2px;
}
/* ── ADVANCED TOGGLE SECTION ─────────────────────────── */
#wmaGadsTool .wma-expand{
border:1.5px solid var(--line);
border-radius:var(--r12);
overflow:hidden;
margin-bottom:16px;
}
#wmaGadsTool .wma-expand summary{
list-style:none;
padding:12px 14px;
cursor:pointer;
font-size:13px;
font-weight:600;
color:var(--ink2);
background:var(--surface2);
display:flex;
align-items:center;
gap:8px;
user-select:none;
transition:background .15s;
}
#wmaGadsTool .wma-expand summary:hover{background:var(--surface3);}
#wmaGadsTool .wma-expand summary::-webkit-details-marker{display:none;}
#wmaGadsTool .wma-expand summary::after{
content:'▸';
margin-left:auto;
font-size:12px;
color:var(--ink3);
transition:transform .2s;
}
#wmaGadsTool .wma-expand[open] summary::after{transform:rotate(90deg);}
#wmaGadsTool .wma-expand-body{
padding:16px;
background:var(--surface);
border-top:1px solid var(--line);
}
#wmaGadsTool .wma-expand-body .field-row{margin-bottom:0;}
/* ── ACTIONS ─────────────────────────────────────────── */
#wmaGadsTool .wma-actions{
display:flex;
gap:10px;
margin-top:4px;
flex-wrap:wrap;
}
#wmaGadsTool .btn{
appearance:none;
border:none;
cursor:pointer;
font-family:var(--ff);
font-weight:700;
border-radius:var(--r8);
transition:all .15s;
display:inline-flex;
align-items:center;
justify-content:center;
gap:8px;
text-decoration:none;
font-size:14px;
position:relative;
overflow:hidden;
}
#wmaGadsTool .btn-primary{
background:var(--blue);
color:#fff;
padding:12px 24px;
box-shadow:0 1px 2px rgba(29,78,216,.3),0 4px 12px rgba(29,78,216,.2);
}
#wmaGadsTool .btn-primary:hover{
background:#1e40af;
box-shadow:0 2px 4px rgba(29,78,216,.3),0 8px 20px rgba(29,78,216,.25);
transform:translateY(-1px);
}
#wmaGadsTool .btn-primary:active{transform:translateY(0);}
#wmaGadsTool .btn-ghost{
background:var(--surface2);
color:var(--ink2);
padding:12px 16px;
border:1.5px solid var(--line);
}
#wmaGadsTool .btn-ghost:hover{
background:var(--surface3);
border-color:var(--line2);
}
#wmaGadsTool .hint-text{
font-size:11.5px;
color:var(--ink3);
line-height:1.5;
margin-top:14px;
}
/* ── DIVIDER ─────────────────────────────────────────── */
#wmaGadsTool .wma-divider{
height:1px;
background:var(--line);
margin:20px 0;
}
/* ── RESULTS AREA ────────────────────────────────────── */
#wmaGadsTool .result-intro{
background:var(--surface);
border-radius:var(--r12);
border:1px solid var(--line);
padding:14px 16px;
font-size:13px;
color:var(--ink2);
font-weight:500;
line-height:1.5;
box-shadow:var(--sh1);
}
#wmaGadsTool .kpi-grid{
display:grid;
grid-template-columns:1fr 1fr;
gap:10px;
}
#wmaGadsTool .kpi-grid .kpi-full{grid-column:1/-1;}
#wmaGadsTool .kpi{
background:var(--surface);
border:1px solid var(--line);
border-radius:var(--r12);
padding:14px 16px;
box-shadow:var(--sh1);
transition:box-shadow .15s,border-color .15s;
display:flex;
flex-direction:column;
gap:4px;
}
#wmaGadsTool .kpi:hover{
box-shadow:var(--sh2);
border-color:var(--line2);
}
#wmaGadsTool .kpi-label{
font-size:10px;
font-weight:700;
letter-spacing:.6px;
text-transform:uppercase;
color:var(--ink3);
line-height:1;
}
#wmaGadsTool .kpi-value{
font-family:var(--ffm);
font-size:20px;
font-weight:500;
color:var(--ink);
letter-spacing:-.5px;
line-height:1.2;
word-break:break-word;
}
#wmaGadsTool .kpi-value.lg{font-size:24px;}
#wmaGadsTool .kpi-sub{
font-size:11px;
color:var(--ink3);
line-height:1.4;
}
/* Status badge */
#wmaGadsTool .status-badge{
display:inline-flex;
align-items:center;
gap:6px;
padding:5px 10px;
border-radius:var(--r99);
font-size:12px;
font-weight:700;
}
#wmaGadsTool .status-badge::before{
content:'';
width:7px;height:7px;
border-radius:50%;
flex-shrink:0;
}
#wmaGadsTool .status-ok{
background:var(--green-light);
color:var(--green);
border:1px solid rgba(21,128,61,.2);
}
#wmaGadsTool .status-ok::before{background:var(--green);}
#wmaGadsTool .status-warn{
background:var(--amber-light);
color:var(--amber);
border:1px solid rgba(180,83,9,.2);
}
#wmaGadsTool .status-warn::before{background:var(--amber);}
#wmaGadsTool .status-bad{
background:var(--red-light);
color:var(--red);
border:1px solid rgba(190,18,60,.2);
}
#wmaGadsTool .status-bad::before{background:var(--red);}
/* ── CTA CARD ────────────────────────────────────────── */
#wmaGadsTool .cta-card{
background:linear-gradient(135deg,#1d4ed8 0%,#4f46e5 100%);
border-radius:var(--r12);
padding:20px;
box-shadow:0 4px 16px rgba(29,78,216,.25);
position:relative;
overflow:hidden;
}
#wmaGadsTool .cta-card::before{
content:'';
position:absolute;
top:-30px;right:-30px;
width:120px;height:120px;
border-radius:50%;
background:rgba(255,255,255,.06);
}
#wmaGadsTool .cta-card::after{
content:'';
position:absolute;
bottom:-20px;left:20px;
width:80px;height:80px;
border-radius:50%;
background:rgba(255,255,255,.04);
}
#wmaGadsTool .cta-title{
font-size:15px;
font-weight:700;
color:#fff;
margin-bottom:4px;
position:relative;z-index:1;
}
#wmaGadsTool .cta-desc{
font-size:12.5px;
color:rgba(255,255,255,.75);
line-height:1.5;
margin-bottom:14px;
position:relative;z-index:1;
}
#wmaGadsTool .btn-cta{
background:#fff;
color:var(--blue);
padding:11px 20px;
border-radius:var(--r8);
font-size:13.5px;
font-weight:700;
display:inline-flex;
align-items:center;
gap:8px;
text-decoration:none;
transition:all .15s;
position:relative;z-index:1;
box-shadow:0 2px 8px rgba(0,0,0,.15);
width:100%;
justify-content:center;
}
#wmaGadsTool .btn-cta:hover{
background:#f0f4ff;
transform:translateY(-1px);
box-shadow:0 4px 14px rgba(0,0,0,.18);
}
/* ── TAGS ROW ────────────────────────────────────────── */
#wmaGadsTool .tags-row{
display:flex;
gap:6px;
flex-wrap:wrap;
margin-top:6px;
}
#wmaGadsTool .tag{
padding:4px 10px;
border-radius:var(--r99);
background:var(--surface3);
border:1px solid var(--line);
font-size:11px;
font-weight:600;
color:var(--ink3);
}
/* ── KPI ACCENT BORDERS ──────────────────────────────── */
#wmaGadsTool .kpi.accent-blue{border-top:2px solid var(--blue);}
#wmaGadsTool .kpi.accent-green{border-top:2px solid #16a34a;}
#wmaGadsTool .kpi.accent-amber{border-top:2px solid #d97706;}
#wmaGadsTool .kpi.accent-violet{border-top:2px solid #7c3aed;}
/* ── MOBILE ──────────────────────────────────────────── */
@media(max-width:780px){
#wmaGadsTool .wma-left{border-right:none;border-bottom:1px solid var(--line);}
#wmaGadsTool .kpi-grid{grid-template-columns:1fr;}
#wmaGadsTool .chip-group{grid-template-columns:1fr 1fr 1fr;}
}
@media(max-width:400px){
#wmaGadsTool .chip-group{grid-template-columns:1fr;}
#wmaGadsTool .chip-group2{grid-template-columns:1fr;}
}
Rapida
Avanzata CR custom
Campagna
Obiettivo
Lead / Servizi
E-commerce
Settore
E-commerce & Retail
Servizi locali
Immobiliare
Legale
Assicurazioni / Finanza
Area geografica / Competitività
Italia (media)
Regioni / Capoluoghi (media)
Grandi città (alta)
Milano / Roma (molto alta)
Province / Aree meno competitive
Scenario CPC
↓ Basso
CPC minimo
● Medio
Realistico
↑ Alto
Aggressivo
Calcolo
🎯
Budget per obiettivo
Quanti € per X lead/ordini
💰
Risultati da budget
Lead/ordini con X €/mese
Obiettivo mensile (lead o ordini)
💼 Parametri business (valore, margini, LTV)
Valore medio cliente (€)
Margine lordo (%)
Chiusura lead→cliente (%)
Moltiplicatore LTV
⚙️ Parametri avanzati (CR & giorni)
Tasso conversione landing (%)
Giorni operativi/mese
Se non hai dati, usa la stima rapida e correggi con i dati reali dell'account.
Calcola
Copia
I CPC e i tassi di conversione reali dipendono da keyword, qualità annunci, landing page e storico account.
Imposta i parametri a sinistra e clicca Calcola per ottenere la stima.
Vuoi numeri precisi?
Analisi reale su keyword, volume di ricerca, competitor e CPC del tuo settore — inclusa una stima budget personalizzata.
Richiedi Consulenza Gratuita
(function(){
var CTA_URL = "/contattaci/";
var BRAND_NAME = "WMA";
var LOCALE = "it-IT";
var SECTORS = {
ecomRetail: { label:"E-commerce & Retail", cpcMin:0.60, cpcMax:2.50 },
localServices:{ label:"Servizi locali", cpcMin:0.40, cpcMax:1.80 },
realEstate: { label:"Immobiliare", cpcMin:1.50, cpcMax:4.50 },
legal: { label:"Legale", cpcMin:2.00, cpcMax:6.00 },
finance: { label:"Assicurazioni / Finanza", cpcMin:3.00, cpcMax:15.00 }
};
var AREA_MULT = {
it: { label:"Italia (media)", m:1.00 },
region:{ label:"Regioni/capoluoghi (media)", m:1.05 },
big: { label:"Grandi città (alta)", m:1.15 },
top: { label:"Milano/Roma (molto alta)", m:1.25 },
prov: { label:"Province/aree meno competitive", m:0.90 }
};
var SCENARIO_T = { low:0.20, mid:0.55, high:0.90 };
var DEFAULTS = {
leads:{ cr:3.5, close:20, margin:40, value:2500 },
ecom: { cr:1.6, close:null, margin:30, value:120 }
};
var nfEUR = new Intl.NumberFormat(LOCALE,{style:"currency",currency:"EUR",maximumFractionDigits:0});
var nfEUR2 = new Intl.NumberFormat(LOCALE,{style:"currency",currency:"EUR",maximumFractionDigits:2});
var nfNum = new Intl.NumberFormat(LOCALE,{maximumFractionDigits:0});
var nfNum1 = new Intl.NumberFormat(LOCALE,{maximumFractionDigits:1});
var clamp = function(n,a,b){return Math.min(b,Math.max(a,n));};
var toNum = function(v,f){var n=parseFloat(String(v).replace(",","."));return isFinite(n)?n:f;};
function cpcRange(sk,ak){
var s=SECTORS[sk]||SECTORS.ecomRetail;
var m=(AREA_MULT[ak]||AREA_MULT.it).m;
return {min:s.cpcMin*m,max:s.cpcMax*m,label:s.label};
}
function pickCpc(min,max,sc){
var t=SCENARIO_T[sc]!=null?SCENARIO_T[sc]:SCENARIO_T.mid;
return min+(max-min)*t;
}
function computeBreakEven(objective,value,marginPct,ltv,closePct){
var margin=clamp(marginPct,1,95)/100;
var ltvM=Math.max(1,ltv);
if(objective==="ecom"){
return {roasBE_first:1/margin,roasBE_first_withLTV:1/(margin*ltvM)};
}
var close=clamp(closePct,1,100)/100;
var profitPerCustomer=value*margin*ltvM;
var valuePerLead=profitPerCustomer*close;
return {profitPerCustomer:profitPerCustomer,valuePerLead:valuePerLead,cpaLeadBE:valuePerLead};
}
var root=document.getElementById("wmaGadsTool");
if(!root)return;
var els={
tabs:root.querySelectorAll(".tab"),
objective:root.querySelector("#wmaObjective"),
sector:root.querySelector("#wmaSector"),
area:root.querySelector("#wmaArea"),
scenario:root.querySelectorAll('input[name="wmaScenario"]'),
direction:root.querySelectorAll('input[name="wmaDirection"]'),
goalFields:root.querySelector("#wmaGoalFields"),
budgetFields:root.querySelector("#wmaBudgetFields"),
target:root.querySelector("#wmaTarget"),
monthlyBudget:root.querySelector("#wmaMonthlyBudget"),
value:root.querySelector("#wmaValue"),
valueLabel:root.querySelector("#wmaValueLabel"),
margin:root.querySelector("#wmaMargin"),
closeWrap:root.querySelector("#wmaCloseWrap"),
close:root.querySelector("#wmaClose"),
ltv:root.querySelector("#wmaLtv"),
advancedOnly:root.querySelector("#wmaAdvancedOnly"),
cr:root.querySelector("#wmaCR"),
days:root.querySelector("#wmaDays"),
calcBtn:root.querySelector("#wmaCalcBtn"),
copyBtn:root.querySelector("#wmaCopyBtn"),
results:root.querySelector("#wmaResults"),
intro:root.querySelector("#wmaResultIntro"),
cta:root.querySelector("#wmaCta")
};
var state={
mode:"quick",objective:"leads",sector:"ecomRetail",area:"it",
scenario:"mid",direction:"goal",target:30,monthlyBudget:1000,
value:200,margin:30,close:20,ltv:1,cr:4,days:30
};
function setDefaultsForObjective(objKey){
var d=DEFAULTS[objKey]||DEFAULTS.leads;
state.value=d.value; state.margin=d.margin;
if(objKey==="leads"){state.close=d.close;}
state.cr=d.cr;
els.value.value=state.value;
els.margin.value=state.margin;
if(objKey==="leads"){els.close.value=state.close;}
els.cr.value=state.cr;
}
function syncVisibility(){
els.closeWrap.style.display=(state.objective==="leads")?"":"none";
els.goalFields.style.display=(state.direction==="goal")?"":"none";
els.budgetFields.style.display=(state.direction==="budget")?"":"none";
els.advancedOnly.style.display=(state.mode==="advanced")?"":"none";
els.cta.href=CTA_URL;
els.valueLabel.textContent=(state.objective==="leads")?"Valore medio cliente (€)":"Valore medio ordine / AOV (€)";
}
function getRadio(nodes){var v="";nodes.forEach(function(r){if(r.checked)v=r.value;});return v;}
function readStateFromUI(){
state.objective=els.objective.value;
state.sector=els.sector.value;
state.area=els.area.value;
state.scenario=getRadio(els.scenario)||"mid";
state.direction=getRadio(els.direction)||"goal";
state.target=clamp(toNum(els.target.value,30),1,1000000);
state.monthlyBudget=clamp(toNum(els.monthlyBudget.value,1000),10,100000000);
state.value=clamp(toNum(els.value.value,200),1,100000000);
state.margin=clamp(toNum(els.margin.value,30),1,95);
state.ltv=clamp(toNum(els.ltv.value,1),1,20);
if(state.objective==="leads"){state.close=clamp(toNum(els.close.value,20),1,100);}
if(state.mode==="advanced"){
state.cr=clamp(toNum(els.cr.value,(DEFAULTS[state.objective]||DEFAULTS.leads).cr),0.1,40);
state.days=clamp(toNum(els.days.value,30),20,31);
}else{
state.cr=(DEFAULTS[state.objective]||DEFAULTS.leads).cr;
state.days=30;
}
syncVisibility();
}
function calc(){
readStateFromUI();
var range=cpcRange(state.sector,state.area);
var cpcMin=range.min,cpcMax=range.max;
var cpcPick=pickCpc(cpcMin,cpcMax,state.scenario);
var cr=state.cr/100;
var margin=state.margin/100;
var ltvM=state.ltv;
var out={cpcMin:cpcMin,cpcMax:cpcMax,cpcPick:cpcPick,cr:cr,objective:state.objective};
out.breakEven=computeBreakEven(state.objective,state.value,state.margin,ltvM,state.close);
if(state.direction==="goal"){
var cg=state.target;
var cn=cg/cr;
out.conversionsGoal=cg;
out.clicksNeeded=cn;
out.budgetMin=cn*cpcMin;
out.budgetMid=cn*cpcPick;
out.budgetMax=cn*cpcMax;
out.cpaMin=out.budgetMin/cg;
out.cpaMid=out.budgetMid/cg;
out.cpaMax=out.budgetMax/cg;
if(state.objective==="ecom"){
out.revenueMid=cg*state.value;
out.profitMid=out.revenueMid*margin*ltvM;
out.roasMid=out.revenueMid/out.budgetMid;
}else{
out.customersMid=cg*(state.close/100);
out.revenueMid=out.customersMid*state.value;
out.profitMid=out.revenueMid*margin*ltvM;
out.roasMid=out.revenueMid/out.budgetMid;
out.cacCustomerMid=out.customersMid>0?(out.budgetMid/out.customersMid):Infinity;
}
}else{
out.budget=state.monthlyBudget;
out.clicksMin=out.budget/cpcMax;
out.clicksMid=out.budget/cpcPick;
out.clicksMax=out.budget/cpcMin;
out.conversionsMin=out.clicksMin*cr;
out.conversionsMid=out.clicksMid*cr;
out.conversionsMax=out.clicksMax*cr;
out.cpaBest=out.budget/Math.max(out.conversionsMax,0.00001);
out.cpaMid=out.budget/Math.max(out.conversionsMid,0.00001);
out.cpaWorst=out.budget/Math.max(out.conversionsMin,0.00001);
if(state.objective==="ecom"){
out.revenueMid=out.conversionsMid*state.value;
out.profitMid=out.revenueMid*margin*ltvM;
out.roasMid=out.revenueMid/out.budget;
}else{
out.customersMid=out.conversionsMid*(state.close/100);
out.revenueMid=out.customersMid*state.value;
out.profitMid=out.revenueMid*margin*ltvM;
out.roasMid=out.revenueMid/out.budget;
out.cacCustomerMid=out.customersMid>0?(out.budget/out.customersMid):Infinity;
}
}
return out;
}
function statusFor(out){
if(out.objective==="ecom"){
var be=out.breakEven.roasBE_first_withLTV;
if(!isFinite(out.roasMid))return{cls:"warn",txt:"Dati insufficienti"};
if(out.roasMid>=be*1.15)return{cls:"ok",txt:"Sembra sostenibile"};
if(out.roasMid>=be*0.95)return{cls:"warn",txt:"Al limite — ottimizza"};
return{cls:"bad",txt:"Probabilmente non sostenibile"};
}else{
var beCpa=out.breakEven.cpaLeadBE;
var cpa=out.cpaMid;
if(!isFinite(cpa)||!isFinite(beCpa))return{cls:"warn",txt:"Dati insufficienti"};
if(cpa<=beCpa*0.75)return{cls:"ok",txt:"Sembra sostenibile"};
if(cpa<=beCpa*1.05)return{cls:"warn",txt:"Al limite — ottimizza"};
return{cls:"bad",txt:"Probabilmente non sostenibile"};
}
}
function kpi(label,val,sub,extraClass){
extraClass=extraClass||"";
return '';
}
function render(out){
var isGoal=(state.direction==="goal");
var labelConv=(state.objective==="ecom")?"ordini/mese":"lead/mese";
var crLabel=(state.mode==="advanced")?"inserito":"stima";
var html="";
// CPC full width
html+=kpi(
"CPC stimato",
nfEUR2.format(out.cpcPick),
"Range "+nfEUR2.format(out.cpcMin)+" – "+nfEUR2.format(out.cpcMax)+" · "+SECTORS[state.sector].label,
"kpi-full accent-blue"
);
if(isGoal){
html+=kpi(
"Budget mensile stimato",
nfEUR.format(out.budgetMid),
"Range "+nfEUR.format(out.budgetMin)+" – "+nfEUR.format(out.budgetMax)+" · "+nfEUR.format(out.budgetMid/state.days)+"/giorno",
"kpi-full accent-blue"
);
html+=kpi("Click necessari",nfNum.format(out.clicksNeeded),"Per "+nfNum.format(out.conversionsGoal)+" "+labelConv,"accent-amber");
html+=kpi("CPA (€/conversione)",nfEUR2.format(out.cpaMid),"Range "+nfEUR2.format(out.cpaMin)+" – "+nfEUR2.format(out.cpaMax),"accent-amber");
}else{
html+=kpi(
"Conversioni stimate",
nfNum1.format(out.conversionsMid)+" "+labelConv,
"Range "+nfNum1.format(out.conversionsMin)+" – "+nfNum1.format(out.conversionsMax),
"kpi-full accent-blue"
);
html+=kpi("Click stimati",nfNum.format(out.clicksMid),"Range "+nfNum.format(out.clicksMin)+" – "+nfNum.format(out.clicksMax),"accent-amber");
html+=kpi("CPA (€/conversione)",nfEUR2.format(out.cpaMid),"Best–Worst: "+nfEUR2.format(out.cpaBest)+" – "+nfEUR2.format(out.cpaWorst),"accent-amber");
}
if(out.objective==="ecom"){
html+=kpi("Ricavi stimati",nfEUR.format(out.revenueMid),"AOV "+nfEUR2.format(state.value)+" · margine "+nfNum1.format(state.margin)+"%","accent-green");
html+=kpi("ROAS stimato",nfNum1.format(out.roasMid)+"×","Break-even: "+nfNum1.format(out.breakEven.roasBE_first_withLTV)+"× (con LTV)","accent-green");
}else{
var custTxt=isFinite(out.customersMid)?nfNum1.format(out.customersMid):"—";
var cacTxt=isFinite(out.cacCustomerMid)?nfEUR2.format(out.cacCustomerMid):"—";
html+=kpi("Clienti stimati",custTxt,"Chiusura "+nfNum1.format(state.close)+"% · cliente "+nfEUR2.format(state.value),"accent-green");
html+=kpi("CAC cliente",cacTxt,"Break-even CPA lead: "+nfEUR2.format(out.breakEven.cpaLeadBE),"accent-green");
}
// Status
var st=statusFor(out);
var stMap={ok:"status-ok",warn:"status-warn",bad:"status-bad"};
html+='
' +
'
Valutazione rapida
'+
'
'+st.txt+'
'+
'
Stima centrale. La differenza reale la fanno: tracking, struttura campagne, qualità annunci, landing page.
'+
'
'+
''+(state.mode==="advanced"?"Avanzata":"Rapida")+' '+
''+(isGoal?"Budget per obiettivo":"Risultati da budget")+' '+
'CR '+nfNum1.format(state.cr)+'% ('+crLabel+') '+
'
'+
'
';
els.results.innerHTML=html;
els.intro.innerHTML=isGoal
?"Budget necessario per
"+nfNum.format(out.conversionsGoal)+" "+labelConv+" con scenario
"+state.scenario+" ."
:"Stima conversioni ottenibili con
"+nfEUR.format(out.budget)+"/mese .";
}
function buildTextSummary(out){
var isGoal=(state.direction==="goal");
var lines=["Calcolatore Google Ads ("+BRAND_NAME+")"];
lines.push("Obiettivo: "+(state.objective==="ecom"?"E-commerce":"Lead/Servizi"));
lines.push("Settore: "+(SECTORS[state.sector]?SECTORS[state.sector].label:""));
lines.push("Area: "+(AREA_MULT[state.area]?AREA_MULT[state.area].label:""));
lines.push("Scenario CPC: "+state.scenario);
lines.push("CPC stimato: "+nfEUR2.format(out.cpcPick)+" (range "+nfEUR2.format(out.cpcMin)+" – "+nfEUR2.format(out.cpcMax)+")");
lines.push("CR: "+nfNum1.format(state.cr)+"%");
if(isGoal){
lines.push("Obiettivo mensile: "+nfNum.format(out.conversionsGoal));
lines.push("Budget stimato: "+nfEUR.format(out.budgetMid)+" (range "+nfEUR.format(out.budgetMin)+" – "+nfEUR.format(out.budgetMax)+")");
lines.push("CPA stimato: "+nfEUR2.format(out.cpaMid));
}else{
lines.push("Budget mensile: "+nfEUR.format(out.budget));
lines.push("Conversioni stimate: "+nfNum1.format(out.conversionsMid));
lines.push("CPA stimato: "+nfEUR2.format(out.cpaMid));
}
if(state.objective==="ecom"){
lines.push("ROAS: "+nfNum1.format(out.roasMid)+" · BE: "+nfNum1.format(out.breakEven.roasBE_first_withLTV));
}else{
lines.push("Chiusura: "+nfNum1.format(state.close)+"% · BE CPA lead: "+nfEUR2.format(out.breakEven.cpaLeadBE));
}
return lines.join("\n");
}
function doCopy(){
var out=calc();
var text=buildTextSummary(out);
if(navigator.clipboard&&navigator.clipboard.writeText){
navigator.clipboard.writeText(text).then(function(){
els.copyBtn.textContent="Copiato ✓";
setTimeout(function(){
els.copyBtn.innerHTML=' Copia';
},1500);
}).catch(function(){fbCopy(text);});
}else{fbCopy(text);}
}
function fbCopy(text){
var ta=document.createElement("textarea");
ta.value=text;ta.style.position="fixed";ta.style.left="-9999px";
document.body.appendChild(ta);ta.select();
try{document.execCommand("copy");}catch(e){}
document.body.removeChild(ta);
els.copyBtn.textContent="Copiato ✓";
setTimeout(function(){
els.copyBtn.innerHTML=' Copia';
},1500);
}
/* ── EVENTS ─────────────────────────────────────────── */
els.tabs.forEach(function(btn){
btn.addEventListener("click",function(){
els.tabs.forEach(function(b){b.setAttribute("aria-selected","false");});
btn.setAttribute("aria-selected","true");
state.mode=btn.getAttribute("data-mode")||"quick";
render(calc());
});
});
els.objective.addEventListener("change",function(){
state.objective=els.objective.value;
setDefaultsForObjective(state.objective);
render(calc());
});
els.direction.forEach(function(r){
r.addEventListener("change",function(){
state.direction=getRadio(els.direction);
syncVisibility();
render(calc());
});
});
els.scenario.forEach(function(r){
r.addEventListener("change",function(){render(calc());});
});
els.calcBtn.addEventListener("click",function(){render(calc());});
els.copyBtn.addEventListener("click",function(){doCopy();});
["change","input"].forEach(function(evt){
["wmaSector","wmaArea","wmaTarget","wmaMonthlyBudget","wmaValue","wmaMargin","wmaClose","wmaLtv","wmaCR","wmaDays"].forEach(function(id){
var el=root.querySelector("#"+id);
if(!el)return;
el.addEventListener(evt,function(){render(calc());});
});
});
/* ── INIT ───────────────────────────────────────────── */
els.cta.href=CTA_URL;
state.objective=els.objective.value;
setDefaultsForObjective(state.objective);
syncVisibility();
render(calc());
})();