:root{
  --bg:#ffffff;
  --fg:#0b0b0b;
  --muted:#666;
  --line:#e6e6e6;
  --soft:#f7f7f7;
  --card:#ffffff;
  --shadow:0 10px 30px rgba(0,0,0,.06);
  --radius:16px;
  --radius-sm:12px;
  --max:1100px;
  --gap:18px;
  --font:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

*{box-sizing:border-box}
html,body{height:100%}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family:var(--font);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}
a{color:inherit}
a.link{color:#0b0b0b;text-decoration:underline;text-underline-offset:3px}
a.link:hover{opacity:.85}

.topbar{
  position:sticky;
  top:0;
  z-index:30;
  background:rgba(255,255,255,.92);
  backdrop-filter:saturate(180%) blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar-inner{
  max-width:var(--max);
  margin:0 auto;
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:14px;
}
.brand{
  display:flex;
  align-items:center;
  gap:12px;
  text-decoration:none;
  min-width:0;
}
.brand img{
  width:42px;
  height:42px;
  object-fit:contain;
  border-radius:10px;
}
.brand .txt{
  display:flex;
  flex-direction:column;
  line-height:1.05;
  min-width:0;
}
.brand .txt strong{
  font-size:14px;
  letter-spacing:.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.brand .txt span{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.wrap{
  max-width:var(--max);
  margin:0 auto;
  padding:22px 16px 84px;
}

.hero{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-bottom:18px;
}
.hero h1{
  font-size:22px;
  margin:0;
  letter-spacing:-.2px;
  line-height:1.15;
}
.hero p{
  margin:0;
  color:var(--muted);
  line-height:1.55;
  max-width:78ch;
  font-size:14px;
}

.grid{
  display:grid;
  grid-template-columns:1fr;
  gap:18px;
  align-items:start;
}
@media (min-width:960px){
  .grid{grid-template-columns:1.05fr .75fr}
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
}
.card .hd{padding:16px 16px 0}
.card .hd h2{margin:0;font-size:14px;letter-spacing:.2px}
.card .bd{padding:16px}

.hd-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--soft);
  font-size:12px;
  color:#111;
  white-space:nowrap;
}
.badge strong{font-weight:700}
.badge .dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#111;
  display:inline-block;
}

.hr{
  height:1px;
  background:var(--line);
  margin:14px 0;
}

.row{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
  margin-bottom:12px;
}
@media (min-width:720px){
  .row{grid-template-columns:1fr 1fr}
}

label{
  display:block;
  font-size:12px;
  color:#333;
  margin:0 0 6px;
}
.help{
  font-size:12px;
  color:var(--muted);
  margin-top:6px;
  line-height:1.35;
}
.order-help{
  align-self:end;
}

input,select,textarea,button{
  width:100%;
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 12px;
  background:#fff;
  color:var(--fg);
  font-size:16px;
  outline:none;
}
input:focus,select:focus,textarea:focus{
  border-color:#111;
  box-shadow:0 0 0 3px rgba(0,0,0,.06);
}
input[readonly]{
  background:#fafafa;
  color:#444;
}

textarea{
  min-height:170px;
  resize:vertical;
  font-family:var(--font);
  line-height:1.45;
}

#summary,
#embSummary{
  min-height:160px;
}

.box{
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--soft);
  padding:14px;
}

.tog{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 0 6px;
}
.tog input{
  width:18px;
  height:18px;
  margin:0;
  accent-color:#111;
}
.tog label{
  margin:0;
  font-size:13px;
  color:#111;
}

.btns{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
button{
  cursor:pointer;
  background:#111;
  color:#fff;
  border-color:#111;
  transition:transform .04s ease, opacity .12s ease;
  font-weight:600;
}
button.secondary{
  background:#fff;
  color:#111;
  border-color:var(--line);
  font-weight:600;
}
button.small{
  width:auto;
  padding:10px 12px;
  border-radius:999px;
}
button:active{transform:translateY(1px)}
button:hover{opacity:.95}
button:disabled{
  opacity:.5;
  cursor:not-allowed;
}

.kpis{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
}
@media (min-width:540px){
  .kpis{grid-template-columns:1fr 1fr}
}
.kpi{
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
  background:#fff;
}
.kpi .t{
  font-size:12px;
  color:var(--muted);
  line-height:1.25;
}
.kpi .v{
  margin-top:6px;
  font-size:18px;
  font-weight:700;
  letter-spacing:-.2px;
  line-height:1.15;
}

.per-item-list{
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--soft);
  padding:12px;
}
.per-item-list .ttl{
  font-size:12px;
  color:var(--muted);
  margin-bottom:8px;
}
.per-item-list .rowi{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:6px 0;
  border-top:1px solid rgba(0,0,0,.05);
}
.per-item-list .rowi:first-of-type{
  border-top:0;
  padding-top:0;
}
.per-item-list .name{
  font-size:13px;
  color:#222;
}
.per-item-list .val{
  font-size:13px;
  font-weight:700;
  white-space:nowrap;
}

