/* CalcolatoreFinanziario.it — componenti condivisi */
:root {
  --c-netto: #2563eb;
  --c-tasse: #e8a33d;
  --c-inps: #8a94a6;
  --c-interessi: #e2665a;
  --c-capitale: #2563eb;
  --c-crescita: #12a37a;
  --font-display: 'Bricolage Grotesque', 'Inter', -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --c-netto: #5b8ef5; --c-tasse: #f0b65a; --c-inps: #7c8597; --c-interessi: #ef7d70; --c-capitale: #5b8ef5; --c-crescita: #34c191; }
}

/* Banner consenso */
#consent-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 999; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 24px rgba(15, 27, 51, 0.10); padding: 1rem 1.5rem; display: none; }
#consent-banner.show { display: block; }
.consent-inner { max-width: 860px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; justify-content: space-between; }
.consent-text { font-size: 13px; color: var(--text-secondary); flex: 1 1 340px; margin: 0; }
.consent-text a { color: var(--accent-text); }
.consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.consent-actions button { font-family: inherit; font-size: 13px; font-weight: 500; padding: 8px 16px; border-radius: var(--radius); cursor: pointer; border: 1px solid var(--border); background: var(--bg); color: var(--text-primary); }
.consent-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Focus visibile */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Slider */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin-top: 6px; cursor: pointer; --fill: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) 0 var(--fill), var(--border) var(--fill) 100%); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); margin-top: -7px; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

/* Barra di ripartizione */
.split { margin-top: 1rem; }
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--border); }
.split-bar span { display: block; height: 100%; transition: width 0.35s ease; }
.split-bar span + span { border-left: 2px solid var(--surface); }
.split-legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.split-legend li { display: grid; grid-template-columns: 10px 1fr auto 42px; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); margin: 0; }
.split-legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.split-legend b { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.split-legend em { font-style: normal; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Grafici */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; font-family: inherit; }
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 8px; margin-top: 1.25rem; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; margin-bottom: 8px; }
.chart-head h3 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text-primary); }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-secondary); }
.chart-key span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--k); margin-right: 6px; vertical-align: -1px; }

/* Bottone secondario */
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text-primary); cursor: pointer; text-decoration: none; }
.btn-ghost:hover { border-color: var(--accent-border); color: var(--accent-text); }

/* ---------- Calcolatore dentro le guide ---------- */
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; margin: 2rem 0; box-shadow: 0 1px 2px rgba(15, 27, 51, 0.04); }
.tool > h2 { margin-top: 0 !important; }
.tool-intro { font-size: 14px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem; align-items: start; }
@media (max-width: 640px) { .tool-grid { grid-template-columns: 1fr; } .tool { padding: 1.1rem; } }
.tool .field { margin-bottom: 1rem; }
.tool .field label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.tool .input-wrap { display: flex; align-items: center; gap: 8px; }
.tool input[type="number"], .tool select { width: 100%; height: 38px; padding: 0 12px; font-size: 14px; font-family: inherit; color: var(--text-primary); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); outline: none; }
.tool input[type="number"]:focus, .tool select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.tool .unit { font-size: 13px; color: var(--text-muted); min-width: 28px; white-space: nowrap; }
.tool .check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); margin: 0.25rem 0 1rem; cursor: pointer; }
.tool .check input { width: 16px; height: 16px; accent-color: var(--accent); }
.tool-result { background: var(--accent-bg); border: 1px solid var(--accent-border); border-radius: 12px; padding: 1.1rem 1.25rem; }
.tool-result .big { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.05; color: var(--accent-text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.tool-result .cap { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
.tool-rows { list-style: none; padding: 0 !important; margin: 0.9rem 0 0 !important; }
.tool-rows li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 7px 0; border-top: 1px solid var(--border); margin: 0 !important; }
.tool-rows li b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tool details.more { margin: 0.25rem 0 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.tool details.more summary { font-size: 14px; font-weight: 500; color: var(--accent-text); cursor: pointer; margin-bottom: 0.75rem; }
.tool-note { font-size: 12px; color: var(--text-muted); margin-top: 1rem !important; margin-bottom: 0 !important; }
.verdict { margin-top: 0.9rem; font-size: 14px; color: var(--text-primary); background: var(--surface); border-radius: var(--radius); padding: 10px 12px; border-left: 3px solid var(--accent); }

/* Box riassuntivo nelle guide */
.keypoints { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; margin: 1.5rem 0; }
.keypoints p:first-child { font-weight: 600; color: var(--text-primary); margin-bottom: 0.4rem; }
.keypoints ul { margin-bottom: 0; }
.keypoints li { margin-bottom: 0.35rem; }

@media (prefers-reduced-motion: reduce) { .split-bar span { transition: none; } html { scroll-behavior: auto; } }

/* Tabelle larghe: scorrono in orizzontale su telefono */
.table-scroll { overflow-x: auto; margin-top: 1.25rem; -webkit-overflow-scrolling: touch; }
.table-scroll table { margin-top: 0; }
table.nowrap th, table.nowrap td { white-space: nowrap; }

/* Intestazione su schermi stretti */
header nav a { white-space: nowrap; }
@media (max-width: 400px) { .logo-name { font-size: 14px; } .header-inner { gap: 10px; } }

/* Affitto o mutuo: su telefono il risultato va prima dei campi */
@media (max-width: 640px) {
  #tool-affitto .tool-grid > div:last-child { order: -1; }
}
