/* ============ TOKENS ============ */
:root {
  --navy-900: #0f1a2e;
  --navy-800: #15233d;
  --navy-700: #1a2740;
  --navy-600: #243559;
  --navy-500: #33476f;
  --gold-600: #a9863b;
  --gold-500: #c2a35a;
  --gold-400: #d4b876;
  --gold-soft: #f3ead4;

  --cream: #fbf8f1;
  --cream-2: #f5efe2;
  --paper: #ffffff;
  --ink: #1c2230;
  --ink-soft: #4a5366;
  --ink-faint: #757d8e;
  --line: rgba(26, 39, 64, 0.12);
  --line-soft: rgba(26, 39, 64, 0.07);

  --primary: var(--navy-700);
  --primary-hover: var(--navy-600);
  --accent: var(--gold-600);

  --ok: #2f6b46;
  --warn-bg: #fbf1d8;
  --warn-line: #d8be7e;
  --warn-ink: #6e561c;

  --bg: var(--cream);
  --surface: var(--paper);
  --surface-2: var(--cream-2);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 26, 46, 0.05), 0 1px 3px rgba(15, 26, 46, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 26, 46, 0.08), 0 1px 4px rgba(15, 26, 46, 0.05);
  --shadow-lg: 0 18px 50px rgba(15, 26, 46, 0.12);

  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --container: 1160px;
}

:root.dark {
  --cream: #0d1422;
  --cream-2: #121b2c;
  --paper: #16203455;
  --ink: #e8ecf3;
  --ink-soft: #aab3c4;
  --ink-faint: #7f899b;
  --line: rgba(210, 220, 235, 0.14);
  --line-soft: rgba(210, 220, 235, 0.08);

  --primary: #1d2b47;
  --primary-hover: #26385c;
  --accent: var(--gold-400);

  --bg: #0a101c;
  --surface: #111a2c;
  --surface-2: #15203400;

  --warn-bg: #2a2412;
  --warn-line: #6e5a23;
  --warn-ink: #e0c887;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 55px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

:root.dark body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(40, 56, 92, 0.35), transparent 60%),
    var(--bg);
}

.container { max-width: var(--container); margin: 0 auto; padding: 0 28px; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--navy-700); color: #fff; padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0; font-size: 0.875rem;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ============ HEADER ============ */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy-800);
  color: #eef1f7;
  border-bottom: 1px solid rgba(194, 163, 90, 0.25);
}
.header-inner {
  display: flex; align-items: center; gap: 20px;
  min-height: 76px; padding-top: 10px; padding-bottom: 10px;
}
.brand {
  display: flex; align-items: center; gap: 13px;
  background: none; border: none; cursor: pointer; color: inherit;
  text-align: left; padding: 4px;
}
.brand-logo { color: var(--gold-400); display: inline-flex; }
.brand-logo .logo-frame { color: rgba(212, 184, 118, 0.45); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.5rem;
  letter-spacing: 0.01em; color: #f6f1e6;
}
.brand-tag { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(212, 184, 118, 0.85); }

.main-nav { display: flex; gap: 4px; margin-left: auto; }
.nav-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(232, 236, 243, 0.75);
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 500;
  padding: 9px 14px; border-radius: var(--radius-sm);
  transition: color 0.18s, background 0.18s;
  position: relative;
}
.nav-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-btn.active { color: var(--gold-400); }
.nav-btn.active::after {
  content: ''; position: absolute; left: 14px; right: 14px; bottom: 2px;
  height: 2px; background: var(--gold-500); border-radius: 2px;
}

.theme-toggle, .nav-toggle {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eef1f7; width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.18s;
}
.theme-toggle:hover, .nav-toggle:hover { background: rgba(255, 255, 255, 0.12); }
.theme-toggle .icon-moon { display: none; }
:root.dark .theme-toggle .icon-sun { display: none; }
:root.dark .theme-toggle .icon-moon { display: block; }
.nav-toggle { display: none; }