.alerts{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:10px 0 0;
  font-size:13px;
  line-height:1.35;
  color:var(--muted);
}
.alert{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  background:var(--soft);
  color:#333;
}
.alert.bad{
  border-color:#ffd1d1;
  background:#fff5f5;
  color:#7a1f1f;
}
.alert.warn{
  border-color:#ffe7b5;
  background:#fffbf0;
  color:#6b4c00;
}

@media (min-width:960px){
  .sticky{position:sticky;top:86px}
}

.note{
  margin-top:18px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:16px;
  background:var(--soft);
  line-height:1.55;
  font-size:13px;
  color:#222;
}

.section-title{
  margin:28px 0 10px;
  font-size:18px;
  letter-spacing:-.2px;
}
.section-sub{
  margin:0 0 16px;
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
  max-width:72ch;
}

.seg-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-bottom:12px;
}
.seg-tabs button{
  width:auto;
  padding:10px 12px;
  border-radius:999px;
  background:#fff;
  color:#111;
  border:1px solid var(--line);
  font-weight:600;
}
.seg-tabs button.active{
  background:#111;
  color:#fff;
  border-color:#111;
}

.lang-switch{
  display:flex;
  gap:6px;
  justify-content:flex-end;
  margin-bottom:14px;
}
.lang-switch button{
  width:auto;
  padding:6px 13px;
  border-radius:999px;
  background:#fff;
  color:#111;
  border:1px solid var(--line);
  font-size:12px;
  font-weight:700;
  letter-spacing:.4px;
}
.lang-switch button.active{
  background:#111;
  color:#fff;
  border-color:#111;
}

.small-links{
  font-size:12px;
  color:var(--muted);
  line-height:1.45;
  margin-top:6px;
}
.small-links .meta-line{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}
.small-links .meta-line .pilllink{
  display:inline-flex;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--soft);
  font-size:12px;
  text-decoration:none;
}
.small-links .meta-line .pilllink:hover{opacity:.9}
.small-links .meta-line .hint{
  font-size:12px;
  color:var(--muted);
}

