body {
  background: #eee !important;
}

main {
  background: #eee url("../img/bg-indice-statistiche.png") repeat-x 0 0;
  padding-top: 1rem;
  margin-top: 0 !important;
  margin-bottom: 5rem !important;
}

.stat-graph-header {
  padding: 24px 28px 30px;
  margin-top: 2rem;
  background: #fff;
  color: #222b3a;
  border-radius: 1rem;
  box-shadow: 0 10px 30px rgba(20, 32, 50, 0.08);
}

.stat-graph-error {
  padding: 24px 28px;
  margin-top: 126px;
  background: #fff;
  color: #222b3a;
  border-left: 6px solid #b02a37;
  border-radius: 4px;
  box-shadow: 0 10px 30px rgba(20, 32, 50, 0.08);
}

.stat-graph-error h1 {
  margin: 0 0 8px;
  color: #8f1f2b;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
}

.stat-graph-error p {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

.stat-graph-header-main {
  min-width: 0;
}

.stat-graph-header-section-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 245px;
  align-items: start;
  gap: 32px;
  margin-bottom: 24px;
}

.stat-graph-header-section {
  margin: 0;
  color: #1d3c6a;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
}

.stat-graph-header-title-row {
  margin-bottom: 22px;
}

.stat-graph-header-title {
  position: relative;
  margin: 0;
  padding: 1rem 0 0 4rem;
  color: #454545;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
}

.stat-graph-header-title::before {
  content: "";
  position: absolute;
  top: calc(1rem + 0.675em);
  left: 0.6rem;
  width: 1rem;
  height: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%233e4b59' d='M2 13h12v1H1V2h1zm2-2H3V6h1zm4 0H5V4h3zm4 0H9V7h3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transform: translateY(-50%) scale(3);
  transform-origin: center;
}

.stat-graph-header-description {
  max-width: 920px;
  color: #4b4f59;
  font-size: 15px;
  line-height: 1.45;
}

.stat-graph-header-description p {
  margin: 0;
}

.stat-graph-header-description a {
  color: #24528d;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stat-graph-header-revision {
  text-align: right;
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  flex-direction: column;
}

.stat-graph-header-revision h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.stat-graph-header-revision > .dropdown > .dropdown-toggle {
  margin: 0;
  padding: 0 0.5rem 0 0;
  color: #2f3034;
  font-size: 1.4rem;
  font-style: italic;
  line-height: 1.3;
}

.stat-graph-header-revision > .dropdown > .dropdown-toggle::after {
  position: relative;
  top: 0.2rem;
  width: 1.3em;
  height: 1.3em;
  margin-left: 0.5rem;
  border: none;
  border-radius: 50%;
  background: #1b3b6c;
  color: #fff;
  content: "\F282";
  font-family: "bootstrap-icons";
  font-style: normal;
  font-weight: 700;
  vertical-align: 0;
}

.stat-graph-header-revision > .dropdown > .dropdown-toggle.show::after {
  transform: rotate(180deg);
}

.stat-graph-header-revision > .dropdown > .dropdown-menu {
  inset: 0 0 auto auto !important;
  width: fit-content;
  max-width: 320px;
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  border: 1px solid #ccc;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item {
  color: #1d3c6a;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: end;
}

.stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item:hover {
  color: #3967ac;
  text-decoration: underline;
}

.stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item.active,
.stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item:focus,
.stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item:active {
  color: white;
  text-decoration: underline;
}

@media (max-width: 767px) {
  .stat-graph-header {
    padding: 22px 18px 24px;
  }

  .stat-graph-header-section-row {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 18px;
  }

  .stat-graph-header-section {
    font-size: 24px;
  }

  .stat-graph-header-title {
    font-size: 18px;
  }

  .stat-graph-header-title-row {
    margin-bottom: 16px;
  }

  .stat-graph-header-revision {
    align-items: flex-start;
    text-align: left;
  }

  .stat-graph-header-revision > .dropdown > .dropdown-menu {
    inset: 0 auto auto 0 !important;
  }

  .stat-graph-header-revision > .dropdown > .dropdown-menu .dropdown-item {
    text-align: start;
  }
}

