:root {
  --bg: #f5f2ea;
  --ink: #191a1c;
  --muted: #65686d;
  --panel: #ffffff;
  --line: #ded8ce;
  --accent: #2f8d97;
  --accent-dark: #17636b;
  --gold: #eeb648;
  --shadow: 0 18px 45px rgba(25, 26, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 141, 151, 0.11), rgba(238, 182, 72, 0.08) 42%, rgba(245, 242, 234, 0) 72%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(222, 216, 206, 0.74);
  background: rgba(245, 242, 234, 0.92);
  backdrop-filter: blur(12px);
}

.brand,
.nav-links {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  text-decoration: none;
}

.brand span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent-dark);
  font-weight: 900;
}

.brand strong {
  font-size: 1rem;
}

.nav-links {
  gap: 14px;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--accent-dark);
}

.hero {
  display: grid;
  min-height: 52svh;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: clamp(28px, 6vw, 78px);
  align-items: end;
  padding: clamp(56px, 8vw, 104px) clamp(16px, 5vw, 72px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero p:not(.eyebrow) {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.04rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.hero-panel {
  display: grid;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.hero-panel span {
  color: var(--accent-dark);
  font-weight: 900;
  text-transform: uppercase;
}

.hero-panel strong {
  font-size: 2.3rem;
  line-height: 1;
}

.hero-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: clamp(58px, 8vw, 104px);
}

.calculator {
  display: grid;
  gap: 22px;
  align-content: start;
  min-height: 420px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.calculator-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.calculator-head span {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(47, 141, 151, 0.25);
  border-radius: 8px;
  color: var(--accent-dark);
  font-weight: 900;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1;
  letter-spacing: 0;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.fields.two-one {
  grid-template-columns: minmax(0, 1fr) 120px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #d9d1c5;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
}

input:focus,
select:focus {
  outline: 3px solid rgba(47, 141, 151, 0.18);
  border-color: var(--accent);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
}

.result-grid output {
  display: grid;
  min-height: 96px;
  align-content: space-between;
  gap: 10px;
  padding: 15px;
  border: 1px solid #e7e1d8;
  border-radius: 8px;
  background: #faf8f3;
}

.result-grid span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-grid strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1;
}

#vat .result-grid,
#rata .result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#prog .result-grid {
  grid-template-columns: 1fr;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 28px clamp(16px, 5vw, 72px);
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.footer a {
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 900px) {
  .hero,
  .calculator-grid {
    grid-template-columns: 1fr;
  }

  .calculator {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    display: grid;
    align-items: start;
    padding: 12px 16px;
  }

  .nav-links {
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .hero {
    min-height: 0;
    padding: 42px 16px 34px;
  }

  .hero-panel {
    padding: 18px;
  }

  .calculator-grid {
    width: calc(100% - 24px);
    gap: 12px;
    padding-bottom: 56px;
  }

  .calculator {
    padding: 18px;
  }

  .calculator-head {
    display: grid;
  }

  .fields,
  .fields.two-one,
  .result-grid,
  #vat .result-grid,
  #rata .result-grid {
    grid-template-columns: 1fr;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