.project{
  border:1px solid var(--line);
  border-radius:16px;
  background:#fff;
  padding:14px;
  margin-bottom:12px;
}
.project-hd{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.project-head-main{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  width:100%;
  cursor:pointer;
}
.project-head-main:active{transform:translateY(1px)}
.project-hd .title{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}
.project-hd .title strong{font-size:13px}
.project-hd .title span{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.project-actions{
  display:flex;
  gap:8px;
  align-items:center;
  flex-shrink:0;
}
.iconbtn{
  width:auto;
  padding:8px 10px;
  border-radius:999px;
}
.iconbtn.danger{
  background:#fff;
  color:#7a1f1f;
  border-color:#ffd1d1;
}
.project-caret{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:#111;
  flex-shrink:0;
  transition:transform .18s ease;
}
.project[data-collapsed="true"] .project-caret{
  transform:rotate(-90deg);
}
.project-body{
  overflow:hidden;
}
.project[data-collapsed="true"] .project-body{
  display:none;
}

.summary-card{
  overflow:hidden;
}
.summary-actions{
  padding-bottom:0;
}

/* ================= MOBILE ================= */
@media (max-width:959px){
  .sticky{position:static}
}

@media (max-width:767px){
  .wrap{
    padding:14px 12px calc(84px + env(safe-area-inset-bottom));
  }

  .topbar-inner{
    padding:10px 12px;
  }

  .brand img{
    width:34px;
    height:34px;
  }

  .brand .txt strong{font-size:13px}
  .brand .txt span{font-size:11px}

  .hero{
    gap:8px;
    margin-bottom:14px;
  }
  .hero h1{
    font-size:18px;
  }
  .hero p{
    font-size:13px;
    line-height:1.5;
  }

  .card{
    border-radius:14px;
  }
  .card .hd{
    padding:14px 14px 0;
  }
  .card .bd{
    padding:14px;
  }

  .hd-row{
    align-items:flex-start;
    flex-direction:column;
  }
  .hd-row .small{
    width:100%;
    justify-content:center;
  }

  .project{
    padding:12px;
    border-radius:14px;
  }
  .project-hd{
    flex-direction:column;
    align-items:flex-start;
  }
  .project-head-main{
    align-items:center;
  }
  .project-actions{
    width:100%;
    display:grid;
    grid-template-columns:1fr 1fr;
  }
  .project-actions button{
    width:100%;
  }

  .box{
    padding:12px;
    border-radius:14px;
  }

  .row{
    gap:10px;
    margin-bottom:10px;
  }

  label{
    font-size:12px;
    margin-bottom:5px;
  }

  .help{
    font-size:12px;
  }
  .order-help{
    align-self:auto;
  }

  input,select,textarea,button{
    padding:11px 12px;
    border-radius:12px;
  }

  .kpis{
    grid-template-columns:1fr;
    gap:8px;
  }
  .kpi{
    padding:11px 12px;
  }
  .kpi .t{
    font-size:12px;
  }
  .kpi .v{
    font-size:16px;
    margin-top:4px;
  }

  .per-item-list{
    padding:10px 12px;
  }
  .per-item-list .name,
  .per-item-list .val{
    font-size:13px;
  }

  #summary,
  #embSummary{
    min-height:110px;
    max-height:220px;
    overflow:auto;
  }

  .btns{
    flex-direction:column;
  }
  .btns button{
    width:100%;
  }

  .summary-actions{
    position:sticky;
    bottom:0;
    background:linear-gradient(to top, #fff 70%, rgba(255,255,255,.9));
    padding-top:10px;
    margin-top:8px;
    z-index:3;
  }

  .note{
    margin-top:14px;
    padding:12px;
    font-size:12px;
    line-height:1.5;
  }

  .section-title{
    margin:22px 0 8px;
    font-size:17px;
  }
  .section-sub{
    font-size:13px;
    line-height:1.45;
    margin-bottom:12px;
  }

  .seg-tabs{
    gap:6px;
  }
  .seg-tabs button{
    width:auto;
    padding:9px 11px;
  }

  .small-links .meta-line{
    gap:8px;
    align-items:flex-start;
    flex-direction:column;
  }
  .small-links .meta-line .pilllink{
    width:max-content;
    max-width:100%;
  }
}

/* ================= EMBED IN IFRAME (WordPress) ================= */
/* Attivate da initEmbed() solo quando la pagina gira dentro un iframe.
   L'altezza auto è indispensabile: con height:100% il documento misurerebbe
   sempre l'altezza dell'iframe e l'auto-resize non potrebbe rimpicciolirlo. */
html.is-embedded,
html.is-embedded body{
  height:auto;
}

/* Il sito ospite ha già il proprio header con il logo. */
html.is-embedded .topbar{
  display:none;
}

html.is-embedded .wrap{
  padding-top:0;
  padding-bottom:24px;
}

/* Dentro un iframe auto-dimensionato non esiste un viewport a cui agganciarsi:
   position:sticky resterebbe inerte, meglio disattivarlo esplicitamente. */
html.is-embedded .sticky{
  position:static;
}
html.is-embedded .summary-actions{
  position:static;
  background:none;
  padding-top:0;
}

/* ?bare=1 — nasconde anche il titolo, se la pagina WordPress ha già il suo. */
html.is-bare .hero{
  display:none;
}

@media (max-width:390px){
  .wrap{
    padding-left:10px;
    padding-right:10px;
  }

  .card .hd,
  .card .bd{
    padding-left:12px;
    padding-right:12px;
  }

  .project,
  .box{
    padding:10px;
  }

  .hero h1{
    font-size:17px;
  }

  .kpi .v{
    font-size:15px;
  }

  #summary,
  #embSummary{
    min-height:96px;
  }
}