.mobile-nav { display: none; flex-direction: column; background: var(--navy-700); border-top: 1px solid rgba(255,255,255,0.08); }
.mobile-nav .nav-btn { text-align: left; border-radius: 0; padding: 14px 28px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.mobile-nav .nav-btn.active::after { display: none; }

/* ============ HOME / HERO ============ */
.hero {
  background:
    linear-gradient(180deg, var(--navy-800) 0%, var(--navy-700) 100%);
  color: #f4f1e9;
  padding: 0;
  border-bottom: 1px solid rgba(194, 163, 90, 0.2);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(212,184,118,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212,184,118,0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(120% 100% at 100% 0%, black, transparent 65%);
  pointer-events: none;
}
.hero-inner { padding: 76px 28px 84px; max-width: 820px; position: relative; z-index: 1; }
.hero-eyebrow {
  font-size: 0.74rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold-400); margin-bottom: 20px; font-weight: 600;
}
.hero-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(3rem, 7vw, 4.75rem); line-height: 1.02;
  letter-spacing: -0.01em; color: #faf6ec;
}
.hero-sub {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.25rem, 2.6vw, 1.7rem); color: #e7e0cf;
  margin-top: 16px; line-height: 1.3;
}
.hero-lead { color: rgba(230, 233, 240, 0.82); margin-top: 22px; max-width: 660px; font-size: 1.02rem; }

.card-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
  margin-top: -48px; position: relative; z-index: 2;
}
.module-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px 26px 24px;
  cursor: pointer; text-align: left; color: var(--ink);
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative; isolation: isolate;
}
:root.dark .module-card { background: #131e33; }
.module-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(169, 134, 59, 0.4); }
.module-num {
  font-family: var(--font-display); font-size: 1rem; font-weight: 600;
  color: var(--accent); letter-spacing: 0.08em;
}
.module-icon { color: var(--primary); }
:root.dark .module-icon { color: var(--gold-400); }
.module-icon svg { width: 38px; height: 38px; }
.module-title {
  font-family: var(--font-display); font-size: 1.6rem; font-weight: 600;
  line-height: 1.12; color: var(--ink);
}
.module-desc { font-size: 0.92rem; color: var(--ink-soft); flex: 1; }
.module-link {
  font-size: 0.85rem; font-weight: 600; color: var(--accent);
  margin-top: 6px; letter-spacing: 0.01em;
}

/* ============ MODULE VIEWS ============ */
.module-wrap { padding: 48px 0 72px; }
.module-head { max-width: 760px; margin-bottom: 36px; }
.module-eyebrow {
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 12px;
}
.module-h {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(2.1rem, 4.5vw, 3rem); line-height: 1.05;
  letter-spacing: -0.01em; color: var(--ink);
}
.module-intro { color: var(--ink-soft); margin-top: 16px; font-size: 1.02rem; max-width: 720px; }

.module-layout {
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 32px; align-items: start;
}

