body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Estrutura */
.organograma {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  font-family: "Open Sans", "Helvetica", "Arial", sans-serif;
  padding: 30px;
}

.titulo-estrutura {
  text-transform: uppercase;
  color: #033649;
  font-weight: 900;
  letter-spacing: -2px;
}

/* Topo (nível pai) */
.topo {
  display: flex;
  align-items: center;
  justify-content: center; /* IMPORTANTE */
  gap: 10px;
  width: 100%;
}

/* Botões */
.toggle {
  position: absolute;
  right: 10px;
  top: 9px;
  background: transparent;
  border: none;
  color: white;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
}
.toggle-interno {
  position: absolute;
  right: 8px;
  top: 5px;
  background: transparent;
  border: none;
  color: white;
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
}

/* Boxes principais */
.box {
  padding: 20px 40px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  position: relative;
}

/* CORES EXATAS */
.prefeito {
  background: #0b3c5d;
}
.prefeito-interno {
  padding: 20px !important;
}
.vice {
  background: #ee7701;
}
.secretaria {
  background: #009245;
}

/* Botões com mesma cor */
.prefeito + .toggle {
  background: #0b3c5d;
}
.vice + .toggle {
  background: #ee7701;
}
.secretaria + .toggle {
  background: #009245;
}

/* Níveis pais */
.nivel {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Subníveis */
.subnivel {
  display: none;
  margin-top: 20px;
  width: 100%;
  justify-content: center;
}
.sub-interno {
  display: none !important;
  padding: 10px;
  border-top: 1px solid #ddd;
}
.sub-interno > .subbox {
  background: #f8fafc;
  border: 1px solid #0b3c5d;
  border-left: 5px solid #0b3c5d;
  border-radius: 6px;
  padding: 10px;
  font-weight: 500;
}
.sub-interno .sub-interno > .subbox {
  background: #ffffff;
  border: none;
  border-left: 8px solid #ee7701 !important;
  border: 1px solid #ee7701;
  padding: 8px 10px;
  margin-left: 15px;
  font-size: 13px;
}
.sub-interno {
  margin-top: 10px;
}
.sub-interno.open {
  display: flex !important;
  flex-direction: column;
  gap: 8px;
}
.btn_pdf {
  display: flex;
  align-items: center; /* Centraliza verticalmente */
  justify-content: center; /* Centraliza horizontalmente */
  gap: 8px;
}
.btn_pdf_gabinete {
  display: flex;
  align-items: center; /* Centraliza verticalmente */
  justify-content: center; /* Centraliza horizontalmente */
  gap: 8px;
  margin-bottom: 20px;
}
.btn_pdf > button {
  padding: 10px;
  border: 1px solid #005485;
  border-radius: 8px;
  font-weight: bold;
  color: white;
  cursor: pointer;
  background-color: #005485;
}
.btn_pdf_gabinete > button {
  padding: 10px;
  border: 1px solid #005485;
  border-radius: 8px;
  font-weight: bold;
  color: white;
  cursor: pointer;
  background-color: #005485;
}

.subnivel.open {
  display: flex; /* antes era block */
  flex-direction: column;
  align-items: center;
}

/* Linha horizontal */
.linha {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
}

/* Subníveis internos */
.subbox {
  background: white;
  border: 2px solid #0b3c5d;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: normal !important;
  position: relative;
}

.subbox .toggle-interno {
  position: absolute;
  right: 5px;
  top: 5px;
  font-size: 14px;
  color: #0b3c5d;
}
.subboxdestaque {
  font-weight: bold !important;
  font-size: 14px;
  color: #0b3c5d;
  background-color: #ffffff;
  border-left: 15px solid #009245 !important;
  border: 1px solid #009245;
  border-radius: 5px;
  padding: 10px;
}
.subbox-interno {
  background: #d9dde7;
  border: 2px solid #0b3c5d;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 10px;
}

/* Cards das secretarias */
.card {
  background: #3b5998;
  border-radius: 8px;
  overflow: hidden;
  width: 180px;
  min-height: 120px;
  border: 2px solid #3b5998;
  align-self: flex-start;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}
.card.ativo {
  flex: 0 0 100%;
  max-width: 100%;
}

.titulo {
  background: #3b5998;
  color: white;
  border-radius: 6px 6px 0 0;
  padding: 8px;
  font-weight: bold;
  text-align: center;
  position: relative;
}
.conteudo {
  background: white;
  flex: 1;
  padding: 10px;
  font-size: 13px;
  text-align: center;
}
.card > .sub-interno {
  background: white;
  margin-top: 0;
  border-top: 0;
}

/* Responsivo */
@media (max-width: 768px) {
  .organograma {
    width: 100%;
    padding: 0 10px;
  }
  .linha {
    flex-direction: column;
    align-items: center;
  }
  .card {
    width: 100%;
    max-width: 100%;
    min-height: 80px !important;
  }
  .box {
    width: 100%;
    text-align: center;
  }
  .subbox {
    background: white;
    border: 2px solid #0b3c5d;
    padding: 10px 15px 10px 6px !important;
    border-radius: 8px;
    font-size: 14px;
    font-weight: normal !important;
    position: relative;
  }
}

@media (max-width: 991.98px) {
  .organograma {
    margin-bottom: 30px;
  }
  .titulo-estrutura {
    text-align: center;
    line-height: 29px;
    margin-top: 30px;
  }
}
