body {
  background-color: #f5f7f6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header h1 {
  letter-spacing: 0.02em;
}

.app-home-link {
  border-radius: 0.75rem;
}

.app-home-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  color: #198754;
  font-size: 0.78rem;
  font-weight: 600;
}

.app-home-hint svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
}

.app-home-link:hover .app-title {
  color: #157347 !important;
}

.app-home-link:hover .app-home-hint {
  color: #0f5132;
  text-decoration: underline;
  text-underline-offset: 0.15rem;
}

.app-home-link:focus-visible {
  outline: 3px solid rgba(25, 135, 84, 0.45);
  outline-offset: 4px;
}

.app-title {
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 2.25rem;
  letter-spacing: 0.04em;
}

.app-logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.lang-switch .btn-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  line-height: 1.1;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  color: #343a40;
  box-shadow: none;
}

.lang-switch .btn-lang:first-child {
  border-top-left-radius: 0.5rem;
  border-bottom-left-radius: 0.5rem;
}

.lang-switch .btn-lang:last-child {
  border-top-right-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.lang-switch .btn-lang:hover {
  border-color: #cfd4da;
  background-color: #f8f9fa;
}

.lang-switch .btn-lang.active {
  border-color: #198754;
  color: #198754;
  background-color: #f2fbf6;
}

.lang-switch .btn-lang:focus {
  box-shadow: 0 0 0 0.15rem rgba(25, 135, 84, 0.2);
}

.lang-switch .lang-label {
  font-weight: 600;
  color: inherit;
}

.subscript {
  font-size: 0.8em;
  vertical-align: sub;
}

.superscript {
  font-size: 0.7em;
  vertical-align: super;
}

main.container {
  max-width: 960px;
}

header .container {
  max-width: 960px;
}

.accordion-item {
  border-radius: 0.75rem !important;
  overflow: hidden;
  border: 1px solid #e0e4e7;
  background-color: #ffffff;
}

.accordion-item + .accordion-item {
  margin-top: 1rem;
}

.accordion-button {
  font-weight: 600;
  background-color: #f8f9fa;
  color: #343a40;
}

.accordion-button:not(.collapsed) {
  color: #1f2933;
  background-color: #eef1f4;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.03);
}

.accordion-body {
  background-color: #ffffff;
}

.alert-warning {
  border-radius: 0.75rem;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

.form-control {
  border-radius: 0.5rem;
  border: 1px solid #ced4da;
  font-size: 0.95rem;
}

.form-control:focus {
  border-color: #198754;
  box-shadow: 0 0 0 0.15rem rgba(25, 135, 84, 0.25);
}

.form-text {
  color: #6c757d;
}

.card {
  border-radius: 0.75rem;
  border: 1px solid #e0e4e7;
}

.card-title {
  color: #1f2933;
}

.progress-card {
  background-color: #ffffff;
}

.preview-card {
  background-color: #f8f9fa;
}

.bg-low {
  background-color: #dc3545 !important;
}

.bg-medium {
  background-color: #ffc107 !important;
  color: #212529 !important;
}

.bg-high {
  background-color: #198754 !important;
}

#calcolaBtn {
  border-radius: 0.5rem;
  background-color: #198754;
  border-color: #198754;
  box-shadow: none;
}

#calcolaBtn:hover {
  background-color: #157347;
  border-color: #157347;
}

.scope-bar-row {
  margin-bottom: 0.75rem;
}

.scope-breakdown-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  color: #343a40;
  text-align: left;
  font: inherit;
  font-weight: 600;
}

.scope-breakdown-toggle::after {
  width: 0.55rem;
  height: 0.55rem;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s ease;
}

.scope-breakdown-toggle[aria-expanded="true"]::after {
  transform: rotate(225deg) translate(-2px, -1px);
}

.scope-breakdown-toggle:focus-visible {
  border-radius: 0.25rem;
  outline: 3px solid rgba(25, 135, 84, 0.35);
  outline-offset: 2px;
}

.scope-breakdown-total {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

.scope-breakdown-detail {
  padding: 0.75rem 0.25rem 0.25rem;
}

.scope-detail-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.scope-detail-track {
  height: 0.45rem;
  margin-bottom: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e9ecef;
}

.scope-detail-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #2d6a4f;
  transition: width 0.3s ease;
}

.scope-bar-track {
  background-color: #e9ecef;
  border-radius: 999px;
  overflow: hidden;
  height: 0.75rem;
}

.scope-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.scope-bar-fill.scope1 {
  background-color: #a4c4b1;
}

.scope-bar-fill.scope2 {
  background-color: #9fb9d6;
}

.scope-bar-fill.scope3-waste {
  background-color: #c6b0cf;
}

.scope-bar-fill.scope3-transport {
  background-color: #b4b8d0;
}

@media (max-width: 575.98px) {
  header h1 {
    font-size: 1.6rem;
  }

  .app-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
  }

  .lang-switch .lang-label {
    display: none;
  }

  #calcolaBtn {
    width: 100%;
  }
}

/* Validazione input */
.form-control.is-invalid {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Miglioramento contrasto per i punteggi e badge */
.badge {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge.text-bg-success-subtle {
  background-color: #d1e7dd !important;
  color: #0f5132 !important;
  border: 1px solid #badbcc;
}

/* Scope bars con migliore contrasto */
.scope-bar-fill {
  min-width: 2px;
  transition: width 0.3s ease;
  border-radius: 0.25rem;
}

.scope-bar-fill.scope1 {
  background-color: #2d6a4f;
}

.scope-bar-fill.scope2 {
  background-color: #1e3a8a;
}

.scope-bar-fill.scope3-waste {
  background-color: #5b21b6;
}

.scope-bar-fill.scope3-transport {
  background-color: #0c4a6e;
}

/* Progress bar colori migliorati */
.progress-bar.bg-low {
  background-color: #dc3545 !important;
}

.progress-bar.bg-medium {
  background-color: #ffc107 !important;
  color: #000;
}

.progress-bar.bg-high {
  background-color: #198754 !important;
}
