/* ============================================================
   CALCOLA.ONLINE — Design System (base.css)
   All components reference CSS variables defined in theme files.
   ============================================================ */

/* --- 1. RESET & BASE --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* --- 2. LAYOUT --- */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* --- 3. HEADER / NAVBAR --- */
.site-header {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: var(--header-bg);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo span { color: var(--text); }

.header-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 5px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}
.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* --- 4. HERO --- */
.hero {
  padding: 40px 0 35px;
  text-align: center;
  /* Il figlio .container ha .fade-up (animation con transform) e crea uno stacking
     context: senza questo, il dropdown della ricerca resta prigioniero li' dentro e
     finisce SOTTO le .tool-card, che sono fratelli successivi nel DOM con un proprio
     contesto allo stesso livello. Lo z-index del dropdown da solo non basta. */
  position: relative;
  z-index: 10;
}
.hero h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 14px;
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin: 0 auto;
}

/* --- 5. CALCULATOR GRIDS --- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-bottom: 48px;
}
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 28px;
  margin-bottom: 48px;
  align-items: start;
}

/* --- 6. CARDS --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 20px; }
.card-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.icon-green  { background: var(--accent-light); color: var(--accent); }
.icon-gold   { background: var(--highlight-light); color: var(--highlight, var(--accent)); }
.icon-blue   { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.icon-orange { background: var(--highlight-light); color: var(--highlight, var(--accent)); }
.icon-purple { background: var(--negative-light); color: var(--negative); }

/* --- 7. FORM ELEMENTS --- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.field .hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}
.field-row > .field { margin-bottom: 0; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  margin-bottom: 18px;
}
.field-row:last-child { margin-bottom: 0; }

.input-wrap { position: relative; }
.input-wrap .prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}
.input-wrap .suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}
.has-suffix input { padding-right: 50px; }

.input-wrap input[type="number"],
.input-wrap input[type="text"] {
  width: 100%;
  padding: 12px 14px 12px 32px;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.input-big {
  font-size: 1.4rem !important;
  padding: 16px 14px 16px 32px !important;
  border-color: var(--accent) !important;
  background: var(--surface) !important;
}
.input-primary {
  border-color: var(--accent) !important;
  background: var(--surface) !important;
}

select {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* --- 8. SLIDER --- */
.slider-field { margin-bottom: 20px; }
.slider-field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.slider-field label .slider-val {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* --- 9. PILL GROUP --- */
.pill-group {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pill-group button {
  flex: 1;
  padding: 9px 6px;
  border: none;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  border-right: 1px solid var(--border);
}
.pill-group button:last-child { border-right: none; }
.pill-group button.active {
  background: var(--accent);
  color: white;
}
.pill-group button:hover:not(.active) {
  background: var(--accent-light);
}

/* Fuel pills variant (grid) */
.fuel-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.fuel-pills button {
  padding: 9px 4px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.3;
}
.fuel-pills button.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}
.fuel-pills button:hover:not(.active) {
  border-color: var(--accent);
  background: var(--accent-light);
}
.fuel-pills button .fuel-icon {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 2px;
}

/* --- 10. TOGGLE --- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-label,
.toggle-row .tl {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.toggle-row .toggle-sublabel,
.toggle-row .tl small {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
  font-weight: 400;
}

.toggle,
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input,
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle .slider,
.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: 0.25s;
}
.toggle .slider:before,
.toggle-switch .slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle input:checked + .slider,
.toggle-switch input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider:before,
.toggle-switch input:checked + .slider:before { transform: translateX(20px); }

/* --- 11. RESULTS --- */
.results-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 80px;
}
.results-panel { position: sticky; top: 80px; }

