/* Cruscotto Forfettario: stile unico, mobile-first, tema chiaro. Nessun framework. */
:root {
  --bg: #f7f8f6;
  --surface: #ffffff;
  --ink: #1d2725;
  --ink-soft: #4a5653;
  --muted: #6b7672;
  --line: #dde3e0;
  --accent: #116466;
  --accent-ink: #0b4a4c;
  --accent-soft: #e4f1f0;
  --warn: #8a5300;
  --warn-soft: #fdf3e2;
  --bad: #a1271b;
  --bad-soft: #fbecea;
  --ok: #24663a;
  --ok-soft: #e7f4ea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 36, .06), 0 4px 16px rgba(16, 40, 36, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid #e0a106; outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { line-height: 1.25; color: var(--ink); }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: .2em 0 .4em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 2em 0 .6em; }
h3 { font-size: 1.08rem; margin: 1.4em 0 .4em; }
p, ul, ol { margin: 0 0 1em; }
small, .small { font-size: .875rem; color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .92em; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5em 1em; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }

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

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand svg { width: 28px; height: 28px; flex: none; }
.nav { display: flex; flex-wrap: wrap; gap: .2rem .9rem; font-size: .95rem; }
.nav a { color: var(--ink-soft); text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--accent); }
.nav a[aria-current="page"] { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }

main { display: block; padding: 1.5rem 0 3rem; }

/* Hero */
.hero { padding: 1.2rem 0 .5rem; }
.eyebrow { display: inline-block; font-size: .85rem; font-weight: 600; color: var(--accent-ink); background: var(--accent-soft); padding: .15rem .6rem; border-radius: 999px; }
.lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 46em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: 600 1rem/1.2 var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--accent-ink); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--accent-ink); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.small { min-height: 36px; padding: .35rem .8rem; font-size: .92rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
  .tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
  .tool .result { position: sticky; top: 1rem; }
}
.feature h3 { margin-top: 0; }
.feature p { margin: 0; color: var(--ink-soft); }
.checklist { list-style: none; padding: 0; }
.checklist li { padding-left: 1.6em; position: relative; margin-bottom: .45em; }
.checklist li::before { content: ""; position: absolute; left: .2em; top: .5em; width: .75em; height: .45em; border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(-45deg); }
.limits li::before { content: "–"; border: 0; transform: none; top: 0; color: var(--warn); font-weight: 700; }

/* Notes */
.note { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: .8rem 1rem; border-radius: 0 8px 8px 0; margin: 1rem 0; }
.note.warn { border-color: #d08a14; background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }
.note > :last-child { margin-bottom: 0; }

/* Forms */
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-weight: 700; margin-bottom: .4rem; padding: 0; }
.field { margin-bottom: .95rem; }
.field > label, .label { display: block; font-weight: 600; margin-bottom: .25rem; }
.hint { display: block; font-size: .86rem; color: var(--muted); margin-top: .2rem; }
input[type="text"], input[type="number"], select {
  width: 100%; min-height: 44px; padding: .5rem .7rem; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #b9c3bf; border-radius: 8px;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-soft); }
.inline { display: flex; align-items: flex-start; gap: .55rem; margin-bottom: .6rem; }
.inline input { width: 1.2rem; height: 1.2rem; margin-top: .2rem; flex: none; accent-color: var(--accent); }
.radio-row { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.radio-row label { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.radio-row input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }
.money { position: relative; }
.money input { padding-left: 1.8rem; }
.money::before { content: "€"; position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
details.helper { border: 1px dashed #b9c3bf; border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0 1rem; background: #fbfcfb; }
details.helper summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
details.helper[open] summary { margin-bottom: .6rem; }
[hidden] { display: none !important; }

/* Results */
.result h2 { margin-top: 0; font-size: 1.2rem; }
.big { font-size: 2rem; font-weight: 750; color: var(--accent-ink); line-height: 1.1; margin: .1em 0 .2em; font-variant-numeric: tabular-nums; }
.kv { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.kv th, .kv td { padding: .45rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv th { text-align: left; font-weight: 400; color: var(--ink-soft); padding-right: .8rem; }
.kv td { text-align: right; font-weight: 600; white-space: nowrap; }
.kv tr.total th, .kv tr.total td { font-weight: 750; color: var(--ink); border-bottom: 2px solid var(--ink); }
.tag { display: inline-block; font-size: .78rem; font-weight: 700; padding: .05rem .45rem; border-radius: 4px; background: var(--accent-soft); color: var(--accent-ink); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.meter { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: .3rem 0 .2rem; }
.meter > span { display: block; height: 100%; background: var(--accent); width: 0; }
.meter.warn > span { background: #d08a14; }
.meter.bad > span { background: var(--bad); }
.empty { color: var(--muted); }

/* Table (fatture) */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { background: #f0f3f1; font-weight: 600; position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.neg td.num { color: var(--bad); }
table.data tr.dup { opacity: .55; }
table.data tfoot td { font-weight: 700; background: #f7f9f8; }
table.data.text th, table.data.text td { white-space: normal; vertical-align: top; min-width: 4.5rem; }

/* Pagine legali */
.legal h2 { margin-top: 2rem; }
.legal h3 { margin-top: 1.25rem; font-size: 1.05rem; }

.dropzone {
  border: 2px dashed #9fb3ad; border-radius: var(--radius); background: var(--surface);
  padding: 1.6rem 1rem; text-align: center; transition: background .15s, border-color .15s;
}
.dropzone.drag { background: var(--accent-soft); border-color: var(--accent); }
.dropzone p { margin: .3rem 0; }
.file-errors { margin: .6rem 0 0; padding-left: 1.2rem; color: var(--bad); font-size: .92rem; }

/* CTA box */
.cta-box { margin-top: 2rem; background: linear-gradient(180deg, #ffffff, var(--accent-soft)); border: 1px solid #c4dedb; border-radius: var(--radius); padding: 1.2rem; }
.cta-box h2 { margin-top: 0; font-size: 1.2rem; }
.price { font-size: 2.4rem; font-weight: 800; color: var(--ink); line-height: 1; }
.price small { font-size: .95rem; font-weight: 500; }

/* FAQ */
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; margin-bottom: .6rem; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details[open] summary { margin-bottom: .5rem; }
.faq details > :last-child { margin-bottom: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 1.5rem 0 2rem; font-size: .9rem; color: var(--ink-soft); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .7rem; }
.site-footer p { margin: .3rem 0; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .95rem; box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px); }

@media print {
  .site-header, .site-footer, .cta-box, .actions, .dropzone { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }
a.card h3 { color: var(--accent-ink); }
.sources li { margin-bottom: .35rem; overflow-wrap: anywhere; }
.coeff-out { margin-top: .35rem; font-size: .92rem; }
textarea { width: 100%; font: .85rem/1.4 var(--mono); padding: .5rem; border: 1px solid #b9c3bf; border-radius: 8px; background: #fff; color: var(--ink); }