.block-graph-statistiche-block {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.stat-graphs-layout {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2rem;
}

.stat-graphs-layout > a {
  display: contents;
}

.stat-graph-layout-item {
  min-width: 0;
  overflow: hidden;
}

.stat-graph-layout-item .h-md {
  width: 100%;
  border-radius: 1rem 1rem 0 0;
  overflow: hidden;
}

.stat-graph-chart-viewport {
  width: 100%;
}

.stat-graph-layout-item .highcharts-container,
.stat-graph-layout-item .highcharts-root {
  width: 100% !important;
}

.stat-graph-layout-columns-1 {
  grid-column: span 1;
}

.stat-graph-layout-columns-2 {
  grid-column: span 2;
}

.stat-graph-layout-columns-3 {
  grid-column: span 3;
}

.stat-graph-layout-columns-4 {
  grid-column: span 4;
}

.stat-graph-layout-columns-5 {
  grid-column: span 5;
}

.stat-graph-layout-columns-6 {
  grid-column: 1 / -1;
  overflow: visible;
}

/*
 * Su mobile i grafici che occupano l'intera riga usano un canvas ampio:
 * Highcharts può così disporre correttamente label e legenda, mentre il
 * renderer ne riduce soltanto la resa visiva.
 */
.stat-graph-layout-fixed-mobile .stat-graph-chart-viewport {
  --stat-chart-mobile-scale: 1;
  height: var(--stat-chart-scaled-height, auto);
}

.stat-graph-layout-fixed-mobile .h-md {
  height: var(--stat-chart-fixed-height, auto);
}

@media (max-width: 767.98px) {
  .stat-graph-layout-fixed-mobile .stat-graph-chart-viewport {
    display: flex;
    justify-content: center;
    touch-action: pan-y pinch-zoom;
  }

  .stat-graph-layout-fixed-mobile .h-md {
    flex: 0 0 1200px;
    width: 1200px;
    max-width: none;
    overflow: visible;
    transform: scale(var(--stat-chart-mobile-scale));
    transform-origin: top center;
  }
}

.stat-graph-layout-fixed-mobile .popup-trigger {
  font-size: var(--stat-chart-note-font-size, 2rem);
  padding: var(--stat-chart-note-padding, 1rem);
}

@media (max-width: 767.98px) {
  .stat-graph-layout-fixed-mobile .highcharts-title {
    font-size: 20px !important;
  }

  .stat-graph-layout-fixed-mobile .highcharts-data-label b {
    font-size: 16px !important;
  }

  .stat-graph-layout-fixed-mobile .highcharts-legend-item text {
    font-size: 14px !important;
  }
}

.stat-graph-legend-html {
  display: flex;
  justify-content: center;
  padding: 16px 0 20px;
  background: white;
}

.stat-graph-legend-html .table-legenda-scala-colori {
  width: auto;
  margin: 0 auto;
  border-collapse: collapse;
}

.stat-graph-legend-html .table-legenda-scala-colori td {
  border: none;
  font-size: 14px;
  font-weight: bold;
  padding: 5px 14px;
  text-align: center;
  white-space: nowrap;
}

.stat-graph-legend-html
  #table_legenda_scala_donne
  td:nth-child(n + 8):nth-child(-n + 10),
.stat-graph-legend-html
  #table_legenda_scala_uomini
  td:nth-child(n + 8):nth-child(-n + 10) {
  color: #fff;
}

.popup-trigger {
  background-color: #1b3b6c;
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  padding: 1rem;
  border-radius: 0 0 1rem 1rem;
}

.popup-trigger a {
  color: #fff;
}

.notesPopupDialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(680px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: #fff;
  color: #333;
  box-shadow: none;
  overflow: auto;
  transform: translate(-50%, -50%);
}

.notesPopupDialog:not([open]) {
  display: none;
}

.notesPopupDialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.statDataTableDialog {
  width: min(920px, calc(100vw - 32px));
}

.notesPopupWrapper {
  padding: 30px 40px 58px;
}

.notesPopupWrapper h3 {
  margin: 0 0 28px;
  padding: 10px 16px;
  background: #1f457c;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.notesPopupIntestazione {
  margin-bottom: 10px;
  color: #333;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.35;
}

.notesPopupNote {
  margin-left: 16px;
  color: #555;
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.5;
  margin-bottom: 2rem;
}

.statDataTableWrapper {
  padding-bottom: 40px;
}

.statDataTableContent {
  overflow-x: auto;
}

.statDataTableContent table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: #333;
  font-size: 1.5rem;
  line-height: 1.35;
}