.net-display,
.total-display {
  text-align: center;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 20px;
}
.net-display .net-label,
.total-display .td-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.net-display .net-amount,
.total-display .td-amount {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.net-display .net-monthly {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}
.net-display .net-monthly strong { color: var(--text); font-weight: 700; }
.net-display .net-sub,
.total-display .td-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}
.rata-range {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.summary-item {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.summary-item .si-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.summary-item .si-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 12px 8px;
  text-align: center;
}
.kpi .kpi-label {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.kpi .kpi-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.breakdown { list-style: none; }
.breakdown li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border-light);
}
.breakdown li:last-child { border-bottom: none; }
.breakdown li .bk-label { color: var(--text-secondary); font-weight: 400; }
.breakdown li .bk-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.breakdown li.negative .bk-value { color: var(--negative); }
.breakdown li.positive .bk-value { color: var(--accent); }
.breakdown li:has(+ li.total) { border-bottom: none; }
.breakdown li.total {
  border-top: 2px solid var(--text);
  border-bottom: none;
  padding-top: 12px;
  margin-top: 4px;
}
.breakdown li.total .bk-label { font-weight: 700; color: var(--text); }
.breakdown li.total .bk-value { font-weight: 700; font-size: 1rem; color: var(--accent); }

/* Breakdown rows (costo-auto style) */
.breakdown-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row .br-label { color: var(--text-secondary); }
.breakdown-row .br-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.breakdown-row:has(+ .total-row) { border-bottom: none; }
.breakdown-row.total-row {
  border-top: 2px solid var(--accent);
  padding-top: 12px;
  margin-top: 4px;
  font-weight: 700;
  font-size: 0.9rem;
}
.breakdown-row.total-row .br-label { color: var(--text); }
.breakdown-row.total-row .br-val { color: var(--accent); }

/* --- 12. BAR --- */
.bar-section { margin-bottom: 16px; }
.bar-section .bar-header,
.tax-rate-bar .bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.bar-section .bar-label,
.tax-rate-bar .bar-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.bar-section .bar-pct,
.tax-rate-bar .bar-pct {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.tax-rate-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.bar-track {
  height: 10px;
  background: var(--surface-alt);
  border-radius: 5px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--highlight));
  border-radius: 5px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Projection bars (costo-auto) */
.proj-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.proj-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.proj-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.proj-bar-row .pb-label {
  font-size: 0.72rem;
  font-weight: 600;
  width: 42px;
  text-align: right;
  color: var(--text-muted);
  flex-shrink: 0;
}
.proj-bar-row .pb-track {
  flex: 1;
  height: 16px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}
.proj-bar-row .pb-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--highlight));
  transition: width 0.5s;
}
.proj-bar-row .pb-val {
  font-size: 0.72rem;
  font-weight: 700;
  width: 72px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* --- 13. CHART (Chart.js + mini CSS chart) --- */
.chart-container {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.chart-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}
.chart-legend span {
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
}
.chart-legend .dot { width: 10px; height: 10px; border-radius: 2px; }
.dot-cap { background: var(--accent); }
.dot-int { background: var(--highlight); }

#miniChart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 80px;
}
.chart-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 3px;
}
.bar-cap { background: var(--accent); border-radius: 1px 1px 0 0; transition: height 0.3s; }
.bar-int { background: var(--highlight); border-radius: 1px 1px 0 0; transition: height 0.3s; }

/* Chart.js canvas */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.chart-card canvas { max-height: 300px; }

/* --- 14. DONUT SVG (costo-auto) --- */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.donut-svg { width: 120px; height: 120px; flex-shrink: 0; }
.donut-legend { flex: 1; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.legend-item:last-child { margin-bottom: 0; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-val { margin-left: auto; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* --- 15. SCHEDULE TABLE (mutuo) --- */
.schedule-section { margin-top: 20px; }
.schedule-toggle {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.schedule-toggle:hover { border-color: var(--accent); color: var(--accent); }
.schedule-table-wrap {
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
  display: none;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.schedule-table-wrap.open { display: block; }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.schedule-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
.schedule-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-light);
  font-variant-numeric: tabular-nums;
}
.schedule-table tr:last-child td { border-bottom: none; }
.schedule-table tr:hover td { background: var(--accent-light); }

/* --- 16. INFO / FAQ SECTIONS --- */
.info-section {
  padding: 56px 0;
  border-top: 1px solid var(--border-light);
}
.info-section h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}
.info-section h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 24px 0 10px;
}
.info-section p {
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.info-section .table-wrap { overflow-x: auto; margin: 20px 0; }
.info-section table {
  width: 100%;
  max-width: 600px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.info-section table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--surface-alt);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}
.info-section table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}
.info-section table tr:last-child td { border-bottom: none; }

