:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #0f1b2d;
  --muted: #4a5568;
  --border: #dde3ea;
  --primary: #0b5cab;
  --primary-dark: #084a8a;
  --primary-soft: #eaf2fb;
  --accent: #138a52;
  --accent-dark: #0f6e41;
  --accent-soft: #eaf7f0;
  --warn: #9a5b00;
  --warn-soft: #fff5e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(15, 27, 45, 0.07);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
img, svg { max-width: 100%; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
:focus-visible { outline: 3px solid rgba(11, 92, 171, 0.35); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.container--narrow { max-width: 820px; }
.muted { color: var(--muted); }
.tiny { font-size: 13px; color: var(--muted); }
.h3 { font-size: 18px; line-height: 1.3; margin: 0 0 10px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: 8px 14px; z-index: 100; }
.skip:focus { left: 10px; top: 10px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; align-items: center; gap: 16px; min-height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand b { color: var(--primary); }
.brand__mark { display: inline-flex; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 500; }
.site-nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }
.site-nav__cta { background: var(--primary); color: #fff !important; }
.site-nav__cta:hover { background: var(--primary-dark) !important; }
.nav-toggle, .nav-burger { display: none; }

@media (max-width: 920px) {
  .nav-burger { display: inline-flex; flex-direction: column; gap: 5px; margin-left: auto; padding: 10px; cursor: pointer; }
  .nav-burger span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
  .site-nav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 14px; gap: 2px; box-shadow: var(--shadow); }
  .site-nav a { padding: 11px 12px; }
  .nav-toggle:checked ~ .site-nav { display: flex; }
}

/* Hero */
.hero { padding: 42px 0 18px; background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%); }
.hero__eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--accent-dark); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.hero__title { font-size: clamp(28px, 4.2vw, 42px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -0.02em; max-width: 880px; }
.hero__lead { font-size: 18px; color: var(--muted); margin: 0; max-width: 780px; }

/* Card / buttons */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tool-wrap { padding: 14px 20px 28px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; line-height: 1.2; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--sm { padding: 7px 12px; font-size: 14px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover:not(:disabled) { background: var(--accent-dark); color: #fff; }
.btn--light { background: var(--primary-soft); color: var(--primary-dark); }
.btn--light:hover:not(:disabled) { background: #d9e8f8; }
.btn--outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn--outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-dark); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover:not(:disabled) { color: var(--danger); }
.btn--block { width: 100%; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--primary); color: #fff; vertical-align: middle; }
.badge--soft { background: var(--primary-soft); color: var(--primary-dark); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }

/* Tool */
.p7m { padding: 22px; }
.p7m__drop { border: 2px dashed #b8c7d9; border-radius: var(--radius); background: #fbfcfe; padding: 30px 20px; text-align: center; color: var(--primary); cursor: pointer; transition: border-color .15s, background .15s; }
.p7m__drop:hover, .p7m__drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.p7m__drop-title { color: var(--text); font-size: 18px; margin: 8px 0 4px; }
.p7m__drop-sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.p7m__demo-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.p7m__mobile-hint { margin: 12px 0 0; padding: 10px 14px; background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 15px; }
.p7m__actions-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.p7m__credits { margin-left: auto; }
.p7m__status { margin: 14px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bg); font-size: 15px; }
.p7m__status[data-tone="ok"] { background: var(--accent-soft); color: var(--accent-dark); }
.p7m__status[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.p7m__notice { margin-top: 12px; padding: 12px 16px; border: 1px solid #f0d49a; background: var(--warn-soft); border-radius: var(--radius-sm); }
.p7m__notice p { margin: 0; }
.p7m__results { margin-top: 22px; }
.p7m__results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.p7m__results-head .h3 { margin: 0; }
.p7m__toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.p7m-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.p7m-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.p7m-item--error { border-color: #f4c7c3; background: #fffafa; }
.p7m-item__head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.p7m-item__title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; flex: 1 1 320px; }
.p7m-file-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 9px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.p7m-item--error .p7m-file-icon { background: var(--danger-soft); color: var(--danger); }
.p7m-item__name { font-weight: 700; word-break: break-all; }
.p7m-item__meta { font-size: 14px; color: var(--muted); word-break: break-word; }
.p7m-item__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.p7m-item__error { margin: 10px 0 0; color: var(--danger); font-weight: 600; }
.p7m-item__note { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.p7m-signers { margin-top: 12px; display: grid; gap: 8px; }
.p7m-signer { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 14px; }
.p7m-signer__name { font-weight: 700; }
.p7m-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px 18px; margin: 6px 0 0; font-size: 14px; }
.p7m-dl dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.p7m-dl dd { margin: 0; }
.p7m-signers > p { margin: 0; }
.p7m-kpis { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 15px; }
.p7m-preview { margin-top: 14px; }
.p7m-text { margin: 12px 0 0; max-height: 260px; overflow: auto; background: #0f1b2d; color: #e2e8f0; padding: 12px 14px; border-radius: var(--radius-sm); font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; }
.p7m__trust { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; font-size: 14px; color: var(--muted); }
.p7m__trust li { padding-left: 22px; position: relative; }
.p7m__trust li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }

/* QR dialog */
.p7m-qr { border: none; border-radius: var(--radius); padding: 0; max-width: 380px; width: calc(100% - 32px); box-shadow: 0 30px 80px rgba(15, 27, 45, .3); }
.p7m-qr::backdrop { background: rgba(15, 27, 45, .45); }
.p7m-qr__box { padding: 22px; text-align: center; }
.p7m-qr__img { display: flex; justify-content: center; margin: 12px 0; }
.p7m-qr__img img { border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.p7m-qr__url { word-break: break-all; }
.p7m-qr__actions { display: flex; gap: 10px; justify-content: center; }

/* Fattura (anteprima A4) */
.fx-invoice { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 26px 28px; color: #111; font-size: 14px; line-height: 1.5; max-width: 820px; margin: 0 auto 14px; }
.fx-invoice__top { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid #111; padding-bottom: 10px; margin-bottom: 16px; }
.fx-doc-type { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.fx-doc-meta { font-size: 15px; }
.fx-doc-code { font: 12px var(--mono); color: #555; white-space: nowrap; }
.fx-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.fx-party { border: 1px solid #d9d9d9; border-radius: 6px; padding: 10px 12px; }
.fx-party__label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #555; font-weight: 700; margin-bottom: 2px; }
.fx-party__name { font-weight: 700; font-size: 15px; }
.fx-causale { margin: 0 0 12px; }
.fx-table-wrap { overflow-x: auto; }
.fx-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fx-table th { text-align: left; background: #f1f3f5; border-bottom: 1px solid #bbb; padding: 6px 8px; font-weight: 700; }
.fx-table td { border-bottom: 1px solid #e3e3e3; padding: 6px 8px; vertical-align: top; }
.fx-table .num { text-align: right; white-space: nowrap; }
.fx-table--sm { font-size: 12px; }
.fx-sub { font-size: 11px; color: #666; }
.fx-bottom { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 14px; align-items: start; }
.fx-totals { margin: 0; border: 1px solid #d9d9d9; border-radius: 6px; padding: 8px 12px; }
.fx-totals div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.fx-totals dt { color: #444; }
.fx-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.fx-totals__grand { border-top: 2px solid #111; margin-top: 4px; padding-top: 6px !important; font-weight: 800; font-size: 16px; }
.fx-pay { margin-top: 14px; border: 1px solid #d9d9d9; border-radius: 6px; padding: 10px 12px; }
.fx-mono { font-family: var(--mono); }
.fx-foot { margin: 16px 0 0; font-size: 11px; color: #666; border-top: 1px solid #e3e3e3; padding-top: 8px; }
@media (max-width: 640px) {
  .fx-invoice { padding: 16px; }
  .fx-parties, .fx-bottom { grid-template-columns: 1fr; }
  .p7m { padding: 14px; }
  .p7m__credits { margin-left: 0; }
}

/* Prose */
.prose { padding-top: 26px; padding-bottom: 50px; max-width: 860px; }
.prose h2 { font-size: 26px; line-height: 1.25; margin: 36px 0 12px; letter-spacing: -0.01em; }
.prose h3 { font-size: 19px; margin: 24px 0 8px; }
.prose p, .prose li { color: #26334a; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose .answer { background: var(--primary-soft); border-left: 4px solid var(--primary); padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose .answer p { margin: 0; }
.prose .steps { counter-reset: s; list-style: none; padding: 0; }
.prose .steps li { counter-increment: s; position: relative; padding: 2px 0 10px 44px; }
.prose .steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.table-wrap { overflow-x: auto; margin: 12px 0 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table-wrap th, .table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table-wrap th { background: #f0f4f8; font-weight: 700; }
.table-wrap tr:last-child td { border-bottom: none; }
.faq details { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 13px 0; font-weight: 600; }
.faq details[open] summary { border-bottom: 1px solid var(--border); }
.faq details div p { margin: 12px 0; }
.callout { background: var(--warn-soft); border: 1px solid #f0d49a; border-radius: var(--radius-sm); padding: 12px 16px; }
.callout p { margin: 0; }
.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; padding: 0 !important; list-style: none; }
.related li { margin: 0; }
.related a { display: block; height: 100%; padding: 12px 14px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; }
.related a:hover { border-color: var(--primary); }

/* Pagine legali / prezzi */
.page-head { padding: 40px 0 8px; background: #fff; border-bottom: 1px solid var(--border); }
.page-head__title { font-size: clamp(28px, 4vw, 38px); line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.02em; }
.prose--page { padding-top: 14px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 20px 0 10px; }
.plan { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
.plan--featured { border: 2px solid var(--primary); box-shadow: var(--shadow); }
.plan h2 { font-size: 20px; margin: 0 0 4px; }
.plan__price { font-size: 30px; font-weight: 800; margin: 6px 0 2px; color: var(--text) !important; letter-spacing: -0.02em; }
.plan__price small { font-size: 15px; font-weight: 600; color: var(--muted); }
.plan ul { padding-left: 20px; margin: 10px 0 16px; flex: 1; font-size: 15px; }
.plan .btn { width: 100%; }

/* Footer */
.site-footer { background: #0f1b2d; color: #cbd5e1; padding: 32px 0 20px; margin-top: 20px; }
.site-footer a { color: #e2e8f0; }
.site-footer .muted, .site-footer .tiny { color: #94a3b8; }
.site-footer__inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.site-footer__about { max-width: 520px; }
.brand--footer { color: #fff; }
.brand--footer b { color: #7cb7f0; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.site-footer__bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid #22324a; margin-top: 20px; padding-top: 14px; font-size: 14px; }

/* Stampa: solo la fattura selezionata, formato A4 */
#p7m-print-root { display: none; }
@page { size: A4; margin: 12mm; }
@media print {
  body.p7m-printing { background: #fff; }
  body.p7m-printing > *:not(#p7m-print-root) { display: none !important; }
  body.p7m-printing #p7m-print-root { display: block; }
  #p7m-print-root .fx-invoice { border: none; border-radius: 0; padding: 0; max-width: none; margin: 0; page-break-after: always; }
  #p7m-print-root .fx-invoice:last-child { page-break-after: auto; }
  #p7m-print-root .fx-table-wrap { overflow: visible; }
  #p7m-print-root .fx-table tr, #p7m-print-root .fx-party, #p7m-print-root .fx-totals { break-inside: avoid; }
  #p7m-print-root .fx-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body:not(.p7m-printing) .site-header, body:not(.p7m-printing) .site-footer, body:not(.p7m-printing) .p7m__drop, body:not(.p7m-printing) .p7m__actions-row { display: none !important; }
}