.statDataTableContent caption {
  margin-bottom: 12px;
  color: #333;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: left;
}

.statDataTableContent th,
.statDataTableContent td {
  padding: 10px 12px;
  border: 1px solid #d7dde6;
  vertical-align: top;
  text-align: right;
}

.statDataTableContent th:first-child,
.statDataTableContent td:first-child,
.statDataTableContent .text {
  text-align: right;
}

.statDataTableContent thead th {
  background: #1f457c;
  color: #fff;
  font-weight: 700;
}

.statDataTableContent tbody tr:nth-child(even) {
  background: #f3f6f9;
}

.notesPopupClose {
  position: absolute;
  top: 12px;
  right: 10px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.notesPopupClose::before,
.notesPopupClose::after {
  position: absolute;
  top: 2px;
  left: 11px;
  width: 3px;
  height: 22px;
  background: #c5c5c5;
  content: "";
}

.notesPopupClose::before {
  transform: rotate(45deg);
}

.notesPopupClose::after {
  transform: rotate(-45deg);
}

.notesPopupClose:hover::before,
.notesPopupClose:hover::after,
.notesPopupClose:focus::before,
.notesPopupClose:focus::after {
  background: #777;
}

.highcharts-container .highcharts-data-label text,
.highcharts-container .highcharts-data-label span,
.highcharts-container .highcharts-stack-labels text,
.highcharts-container .highcharts-stack-labels span,
.stat-vpie-center-label {
  text-shadow:
    -1px -1px 0 #fff,
    1px -1px 0 #fff,
    -1px 1px 0 #fff,
    1px 1px 0 #fff;
}

.stat-vpie-center-label {
  display: inline-block;
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 999px;
  line-height: 1.1;
  text-align: center;
  /* box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04); */
  max-width: 230px;
  white-space: normal;
}

@media (max-width: 767.98px) {
  .stat-graphs-layout {
    grid-template-columns: 1fr;
  }

  .stat-graph-layout-columns-1,
  .stat-graph-layout-columns-2,
  .stat-graph-layout-columns-3,
  .stat-graph-layout-columns-4,
  .stat-graph-layout-columns-5,
  .stat-graph-layout-columns-6 {
    grid-column: 1 / -1;
  }

  .notesPopupWrapper {
    padding: 28px 24px 42px;
  }

  .notesPopupWrapper h3,
  .notesPopupIntestazione,
  .notesPopupNote {
    font-size: 1.5rem;
  }

  .notesPopupNote {
    margin-left: 0;
  }

  .statDataTableWrapper {
    padding: 28px 16px 32px;
  }

  .statDataTableContent table {
    font-size: 1.35rem;
  }

  .statDataTableContent th,
  .statDataTableContent td {
    padding: 8px 10px;
  }
}

.section-name {
  font-size: 1.2rem !important;
}

@media (min-width: 360px) {
  .section-name {
    font-size: 1.4rem !important;
  }
}

@media (min-width: 425px) {
  .section-name {
    font-size: 1.6rem !important;
  }
}

@media (min-width: 560px) {
  .section-name {
    font-size: 1.8rem !important;
  }
}

@media (min-width: 561px) {
  .section-name {
    font-size: 2.2rem !important;
  }
}

@media (min-width: 600px) {
  .section-name {
    font-size: 2.4rem !important;
  }
}

@media (min-width: 768px) {
  .section-name {
    font-size: 3rem !important;
  }
}

@media (min-width: 1200px) {
  .section-name {
    font-size: 4rem !important;
  }
}