/* Variante larga: tabelle con troppe colonne per stare in 600px (es. rata per
   TAN x durata in /prestito/). Sotto i 640px il wrap scorre in orizzontale. */
.info-section .table-wrap.wide table { max-width: none; min-width: 640px; }
.info-section .table-wrap.wide thead th ~ th,
.info-section .table-wrap.wide tbody td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.info-section .table-wrap.wide tbody th {
  font-size: 0.88rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}
.info-section .table-wrap.wide tbody tr:last-child th { border-bottom: none; }

.cost-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.88rem; }
.cost-table th,
.cost-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); }
.cost-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-alt);
}
.cost-table td { font-variant-numeric: tabular-nums; }

.faq-item {
  border-bottom: 1px solid var(--border-light);
  padding: 18px 0;
}
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { margin: 0 0 8px; font-size: 1.05rem; cursor: default; }
.faq-item p { margin: 0; }

/* Reference list */
.ref-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ref-list li {
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.ref-list li:last-child { border-bottom: none; }
.ref-list a {
  color: var(--accent);
  text-decoration: none;
}
.ref-list a:hover { text-decoration: underline; }

/* --- 17. FOOTER --- */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-secondary); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.footer-links {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 20px;
}
.footer-links a { white-space: nowrap; }

/* --- 18. ANIMATIONS --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up  { animation: fadeUp 0.5s ease-out both; }
.delay-1  { animation-delay: 0.1s; }
.delay-2  { animation-delay: 0.2s; }
.delay-3  { animation-delay: 0.3s; }

/* --- 19. AD SLOT --- */
.ad-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
  text-align: center;
  overflow: hidden;
  display: none;
}
.ad-container.ad-loaded {
  display: block;
  margin: 24px auto;
}
.ad-container ins { background: transparent !important; }

/* --- 20. HOMEPAGE --- */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 48px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tool-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.tool-card .tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--accent);
  background: var(--accent-light);
}
.tool-card h2 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.tool-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}
.tool-card .tool-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tool-card .tool-cta::after {
  content: '\2192';
}

/* --- 20b. RICERCA TOOL (home) --- */
.hero-search {
  position: relative;
  max-width: 480px;
  margin: 24px auto 0;
  text-align: left;
}
.hero-search .search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
  pointer-events: none;
}
#toolSearch {
  width: 100%;
  padding: 13px 16px 13px 44px;
  font-family: var(--font-sans);
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#toolSearch::placeholder { color: var(--text-muted); }
#toolSearch:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-results.open { display: block; }
.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover,
.search-item.active { background: var(--accent-light); }
.search-nome { font-weight: 600; font-size: 0.95rem; }
.search-cat { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.search-empty {
  padding: 14px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* --- 21. THEME SWITCHER UI --- */
.theme-switcher { position: relative; }
.theme-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s;
}
.theme-btn:hover { border-color: var(--accent); }
.theme-btn .theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}

.theme-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 200px;
  z-index: 200;
}
.theme-dropdown.open { display: block; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}
.theme-option:hover { background: var(--surface-alt); }
.theme-option.active { color: var(--accent); font-weight: 600; }
.theme-option .to-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

/* --- 22. AD SLOTS --- */
/* Ad slot — decommentare quando si attiva AdSense
.ad-slot {
  width: calc(100% - 40px);
  max-width: 800px;
  margin: 32px auto;
  padding: 16px 0 8px;
  text-align: center;
  min-height: 100px;
}
.ad-slot::before {
  content: "Pubblicità";
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
*/
.ad-slot { display: none; }

