/* Layout: colonna singola da ~70ch; il calcolatore è un "modulo" con i campi a sinistra
   e lo scontrino del risultato a destra, che si impilano sotto i 760px. */
:root {
  --paper: #f6f7f4;      /* fondo, grigio con una punta di verde */
  --sheet: #ffffff;      /* superficie del modulo */
  --ink: #1b2a2a;        /* testo */
  --muted: #5b6b69;      /* testo secondario */
  --line: #d9dfdb;       /* bordi e righe */
  --accent: #0f6b5c;     /* verde petrolio: link, pulsanti, evidenze */
  --accent-soft: #e3f0ec;
  --result: #fff6dc;     /* scontrino del risultato */
  --result-ink: #3d2f00;
  --warn: #8a4b00;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-num: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121817; --sheet: #1a2221; --ink: #e5ecea; --muted: #9aaba8; --line: #2e3b39;
    --accent: #5cc4ae; --accent-soft: #1d3430; --result: #2b2614; --result-ink: #f3e2ad; --warn: #f0b36b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121817; --sheet: #1a2221; --ink: #e5ecea; --muted: #9aaba8; --line: #2e3b39;
  --accent: #5cc4ae; --accent-soft: #1d3430; --result: #2b2614; --result-ink: #f3e2ad; --warn: #f0b36b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 var(--font-body);
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

.wrap { max-width: 980px; margin: 0 auto; padding-inline: 16px; }

.site-header { border-bottom: 1px solid var(--line); background: var(--sheet); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-block: 14px; }
.logo { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.logo span { color: var(--accent); }
.site-nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.95rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

main { padding-block: 32px 56px; }
.crumbs { font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); margin: 8px 0 8px; }
h2 { font-size: 1.45rem; margin: 40px 0 10px; }
h3 { font-size: 1.1rem; margin: 24px 0 6px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; margin: 0 0 24px; }
.prose { max-width: 68ch; }
.updated { display: inline-block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 99px; }

/* Il modulo */
.tool {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0;
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
@media (max-width: 760px) { .tool { grid-template-columns: minmax(0, 1fr); } }
.tool form { padding: 24px; display: grid; gap: 16px; align-content: start; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 600; font-size: 0.95rem; }
.field .hint { font-size: 0.82rem; color: var(--muted); }
.field input, .field select {
  font: 500 1.05rem var(--font-num); color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { flex: 1; text-align: center; padding: 9px 6px; cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: var(--accent); }
.seg label:has(input:checked) { background: var(--accent-soft); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }

/* Lo scontrino */
.receipt { background: var(--result); color: var(--result-ink); padding: 24px; border-left: 1px dashed var(--line); display: grid; gap: 14px; align-content: start; }
@media (max-width: 760px) { .receipt { border-left: 0; border-top: 1px dashed var(--line); } }
.receipt .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.receipt .big { font: 700 clamp(2rem, 6vw, 2.8rem)/1.1 var(--font-num); font-variant-numeric: tabular-nums; }
.receipt .sub { font: 500 1rem var(--font-num); }
.lines { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.lines td { padding: 5px 0; border-bottom: 1px dotted currentColor; border-bottom-color: color-mix(in srgb, currentColor 25%, transparent); }
.lines td:last-child { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.lines tr.total td { font-weight: 700; border-bottom: 0; }
.note { font-size: 0.85rem; color: var(--warn); }

/* Tabella piano ammortamento */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); max-height: 420px; }
.table-scroll table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table-scroll th, .table-scroll td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-scroll th:first-child, .table-scroll td:first-child { text-align: left; }
.table-scroll th { position: sticky; top: 0; background: var(--sheet); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.table-scroll td { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* Spazi pubblicitari: riservano l'altezza per evitare salti di layout (CLS). */
.ad-slot { min-height: 120px; margin-block: 28px; border: 1px dashed var(--line); border-radius: var(--radius); display: grid; place-items: center; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* FAQ */
details { border-bottom: 1px solid var(--line); padding-block: 12px; max-width: 68ch; }
summary { font-weight: 600; cursor: pointer; }

/* Home */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: var(--ink); display: grid; gap: 6px; }
.card:hover { border-color: var(--accent); }
.card .k { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.card strong { font-family: var(--font-display); font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card.soon { opacity: 0.6; pointer-events: none; }

.site-footer { border-top: 1px solid var(--line); padding-block: 24px; font-size: 0.85rem; color: var(--muted); }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer p { max-width: 70ch; }

@media (prefers-reduced-motion: no-preference) {
  .receipt .big { transition: color .2s; }
}
