:root {
  --green: #006B3F;
  --green-light: #e8f5ee;
  --green-mid: #c2e0cf;
  --amber: #E8A020;
  --ink: #1a1a1a;
  --ink-mid: #444;
  --ink-soft: #777;
  --border: #e2e2e2;
  --surface: #f8f8f6;
  --white: #ffffff;
  --radius: 10px;
  --radius-lg: 16px;
  --nav-w: 240px;
  --font: 'Inter', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--white); line-height: 1.6; font-size: 15px; }

/* NAV */
.nav { position: fixed; top: 0; left: 0; width: var(--nav-w); height: 100vh; background: var(--ink); color: var(--white); display: flex; flex-direction: column; padding: 28px 0; z-index: 100; overflow-y: auto; }
.nav-logo { padding: 0 24px 28px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 8px; }
.nav-logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; background: var(--green); border-radius: 8px; font-weight: 800; font-size: 14px; color: white; margin-bottom: 10px; }
.nav-site-name { font-size: 14px; font-weight: 700; color: var(--white); line-height: 1.2; }
.nav-tagline { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.nav-section { padding: 4px 16px 2px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; color: rgba(255,255,255,0.3); text-transform: uppercase; margin-top: 14px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 24px; font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.6); text-decoration: none; transition: color 0.15s, background 0.15s; cursor: pointer; border: none; background: none; width: 100%; text-align: left; position: relative; }
.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--white); background: rgba(0,107,63,0.35); }
.nav-link.active::before { content: ''; position: absolute; left: 0; width: 3px; height: 36px; background: var(--green); border-radius: 0 2px 2px 0; margin-top: -4px; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-link.active .nav-icon { opacity: 1; }
.nav-footer { margin-top: auto; padding: 16px 24px 0; border-top: 1px solid rgba(255,255,255,0.08); font-size: 11px; color: rgba(255,255,255,0.25); line-height: 1.5; }

/* MAIN */
.main { margin-left: var(--nav-w); min-height: 100vh; }

/* CALC SECTION */
.calc-section { padding: 64px; }
.calc-header { margin-bottom: 40px; }
.calc-cat-tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--green); background: var(--green-light); padding: 3px 10px; border-radius: 20px; margin-bottom: 12px; }
.calc-title { font-size: clamp(22px, 2.5vw, 32px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.15; margin-bottom: 10px; }
.calc-desc { font-size: 14px; color: var(--ink-mid); max-width: 540px; font-weight: 300; line-height: 1.7; }
.calc-body { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; }

/* INPUTS */
.input-group { margin-bottom: 24px; }
.input-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.input-val { font-size: 13px; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; width: 100%; height: 4px; background: var(--border); border-radius: 2px; outline: none; cursor: pointer; margin-bottom: 4px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--green); cursor: pointer; box-shadow: 0 1px 4px rgba(0,107,63,0.3); }
.range-hints { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); }
.select-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--ink-mid); margin-bottom: 6px; }
select, input[type="number"] { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--white); outline: none; transition: border-color 0.15s; }
select:focus, input[type="number"]:focus { border-color: var(--green); }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; flex-shrink: 0; }
.checkbox-row span { font-size: 13px; color: var(--ink-mid); }

/* RESULTS */
.result-box { background: var(--ink); border-radius: var(--radius-lg); padding: 32px; color: var(--white); position: sticky; top: 24px; }
.result-main-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.4); margin-bottom: 6px; }
.result-main-val { font-size: 48px; font-weight: 800; letter-spacing: -0.04em; color: var(--amber); font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 4px; }
.result-main-period { font-size: 13px; color: rgba(255,255,255,0.35); margin-bottom: 28px; }
.result-breakdown { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.result-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.result-row-label { color: rgba(255,255,255,0.5); }
.result-row-val { font-weight: 600; color: var(--white); font-variant-numeric: tabular-nums; }
.result-row-val.negative { color: #ff8a80; }
.result-row-val.positive { color: #69f0ae; }
.result-row-val.accent { color: var(--amber); }
.result-divider { border: none; border-top: 1px solid rgba(255,255,255,0.08); margin: 4px 0; }
.result-aliquota { background: rgba(0,107,63,0.25); border: 1px solid rgba(0,107,63,0.3); border-radius: 8px; padding: 12px 16px; margin-top: 16px; font-size: 12px; color: rgba(255,255,255,0.7); line-height: 1.5; }
.result-aliquota strong { color: var(--white); }

/* SEO TEXT BLOCK */
.seo-block { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--border); max-width: 680px; }
.seo-block h2 { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 12px; letter-spacing: -0.01em; }
.seo-block h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin: 20px 0 8px; }
.seo-block p { font-size: 14px; color: var(--ink-mid); line-height: 1.75; margin-bottom: 12px; }

/* NOTA LEGALE */
.nota-legale { font-size: 11px; color: var(--ink-soft); margin-top: 24px; padding: 12px 16px; background: var(--surface); border-radius: 8px; border-left: 3px solid var(--border); line-height: 1.5; }

/* RELATED */
.related-tools { margin-top: 40px; padding-top: 32px; border-top: 1px solid var(--border); }
.related-title { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 14px; }
.related-list { display: flex; flex-wrap: wrap; gap: 8px; }
.related-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px; font-size: 12px; font-weight: 500; color: var(--ink-mid); text-decoration: none; background: var(--white); transition: border-color 0.15s, color 0.15s; }
.related-chip:hover { border-color: var(--green); color: var(--green); }