/* --- 23. RELATED TOOLS --- */
.related-tools {
  width: calc(100% - 40px);
  max-width: 800px;
  margin: 0 auto 32px;
}
.related-tools h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.related-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.related-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.related-card .rc-icon {
  font-size: 1.3rem;
  color: var(--accent);
  flex-shrink: 0;
}
.related-card .rc-text {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
}
.related-card .rc-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}
@media (max-width: 600px) {
  .related-grid { grid-template-columns: 1fr; }
}

/* --- 24. RESPONSIVE --- */
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .calc-grid { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: 1fr; }
  .results-card { position: static; }
  .results-panel { position: static; }

  .nav-links { display: none; }

  .summary-grid { grid-template-columns: 1fr 1fr; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .field-row { display: block; margin-bottom: 0; }
  .field-row > .field { margin-bottom: 16px; }
  .field-row:last-child > .field:last-child { margin-bottom: 0; }
  .fuel-pills { grid-template-columns: repeat(2, 1fr); }
  .kpi-row { grid-template-columns: 1fr; }
}

/* --- 23. UTILITY --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- 24. MEGA MENU HEADER --- */
.v1-header {
  position: sticky; top: 0; z-index: 9000;
  background: var(--header-bg, var(--surface));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
}
.v1-header .v1-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; height: 56px; gap: 24px;
}
.v1-header .v1-logo {
  font-family: var(--font-serif); font-size: 1.2rem; font-weight: 800; color: var(--text);
  text-decoration: none; white-space: nowrap;
}
.v1-header .v1-logo span { color: var(--accent); }

.v1-header .v1-quick-links {
  display: flex; gap: 6px; margin-left: auto;
}
.v1-header .v1-quick-links a {
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.v1-header .v1-quick-links a:hover,
.v1-header .v1-quick-links a.active {
  background: var(--accent-light); color: var(--accent-dark);
}

.v1-mega-wrap { position: relative; }
.v1-mega-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 600;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  transition: background 0.15s;
}
.v1-mega-btn:hover { background: var(--accent-dark); }
.v1-mega-btn .arrow { font-size: 0.65rem; transition: transform 0.2s; }
.v1-mega-wrap.open .v1-mega-btn .arrow { transform: rotate(180deg); }

.v1-mega-dropdown {
  display: none; position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 20px 24px; min-width: 600px; z-index: 9500;
}
.v1-mega-wrap.open .v1-mega-dropdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.v1-mega-dropdown .mega-cat-title {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px;
}
.v1-mega-dropdown .mega-cat a {
  display: block; font-size: 0.82rem; color: var(--text);
  text-decoration: none; padding: 4px 0; transition: color 0.15s;
}
.v1-mega-dropdown .mega-cat a:hover { color: var(--accent); }

/* Theme toggle (light/dark) */
.v1-theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 1.4rem;
  transition: color 0.2s;
  margin-left: 8px;
}
.v1-theme-toggle:hover { color: var(--accent); }
.v1-theme-toggle .ph-sun { display: inline; }
.v1-theme-toggle .ph-moon { display: none; }
.v1-theme-toggle.is-dark .ph-sun { display: none; }
.v1-theme-toggle.is-dark .ph-moon { display: inline; }

/* Mega menu mobile */
@media (max-width: 768px) {
  .v1-header .v1-quick-links { display: none; }
  .v1-mega-btn .btn-prefix { display: none; }
  .v1-mega-btn { text-transform: capitalize; }
  .v1-mega-wrap.open .v1-mega-dropdown {
    position: fixed; top: 56px; left: 0; right: 0;
    grid-template-columns: repeat(2, 1fr);
    min-width: unset; border-radius: 0;
    max-height: calc(100vh - 56px); overflow-y: auto;
  }
}
@media (max-width: 480px) {
  .v1-mega-wrap.open .v1-mega-dropdown { grid-template-columns: 1fr; }
}

@media print {
  .site-header,
  .v1-header,
  .site-footer,
  .info-section,
  .theme-switcher,
  .ad-slot { display: none; }
  .calc-grid,
  .calc-layout { display: block; }
  .results-card { position: static; border: 2px solid #000; }
  body { background: white; color: black; }
}
