:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #17201c;
  --muted: #5b6862;
  --line: #d9e0dc;
  --accent: #0f766e;
  --accent-strong: #0b5c56;
  --accent-soft: #e0f2ef;
  --on-accent: #ffffff;
  --tax: #c2410c;
  --inps: #b45309;
  --net: #0f766e;
  --cost: #64748b;
  --warn-bg: #fff7e6;
  --warn-line: #f2c26b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #161d1a;
    --surface-2: #1d2622;
    --text: #e6ece9;
    --muted: #9aa8a1;
    --line: #2b3632;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123430;
    --on-accent: #0f1412;
    --tax: #fb923c;
    --inps: #fbbf24;
    --net: #2dd4bf;
    --cost: #94a3b8;
    --warn-bg: #2a2212;
    --warn-line: #7a5b1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--font);
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; }
.site-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 0.92rem; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

@media (max-width: 720px) {
  .header-inner { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 0 6px; }
}

main { padding: 20px 16px 48px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 8px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; line-height: 1.3; margin: 36px 0 12px; }
h3 { font-size: 1.1rem; margin: 24px 0 8px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 70ch; }
.lead p { margin: 0 0 8px; }
.small { font-size: 0.88rem; }
.muted { color: var(--muted); }
.crumbs { font-size: 0.88rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* Calcolatore */
.tool { margin: 20px 0 8px; }
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
@media (max-width: 760px) { .calc { grid-template-columns: minmax(0, 1fr); } }

.fields { padding: 20px; display: grid; gap: 14px; align-content: start; }
.fields label { display: grid; gap: 4px; font-weight: 600; font-size: 0.93rem; }
.fields .hint { font-weight: 400; color: var(--muted); font-size: 0.83rem; }
.fields input:not([type="checkbox"]):not([type="radio"]), .fields select {
  width: 100%;
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  min-height: 44px;
}
.fields input:focus, .fields select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.fields input[aria-invalid="true"] { border-color: var(--tax); }
.fields .check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.fields .check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; }
.segmented legend { font-weight: 600; font-size: 0.93rem; margin-bottom: 4px; padding: 0; }
.segmented label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 500; cursor: pointer; background: var(--bg); }
.segmented label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.segmented input { accent-color: var(--accent); margin: 0; }

.results { padding: 20px; background: var(--surface-2); border-left: 1px solid var(--line); display: grid; gap: 14px; align-content: start; }
@media (max-width: 760px) { .results { border-left: 0; border-top: 1px solid var(--line); } }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi span { display: block; font-size: 0.82rem; color: var(--muted); }
.kpi strong { display: block; font-size: clamp(1.25rem, 3.5vw, 1.6rem); line-height: 1.25; font-variant-numeric: tabular-nums; }
.kpi.main strong { color: var(--net); }

.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--line); }
.seg { display: block; height: 100%; transition: width 0.25s ease; }
.seg.net, .dot.net { background: var(--net); }
.seg.tax, .dot.tax { background: var(--tax); }
.seg.inps, .dot.inps { background: var(--inps); }
.seg.cost, .dot.cost { background: var(--cost); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: -6px 0 0; padding: 0; font-size: 0.82rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
.breakdown th, .breakdown td { padding: 7px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.breakdown td { text-align: right; white-space: nowrap; padding-left: 12px; }
.breakdown tr.total th, .breakdown tr.total td { font-weight: 700; border-bottom: 0; }

.avvisi { margin: 0; padding: 10px 14px 10px 30px; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; font-size: 0.9rem; }
.btn-link { justify-self: start; background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: 0.9rem; text-decoration: underline; cursor: pointer; }

.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; border: 0; }
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--accent-strong); border: 1px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* Offerte */
.offers { margin: 28px 0 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.offers h2 { margin: 0 0 10px; font-size: 1.1rem; }
.offers ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.offer { display: grid; gap: 6px; align-content: start; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.offer p { margin: 0; font-size: 0.92rem; color: var(--muted); }
.offer .btn { justify-self: start; margin-top: 4px; }
.offer-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* Contenuti */
.prose { max-width: 72ch; }
.prose p, .prose li { margin: 0 0 12px; }
.prose table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; font-size: 0.93rem; font-variant-numeric: tabular-nums; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.prose td.num, .prose th.num { text-align: right; white-space: nowrap; }
.prose .example { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 14px 16px; margin: 16px 0; }
.prose .example p:last-child { margin-bottom: 0; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.prose blockquote { margin: 16px 0; padding: 10px 16px; border-left: 4px solid var(--line); color: var(--muted); }

.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 16px; margin: 0 0 8px; max-width: 72ch; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.faq details > div { padding: 0 0 14px; }
.faq details > div p { margin: 0 0 10px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: grid; gap: 4px; height: 100%; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.card:hover { border-color: var(--accent); color: var(--text); }
.card strong { color: var(--accent-strong); }
.card span { font-size: 0.92rem; color: var(--muted); }

.disclaimer { margin-top: 32px; max-width: 72ch; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0 28px; font-size: 0.92rem; }
.site-footer p { margin: 0 0 6px; }

.home-cards { margin-top: 24px; }
.piano { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.piano summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.piano .prose { max-width: none; }

/* Prodotti del sito (fogli venduti su Etsy) */
.products { margin: 28px 0 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); }
.products h2 { margin: 0 0 12px; font-size: 1.1rem; }
.products > p.small { margin: 14px 0 0; }
.product-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.product-list > .product { margin: 0; }
.product { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 16px; align-items: start; }
.product-img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.product-body { display: grid; gap: 6px; align-content: start; min-width: 0; }
.product-body > p { margin: 0; }
.product-body > p:not(.product-price) { font-size: 0.92rem; color: var(--muted); }
.product-name { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.product-price { font-weight: 700; font-variant-numeric: tabular-nums; }
.product-body > .btn { justify-self: start; margin-top: 4px; }

/* Pagina /prodotti/ */
.product-list-page { margin: 20px 0 8px; }
.product-list-page > .product { grid-template-columns: minmax(0, 280px) minmax(0, 1fr); padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.product-list-page .product-name { font-size: 1.2rem; }
.product-details { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.product-details summary { cursor: pointer; padding: 12px 0 0; font-weight: 600; color: var(--accent-strong); }
.product-details > div { padding: 4px 0 0; font-size: 0.93rem; }
.product-details h3 { font-size: 1rem; margin: 16px 0 6px; }
.product-details p, .product-details li { margin: 0 0 6px; }
.product-details ul, .product-details ol { margin: 0 0 8px; padding-left: 22px; }

@media (max-width: 560px) {
  .product, .product-list-page > .product { grid-template-columns: minmax(0, 1fr); }
  .product-img { max-width: 400px; }
}