/* FOOTER */
.site-footer { padding: 24px 64px; background: var(--surface); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--ink-soft); }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--green); }

/* MOBILE */
/* ── MOBILE NAV BTN: hidden — replaced by bottom bar ── */
.mobile-nav-btn { display: none !important; }
.bottom-nav { display: none !important; }
.bottom-nav-drawer { display: none !important; }
.bottom-nav-overlay { display: none !important; }

@media (max-width: 768px) {
  .bottom-nav { display: flex !important; }
  .bottom-nav-drawer { display: block !important; transform: translateY(100%); }
  .bottom-nav-drawer.open { transform: translateY(0) !important; }
  .bottom-nav-overlay { display: none; }
  .bottom-nav-overlay.open { display: block !important; }
}

/* ════════════════════════════════════════
   BOTTOM NAVIGATION BAR (mobile only)
════════════════════════════════════════ */

@media (max-width: 768px) {

  /* Hide desktop sidebar entirely */
  .nav { display: none !important; }
  .main { margin-left: 0; }

  /* Show bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.07);
    /* iOS safe area */
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 500;
    font-family: var(--font);
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .bottom-nav-item svg {
    width: 22px; height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    flex-shrink: 0;
  }
  .bottom-nav-item span {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
  }
  .bottom-nav-item.active {
    color: var(--green);
  }
  .bottom-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 2px;
    background: var(--green);
    border-radius: 0 0 2px 2px;
  }

  /* "Altro" drawer */
  .bottom-nav-drawer {
    position: fixed;
    bottom: 64px; left: 0; right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
    z-index: 199;
    padding: 16px 0 8px;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .bottom-nav-drawer.open {
    transform: translateY(0);
  }
  .bottom-nav-drawer-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  .bottom-nav-drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    text-decoration: none;
    color: var(--ink);
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font);
    transition: background 0.1s;
  }
  .bottom-nav-drawer-item:active { background: var(--surface); }
  .bottom-nav-drawer-item svg {
    width: 20px; height: 20px;
    stroke: var(--green);
    fill: none;
    stroke-width: 1.8;
    flex-shrink: 0;
  }
  .bottom-nav-drawer-item .drawer-cat {
    font-size: 11px;
    color: var(--ink-soft);
    display: block;
    font-weight: 400;
    margin-top: 1px;
  }

  /* Overlay when drawer open */
  .bottom-nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 198;
  }
  .bottom-nav-overlay.open { display: block; }

  /* Page padding for bottom bar */
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* Calc pages */
  .calc-section { padding: 24px 20px 40px; }
  .calc-body { grid-template-columns: 1fr; }
  .select-row { grid-template-columns: 1fr; gap: 10px; }
  .input-label { font-size: 13px; }
  .result-main-val { font-size: 36px; }
  .result-box { padding: 24px 20px; position: static; }
  .seo-block { margin-top: 32px; padding-top: 28px; }
  .seo-block h2 { font-size: 17px; }
  .seo-block h3 { font-size: 14px; }
  .related-list { gap: 6px; }
  .related-chip { font-size: 12px; padding: 6px 12px; }
  .site-footer { flex-direction: column; gap: 10px; padding: 20px; text-align: center; }
}

@media (max-width: 480px) {
  .calc-section { padding: 20px 16px 40px; }
  .calc-title { font-size: 22px; }
  .calc-desc { font-size: 13px; }
  .result-main-val { font-size: 28px; }
  .result-breakdown { gap: 8px; }
  .result-row { font-size: 12px; }
}
