:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #121826;
  --muted: #4b5565;
  --border: #dde1ec;
  --accent: #4338ca;
  --accent-strong: #3730a3;
  --accent-soft: #e0e7ff;
  --on-accent: #ffffff;
  --net: #16a34a;
  --inps: #f59e0b;
  --irpef: #ef4444;
  --add: #8b5cf6;
  --shadow: 0 1px 2px rgba(18, 24, 38, .05), 0 8px 24px rgba(18, 24, 38, .07);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1b2440;
    --text: #e8ecf5;
    --muted: #a3adc2;
    --border: #27324f;
    --accent: #a5b4fc;
    --accent-strong: #c7d2fe;
    --accent-soft: #1e2350;
    --on-accent: #0b1020;
    --net: #4ade80;
    --inps: #fbbf24;
    --irpef: #f87171;
    --add: #a78bfa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #131a2e; --surface-2: #1b2440; --text: #e8ecf5; --muted: #a3adc2; --border: #27324f;
  --accent: #a5b4fc; --accent-strong: #c7d2fe; --accent-soft: #1e2350; --on-accent: #0b1020;
  --net: #4ade80; --inps: #fbbf24; --irpef: #f87171; --add: #a78bfa; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
img, svg { max-width: 100%; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header and tools */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; flex: none; }
.year-badge { font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.toolbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.toolbar ul { list-style: none; margin: 0; padding: 8px 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.toolbar ul::-webkit-scrollbar { display: none; }
.toolbar a { display: block; white-space: nowrap; padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 600; }
.toolbar a:hover { background: var(--surface-2); color: var(--text); }
.toolbar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

main { padding: 24px 0 40px; }
.intro h1 { font-size: clamp(1.6rem, 4.2vw, 2.3rem); line-height: 1.2; margin: 8px 0 8px; letter-spacing: -.02em; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 18px; max-width: 72ch; }
.crumbs { font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* Calculator */
.calc { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; align-items: start; }
.calc-form, .calc-out { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.calc-out { position: sticky; top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .label { font-size: .9rem; font-weight: 650; }
.field input[type="number"], .field input[type="text"], .field select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.money { position: relative; }
.money input { padding-right: 34px; font-size: 1.15rem; font-weight: 700; }
.money span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 8px 6px; border-radius: 8px; font-size: .9rem; font-weight: 650; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.comune-field { position: relative; grid-column: 1 / -1; }
.suggest { position: absolute; z-index: 5; left: 0; right: 0; top: 72px; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow: auto; }
.suggest li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--accent-soft); }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.check label { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; }
.check input { width: 18px; height: 18px; }
details.more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 6px 0; }
details.more .grid2 { margin-top: 10px; }

.big { display: flex; flex-direction: column; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.big-label { color: var(--muted); font-size: .9rem; font-weight: 650; }
.big-num { font-size: clamp(2rem, 6vw, 2.7rem); font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.15; }
.kv { list-style: none; margin: 10px 0; padding: 0; }
.kv li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.kv li span { color: var(--muted); }
.rates { color: var(--muted); font-size: .9rem; margin: 8px 0; }
.vs { margin: 8px 0; font-size: .92rem; background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 8px 10px; }
.where { margin: 12px 0; }
.where-title { font-size: .85rem; font-weight: 700; margin: 0 0 6px; color: var(--muted); }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.bar span { display: block; height: 100%; }
.seg-net { background: var(--net); } .seg-inps { background: var(--inps); } .seg-irpef { background: var(--irpef); } .seg-add { background: var(--add); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; padding: 0; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text); }
details.detail { margin-top: 10px; }
details.detail > summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.share-row { margin: 12px 0 0; font-size: .9rem; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 700; border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); }
.btn:hover { background: var(--accent-strong); color: var(--on-accent); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }
.disclaimer { color: var(--muted); font-size: .85rem; margin: 12px 0 0; max-width: 80ch; }

/* RAL pages */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 10px; }
.summary > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.summary .big-num { font-size: clamp(1.5rem, 4vw, 2rem); }
.summary .sub { color: var(--muted); font-size: .85rem; }
.calc-title { margin-top: 28px; }
.near { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.near a { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-weight: 600; font-size: .92rem; }

/* Text */
.prose { max-width: 820px; }
.prose h2 { font-size: 1.35rem; line-height: 1.3; margin: 30px 0 10px; letter-spacing: -.01em; }
.prose p, .prose li { color: var(--text); }
.prose ol, .prose ul { padding-left: 1.3em; }
.prose li { margin: 4px 0; }
.updated { color: var(--muted); font-size: .9rem; }
.method-link { margin-top: 24px; font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data thead th { background: var(--surface-2); font-size: .85rem; color: var(--muted); }
table.data thead th:not(:first-child) { text-align: right; }
table.data tbody tr:last-child th, table.data tbody tr:last-child td { border-bottom: 0; }
table.data .sub { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
table.breakdown tr.subtotal th, table.breakdown tr.subtotal td { background: var(--surface-2); font-weight: 650; }
table.breakdown tr.total th, table.breakdown tr.total td { font-weight: 800; font-size: 1.02rem; }
table.breakdown th { font-weight: 500; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
.faq summary { cursor: pointer; font-weight: 700; }
.faq p { margin: 8px 0 2px; }
.ad { margin: 20px 0; min-height: 100px; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 28px 0 18px; margin-top: 30px; font-size: .92rem; }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; }
.site-footer h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 5px 0; }
.site-footer a { color: var(--text); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.foot-brand p { color: var(--muted); margin: 8px 0; }
.foot-sisters-title { margin-top: 14px !important; }
.foot-sisters span { color: var(--muted); }
.copyright { color: var(--muted); margin: 18px 0 0; font-size: .85rem; }

@media (max-width: 860px) {
  .calc { grid-template-columns: 1fr; }
  .calc-out { position: static; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr; }
  .calc-form, .calc-out { padding: 14px; }
}
@media print {
  .site-header, .toolbar, .site-footer, .ad, .share-row { display: none; }
}