/* ============ FORM ============ */
.form-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 30px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 26px;
}
:root.dark .form-panel { background: #111a2c; }
fieldset { border: none; display: flex; flex-direction: column; gap: 18px; }
legend {
  font-family: var(--font-display); font-size: 1.3rem; font-weight: 600;
  color: var(--ink); padding-bottom: 14px; margin-bottom: 4px;
  border-bottom: 1px solid var(--line); width: 100%;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label, .field-label {
  font-size: 0.85rem; font-weight: 600; color: var(--ink); line-height: 1.35;
}
.req { color: var(--accent); }
.field-hint { font-size: 0.76rem; color: var(--ink-faint); }
.field-err { font-size: 0.78rem; color: #c0392b; min-height: 0; }
:root.dark .field-err { color: #f08a7c; }
.field.invalid input, .field.invalid select { border-color: #c0392b; }

input[type="number"], select {
  font-family: var(--font-body); font-size: 0.95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
:root.dark input[type="number"], :root.dark select { background: #0e1626; }
input[type="number"]:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 134, 59, 0.16);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23757d8e' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}

.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill { position: relative; cursor: pointer; }
.radio-pill input { position: absolute; opacity: 0; pointer-events: none; }
.radio-pill span {
  display: inline-block; padding: 9px 16px; border-radius: 100px;
  border: 1px solid var(--line); font-size: 0.85rem; font-weight: 500;
  color: var(--ink-soft); background: var(--surface); transition: all 0.15s;
}
:root.dark .radio-pill span { background: #0e1626; }
.radio-pill input:checked + span {
  background: var(--navy-700); color: #f4f1e9; border-color: var(--navy-700);
}
:root.dark .radio-pill input:checked + span { background: var(--gold-600); color: #1a1306; border-color: var(--gold-600); }
.radio-pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  font-family: var(--font-body); font-size: 0.92rem; font-weight: 600;
  padding: 12px 24px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; transition: all 0.16s; min-height: 44px;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--navy-700); color: #f6f1e6; }
.btn-primary:hover { background: var(--navy-600); }
:root.dark .btn-primary { background: var(--gold-600); color: #1a1306; }
:root.dark .btn-primary:hover { background: var(--gold-500); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-gold { background: var(--gold-600); color: #fff; }
.btn-gold:hover { background: var(--gold-500); }
:root.dark .btn-gold { background: var(--navy-600); color: #f4f1e9; border-color: rgba(212,184,118,0.35); }

/* ============ FIGLI DYNAMIC ============ */
.figli-container { display: flex; flex-direction: column; gap: 16px; }
.figlio-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  background: var(--surface-2);
}
:root.dark .figlio-card { background: rgba(255,255,255,0.02); }
.figlio-card-head {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600;
  color: var(--ink); margin-bottom: 14px;
}
.figlio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============ RESULT PANEL ============ */
.result-panel {
  position: sticky; top: 96px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
:root.dark .result-panel { background: #111a2c; }
.module-layout-figli .result-panel { position: static; }

.result-empty {
  padding: 56px 32px; text-align: center; color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.result-empty svg { color: var(--line); opacity: 0.8; }
.result-empty p { font-size: 0.95rem; max-width: 320px; }
.result-empty strong { color: var(--ink-soft); }

.result-content { display: flex; flex-direction: column; }
.result-banner {
  background: var(--navy-800); color: #f4f1e9; padding: 26px 30px;
  border-bottom: 3px solid var(--gold-500);
}
.result-banner-label { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-400); font-weight: 600; }
.result-amount {
  font-family: var(--font-display); font-weight: 600; line-height: 1;
  font-size: clamp(2.6rem, 6vw, 3.4rem); margin: 8px 0 4px; color: #faf6ec;
}
.result-amount .euro { font-size: 0.55em; vertical-align: top; margin-right: 4px; color: var(--gold-400); }
.result-period { font-size: 0.92rem; color: rgba(230,233,240,0.8); }

.result-body { padding: 24px 30px 28px; display: flex; flex-direction: column; gap: 22px; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.result-stat {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  background: var(--surface-2);
}
:root.dark .result-stat { background: rgba(255,255,255,0.02); }
.result-stat-label { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.result-stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--ink); margin-top: 4px; }

.result-section-title {
  font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--ink);
  padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.result-detail-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.result-detail-table th, .result-detail-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft);
}
.result-detail-table th { color: var(--ink-faint); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }
.result-detail-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.result-detail-table tr.total td { font-weight: 700; border-top: 1.5px solid var(--line); border-bottom: none; padding-top: 11px; }

.result-motiv {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
:root.dark .result-motiv { background: rgba(212,184,118,0.05); border-color: rgba(212,184,118,0.18); }
.result-motiv h4 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; color: var(--ink); margin-bottom: 10px; }
.result-motiv p { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 8px; }
.result-motiv ul { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.result-motiv li { font-size: 0.85rem; color: var(--ink-soft); display: flex; gap: 9px; align-items: baseline; }
.result-motiv li::before { content: ''; flex: none; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-top: 7px; }

.result-export { padding: 0 30px 28px; }
.result-export .btn { width: 100%; justify-content: center; }

/* ============ DISCLAIMER ============ */
.disclaimer {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  border-radius: var(--radius); padding: 16px 20px; margin-top: 28px;
}
.disclaimer-home { margin-top: 40px; }
.disclaimer-mark {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--warn-line); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
}
.disclaimer p { font-size: 0.86rem; color: var(--warn-ink); line-height: 1.5; }

/* ============ FOOTER ============ */
.site-footer { background: var(--navy-900); color: rgba(230,233,240,0.7); margin-top: 40px; border-top: 1px solid rgba(194,163,90,0.18); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 32px 28px; flex-wrap: wrap; }
.footer-brand { display: flex; flex-direction: column; gap: 2px; }
.footer-name { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; color: #f4f1e9; }
.footer-desc { font-size: 0.82rem; color: rgba(230,233,240,0.6); }
.footer-credit { font-size: 0.82rem; color: rgba(212,184,118,0.85); }

/* ============ RESPONSIVE ============ */
@media (max-width: 940px) {
  .main-nav { display: none; }
  .nav-toggle { display: inline-flex; }
  .mobile-nav:not([hidden]) { display: flex; }
  .module-layout { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .container { padding: 0 18px; }
  .header-inner { gap: 12px; min-height: 64px; }
  .brand-tag { display: none; }
  .brand-name { font-size: 1.3rem; }
  .hero-inner { padding: 52px 18px 64px; }
  .module-wrap { padding: 32px 0 56px; }
  .form-panel { padding: 22px; }
  .field-row, .figlio-grid, .result-stats { grid-template-columns: 1fr; }
  .result-banner, .result-body, .result-export { padding-left: 22px; padding-right: 22px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

[hidden] { display: none !important; }
