:root {
  --ink: #12211c;
  --ink-2: #4a5a54;
  --ink-3: #7a8a84;
  --bg: #f4f6f3;
  --card: #ffffff;
  --line: #e2e8e4;
  --brand: #0b3d33;
  --brand-2: #0e6b55;
  --accent: #19b88a;
  --accent-soft: #e4f6ef;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --err: #a32a2a;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(11, 61, 51, .05), 0 8px 24px -12px rgba(11, 61, 51, .18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
  overflow-x: hidden;
}
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* Hero */
.hero {
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(25, 184, 138, .35), transparent 60%),
    linear-gradient(160deg, #0b3d33 0%, #0a2e27 100%);
  color: #fff;
  padding: 40px 0 88px;
}
.eyebrow { margin: 0 0 10px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: #9fe3cc; font-weight: 600; }
h1 { margin: 0 0 10px; font-size: clamp(32px, 8vw, 48px); line-height: 1.08; letter-spacing: -.02em; }
.lead { margin: 0 0 26px; color: #cfe6dd; max-width: 46ch; }
.hero-total {
  display: flex; flex-direction: column; gap: 2px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 20px;
  padding: 18px 20px;
  backdrop-filter: blur(6px);
}
.hero-label { font-size: 13px; color: #9fe3cc; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.hero-num { font-size: clamp(40px, 12vw, 64px); line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-sub { color: #cfe6dd; font-size: 15px; }

main { margin-top: -56px; padding-bottom: 48px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 18px;
  margin-bottom: 16px;
  min-width: 0;
}
.card h2 { margin: 0 0 16px; font-size: 20px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.step {
  flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 14px; display: inline-flex; align-items: center; justify-content: center;
}

/* Form */
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span, .field > label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field.is-off { opacity: .5; }
input[type="text"], select {
  width: 100%;
  font: inherit; color: var(--ink);
  background: #fbfcfb;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
  min-width: 0;
}
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid rgba(25, 184, 138, .5); outline-offset: 2px; border-color: var(--accent); }
.money { position: relative; }
.money input { padding-right: 40px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cur { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-weight: 600; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.check:first-of-type { border-top: 0; }
.check input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand-2); }
.check span { min-width: 0; font-weight: 600; }
.check small { display: block; font-weight: 400; color: var(--ink-2); font-size: 14px; margin-top: 2px; }

.hint { font-size: 14px; margin: 6px 0 10px; padding: 8px 12px; border-radius: 10px; }
.hint.err { color: var(--err); background: #fdecec; }
.hint.warn { color: var(--warn); background: var(--warn-bg); }
.note { font-size: 14px; color: var(--ink-2); margin: 12px 0 0; }

/* Figli */
.children { display: grid; gap: 12px; margin-bottom: 14px; }
.child { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; background: #fbfcfb; min-width: 0; }
.child-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.badge { background: var(--accent-soft); color: var(--brand-2); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.rm { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 20px; line-height: 1; color: var(--ink-2); cursor: pointer; }
.rm:hover { background: #fdecec; color: var(--err); }
.child-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.child .req { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 12px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 0; border-radius: 12px;
  padding: 12px 18px; min-height: 48px;
  background: var(--brand); color: #fff;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { background: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-soft { background: var(--accent-soft); color: var(--brand); }
.btn-soft:hover { background: #d3f0e5; }

/* Breakdown */
.bd { display: grid; gap: 14px; }
.bd-card { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
caption { text-align: left; font-weight: 700; padding: 12px 14px; background: var(--accent-soft); color: var(--brand); font-size: 15px; overflow-wrap: anywhere; }
th, td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; text-align: left; font-size: 15px; }
th { font-weight: 500; overflow-wrap: anywhere; }
td { width: 112px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
th small { display: block; color: var(--ink-3); font-size: 13px; font-weight: 400; }
tr.zero th, tr.zero td { color: var(--ink-3); }
tfoot th, tfoot td { font-weight: 700; background: #f8faf8; color: var(--ink); }
.sum table { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.sum tr:first-child th, .sum tr:first-child td { border-top: 0; }
.muted { color: var(--ink-2); margin: 0; }

/* Total */
.total-card { background: linear-gradient(160deg, #0b3d33, #0a2e27); color: #fff; border: 0; }
.total-card h2 { color: #fff; }
.tot-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 8px; }
.tot-label { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #9fe3cc; font-weight: 600; }
.tot-num { font-size: clamp(34px, 10vw, 48px); line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tot-num.sm { font-size: clamp(24px, 7vw, 32px); color: #d7f5ea; }
.total-card .note { color: #cfe6dd; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.total-card .btn { background: #fff; color: var(--brand); }
.total-card .btn:hover { background: #e9f7f1; }
.total-card .btn-soft { background: rgba(255, 255, 255, .12); color: #fff; }
.total-card .btn-soft:hover { background: rgba(255, 255, 255, .2); }

/* Guide + FAQ */
.guide p { margin: 0 0 14px; }
.steps { padding-left: 20px; margin: 0 0 24px; display: grid; gap: 8px; }
.faq-title { margin-top: 8px !important; }
.faq { display: grid; gap: 8px; }
.faq-item { border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.faq-item summary { cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none; position: relative; padding-right: 40px; overflow-wrap: anywhere; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 16px; top: 12px; font-size: 20px; color: var(--brand-2); }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { margin: 0; padding: 0 16px 16px; color: var(--ink-2); }

.disclaimer { font-size: 13.5px; color: var(--ink-2); padding: 4px 4px 0; }
.disclaimer p { margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .card { padding: 26px 26px; }
  .child-grid { grid-template-columns: 1fr 1fr; }
  .tot-grid { grid-template-columns: 1fr 1fr; align-items: end; }
  .actions { grid-template-columns: repeat(4, auto); justify-content: start; }
  td { width: 140px; }
}

@media print {
  body { background: #fff; }
  .hero { background: none; color: #000; padding: 0 0 12px; }
  .hero .lead, .hero-sub, .hero-label, .eyebrow { color: #333; }
  .hero-total { background: none; border-color: #999; }
  main { margin-top: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  .total-card { background: none; color: #000; border: 1px solid #999; }
  .total-card h2, .tot-label, .total-card .note { color: #000; }
  .actions, .guide, #h-figli ~ #addFiglio, #addFiglio, .rm, .skip, .toast { display: none !important; }
  .hint { display: none; }
}
