:root {
  --blue-950: #0b1f3a;
  --blue-900: #12355b;
  --blue-700: #1f5f91;
  --green-700: #138463;
  --green-600: #18a77a;
  --green-100: #e7f8f1;
  --red-700: #b42318;
  --amber-700: #b45309;
  --slate-900: #111827;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--slate-50);
  color: var(--slate-900);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  padding: 42px 0 36px;
  background:
    linear-gradient(135deg, rgba(11, 31, 58, 0.96), rgba(18, 53, 91, 0.94)),
    radial-gradient(circle at 85% 20%, rgba(24, 167, 122, 0.35), transparent 32%);
  color: var(--white);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: end;
  gap: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--green-600);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .kicker {
  color: #92f1cb;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.12;
}

h1 {
  max-width: 900px;
  font-size: clamp(2rem, 5vw, 4rem);
}

h2 {
  color: var(--blue-950);
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.hero-copy {
  max-width: 740px;
  margin: 18px 0 0;
  color: #dbeafe;
  font-size: 1.08rem;
}

.disclaimer {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
}

.page {
  padding: 28px 0 52px;
}

.panel,
.limits {
  animation: fadeIn 260ms ease-out;
}

.section-title {
  margin-bottom: 18px;
}

.section-title p:not(.kicker) {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--slate-500);
}

.form-card,
.result-card,
.chart-card,
.table-card,
.purpose-card,
.progress-card,
.limits {
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.result-card span,
.progress-card span {
  color: var(--slate-500);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 24px;
  padding: 8px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.tab,
.button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab {
  flex: 1 1 180px;
  padding: 10px 16px;
  background: transparent;
  color: var(--slate-700);
}

.tab:hover,
.tab:focus-visible {
  background: var(--slate-100);
  outline: none;
}

.tab.active {
  background: var(--blue-900);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(18, 53, 91, 0.2);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(420px, 1.12fr);
  align-items: start;
  gap: 18px;
}

.purpose-card {
  margin-bottom: 18px;
  padding: 16px;
  border-color: rgba(18, 53, 91, 0.12);
}

.purpose-card strong {
  display: block;
  color: var(--blue-950);
  margin-bottom: 6px;
}

.purpose-card p {
  max-width: 820px;
  margin: 0;
  color: var(--slate-500);
}

.form-card {
  padding: 18px;
}

.auto-note {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(19, 132, 99, 0.22);
  border-radius: 8px;
  background: #f1fff8;
  color: var(--slate-700);
  font-weight: 800;
}

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

label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--blue-950);
  font-size: 0.92rem;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-900);
  padding: 10px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(19, 132, 99, 0.16);
  outline: none;
}

input[aria-invalid="true"] {
  border-color: var(--red-700);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

label small {
  color: var(--slate-500);
  font-size: 0.78rem;
  font-weight: 600;
}

.errors {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  border-radius: 8px;
  background: #fff5f5;
  color: var(--red-700);
  font-weight: 700;
}

.errors ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.button {
  padding: 10px 18px;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.primary {
  background: var(--green-700);
  color: var(--white);
  box-shadow: 0 10px 22px rgba(19, 132, 99, 0.2);
}

.primary:hover,
.primary:focus-visible {
  background: #0f7055;
}

.secondary {
  background: var(--slate-100);
  color: var(--blue-950);
}

.secondary:hover,
.secondary:focus-visible {
  background: var(--slate-200);
}

.results {
  display: grid;
  gap: 16px;
}

.results-heading {
  padding: 2px 0 0;
}

.results-heading h3 {
  margin: 0;
  color: var(--blue-950);
  font-size: 1.18rem;
  line-height: 1.2;
}

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

.result-card {
  min-height: 112px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.result-card strong,
.progress-card strong {
  color: var(--blue-950);
  font-size: clamp(1.16rem, 2.2vw, 1.6rem);
  line-height: 1.15;
}

.highlight {
  border-color: rgba(19, 132, 99, 0.28);
  background: linear-gradient(180deg, #ffffff, var(--green-100));
}

.chart-card {
  position: relative;
  min-height: 330px;
  padding: 14px;
}

.chart-card.empty-chart::after {
  content: "Il grafico apparirà appena i dati saranno completi.";
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--slate-300);
  border-radius: 8px;
  color: var(--slate-500);
  font-weight: 800;
  text-align: center;
  padding: 20px;
}

.chart-card canvas {
  width: 100% !important;
  height: 300px !important;
}

.table-card {
  padding: 14px 16px;
}

.table-card summary {
  cursor: pointer;
  color: var(--blue-950);
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--slate-200);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: var(--slate-100);
  color: var(--blue-950);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.scenario-message {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-700);
  box-shadow: var(--shadow);
  font-weight: 800;
}

.scenario-message[data-status="sostenibile"] {
  border-color: rgba(19, 132, 99, 0.32);
  background: #f1fff8;
}

.scenario-message[data-status="rischio"] {
  border-color: rgba(180, 83, 9, 0.32);
  background: #fffbeb;
}

.scenario-message[data-status="non-sostenibile"] {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff5f5;
}

.progress-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate-200);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green-700), var(--green-600));
  transition: width 260ms ease;
}

.limits {
  margin-top: 28px;
  padding: 22px;
}

.limits ul {
  margin: 0;
  padding-left: 20px;
  color: var(--slate-700);
}

.limits li + li {
  margin-top: 8px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

}

@media (max-width: 720px) {
  .container {
    width: min(100% - 24px, 1180px);
  }

  .hero {
    padding: 32px 0 28px;
  }

  .form-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: static;
  }

  .tab {
    flex-basis: 100%;
  }

  .chart-card {
    min-height: 280px;
  }

  .chart-card canvas {
    height: 250px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
